@webiny/app-file-manager 6.0.0 → 6.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/BottomInfoBar/BottomInfoBar.js +0 -10
- package/components/BottomInfoBar/BottomInfoBar.js.map +1 -1
- package/components/BottomInfoBar/SupportedFileTypes.js +5 -2
- package/components/BottomInfoBar/SupportedFileTypes.js.map +1 -1
- package/components/BulkActions/ActionEdit/domain/Batch.d.ts +3 -24
- package/components/FileDetails/FileDetails.js +1 -2
- package/components/FileDetails/FileDetails.js.map +1 -1
- package/components/FileDetails/components/ActionButton.d.ts +1 -1
- package/components/FileDetails/components/ActionButton.js.map +1 -1
- package/components/Grid/ActionButton.d.ts +1 -1
- package/components/Grid/ActionButton.js.map +1 -1
- package/components/Grid/File.d.ts +1 -1
- package/components/Grid/File.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/FileManagerView.js +1 -2
- package/modules/FileManagerRenderer/FileManagerView/FileManagerView.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Grid/Thumbnail.d.ts +2 -2
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Grid/Thumbnail.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Table/Thumbnail.d.ts +2 -2
- package/modules/FileManagerRenderer/FileManagerView/configComponents/Browser/Table/Thumbnail.js.map +1 -1
- package/modules/FileManagerRenderer/FileManagerView/configComponents/FileDetails/Thumbnail.d.ts +2 -2
- package/modules/FileManagerRenderer/FileManagerView/configComponents/FileDetails/Thumbnail.js.map +1 -1
- package/package.json +25 -29
- package/components/ImageEditor/ImageEditor.d.ts +0 -45
- package/components/ImageEditor/ImageEditor.js +0 -218
- package/components/ImageEditor/ImageEditor.js.map +0 -1
- package/components/ImageEditor/ImageEditorDialog.d.ts +0 -16
- package/components/ImageEditor/ImageEditorDialog.js +0 -53
- package/components/ImageEditor/ImageEditorDialog.js.map +0 -1
- package/components/ImageEditor/index.d.ts +0 -1
- package/components/ImageEditor/index.js +0 -3
- package/components/ImageEditor/index.js.map +0 -1
- package/components/ImageEditor/toolbar/crop.d.ts +0 -4
- package/components/ImageEditor/toolbar/crop.js +0 -67
- package/components/ImageEditor/toolbar/crop.js.map +0 -1
- package/components/ImageEditor/toolbar/filter.d.ts +0 -3
- package/components/ImageEditor/toolbar/filter.js +0 -167
- package/components/ImageEditor/toolbar/filter.js.map +0 -1
- package/components/ImageEditor/toolbar/flip.d.ts +0 -4
- package/components/ImageEditor/toolbar/flip.js +0 -94
- package/components/ImageEditor/toolbar/flip.js.map +0 -1
- package/components/ImageEditor/toolbar/index.d.ts +0 -4
- package/components/ImageEditor/toolbar/index.js +0 -6
- package/components/ImageEditor/toolbar/index.js.map +0 -1
- package/components/ImageEditor/toolbar/rotate.d.ts +0 -4
- package/components/ImageEditor/toolbar/rotate.js +0 -93
- package/components/ImageEditor/toolbar/rotate.js.map +0 -1
- package/components/ImageEditor/toolbar/types.d.ts +0 -32
- package/components/ImageEditor/toolbar/types.js +0 -3
- package/components/ImageEditor/toolbar/types.js.map +0 -1
- package/modules/FileManagerRenderer/FileActions/FileDetails/EditImage.d.ts +0 -2
- package/modules/FileManagerRenderer/FileActions/FileDetails/EditImage.js +0 -111
- package/modules/FileManagerRenderer/FileActions/FileDetails/EditImage.js.map +0 -1
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* When using Caman, we added @ts-expect-error because it does not exist in packages, but it is loaded in packages/ui/src/ImageEditor/ImageEditor.tsx:38.
|
|
3
|
-
* TODO: use some other library to edit images
|
|
4
|
-
*/
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { ReactComponent as FilterIcon } from "@webiny/icons/tune.svg";
|
|
7
|
-
import debounce from "lodash/debounce.js";
|
|
8
|
-
import { Button, Grid, IconButton, Slider, Tooltip } from "@webiny/admin-ui";
|
|
9
|
-
const sliders = [{
|
|
10
|
-
key: "brightness",
|
|
11
|
-
label: "Brightness",
|
|
12
|
-
min: -100
|
|
13
|
-
}, {
|
|
14
|
-
key: "vibrance",
|
|
15
|
-
label: "Vibrance",
|
|
16
|
-
min: -100
|
|
17
|
-
}, {
|
|
18
|
-
key: "hue",
|
|
19
|
-
label: "Hue",
|
|
20
|
-
min: -100
|
|
21
|
-
}, {
|
|
22
|
-
key: "gamma",
|
|
23
|
-
label: "Gamma"
|
|
24
|
-
}, {
|
|
25
|
-
key: "clip",
|
|
26
|
-
label: "Clip"
|
|
27
|
-
}, {
|
|
28
|
-
key: "stackBlur",
|
|
29
|
-
label: "Blur"
|
|
30
|
-
}, {
|
|
31
|
-
key: "contrast",
|
|
32
|
-
label: "Contrast",
|
|
33
|
-
min: -100
|
|
34
|
-
}, {
|
|
35
|
-
key: "saturation",
|
|
36
|
-
label: "Saturation",
|
|
37
|
-
min: -100
|
|
38
|
-
}, {
|
|
39
|
-
key: "exposure",
|
|
40
|
-
label: "Exposure",
|
|
41
|
-
min: -100
|
|
42
|
-
}, {
|
|
43
|
-
key: "sepia",
|
|
44
|
-
label: "Sepia"
|
|
45
|
-
}, {
|
|
46
|
-
key: "noise",
|
|
47
|
-
label: "Noise"
|
|
48
|
-
}, {
|
|
49
|
-
key: "sharpen",
|
|
50
|
-
label: "Sharpen"
|
|
51
|
-
}];
|
|
52
|
-
class RenderForm extends React.Component {
|
|
53
|
-
state = {
|
|
54
|
-
processing: false,
|
|
55
|
-
values: {}
|
|
56
|
-
};
|
|
57
|
-
componentDidMount() {
|
|
58
|
-
this.resetFiltersValues();
|
|
59
|
-
}
|
|
60
|
-
applyFilters = debounce(() => {
|
|
61
|
-
const {
|
|
62
|
-
canvas
|
|
63
|
-
} = this.props;
|
|
64
|
-
const {
|
|
65
|
-
values
|
|
66
|
-
} = this.state;
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
68
|
-
const component = this;
|
|
69
|
-
|
|
70
|
-
// @ts-expect-error
|
|
71
|
-
Caman(canvas.current, function () {
|
|
72
|
-
// @ts-expect-error
|
|
73
|
-
this.revert(false);
|
|
74
|
-
Object.keys(values).forEach(
|
|
75
|
-
// @ts-expect-error
|
|
76
|
-
key => values[key] !== 0 && this[key] && this[key](values[key]));
|
|
77
|
-
// @ts-expect-error
|
|
78
|
-
this.render();
|
|
79
|
-
component.setState({
|
|
80
|
-
processing: false
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
}, 200);
|
|
84
|
-
resetFiltersValues = () => {
|
|
85
|
-
this.setState(state => {
|
|
86
|
-
sliders.reduce((output, current) => {
|
|
87
|
-
state.values[current.key] = 0;
|
|
88
|
-
return output;
|
|
89
|
-
}, {});
|
|
90
|
-
return state;
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
render() {
|
|
94
|
-
return /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(React.Fragment, null, sliders.map(props => /*#__PURE__*/React.createElement(Grid.Column, {
|
|
95
|
-
span: 4,
|
|
96
|
-
key: props.key
|
|
97
|
-
}, /*#__PURE__*/React.createElement(Slider, Object.assign({
|
|
98
|
-
value: Number(this.state.values[props.key]),
|
|
99
|
-
min: 0,
|
|
100
|
-
max: 100,
|
|
101
|
-
disabled: this.state.processing,
|
|
102
|
-
onValueChange: value => {
|
|
103
|
-
this.setState(state => {
|
|
104
|
-
const values = {
|
|
105
|
-
...state.values
|
|
106
|
-
};
|
|
107
|
-
values[props.key] = value;
|
|
108
|
-
return {
|
|
109
|
-
...state,
|
|
110
|
-
processing: true,
|
|
111
|
-
values
|
|
112
|
-
};
|
|
113
|
-
}, this.applyFilters);
|
|
114
|
-
}
|
|
115
|
-
}, props))))), /*#__PURE__*/React.createElement(Grid.Column, {
|
|
116
|
-
span: 12,
|
|
117
|
-
className: "text-center"
|
|
118
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
119
|
-
text: "Reset filters",
|
|
120
|
-
variant: "secondary",
|
|
121
|
-
onClick: () => {
|
|
122
|
-
this.setState({
|
|
123
|
-
processing: true
|
|
124
|
-
}, () => {
|
|
125
|
-
this.resetFiltersValues();
|
|
126
|
-
this.applyFilters();
|
|
127
|
-
this.setState({
|
|
128
|
-
processing: false
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
})));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const tool = {
|
|
136
|
-
name: "filter",
|
|
137
|
-
icon({
|
|
138
|
-
activateTool
|
|
139
|
-
}) {
|
|
140
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
141
|
-
trigger: /*#__PURE__*/React.createElement(IconButton, {
|
|
142
|
-
variant: "ghost",
|
|
143
|
-
icon: /*#__PURE__*/React.createElement(FilterIcon, null),
|
|
144
|
-
onClick: () => activateTool("filter"),
|
|
145
|
-
"data-testid": "filter-item"
|
|
146
|
-
}),
|
|
147
|
-
content: "Filter"
|
|
148
|
-
});
|
|
149
|
-
},
|
|
150
|
-
renderForm(props) {
|
|
151
|
-
return /*#__PURE__*/React.createElement(RenderForm, props);
|
|
152
|
-
},
|
|
153
|
-
cancel: ({
|
|
154
|
-
canvas
|
|
155
|
-
}) => {
|
|
156
|
-
// @ts-expect-error
|
|
157
|
-
Caman(canvas.current, function () {
|
|
158
|
-
// @ts-expect-error
|
|
159
|
-
this.revert(false);
|
|
160
|
-
// @ts-expect-error
|
|
161
|
-
this.render();
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
export default tool;
|
|
166
|
-
|
|
167
|
-
//# sourceMappingURL=filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","ReactComponent","FilterIcon","debounce","Button","Grid","IconButton","Slider","Tooltip","sliders","key","label","min","RenderForm","Component","state","processing","values","componentDidMount","resetFiltersValues","applyFilters","canvas","props","component","Caman","current","revert","Object","keys","forEach","render","setState","reduce","output","createElement","Fragment","map","Column","span","assign","value","Number","max","disabled","onValueChange","className","text","variant","onClick","tool","name","icon","activateTool","trigger","content","renderForm","cancel"],"sources":["filter.tsx"],"sourcesContent":["/**\n * When using Caman, we added @ts-expect-error because it does not exist in packages, but it is loaded in packages/ui/src/ImageEditor/ImageEditor.tsx:38.\n * TODO: use some other library to edit images\n */\nimport React from \"react\";\nimport { ReactComponent as FilterIcon } from \"@webiny/icons/tune.svg\";\nimport debounce from \"lodash/debounce.js\";\nimport { Button, Grid, IconButton, Slider, Tooltip } from \"@webiny/admin-ui\";\nimport type { ImageEditorTool } from \"./types.js\";\n\ninterface RenderFormState {\n values: Record<string, any>;\n processing: boolean;\n}\n\ninterface RenderFormProps {\n canvas: any;\n renderApplyCancel?: () => void;\n}\n\nconst sliders = [\n {\n key: \"brightness\",\n label: \"Brightness\",\n min: -100\n },\n {\n key: \"vibrance\",\n label: \"Vibrance\",\n min: -100\n },\n {\n key: \"hue\",\n label: \"Hue\",\n min: -100\n },\n {\n key: \"gamma\",\n label: \"Gamma\"\n },\n {\n key: \"clip\",\n label: \"Clip\"\n },\n {\n key: \"stackBlur\",\n label: \"Blur\"\n },\n {\n key: \"contrast\",\n label: \"Contrast\",\n min: -100\n },\n {\n key: \"saturation\",\n label: \"Saturation\",\n min: -100\n },\n {\n key: \"exposure\",\n label: \"Exposure\",\n min: -100\n },\n {\n key: \"sepia\",\n label: \"Sepia\"\n },\n {\n key: \"noise\",\n label: \"Noise\"\n },\n {\n key: \"sharpen\",\n label: \"Sharpen\"\n }\n];\n\nclass RenderForm extends React.Component<RenderFormProps, RenderFormState> {\n public override state: RenderFormState = {\n processing: false,\n values: {}\n };\n\n public override componentDidMount() {\n this.resetFiltersValues();\n }\n\n private readonly applyFilters = debounce(() => {\n const { canvas } = this.props;\n const { values } = this.state;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const component = this;\n\n // @ts-expect-error\n Caman(canvas.current, function () {\n // @ts-expect-error\n this.revert(false);\n Object.keys(values).forEach(\n // @ts-expect-error\n key => values[key] !== 0 && this[key] && this[key](values[key])\n );\n // @ts-expect-error\n this.render();\n component.setState({ processing: false });\n });\n }, 200);\n\n private readonly resetFiltersValues = () => {\n this.setState(state => {\n sliders.reduce((output, current) => {\n state.values[current.key] = 0;\n return output;\n }, {});\n\n return state;\n });\n };\n\n public override render() {\n return (\n <Grid>\n <>\n {sliders.map(props => (\n <Grid.Column span={4} key={props.key}>\n <Slider\n value={Number(this.state.values[props.key])}\n min={0}\n max={100}\n disabled={this.state.processing}\n onValueChange={(value: number) => {\n this.setState(state => {\n const values = { ...state.values };\n values[props.key] = value;\n\n return { ...state, processing: true, values };\n }, this.applyFilters);\n }}\n {...props}\n />\n </Grid.Column>\n ))}\n </>\n <Grid.Column span={12} className={\"text-center\"}>\n <Button\n text={\"Reset filters\"}\n variant={\"secondary\"}\n onClick={() => {\n this.setState({ processing: true }, () => {\n this.resetFiltersValues();\n this.applyFilters();\n this.setState({ processing: false });\n });\n }}\n />\n </Grid.Column>\n </Grid>\n );\n }\n}\n\nconst tool: ImageEditorTool = {\n name: \"filter\",\n icon({ activateTool }) {\n return (\n <Tooltip\n trigger={\n <IconButton\n variant={\"ghost\"}\n icon={<FilterIcon />}\n onClick={() => activateTool(\"filter\")}\n data-testid={\"filter-item\"}\n />\n }\n content={\"Filter\"}\n />\n );\n },\n renderForm(props) {\n return <RenderForm {...props} />;\n },\n cancel: ({ canvas }) => {\n // @ts-expect-error\n Caman(canvas.current, function () {\n // @ts-expect-error\n this.revert(false);\n // @ts-expect-error\n this.render();\n });\n }\n};\n\nexport default tool;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,IAAIC,UAAU,QAAQ,wBAAwB;AACrE,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,SAASC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAQ,kBAAkB;AAa5E,MAAMC,OAAO,GAAG,CACZ;EACIC,GAAG,EAAE,YAAY;EACjBC,KAA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5B,UAAU;QACPyC,OAAO,EAAE,OAAQ;QACjBI,IAAI,eAAEnD,KAAA,CAAAkC,aAAA,CAAChC,UAAU,MAAE,CAAE;QACrB8C,OAAO,EAAEA,CAAA,KAAMI,YAAY,CAAC,QAAQ,CAAE;QACtC,eAAa;MAAc,CAC9B,CACJ;MACDE,OAAO,EAAE;IAAS,CACrB,CAAC;EAEV,CAAC;EACDC,UAAUA,CAACjC,KAAK,EAAE;IACd,oBAAOtB,KAAA,CAAAkC,aAAA,CAACrB,UAAU,EAAKS,KAAQ,CAAC;EACpC,CAAC;EACDkC,MAAM,EAAEA,CAAC;IAAEnC;EAAO,CAAC,KAAK;IACpB;IACAG,KAAK,CAACH,MAAM,CAACI,OAAO,EAAE,YAAY;MAC9B;MACA,IAAI,CAACC,MAAM,CAAC,KAAK,CAAC;MAClB;MACA,IAAI,CAACI,MAAM,CAAC,CAAC;IACjB,CAAC,CAAC;EACN;AACJ,CAAC;AAED,eAAemB,IAAI","ignoreList":[]}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Button, IconButton, Tooltip } from "@webiny/admin-ui";
|
|
3
|
-
import { ReactComponent as FlipIcon } from "@webiny/icons/flip.svg";
|
|
4
|
-
import Cropper from "cropperjs";
|
|
5
|
-
import "cropperjs/dist/cropper.css";
|
|
6
|
-
let cropper;
|
|
7
|
-
const flipped = {
|
|
8
|
-
x: 1,
|
|
9
|
-
y: 1
|
|
10
|
-
};
|
|
11
|
-
const renderForm = () => {
|
|
12
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
13
|
-
className: "flex justify-center gap-sm"
|
|
14
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
15
|
-
text: "FlipX",
|
|
16
|
-
variant: "secondary",
|
|
17
|
-
onClick: () => {
|
|
18
|
-
if (!cropper) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
flipped.x = flipped.x === 1 ? -1 : 1;
|
|
22
|
-
cropper.scaleX(flipped.x);
|
|
23
|
-
}
|
|
24
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
25
|
-
text: "FlipY",
|
|
26
|
-
variant: "secondary",
|
|
27
|
-
onClick: () => {
|
|
28
|
-
if (!cropper) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
flipped.y = flipped.y === 1 ? -1 : 1;
|
|
32
|
-
cropper.scaleY(flipped.y);
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
36
|
-
const tool = {
|
|
37
|
-
name: "flip",
|
|
38
|
-
icon({
|
|
39
|
-
activateTool
|
|
40
|
-
}) {
|
|
41
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
42
|
-
side: "bottom",
|
|
43
|
-
content: "Flip",
|
|
44
|
-
trigger: /*#__PURE__*/React.createElement(IconButton, {
|
|
45
|
-
variant: "ghost",
|
|
46
|
-
icon: /*#__PURE__*/React.createElement(FlipIcon, null),
|
|
47
|
-
onClick: () => activateTool("flip"),
|
|
48
|
-
"data-testid": "flip-item"
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
renderForm,
|
|
53
|
-
cancel: () => cropper && cropper.destroy(),
|
|
54
|
-
onActivate: ({
|
|
55
|
-
canvas
|
|
56
|
-
}) => {
|
|
57
|
-
cropper = new Cropper(canvas.current, {
|
|
58
|
-
background: false,
|
|
59
|
-
modal: false,
|
|
60
|
-
guides: false,
|
|
61
|
-
dragMode: "none",
|
|
62
|
-
highlight: false,
|
|
63
|
-
autoCrop: false
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
apply: ({
|
|
67
|
-
canvas
|
|
68
|
-
}) => {
|
|
69
|
-
return new Promise(resolve => {
|
|
70
|
-
if (!cropper) {
|
|
71
|
-
resolve();
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const current = canvas.current;
|
|
75
|
-
const src = cropper.getCroppedCanvas().toDataURL();
|
|
76
|
-
if (current) {
|
|
77
|
-
const image = new window.Image();
|
|
78
|
-
const ctx = current.getContext("2d");
|
|
79
|
-
image.onload = () => {
|
|
80
|
-
ctx.drawImage(image, 0, 0);
|
|
81
|
-
current.width = image.width;
|
|
82
|
-
current.height = image.height;
|
|
83
|
-
ctx.drawImage(image, 0, 0);
|
|
84
|
-
resolve();
|
|
85
|
-
};
|
|
86
|
-
image.src = src;
|
|
87
|
-
}
|
|
88
|
-
cropper.destroy();
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
export default tool;
|
|
93
|
-
|
|
94
|
-
//# sourceMappingURL=flip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","Button","IconButton","Tooltip","ReactComponent","FlipIcon","Cropper","cropper","flipped","x","y","renderForm","createElement","className","text","variant","onClick","scaleX","scaleY","tool","name","icon","activateTool","side","content","trigger","cancel","destroy","onActivate","canvas","current","background","modal","guides","dragMode","highlight","autoCrop","apply","Promise","resolve","src","getCroppedCanvas","toDataURL","image","window","Image","ctx","getContext","onload","drawImage","width","height"],"sources":["flip.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button, IconButton, Tooltip } from \"@webiny/admin-ui\";\nimport { ReactComponent as FlipIcon } from \"@webiny/icons/flip.svg\";\nimport Cropper from \"cropperjs\";\nimport \"cropperjs/dist/cropper.css\";\nimport type { ImageEditorTool } from \"./types.js\";\n\nlet cropper: Cropper;\n\nconst flipped = { x: 1, y: 1 };\n\nconst renderForm = () => {\n return (\n <div className={\"flex justify-center gap-sm\"}>\n <Button\n text={\"FlipX\"}\n variant={\"secondary\"}\n onClick={() => {\n if (!cropper) {\n return;\n }\n\n flipped.x = flipped.x === 1 ? -1 : 1;\n cropper.scaleX(flipped.x);\n }}\n />\n <Button\n text={\"FlipY\"}\n variant={\"secondary\"}\n onClick={() => {\n if (!cropper) {\n return;\n }\n\n flipped.y = flipped.y === 1 ? -1 : 1;\n cropper.scaleY(flipped.y);\n }}\n />\n </div>\n );\n};\n\nconst tool: ImageEditorTool = {\n name: \"flip\",\n icon({ activateTool }) {\n return (\n <Tooltip\n side={\"bottom\"}\n content={\"Flip\"}\n trigger={\n <IconButton\n variant={\"ghost\"}\n icon={<FlipIcon />}\n onClick={() => activateTool(\"flip\")}\n data-testid={\"flip-item\"}\n />\n }\n />\n );\n },\n renderForm,\n cancel: () => cropper && cropper.destroy(),\n onActivate: ({ canvas }) => {\n cropper = new Cropper(canvas.current as HTMLCanvasElement, {\n background: false,\n modal: false,\n guides: false,\n dragMode: \"none\",\n highlight: false,\n autoCrop: false\n });\n },\n apply: ({ canvas }) => {\n return new Promise((resolve: any) => {\n if (!cropper) {\n resolve();\n return;\n }\n\n const current = canvas.current;\n const src = cropper.getCroppedCanvas().toDataURL();\n if (current) {\n const image = new window.Image();\n const ctx = current.getContext(\"2d\") as CanvasRenderingContext2D;\n image.onload = () => {\n ctx.drawImage(image, 0, 0);\n current.width = image.width;\n current.height = image.height;\n\n ctx.drawImage(image, 0, 0);\n resolve();\n };\n image.src = src;\n }\n\n cropper.destroy();\n });\n }\n};\n\nexport default tool;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,QAAQ,kBAAkB;AAC9D,SAASC,cAAc,IAAIC,QAAQ,QAAQ,wBAAwB;AACnE,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,4BAA4B;AAGnC,IAAIC,OAAgB;AAEpB,MAAMC,OAAO,GAAG;EAAEC,CAAC,EAAE,CAAC;EAAEC,CAAC,EAAE;AAAE,CAAC;AAE9B,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACrB,oBACIX,KAAA,CAAAY,aAAA;IAAKC,SAAS,EAAE;EAA6B,gBACzCb,KAAA,CAAAY,aAAA,CAACX,MAAM;IACHa,IAAI,EAAE,OAAQ;IACdC,OAAO,EAAE,WAAY;IACrBC,OAAO,EAAEA,CAAA,KAAM;MACX,IAAI,CAACT,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K,EAAE,KAAK;MACZC,MAAM,EAAE,KAAK;MACbC,QAAQ,EAAE,MAAM;MAChBC,SAAS,EAAE,KAAK;MAChBC,QAAQ,EAAE;IACd,CAAC,CAAC;EACN,CAAC;EACDC,KAAK,EAAEA,CAAC;IAAER;EAAO,CAAC,KAAK;IACnB,OAAO,IAAIS,OAAO,CAAEC,OAAY,IAAK;MACjC,IAAI,CAAChC,OAAO,EAAE;QACVgC,OAAO,CAAC,CAAC;QACT;MACJ;MAEA,MAAMT,OAAO,GAAGD,MAAM,CAACC,OAAO;MAC9B,MAAMU,GAAG,GAAGjC,OAAO,CAACkC,gBAAgB,CAAC,CAAC,CAACC,SAAS,CAAC,CAAC;MAClD,IAAIZ,OAAO,EAAE;QACT,MAAMa,KAAK,GAAG,IAAIC,MAAM,CAACC,KAAK,CAAC,CAAC;QAChC,MAAMC,GAAG,GAAGhB,OAAO,CAACiB,UAAU,CAAC,IAAI,CAA6B;QAChEJ,KAAK,CAACK,MAAM,GAAG,MAAM;UACjBF,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1Bb,OAAO,CAACoB,KAAK,GAAGP,KAAK,CAACO,KAAK;UAC3BpB,OAAO,CAACqB,MAAM,GAAGR,KAAK,CAACQ,MAAM;UAE7BL,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1BJ,OAAO,CAAC,CAAC;QACb,CAAC;QACDI,KAAK,CAACH,GAAG,GAAGA,GAAG;MACnB;MAEAjC,OAAO,CAACoB,OAAO,CAAC,CAAC;IACrB,CAAC,CAAC;EACN;AACJ,CAAC;AAED,eAAeR,IAAI","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["default","crop","flip","filter","rotate"],"sources":["index.ts"],"sourcesContent":["export { default as crop } from \"./crop.js\";\nexport { default as flip } from \"./flip.js\";\nexport { default as filter } from \"./filter.js\";\nexport { default as rotate } from \"./rotate.js\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAAI;AACxB,SAASD,OAAO,IAAIE,IAAI;AACxB,SAASF,OAAO,IAAIG,MAAM;AAC1B,SAASH,OAAO,IAAII,MAAM","ignoreList":[]}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { IconButton, Slider, Tooltip } from "@webiny/admin-ui";
|
|
3
|
-
import { ReactComponent as RotateRight } from "@webiny/icons/rotate_right.svg";
|
|
4
|
-
import Cropper from "cropperjs";
|
|
5
|
-
import "cropperjs/dist/cropper.css";
|
|
6
|
-
let cropper;
|
|
7
|
-
class RenderForm extends React.Component {
|
|
8
|
-
state = {
|
|
9
|
-
rangeInput: 0
|
|
10
|
-
};
|
|
11
|
-
render() {
|
|
12
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Slider, {
|
|
13
|
-
label: "Range Input",
|
|
14
|
-
value: Number(this.state.rangeInput),
|
|
15
|
-
min: 0,
|
|
16
|
-
max: 360,
|
|
17
|
-
step: 10,
|
|
18
|
-
onValueChange: value => {
|
|
19
|
-
this.setState({
|
|
20
|
-
rangeInput: value
|
|
21
|
-
}, async () => {
|
|
22
|
-
if (cropper) {
|
|
23
|
-
cropper.rotateTo(parseInt(String(value), 10));
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const tool = {
|
|
31
|
-
name: "rotate",
|
|
32
|
-
icon({
|
|
33
|
-
activateTool
|
|
34
|
-
}) {
|
|
35
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
36
|
-
side: "bottom",
|
|
37
|
-
content: "Rotate",
|
|
38
|
-
trigger: /*#__PURE__*/React.createElement(IconButton, {
|
|
39
|
-
variant: "ghost",
|
|
40
|
-
icon: /*#__PURE__*/React.createElement(RotateRight, null),
|
|
41
|
-
onClick: () => activateTool("rotate"),
|
|
42
|
-
"data-testid": "rotate-item"
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
renderForm(props) {
|
|
47
|
-
return /*#__PURE__*/React.createElement(RenderForm, props);
|
|
48
|
-
},
|
|
49
|
-
onActivate: ({
|
|
50
|
-
canvas
|
|
51
|
-
}) => {
|
|
52
|
-
/**
|
|
53
|
-
* We can safely cast canvas.current as HTMLCanvasElement
|
|
54
|
-
*/
|
|
55
|
-
cropper = new Cropper(canvas.current, {
|
|
56
|
-
background: false,
|
|
57
|
-
modal: false,
|
|
58
|
-
guides: false,
|
|
59
|
-
dragMode: "none",
|
|
60
|
-
highlight: false,
|
|
61
|
-
autoCrop: false
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
cancel: () => cropper && cropper.destroy(),
|
|
65
|
-
apply: ({
|
|
66
|
-
canvas
|
|
67
|
-
}) => {
|
|
68
|
-
return new Promise(resolve => {
|
|
69
|
-
if (!cropper) {
|
|
70
|
-
resolve();
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const current = canvas.current;
|
|
74
|
-
const src = cropper.getCroppedCanvas().toDataURL();
|
|
75
|
-
if (current) {
|
|
76
|
-
const image = new window.Image();
|
|
77
|
-
const ctx = current.getContext("2d");
|
|
78
|
-
image.onload = () => {
|
|
79
|
-
ctx.drawImage(image, 0, 0);
|
|
80
|
-
current.width = image.width;
|
|
81
|
-
current.height = image.height;
|
|
82
|
-
ctx.drawImage(image, 0, 0);
|
|
83
|
-
};
|
|
84
|
-
image.src = src;
|
|
85
|
-
resolve();
|
|
86
|
-
}
|
|
87
|
-
cropper.destroy();
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
export default tool;
|
|
92
|
-
|
|
93
|
-
//# sourceMappingURL=rotate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","IconButton","Slider","Tooltip","ReactComponent","RotateRight","Cropper","cropper","RenderForm","Component","state","rangeInput","render","createElement","label","value","Number","min","max","step","onValueChange","setState","rotateTo","parseInt","String","tool","name","icon","activateTool","side","content","trigger","variant","onClick","renderForm","props","onActivate","canvas","current","background","modal","guides","dragMode","highlight","autoCrop","cancel","destroy","apply","Promise","resolve","src","getCroppedCanvas","toDataURL","image","window","Image","ctx","getContext","onload","drawImage","width","height"],"sources":["rotate.tsx"],"sourcesContent":["import React from \"react\";\nimport { IconButton, Slider, Tooltip } from \"@webiny/admin-ui\";\nimport { ReactComponent as RotateRight } from \"@webiny/icons/rotate_right.svg\";\nimport type { ImageEditorTool } from \"./types.js\";\n\nimport Cropper from \"cropperjs\";\nimport \"cropperjs/dist/cropper.css\";\n\nlet cropper: Cropper;\n\nclass RenderForm extends React.Component<any, any> {\n public override state = {\n rangeInput: 0\n };\n\n public override render() {\n return (\n <div>\n <Slider\n label={\"Range Input\"}\n value={Number(this.state.rangeInput)}\n min={0}\n max={360}\n step={10}\n onValueChange={(value: number) => {\n this.setState({ rangeInput: value }, async () => {\n if (cropper) {\n cropper.rotateTo(parseInt(String(value), 10));\n }\n });\n }}\n />\n </div>\n );\n }\n}\n\nconst tool: ImageEditorTool = {\n name: \"rotate\",\n icon({ activateTool }) {\n return (\n <Tooltip\n side={\"bottom\"}\n content={\"Rotate\"}\n trigger={\n <IconButton\n variant={\"ghost\"}\n icon={<RotateRight />}\n onClick={() => activateTool(\"rotate\")}\n data-testid={\"rotate-item\"}\n />\n }\n />\n );\n },\n renderForm(props) {\n return <RenderForm {...props} />;\n },\n onActivate: ({ canvas }) => {\n /**\n * We can safely cast canvas.current as HTMLCanvasElement\n */\n cropper = new Cropper(canvas.current as HTMLCanvasElement, {\n background: false,\n modal: false,\n guides: false,\n dragMode: \"none\",\n highlight: false,\n autoCrop: false\n });\n },\n cancel: () => cropper && cropper.destroy(),\n apply: ({ canvas }) => {\n return new Promise((resolve: any) => {\n if (!cropper) {\n resolve();\n return;\n }\n\n const current = canvas.current;\n const src = cropper.getCroppedCanvas().toDataURL();\n if (current) {\n const image = new window.Image();\n const ctx = current.getContext(\"2d\") as CanvasRenderingContext2D;\n image.onload = () => {\n ctx.drawImage(image, 0, 0);\n current.width = image.width;\n current.height = image.height;\n\n ctx.drawImage(image, 0, 0);\n };\n image.src = src;\n resolve();\n }\n\n cropper.destroy();\n });\n }\n};\n\nexport default tool;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAQ,kBAAkB;AAC9D,SAASC,cAAc,IAAIC,WAAW,QAAQ,gCAAgC;AAG9E,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,4BAA4B;AAEnC,IAAIC,OAAgB;AAEpB,MAAMC,UAAU,SAASR,KAAK,CAACS,SAAS,CAAW;EAC/BC,KAAK,GAAG;IACpBC,UAAU,EAAE;EAChB,CAAC;EAEeC,MAAMA,CAAA,EAAG;IACrB,oBACIZ,KAAA,CAAAa,aAAA,2BACIb,KAAA,CAAAa,aAAA,CAACX,MAAM;MACHY,KAAK,EAAE,aAAc;MACrBC,KAAK,EAAEC,MAAM,CAAC,IAAI,CAACN,KAAK,CAACC,UAAU,CAAE;MACrCM,GAAG,EAAE,CAAE;MACPC,GAAG,EAAE,GAAI;MACTC,IAAI,EAAE,EAAG;MACTC,aAAa,EAAGL,KAAa,IAAK;QAC9B,IAAI,CAACM,QAAQ,CAAC;UAAEV,UAAU,EAAEI;QAAM,CAAC,EAAE,YAAY;UAC7C,IAAIR,OAAO,EAAE;YACTA,OAAO,CAACe,QAAQ,CAACC,QAAQ,CAACC,MAAM,CAACT,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;UACjD;QACJ,CAAC,CAAC;MACN;IAAE,CACL,CACA,CAAC;EAEd;AACJ;AAEA,MAAMU,IAAqB,GAAG;EAC1BC,IAAI,EAAE,QAAQ;EACdC,IAAIA,CAAC;IAAEC;EAAa,CAAC,EAAE;IACnB,oBACI5B,KAAA,CAAAa,aAAA,CAACV,OAA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AAU,CAAC,IAAI,CAA6B;QAChEJ,KAAK,CAACK,MAAM,GAAG,MAAM;UACjBF,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1Bf,OAAO,CAACsB,KAAK,GAAGP,KAAK,CAACO,KAAK;UAC3BtB,OAAO,CAACuB,MAAM,GAAGR,KAAK,CAACQ,MAAM;UAE7BL,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9B,CAAC;QACDA,KAAK,CAACH,GAAG,GAAGA,GAAG;QACfD,OAAO,CAAC,CAAC;MACb;MAEA1C,OAAO,CAACuC,OAAO,CAAC,CAAC;IACrB,CAAC,CAAC;EACN;AACJ,CAAC;AAED,eAAerB,IAAI","ignoreList":[]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
export type ToolbarTool = "crop" | "flip" | "rotate" | "filter";
|
|
3
|
-
interface RenderFormParams {
|
|
4
|
-
canvas: React.RefObject<HTMLCanvasElement | null>;
|
|
5
|
-
image: HTMLImageElement;
|
|
6
|
-
renderApplyCancel?: () => void;
|
|
7
|
-
options?: {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface OnActivateParams {
|
|
12
|
-
options: any;
|
|
13
|
-
canvas: React.RefObject<HTMLCanvasElement | null>;
|
|
14
|
-
}
|
|
15
|
-
interface IconParams {
|
|
16
|
-
activateTool: (tool: ToolbarTool) => void;
|
|
17
|
-
}
|
|
18
|
-
interface ApplyParams {
|
|
19
|
-
canvas: React.RefObject<HTMLCanvasElement | null>;
|
|
20
|
-
}
|
|
21
|
-
interface CancelParams {
|
|
22
|
-
canvas: React.RefObject<HTMLCanvasElement | null>;
|
|
23
|
-
}
|
|
24
|
-
export interface ImageEditorTool {
|
|
25
|
-
name: string;
|
|
26
|
-
apply?: (params: ApplyParams) => void;
|
|
27
|
-
cancel?: (params: CancelParams) => void;
|
|
28
|
-
onActivate?: (params: OnActivateParams) => void;
|
|
29
|
-
icon: (params: IconParams) => React.ReactElement<any>;
|
|
30
|
-
renderForm?: (params: RenderFormParams) => React.ReactNode;
|
|
31
|
-
}
|
|
32
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type React from \"react\";\n\nexport type ToolbarTool = \"crop\" | \"flip\" | \"rotate\" | \"filter\";\n\ninterface RenderFormParams {\n canvas: React.RefObject<HTMLCanvasElement | null>;\n image: HTMLImageElement;\n renderApplyCancel?: () => void;\n options?: { [key: string]: any };\n}\n\ninterface OnActivateParams {\n options: any;\n canvas: React.RefObject<HTMLCanvasElement | null>;\n}\n\ninterface IconParams {\n activateTool: (tool: ToolbarTool) => void;\n}\n\ninterface ApplyParams {\n canvas: React.RefObject<HTMLCanvasElement | null>;\n}\n\ninterface CancelParams {\n canvas: React.RefObject<HTMLCanvasElement | null>;\n}\n\nexport interface ImageEditorTool {\n name: string;\n apply?: (params: ApplyParams) => void;\n cancel?: (params: CancelParams) => void;\n onActivate?: (params: OnActivateParams) => void;\n icon: (params: IconParams) => React.ReactElement<any>;\n renderForm?: (params: RenderFormParams) => React.ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
// @ts-expect-error
|
|
3
|
-
import { Hotkeys } from "react-hotkeyz";
|
|
4
|
-
// @ts-expect-error
|
|
5
|
-
import dataURLtoBlob from "dataurl-to-blob";
|
|
6
|
-
import { ImageEditorDialog } from "../../../../components/ImageEditor/ImageEditorDialog.js";
|
|
7
|
-
import { ReactComponent as EditIcon } from "@webiny/icons/edit.svg";
|
|
8
|
-
import { FileManagerViewConfig, useFile, useFileDetails, useFileManagerApi, useFileManagerView } from "../../../../index.js";
|
|
9
|
-
import { useSnackbar } from "@webiny/app-admin";
|
|
10
|
-
function toDataUrl(url) {
|
|
11
|
-
return new Promise(resolve => {
|
|
12
|
-
const xhr = new window.XMLHttpRequest();
|
|
13
|
-
xhr.onload = function () {
|
|
14
|
-
const reader = new window.FileReader();
|
|
15
|
-
reader.onloadend = function () {
|
|
16
|
-
resolve(reader.result);
|
|
17
|
-
};
|
|
18
|
-
reader.readAsDataURL(xhr.response);
|
|
19
|
-
};
|
|
20
|
-
xhr.open("GET", url);
|
|
21
|
-
xhr.responseType = "blob";
|
|
22
|
-
xhr.send();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const initialState = {
|
|
26
|
-
showImageEditor: false,
|
|
27
|
-
dataUrl: null
|
|
28
|
-
};
|
|
29
|
-
const reducer = (state, action) => {
|
|
30
|
-
const next = {
|
|
31
|
-
...state
|
|
32
|
-
};
|
|
33
|
-
switch (action.type) {
|
|
34
|
-
case "setDataUrl":
|
|
35
|
-
next.dataUrl = action.dataUrl;
|
|
36
|
-
next.showImageEditor = true;
|
|
37
|
-
break;
|
|
38
|
-
case "hideImageEditor":
|
|
39
|
-
next.dataUrl = null;
|
|
40
|
-
next.showImageEditor = false;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
return next;
|
|
44
|
-
};
|
|
45
|
-
const {
|
|
46
|
-
FileDetails
|
|
47
|
-
} = FileManagerViewConfig;
|
|
48
|
-
export const EditImage = () => {
|
|
49
|
-
const {
|
|
50
|
-
file
|
|
51
|
-
} = useFile();
|
|
52
|
-
const {
|
|
53
|
-
canEdit
|
|
54
|
-
} = useFileManagerApi();
|
|
55
|
-
const fileDetails = useFileDetails();
|
|
56
|
-
const {
|
|
57
|
-
uploadFile
|
|
58
|
-
} = useFileManagerView();
|
|
59
|
-
const [state, dispatch] = React.useReducer(reducer, initialState);
|
|
60
|
-
const {
|
|
61
|
-
showSnackbar
|
|
62
|
-
} = useSnackbar();
|
|
63
|
-
if (!file.type.startsWith("image/")) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Render nothing if the user doesn't have the required permissions for "edit".
|
|
68
|
-
if (!canEdit(file)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FileDetails.Action.Button, {
|
|
72
|
-
className: "order-last ml-auto",
|
|
73
|
-
label: "Edit image",
|
|
74
|
-
"data-testid": "fm-edit-image-button",
|
|
75
|
-
icon: /*#__PURE__*/React.createElement(EditIcon, null),
|
|
76
|
-
onAction: async () => {
|
|
77
|
-
const dataUrl = await toDataUrl(file.src);
|
|
78
|
-
dispatch({
|
|
79
|
-
type: "setDataUrl",
|
|
80
|
-
dataUrl
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}), /*#__PURE__*/React.createElement(Hotkeys, {
|
|
84
|
-
zIndex: 100,
|
|
85
|
-
disabled: !state.dataUrl
|
|
86
|
-
}, /*#__PURE__*/React.createElement(ImageEditorDialog, {
|
|
87
|
-
"data-testid": "fm-image-editor-dialog",
|
|
88
|
-
dialogZIndex: 100,
|
|
89
|
-
open: state.showImageEditor,
|
|
90
|
-
src: state.dataUrl,
|
|
91
|
-
onClose: () => dispatch({
|
|
92
|
-
type: "hideImageEditor"
|
|
93
|
-
}),
|
|
94
|
-
onAccept: async src => {
|
|
95
|
-
const blob = dataURLtoBlob(src);
|
|
96
|
-
blob.name = file.name;
|
|
97
|
-
blob.key = file.key.split("/").pop();
|
|
98
|
-
const newFile = await uploadFile(blob);
|
|
99
|
-
if (newFile) {
|
|
100
|
-
showSnackbar("A new version of the image has been created!");
|
|
101
|
-
dispatch({
|
|
102
|
-
type: "hideImageEditor"
|
|
103
|
-
});
|
|
104
|
-
fileDetails.setFile(newFile);
|
|
105
|
-
fileDetails.close();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
})));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
//# sourceMappingURL=EditImage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","Hotkeys","dataURLtoBlob","ImageEditorDialog","ReactComponent","EditIcon","FileManagerViewConfig","useFile","useFileDetails","useFileManagerApi","useFileManagerView","useSnackbar","toDataUrl","url","Promise","resolve","xhr","window","XMLHttpRequest","onload","reader","FileReader","onloadend","result","readAsDataURL","response","open","responseType","send","initialState","showImageEditor","dataUrl","reducer","state","action","next","type","FileDetails","EditImage","file","canEdit","fileDetails","uploadFile","dispatch","useReducer","showSnackbar","startsWith","createElement","Fragment","Action","Button","className","label","icon","onAction","src","zIndex","disabled","dialogZIndex","onClose","onAccept","blob","name","key","split","pop","newFile","setFile","close"],"sources":["EditImage.tsx"],"sourcesContent":["import React from \"react\";\n// @ts-expect-error\nimport { Hotkeys } from \"react-hotkeyz\";\n// @ts-expect-error\nimport dataURLtoBlob from \"dataurl-to-blob\";\nimport { ImageEditorDialog } from \"~/components/ImageEditor/ImageEditorDialog.js\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport {\n FileManagerViewConfig,\n useFile,\n useFileDetails,\n useFileManagerApi,\n useFileManagerView\n} from \"~/index.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\n\nfunction toDataUrl(url: string): Promise<string> {\n return new Promise((resolve: (value: string) => void) => {\n const xhr = new window.XMLHttpRequest();\n xhr.onload = function () {\n const reader = new window.FileReader();\n reader.onloadend = function () {\n resolve(reader.result as string);\n };\n reader.readAsDataURL(xhr.response);\n };\n xhr.open(\"GET\", url);\n xhr.responseType = \"blob\";\n xhr.send();\n });\n}\n\ninterface State {\n showImageEditor: boolean;\n dataUrl: string | null;\n}\n\ninterface Action {\n type: \"setDataUrl\" | \"hideImageEditor\";\n dataUrl?: string | null;\n}\n\nconst initialState: State = {\n showImageEditor: false,\n dataUrl: null\n};\n\nconst reducer = (state: State, action: Action): State => {\n const next: State = { ...state };\n\n switch (action.type) {\n case \"setDataUrl\":\n next.dataUrl = action.dataUrl as string;\n next.showImageEditor = true;\n break;\n case \"hideImageEditor\":\n next.dataUrl = null;\n next.showImageEditor = false;\n break;\n }\n\n return next;\n};\n\nconst { FileDetails } = FileManagerViewConfig;\n\nexport const EditImage = () => {\n const { file } = useFile();\n const { canEdit } = useFileManagerApi();\n const fileDetails = useFileDetails();\n const { uploadFile } = useFileManagerView();\n const [state, dispatch] = React.useReducer(reducer, initialState);\n const { showSnackbar } = useSnackbar();\n\n if (!file.type.startsWith(\"image/\")) {\n return null;\n }\n\n // Render nothing if the user doesn't have the required permissions for \"edit\".\n if (!canEdit(file)) {\n return null;\n }\n\n return (\n <>\n <FileDetails.Action.Button\n className={\"order-last ml-auto\"}\n label={\"Edit image\"}\n data-testid={\"fm-edit-image-button\"}\n icon={<EditIcon />}\n onAction={async () => {\n const dataUrl = await toDataUrl(file.src);\n dispatch({ type: \"setDataUrl\", dataUrl });\n }}\n />\n <Hotkeys zIndex={100} disabled={!state.dataUrl}>\n <ImageEditorDialog\n data-testid={\"fm-image-editor-dialog\"}\n dialogZIndex={100}\n open={state.showImageEditor}\n src={state.dataUrl as string}\n onClose={() => dispatch({ type: \"hideImageEditor\" })}\n onAccept={async src => {\n const blob = dataURLtoBlob(src);\n blob.name = file.name;\n blob.key = file.key.split(\"/\").pop();\n const newFile = await uploadFile(blob);\n\n if (newFile) {\n showSnackbar(\"A new version of the image has been created!\");\n dispatch({ type: \"hideImageEditor\" });\n fileDetails.setFile(newFile);\n fileDetails.close();\n }\n }}\n />\n </Hotkeys>\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB;AACA,SAASC,OAAO,QAAQ,eAAe;AACvC;AACA,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,SAASC,iBAAiB;AAC1B,SAASC,cAAc,IAAIC,QAAQ,QAAQ,wBAAwB;AACnE,SACIC,qBAAqB,EACrBC,OAAO,EACPC,cAAc,EACdC,iBAAiB,EACjBC,kBAAkB;AAEtB,SAASC,WAAW,QAAQ,mBAAmB;AAE/C,SAASC,SAASA,CAACC,GAAW,EA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