File size: 2,237 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {
	IMAGE_EDITOR_CROP,
	IMAGE_EDITOR_COMPUTED_CROP,
	IMAGE_EDITOR_ROTATE_COUNTERCLOCKWISE,
	IMAGE_EDITOR_FLIP,
	IMAGE_EDITOR_SET_ASPECT_RATIO,
	IMAGE_EDITOR_SET_DEFAULT_ASPECT_RATIO,
	IMAGE_EDITOR_SET_CROP_BOUNDS,
	IMAGE_EDITOR_SET_FILE_INFO,
	IMAGE_EDITOR_STATE_RESET,
	IMAGE_EDITOR_STATE_RESET_ALL,
	IMAGE_EDITOR_IMAGE_HAS_LOADED,
} from 'calypso/state/action-types';

import 'calypso/state/editor/init';

// Doesn't reset image file info (src, fileName, etc).
// additionalData can contain arbitrarily needed data.
export function resetImageEditorState( additionalData = {} ) {
	return {
		type: IMAGE_EDITOR_STATE_RESET,
		additionalData,
	};
}

// Resets image file info as well (src, fileName, etc).
// additionalData can contain arbitrarily needed data.
export function resetAllImageEditorState( additionalData = {} ) {
	return {
		type: IMAGE_EDITOR_STATE_RESET_ALL,
		additionalData,
	};
}

export function imageEditorRotateCounterclockwise() {
	return {
		type: IMAGE_EDITOR_ROTATE_COUNTERCLOCKWISE,
	};
}

export function imageEditorFlip() {
	return {
		type: IMAGE_EDITOR_FLIP,
	};
}

export function setImageEditorAspectRatio( ratio ) {
	return {
		type: IMAGE_EDITOR_SET_ASPECT_RATIO,
		ratio,
	};
}

export function setImageEditorDefaultAspectRatio( ratio ) {
	return {
		type: IMAGE_EDITOR_SET_DEFAULT_ASPECT_RATIO,
		ratio,
	};
}

export function setImageEditorFileInfo( src, fileName, mimeType, title ) {
	return {
		type: IMAGE_EDITOR_SET_FILE_INFO,
		src,
		fileName,
		mimeType,
		title,
	};
}

export function setImageEditorCropBounds( topBound, leftBound, bottomBound, rightBound ) {
	return {
		type: IMAGE_EDITOR_SET_CROP_BOUNDS,
		topBound,
		leftBound,
		bottomBound,
		rightBound,
	};
}

export function imageEditorComputedCrop( topRatio, leftRatio, widthRatio, heightRatio ) {
	return {
		type: IMAGE_EDITOR_COMPUTED_CROP,
		topRatio,
		leftRatio,
		widthRatio,
		heightRatio,
	};
}

export function imageEditorCrop( topRatio, leftRatio, widthRatio, heightRatio ) {
	return {
		type: IMAGE_EDITOR_CROP,
		topRatio,
		leftRatio,
		widthRatio,
		heightRatio,
	};
}

export function setImageEditorImageHasLoaded( width, height ) {
	return {
		type: IMAGE_EDITOR_IMAGE_HAS_LOADED,
		width,
		height,
	};
}