@uploadcare/file-uploader 1.19.5-alpha.0 → 1.20.0-alpha.0
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/abstract/UploaderBlock.d.ts +0 -2
- package/abstract/UploaderBlock.d.ts.map +1 -1
- package/abstract/UploaderBlock.js +7 -19
- package/blocks/CloudImageEditor/src/CropFrame.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/CropFrame.js +4 -2
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts +9 -0
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.js +98 -0
- package/blocks/CloudImageEditor/src/EditorButtonControl.js +1 -1
- package/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorCropButtonControl.js +1 -0
- package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorImageCropper.js +3 -2
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +9 -0
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorToolbar.js +62 -1
- package/blocks/CloudImageEditor/src/css/common.css +24 -1
- package/blocks/CloudImageEditor/src/index.d.ts +1 -0
- package/blocks/CloudImageEditor/src/index.js +1 -0
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +7 -1
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.js +16 -9
- package/blocks/CloudImageEditor/src/state.d.ts +0 -1
- package/blocks/CloudImageEditor/src/state.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/state.js +1 -2
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts +1 -1
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/svg-sprite.js +1 -1
- package/blocks/CloudImageEditor/src/types.d.ts +3 -0
- package/blocks/CloudImageEditor/src/types.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/types.js +10 -1
- package/blocks/themes/uc-basic/svg-sprite.d.ts +1 -1
- package/blocks/themes/uc-basic/svg-sprite.d.ts.map +1 -1
- package/blocks/themes/uc-basic/svg-sprite.js +1 -1
- package/index.ssr.d.ts +8 -0
- package/index.ssr.d.ts.map +1 -1
- package/index.ssr.js +22 -6
- package/locales/file-uploader/ar.d.ts +3 -0
- package/locales/file-uploader/ar.js +3 -0
- package/locales/file-uploader/az.d.ts +3 -0
- package/locales/file-uploader/az.js +3 -0
- package/locales/file-uploader/ca.d.ts +3 -0
- package/locales/file-uploader/ca.js +3 -0
- package/locales/file-uploader/cs.d.ts +3 -0
- package/locales/file-uploader/cs.js +3 -0
- package/locales/file-uploader/da.d.ts +3 -0
- package/locales/file-uploader/da.js +3 -0
- package/locales/file-uploader/de.d.ts +3 -0
- package/locales/file-uploader/de.js +3 -0
- package/locales/file-uploader/el.d.ts +3 -0
- package/locales/file-uploader/el.js +3 -0
- package/locales/file-uploader/en.d.ts +3 -0
- package/locales/file-uploader/en.js +3 -0
- package/locales/file-uploader/es.d.ts +3 -0
- package/locales/file-uploader/es.js +3 -0
- package/locales/file-uploader/et.d.ts +3 -0
- package/locales/file-uploader/et.js +3 -0
- package/locales/file-uploader/fi.d.ts +3 -0
- package/locales/file-uploader/fi.js +3 -0
- package/locales/file-uploader/fr.d.ts +3 -0
- package/locales/file-uploader/fr.js +3 -0
- package/locales/file-uploader/he.d.ts +3 -0
- package/locales/file-uploader/he.js +3 -0
- package/locales/file-uploader/hy.d.ts +3 -0
- package/locales/file-uploader/hy.js +3 -0
- package/locales/file-uploader/is.d.ts +3 -0
- package/locales/file-uploader/is.js +3 -0
- package/locales/file-uploader/it.d.ts +3 -0
- package/locales/file-uploader/it.js +3 -0
- package/locales/file-uploader/ja.d.ts +3 -0
- package/locales/file-uploader/ja.js +3 -0
- package/locales/file-uploader/ka.d.ts +3 -0
- package/locales/file-uploader/ka.js +3 -0
- package/locales/file-uploader/kk.d.ts +3 -0
- package/locales/file-uploader/kk.js +3 -0
- package/locales/file-uploader/ko.d.ts +3 -0
- package/locales/file-uploader/ko.js +3 -0
- package/locales/file-uploader/lv.d.ts +3 -0
- package/locales/file-uploader/lv.js +3 -0
- package/locales/file-uploader/nb.d.ts +3 -0
- package/locales/file-uploader/nb.js +3 -0
- package/locales/file-uploader/nl.d.ts +3 -0
- package/locales/file-uploader/nl.js +3 -0
- package/locales/file-uploader/pl.d.ts +3 -0
- package/locales/file-uploader/pl.js +3 -0
- package/locales/file-uploader/pt.d.ts +3 -0
- package/locales/file-uploader/pt.js +3 -0
- package/locales/file-uploader/ro.d.ts +3 -0
- package/locales/file-uploader/ro.js +3 -0
- package/locales/file-uploader/ru.d.ts +3 -0
- package/locales/file-uploader/ru.js +3 -0
- package/locales/file-uploader/sk.d.ts +3 -0
- package/locales/file-uploader/sk.js +3 -0
- package/locales/file-uploader/sr.d.ts +3 -0
- package/locales/file-uploader/sr.js +3 -0
- package/locales/file-uploader/sv.d.ts +3 -0
- package/locales/file-uploader/sv.js +3 -0
- package/locales/file-uploader/tr.d.ts +3 -0
- package/locales/file-uploader/tr.js +3 -0
- package/locales/file-uploader/uk.d.ts +3 -0
- package/locales/file-uploader/uk.js +3 -0
- package/locales/file-uploader/vi.d.ts +3 -0
- package/locales/file-uploader/vi.js +3 -0
- package/locales/file-uploader/zh-TW.d.ts +3 -0
- package/locales/file-uploader/zh-TW.js +3 -0
- package/locales/file-uploader/zh.d.ts +3 -0
- package/locales/file-uploader/zh.js +3 -0
- package/package.json +4 -2
- package/types/jsx.d.ts +1 -0
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.min.js +4 -4
- package/web/uc-basic.min.css +1 -1
- package/web/uc-cloud-image-editor.min.css +1 -1
- package/web/uc-cloud-image-editor.min.js +4 -4
- package/web/uc-file-uploader-inline.min.css +1 -1
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-minimal.min.css +1 -1
- package/web/uc-file-uploader-minimal.min.js +4 -4
- package/web/uc-file-uploader-regular.min.css +1 -1
- package/web/uc-file-uploader-regular.min.js +4 -4
|
@@ -36,8 +36,6 @@ export class UploaderBlock extends ActivityBlock {
|
|
|
36
36
|
private _unobserveCollection;
|
|
37
37
|
/** @private */
|
|
38
38
|
private _unobserveCollectionProperties;
|
|
39
|
-
/** @private */
|
|
40
|
-
private destroyCtxOwner;
|
|
41
39
|
/**
|
|
42
40
|
* @private
|
|
43
41
|
* @param {import('../types').OutputCollectionState} collectionState
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploaderBlock.d.ts","sourceRoot":"","sources":["UploaderBlock.js"],"names":[],"mappings":"AAmBA;IACE,iBAAiB;IACjB,mCAAwB;IAExB,eAAe;IACf,mBAAmB;IAEnB;;;;;;;;;;;;;;MAA+B;IAE/B,eAAe;IACf,0BAOC;IA2BD;;;OAGG;IACH,mCAHa,iBAAiB,CAQ7B;IAED,mCAAmC;IACnC,WADc,iBAAiB,CAM9B;IAED,4BAEC;IAED,2DAA2D;IAC3D,wBADc,eAAe,CAAC,OAAO,iBAAiB,CAAC,CAMtD;
|
|
1
|
+
{"version":3,"file":"UploaderBlock.d.ts","sourceRoot":"","sources":["UploaderBlock.js"],"names":[],"mappings":"AAmBA;IACE,iBAAiB;IACjB,mCAAwB;IAExB,eAAe;IACf,mBAAmB;IAEnB;;;;;;;;;;;;;;MAA+B;IAE/B,eAAe;IACf,0BAOC;IA2BD;;;OAGG;IACH,mCAHa,iBAAiB,CAQ7B;IAED,mCAAmC;IACnC,WADc,iBAAiB,CAM9B;IAED,4BAEC;IAED,2DAA2D;IAC3D,wBADc,eAAe,CAAC,OAAO,iBAAiB,CAAC,CAMtD;IAkBD,eAAe;IACf,qBAkBC;IAfC,eAAe;IACf,6BAAiG;IAEjG,eAAe;IACf,uCAEC;IAWH;;;OAGG;IACH,qBAkBC;IAED,eAAe;IACf,0BAYQ;IAER;;;OAGG;IACH,gCAkCE;IAEF;;;OAGG;IACH,0CA6FE;IAEF,eAAe;IACf,mCAsBE;IAEF,6BAiBC;IAED,eAAe;IACf,uBAsDC;IAED;;;OAGG;IACH,kCAHW,MAAM,qEAWhB;IAED;;;OAGG;IACH,oCAHa,OAAO,CAAC,OAAO,2BAA2B,EAAE,eAAe,CAAC,CA4BxE;IAED,kEAAkE;IAClE,iBADc,OAAO,sBAAsB,EAAE,eAAe,EAAE,CAK7D;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA5c6B,oBAAoB;qCAWb,2BAA2B;kCAG9B,wBAAwB;kCADxB,wBAAwB;gCAD1B,sBAAsB;kCAGpB,wBAAwB"}
|
|
@@ -94,9 +94,8 @@ export class UploaderBlock extends ActivityBlock {
|
|
|
94
94
|
|
|
95
95
|
/** @protected */
|
|
96
96
|
destroyCtxCallback() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
97
|
+
this._unobserveCollectionProperties?.();
|
|
98
|
+
this._unobserveCollection?.();
|
|
100
99
|
this.uploadCollection.destroy();
|
|
101
100
|
this.$['*uploadCollection'] = null;
|
|
102
101
|
|
|
@@ -106,9 +105,6 @@ export class UploaderBlock extends ActivityBlock {
|
|
|
106
105
|
destroyCallback() {
|
|
107
106
|
super.destroyCallback();
|
|
108
107
|
|
|
109
|
-
if (this.isCtxOwner) {
|
|
110
|
-
this.destroyCtxOwner();
|
|
111
|
-
}
|
|
112
108
|
this._flushOutputItems.cancel();
|
|
113
109
|
}
|
|
114
110
|
|
|
@@ -133,18 +129,6 @@ export class UploaderBlock extends ActivityBlock {
|
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
131
|
|
|
136
|
-
/** @private */
|
|
137
|
-
destroyCtxOwner() {
|
|
138
|
-
if (!this.isCtxOwner) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
this._unobserveCollectionProperties?.();
|
|
143
|
-
this._unobserveCollection?.();
|
|
144
|
-
this.$['*secureUploadsManager'] = null;
|
|
145
|
-
this.isCtxOwner = false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
132
|
/**
|
|
149
133
|
* @private
|
|
150
134
|
* @param {import('../types').OutputCollectionState} collectionState
|
|
@@ -390,7 +374,11 @@ export class UploaderBlock extends ActivityBlock {
|
|
|
390
374
|
continue;
|
|
391
375
|
}
|
|
392
376
|
const { width, height } = fileInfo.imageInfo;
|
|
393
|
-
|
|
377
|
+
console.log({ aspectRatioPreset });
|
|
378
|
+
const expectedAspectRatio =
|
|
379
|
+
typeof aspectRatioPreset?.width === 'number' && typeof aspectRatioPreset?.height === 'number'
|
|
380
|
+
? aspectRatioPreset.width / aspectRatioPreset.height
|
|
381
|
+
: 1; // fallback to 1:1 if not present
|
|
394
382
|
const crop = calculateMaxCenteredCropFrame(width, height, expectedAspectRatio);
|
|
395
383
|
const cdnUrlModifiers = createCdnUrlModifiers(
|
|
396
384
|
`crop/${crop.width}x${crop.height}/${crop.x},${crop.y}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CropFrame.d.ts","sourceRoot":"","sources":["CropFrame.js"],"names":[],"mappings":"AA2BA;IAII;;MAGC;IAED,eAAe;IACf,yBAAyD;IAEzD,eAAe;IACf,2BAA6D;IAE7D,eAAe;IACf,8BAAmE;IAGrE;;;OAGG;IACH,+BAaC;IAED,eAAe;IACf,wBAyCC;IAFC,sCAAyB;IACzB,2CAAuC;IAGzC;;;OAGG;IACH,wBAUC;IAED,eAAe;IACf,wBASC;IAED,eAAe;IACf,qBAgEC;IAED;;;OAGG;IACH,0BAHW,OAAO,YAAY,EAAE,WAAW,aAChC,OAAO,YAAY,EAAE,SAAS,QA4BxC;IAED,eAAe;IACf,sBAiBC;IAED,eAAe;IACf,sBA4CC;IAED,eAAe;IACf,qBAeC;IAFC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAA+B;IAC/B,qCAA+B;IAGjC;;;;OAIG;IACH,2BAiBC;IAJC;;;;;kBAA2B;IAC3B,sCAA6B;IAC7B,6CAA6C;IAC7C,2DAAoC;IAGtC;;;OAGG;IACH,0BAUC;IAED;;;OAGG;IACH,4BAmBC;IAED;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"CropFrame.d.ts","sourceRoot":"","sources":["CropFrame.js"],"names":[],"mappings":"AA2BA;IAII;;MAGC;IAED,eAAe;IACf,yBAAyD;IAEzD,eAAe;IACf,2BAA6D;IAE7D,eAAe;IACf,8BAAmE;IAGrE;;;OAGG;IACH,+BAaC;IAED,eAAe;IACf,wBAyCC;IAFC,sCAAyB;IACzB,2CAAuC;IAGzC;;;OAGG;IACH,wBAUC;IAED,eAAe;IACf,wBASC;IAED,eAAe;IACf,qBAgEC;IAED;;;OAGG;IACH,0BAHW,OAAO,YAAY,EAAE,WAAW,aAChC,OAAO,YAAY,EAAE,SAAS,QA4BxC;IAED,eAAe;IACf,sBAiBC;IAED,eAAe;IACf,sBA4CC;IAED,eAAe;IACf,qBAeC;IAFC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAA+B;IAC/B,qCAA+B;IAGjC;;;;OAIG;IACH,2BAiBC;IAJC;;;;;kBAA2B;IAC3B,sCAA6B;IAC7B,6CAA6C;IAC7C,2DAAoC;IAGtC;;;OAGG;IACH,0BAUC;IAED;;;OAGG;IACH,4BAmBC;IAED;;;;OAIG;IACH,qBAwBC;IAED;;;OAGG;IACH,+BAqBC;IAFC;;;;;kBAA6B;IAI/B,eAAe;IACf,sBAGC;IAED;;;OAGG;IACH,oBAoBC;IADC,oCAA4B;IAG9B,oBAeC;IAED,eAAe;IACf,gBAIC;IAED,+BAA+B;IAC/B,sBADY,OAAO,QAclB;IAmBG,mCAAsF;CAmC3F;;;;sBAvjBqB,4BAA4B"}
|
|
@@ -394,8 +394,10 @@ export class CropFrame extends Block {
|
|
|
394
394
|
/** @type {import('./types.js').Rectangle} */
|
|
395
395
|
let imageBox = this.$['*imageBox'];
|
|
396
396
|
let rect = /** @type {import('./types.js').Rectangle} */ (this._dragStartCrop) ?? this.$['*cropBox'];
|
|
397
|
-
|
|
398
|
-
const cropPreset = this.$['*cropPresetList']?.
|
|
397
|
+
|
|
398
|
+
const cropPreset = /** @type {import('./types.js').CropPresetList} */ (this.$['*cropPresetList'])?.find(
|
|
399
|
+
(it) => it._active,
|
|
400
|
+
);
|
|
399
401
|
const aspectRatio = cropPreset ? cropPreset.width / cropPreset.height : undefined;
|
|
400
402
|
|
|
401
403
|
if (direction === '') {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export class EditorAspectRatioButtonControl extends EditorButtonControl {
|
|
2
|
+
_aspectRatio: import("./types.js").CropAspectRatio | undefined;
|
|
3
|
+
handleFreedom(): void;
|
|
4
|
+
handleClick(): void;
|
|
5
|
+
/** @param {import('./types.js').CropAspectRatio} value */
|
|
6
|
+
_renderRectBasedOnAspectRatio(value: import("./types.js").CropAspectRatio): void;
|
|
7
|
+
}
|
|
8
|
+
import { EditorButtonControl } from './EditorButtonControl.js';
|
|
9
|
+
//# sourceMappingURL=EditorAspectRatioButtonControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorAspectRatioButtonControl.d.ts","sourceRoot":"","sources":["EditorAspectRatioButtonControl.js"],"names":[],"mappings":"AAOA;IAoBQ,+DAAyB;IAe/B,sBAEC;IAED,oBAeC;IAED,0DAA0D;IAC1D,qCADY,OAAO,YAAY,EAAE,eAAe,QAiC/C;CACF;oCA9FmC,0BAA0B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
|
|
3
|
+
import { createSvgNode } from './crop-utils.js';
|
|
4
|
+
import { EditorButtonControl } from './EditorButtonControl.js';
|
|
5
|
+
|
|
6
|
+
const FREEFORM_ID = 'freeform';
|
|
7
|
+
|
|
8
|
+
export class EditorAspectRatioButtonControl extends EditorButtonControl {
|
|
9
|
+
initCallback() {
|
|
10
|
+
super.initCallback();
|
|
11
|
+
|
|
12
|
+
this.defineAccessor(
|
|
13
|
+
'aspectRatio',
|
|
14
|
+
/** @param {import('./types.js').CropAspectRatio} value */ (value) => {
|
|
15
|
+
if (!value) return;
|
|
16
|
+
|
|
17
|
+
if (value.hasFreeform) {
|
|
18
|
+
this.$['title'] = this.l10n('freeform');
|
|
19
|
+
this.$['icon'] = FREEFORM_ID;
|
|
20
|
+
} else {
|
|
21
|
+
this.$['icon'] = value.type;
|
|
22
|
+
if (value.width && value.height) {
|
|
23
|
+
this.$['title'] = `${value.width}:${value.height}`;
|
|
24
|
+
}
|
|
25
|
+
this._renderRectBasedOnAspectRatio(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this._aspectRatio = value;
|
|
29
|
+
|
|
30
|
+
this.bindL10n('title-prop', () => {
|
|
31
|
+
const isFreeform = !!value.hasFreeform;
|
|
32
|
+
const name = this.l10n(isFreeform ? 'freeform' : value.type).toLowerCase();
|
|
33
|
+
|
|
34
|
+
const val = isFreeform ? '' : `${value.width}:${value.height}`;
|
|
35
|
+
return this.l10n('a11y-cloud-editor-apply-aspect-ratio', { name, value: val });
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
this.$['on.click'] = this.handleClick.bind(this);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
handleFreedom() {
|
|
44
|
+
this.$['*showListAspectRatio'] = true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
handleClick() {
|
|
48
|
+
if (this._aspectRatio?.hasFreeform) {
|
|
49
|
+
this.handleFreedom();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const list = /** @type {import('./types.js').CropPresetList} */ (this.$['*cropPresetList']);
|
|
54
|
+
if (!Array.isArray(list)) return;
|
|
55
|
+
|
|
56
|
+
this.$['*cropPresetList'] = list.map(
|
|
57
|
+
/** @param {import('./types.js').CropAspectRatio} it */ (it) => ({
|
|
58
|
+
...it,
|
|
59
|
+
_active: it.id === this._aspectRatio?.id,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @param {import('./types.js').CropAspectRatio} value */
|
|
65
|
+
_renderRectBasedOnAspectRatio(value) {
|
|
66
|
+
const SIZE_RECT_FIXED = 12;
|
|
67
|
+
const SIZE_SVG_WRAPPER = 16;
|
|
68
|
+
let width = 12;
|
|
69
|
+
let height = 12;
|
|
70
|
+
const adjustResolutions = value.width / value.height;
|
|
71
|
+
|
|
72
|
+
if (adjustResolutions >= 1) {
|
|
73
|
+
width = SIZE_RECT_FIXED;
|
|
74
|
+
height = Math.round((SIZE_RECT_FIXED * value.height) / value.width);
|
|
75
|
+
} else {
|
|
76
|
+
height = SIZE_RECT_FIXED;
|
|
77
|
+
width = Math.round((SIZE_RECT_FIXED * value.width) / value.height);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const rect = createSvgNode('rect', {
|
|
81
|
+
'stroke-linejoin': 'round',
|
|
82
|
+
fill: 'none',
|
|
83
|
+
stroke: 'currentColor',
|
|
84
|
+
'stroke-width': 1.2,
|
|
85
|
+
'fill-rule': 'evenodd',
|
|
86
|
+
x: (SIZE_SVG_WRAPPER - width) / 2,
|
|
87
|
+
y: (SIZE_SVG_WRAPPER - height) / 2,
|
|
88
|
+
width,
|
|
89
|
+
height,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const svgEl = this.ref['icon-el']?.ref?.svg;
|
|
93
|
+
|
|
94
|
+
if (!svgEl) return;
|
|
95
|
+
svgEl.innerHTML = '';
|
|
96
|
+
svgEl.appendChild(rect);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -39,7 +39,7 @@ export class EditorButtonControl extends Block {
|
|
|
39
39
|
|
|
40
40
|
EditorButtonControl.template = /* HTML */ `
|
|
41
41
|
<button role="option" type="button" set="@aria-label:title-prop;" l10n="@title:title-prop;">
|
|
42
|
-
<uc-icon set="@name: icon;"></uc-icon>
|
|
42
|
+
<uc-icon ref="icon-el" set="@name: icon;"></uc-icon>
|
|
43
43
|
<div class="uc-title" ref="title-el">{{title}}</div>
|
|
44
44
|
</button>
|
|
45
45
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorCropButtonControl.d.ts","sourceRoot":"","sources":["EditorCropButtonControl.js"],"names":[],"mappings":"AAkBA;IASM,eAAe;IACf,mBAA2B;
|
|
1
|
+
{"version":3,"file":"EditorCropButtonControl.d.ts","sourceRoot":"","sources":["EditorCropButtonControl.js"],"names":[],"mappings":"AAkBA;IASM,eAAe;IACf,mBAA2B;CAgBhC;oCA5CmC,0BAA0B"}
|
|
@@ -28,6 +28,7 @@ export class EditorCropButtonControl extends EditorButtonControl {
|
|
|
28
28
|
/** @private */
|
|
29
29
|
this._operation = operation;
|
|
30
30
|
this.$['icon'] = operation;
|
|
31
|
+
|
|
31
32
|
this.bindL10n('title-prop', () =>
|
|
32
33
|
this.l10n('a11y-cloud-editor-apply-crop', {
|
|
33
34
|
name: this.l10n(operation).toLowerCase(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorImageCropper.d.ts","sourceRoot":"","sources":["EditorImageCropper.js"],"names":[],"mappings":"AA2CA;IAKI;;;QAIE,yBAAyB;uBAAd,UAAU;QAMrB,6CAA6C;qBAAlC,OAAO,YAAY,EAAE,SAAS;QAOzC,6CAA6C;oBAAlC,OAAO,YAAY,EAAE,SAAS;MAO1C;IAED,eAAe;IACf,yBAA8D;IAE9D,eAAe;IACf,+BAA0E;IAE1E;;;MAAyC;IAG3C,eAAe;IACf,sBASC;IAED,eAAe;IACf,6BAKC;IAED,eAAe;IACf,oBAgBC;IAFC,uCAAqB;IACrB,kDAAe;IAGjB,eAAe;IACf,oBAuCC;IAED,eAAe;IACf,
|
|
1
|
+
{"version":3,"file":"EditorImageCropper.d.ts","sourceRoot":"","sources":["EditorImageCropper.js"],"names":[],"mappings":"AA2CA;IAKI;;;QAIE,yBAAyB;uBAAd,UAAU;QAMrB,6CAA6C;qBAAlC,OAAO,YAAY,EAAE,SAAS;QAOzC,6CAA6C;oBAAlC,OAAO,YAAY,EAAE,SAAS;MAO1C;IAED,eAAe;IACf,yBAA8D;IAE9D,eAAe;IACf,+BAA0E;IAE1E;;;MAAyC;IAG3C,eAAe;IACf,sBASC;IAED,eAAe;IACf,6BAKC;IAED,eAAe;IACf,oBAgBC;IAFC,uCAAqB;IACrB,kDAAe;IAGjB,eAAe;IACf,oBAuCC;IAED,eAAe;IACf,mBAsDC;IAED,eAAe;IACf,mBAcC;IAED,eAAe;IACf,cAUC;IAED;;;OAGG;IACH,mBAYC;IAED;;;OAGG;IACH,2BAkBC;IAED;;;OAGG;IACH,+BA8BC;IAED,eAAe;IACf,gBAkBC;IAED;;;;OAIG;IACH,4CAFa,IAAI,CAehB;IAED;;;OAGG;IACH,oBAHW,MAAM,UAAU,GACd,SAAS,OAAO,CAI5B;IAED;;;OAGG;IACH,oBAHW,OAAO,YAAY,EAAE,SAAS,mBAC9B;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,iBAyBlC;IAnBC,+BAAqB;IAYrB,sCAKE;IAGJ;;aAkBC;IAED,eAAe;IACf,0BAYC;IAED,eAAe;IACf,2BAMC;IAED,eAAe;IACf,eAKC;IAED;;;;;OAKG;IACH,sBAyBC;IATC,yCAA4B;IAW9B;;;;OAIG;IACH,4BAkBC;CAgCF;;;;;UA7gBa,OAAO;YACP,OAAO;;;sBApBC,4BAA4B"}
|
|
@@ -189,8 +189,9 @@ export class EditorImageCropper extends Block {
|
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
/** @type {import('./types.js').CropPresetList
|
|
193
|
-
|
|
192
|
+
const cropPreset = /** @type {import('./types.js').CropPresetList} */ (this.$['*cropPresetList'])?.find(
|
|
193
|
+
(it) => it._active,
|
|
194
|
+
);
|
|
194
195
|
const cropAspectRatio = cropPreset ? cropPreset.width / cropPreset.height : undefined;
|
|
195
196
|
|
|
196
197
|
if (
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export class EditorToolbar extends Block {
|
|
2
2
|
init$: {
|
|
3
3
|
'*sliderEl': null;
|
|
4
|
+
'*listAspectRatioEl': null;
|
|
4
5
|
/** @type {import('./types.js').LoadingOperations} */
|
|
5
6
|
'*loadingOperations': import("./types.js").LoadingOperations;
|
|
6
7
|
'*showSlider': boolean;
|
|
8
|
+
'*showListAspectRatio': boolean;
|
|
9
|
+
hideSliderOrList: boolean;
|
|
7
10
|
'*currentFilter': string;
|
|
8
11
|
'*currentOperation': null;
|
|
9
12
|
showLoader: boolean;
|
|
@@ -72,6 +75,12 @@ export class EditorToolbar extends Block {
|
|
|
72
75
|
* @param {String} operation
|
|
73
76
|
*/
|
|
74
77
|
private _createToggleControl;
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
* @param {import('./types.js').CropAspectRatio} config
|
|
81
|
+
*/
|
|
82
|
+
private _createAspectRatioConrol;
|
|
83
|
+
_clearListAspectRatio(): void;
|
|
75
84
|
/**
|
|
76
85
|
* @private
|
|
77
86
|
* @param {String} tabId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorToolbar.d.ts","sourceRoot":"","sources":["EditorToolbar.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorToolbar.d.ts","sourceRoot":"","sources":["EditorToolbar.js"],"names":[],"mappings":"AA4DA;IAII;;;QAIE,qDAAqD;8BAA1C,OAAO,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyDjD,4BAA4B;2BAAhB,UAAU;;;;;;;MAgBvB;IAED,eAAe;IAEf,6BAAsE;IAGxE,eAAe;IACf,uBAOC;IAED;;;OAGG;IACH,gCAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,iCAKC;IAED,8BAEC;IAED;;;OAGG;IACH,4BA8DC;IAED;;;;OAIG;IACH,qBAyBC;IAED;;;OAGG;IACH,4BAKC;IAED,eAAe;IACf,0BAIC;IAED,eAAe;IACf,4BAWC;IALG,oBAGC;IAIL;;;OAGG;IACH,oBAEC;IAED;;MAwBM;CA+FP;;;;sBA/cqB,4BAA4B"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { debounce } from '../../utils/debounce.js';
|
|
3
3
|
import { Block } from '../../../abstract/Block.js';
|
|
4
4
|
import { EditorCropButtonControl } from './EditorCropButtonControl.js';
|
|
5
|
+
import { EditorAspectRatioButtonControl } from './EditorAspectRatioButtonControl.js';
|
|
5
6
|
import { EditorFilterControl } from './EditorFilterControl.js';
|
|
6
7
|
import { EditorOperationControl } from './EditorOperationControl.js';
|
|
7
8
|
import { FAKE_ORIGINAL_FILTER } from './EditorSlider.js';
|
|
@@ -64,9 +65,12 @@ export class EditorToolbar extends Block {
|
|
|
64
65
|
this.init$ = {
|
|
65
66
|
...this.init$,
|
|
66
67
|
'*sliderEl': null,
|
|
68
|
+
'*listAspectRatioEl': null,
|
|
67
69
|
/** @type {import('./types.js').LoadingOperations} */
|
|
68
70
|
'*loadingOperations': new Map(),
|
|
69
71
|
'*showSlider': false,
|
|
72
|
+
'*showListAspectRatio': false,
|
|
73
|
+
hideSliderOrList: false,
|
|
70
74
|
'*currentFilter': FAKE_ORIGINAL_FILTER,
|
|
71
75
|
'*currentOperation': null,
|
|
72
76
|
showLoader: false,
|
|
@@ -145,6 +149,8 @@ export class EditorToolbar extends Block {
|
|
|
145
149
|
/** @private */
|
|
146
150
|
_onSliderClose() {
|
|
147
151
|
this.$['*showSlider'] = false;
|
|
152
|
+
this.$['*showListAspectRatio'] = false;
|
|
153
|
+
|
|
148
154
|
if (this.$['*tabId'] === TabId.TUNING) {
|
|
149
155
|
this.ref['tooltip-el'].classList.toggle('uc-info-tooltip_visible', false);
|
|
150
156
|
}
|
|
@@ -183,6 +189,21 @@ export class EditorToolbar extends Block {
|
|
|
183
189
|
return el;
|
|
184
190
|
}
|
|
185
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @private
|
|
194
|
+
* @param {import('./types.js').CropAspectRatio} config
|
|
195
|
+
*/
|
|
196
|
+
_createAspectRatioConrol(config) {
|
|
197
|
+
const el = new EditorAspectRatioButtonControl();
|
|
198
|
+
// @ts-expect-error TODO: fix
|
|
199
|
+
el.aspectRatio = config;
|
|
200
|
+
return el;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
_clearListAspectRatio() {
|
|
204
|
+
this.$['*listAspectRatioEl'].innerHTML = '';
|
|
205
|
+
}
|
|
206
|
+
|
|
186
207
|
/**
|
|
187
208
|
* @private
|
|
188
209
|
* @param {String} tabId
|
|
@@ -191,7 +212,33 @@ export class EditorToolbar extends Block {
|
|
|
191
212
|
let listEl = this.ref[`controls-list-${tabId}`];
|
|
192
213
|
let fr = document.createDocumentFragment();
|
|
193
214
|
|
|
215
|
+
this._clearListAspectRatio();
|
|
216
|
+
|
|
194
217
|
if (tabId === TabId.CROP) {
|
|
218
|
+
const hasFreeformAspectRatio = this.$['*cropPresetList'].length >= 3;
|
|
219
|
+
|
|
220
|
+
if (hasFreeformAspectRatio) {
|
|
221
|
+
let el = this._createAspectRatioConrol({
|
|
222
|
+
id: 'freeform-aspect-ratio',
|
|
223
|
+
type: 'aspect-ratio',
|
|
224
|
+
width: 0,
|
|
225
|
+
height: 0,
|
|
226
|
+
hasFreeform: true,
|
|
227
|
+
});
|
|
228
|
+
fr.appendChild(el);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
this.$['*cropPresetList'].forEach(
|
|
232
|
+
/** @param {import('./types.js').CropAspectRatio} it */ (it) => {
|
|
233
|
+
let el = this._createAspectRatioConrol(it);
|
|
234
|
+
fr.appendChild(el);
|
|
235
|
+
|
|
236
|
+
if (hasFreeformAspectRatio) {
|
|
237
|
+
this.$['*listAspectRatioEl'].appendChild(el);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
);
|
|
241
|
+
|
|
195
242
|
this.$.cropOperations.forEach(
|
|
196
243
|
/** @param {string} operation */ (operation) => {
|
|
197
244
|
let el = this._createToggleControl(operation);
|
|
@@ -327,6 +374,7 @@ export class EditorToolbar extends Block {
|
|
|
327
374
|
super.initCallback();
|
|
328
375
|
|
|
329
376
|
this.$['*sliderEl'] = this.ref['slider-el'];
|
|
377
|
+
this.$['*listAspectRatioEl'] = this.ref['list-el'];
|
|
330
378
|
|
|
331
379
|
this.sub('*imageSize', (imageSize) => {
|
|
332
380
|
if (imageSize) {
|
|
@@ -385,6 +433,14 @@ export class EditorToolbar extends Block {
|
|
|
385
433
|
this.sub('*showSlider', (showSlider) => {
|
|
386
434
|
this.$['presence.subToolbar'] = showSlider;
|
|
387
435
|
this.$['presence.mainToolbar'] = !showSlider;
|
|
436
|
+
|
|
437
|
+
this.$.hideSliderOrList = true;
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
this.sub('*showListAspectRatio', (show) => {
|
|
441
|
+
this.$['presence.subToolbar'] = show;
|
|
442
|
+
this.$['presence.mainToolbar'] = !show;
|
|
443
|
+
this.$.hideSliderOrList = false;
|
|
388
444
|
});
|
|
389
445
|
|
|
390
446
|
this.sub('*tabList', (tabList) => {
|
|
@@ -405,6 +461,7 @@ export class EditorToolbar extends Block {
|
|
|
405
461
|
|
|
406
462
|
destroyCallback() {
|
|
407
463
|
this.$['*showSlider'] = false;
|
|
464
|
+
this.$['*showListAspectRatio'] = false;
|
|
408
465
|
}
|
|
409
466
|
}
|
|
410
467
|
|
|
@@ -439,9 +496,13 @@ EditorToolbar.template = /* HTML */ `
|
|
|
439
496
|
class="uc-sub-toolbar"
|
|
440
497
|
set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles"
|
|
441
498
|
>
|
|
442
|
-
<div class="uc-slider">
|
|
499
|
+
<div class="uc-slider" set="@hidden:!hideSliderOrList">
|
|
443
500
|
<uc-editor-slider ref="slider-el"></uc-editor-slider>
|
|
444
501
|
</div>
|
|
502
|
+
|
|
503
|
+
<div set="@hidden:hideSliderOrList" class="uc-list-aspect-ratio-container">
|
|
504
|
+
<div class="uc-list-aspect-ratio" ref="list-el"></div>
|
|
505
|
+
</div>
|
|
445
506
|
<div class="uc-controls-row">
|
|
446
507
|
<uc-btn-ui theme="secondary" set="onclick: on.cancelSlider" l10n="@text:cancel"> </uc-btn-ui>
|
|
447
508
|
<uc-btn-ui theme="primary" set="onclick: on.applySlider" l10n="@text:apply"> </uc-btn-ui>
|
|
@@ -329,6 +329,7 @@ uc-crop-frame > .uc-guides--visible {
|
|
|
329
329
|
|
|
330
330
|
uc-editor-button-control,
|
|
331
331
|
uc-editor-crop-button-control,
|
|
332
|
+
uc-editor-aspect-ratio-button-control,
|
|
332
333
|
uc-editor-filter-control,
|
|
333
334
|
uc-editor-operation-control {
|
|
334
335
|
--l-base-min-width: var(--uc-button-size);
|
|
@@ -356,6 +357,7 @@ uc-editor-operation-control {
|
|
|
356
357
|
|
|
357
358
|
uc-editor-button-control > button,
|
|
358
359
|
uc-editor-crop-button-control > button,
|
|
360
|
+
uc-editor-aspect-ratio-button-control > button,
|
|
359
361
|
uc-editor-filter-control > button,
|
|
360
362
|
uc-editor-operation-control > button {
|
|
361
363
|
all: unset;
|
|
@@ -371,7 +373,13 @@ uc-editor-operation-control > button {
|
|
|
371
373
|
transition: var(--l-width-transition);
|
|
372
374
|
}
|
|
373
375
|
|
|
374
|
-
:where(
|
|
376
|
+
:where(
|
|
377
|
+
uc-editor-button-control,
|
|
378
|
+
uc-editor-crop-button-control,
|
|
379
|
+
uc-editor-aspect-ratio-button-control,
|
|
380
|
+
uc-editor-filter-control,
|
|
381
|
+
uc-editor-operation-control
|
|
382
|
+
)
|
|
375
383
|
> uc-icon
|
|
376
384
|
> svg {
|
|
377
385
|
width: var(--size-icon);
|
|
@@ -386,6 +394,7 @@ uc-editor-filter-control > uc-icon.uc-original-icon > svg {
|
|
|
386
394
|
uc-editor-button-control.uc-active,
|
|
387
395
|
uc-editor-operation-control.uc-active,
|
|
388
396
|
uc-editor-crop-button-control.uc-active,
|
|
397
|
+
uc-editor-aspect-ratio-button-control.uc-active,
|
|
389
398
|
uc-editor-filter-control.uc-active {
|
|
390
399
|
--idle-color-rgb: var(--uc-primary-foreground);
|
|
391
400
|
--idle-background: var(--uc-primary);
|
|
@@ -406,6 +415,7 @@ uc-editor-filter-control.uc-active .uc-preview {
|
|
|
406
415
|
uc-editor-button-control.uc-not_active,
|
|
407
416
|
uc-editor-operation-control.uc-not_active,
|
|
408
417
|
uc-editor-crop-button-control.uc-not_active,
|
|
418
|
+
uc-editor-aspect-ratio-button-control.uc-not_active,
|
|
409
419
|
uc-editor-filter-control.uc-not_active {
|
|
410
420
|
--idle-color-rgb: var(--uc-secondary-foreground);
|
|
411
421
|
}
|
|
@@ -413,6 +423,7 @@ uc-editor-filter-control.uc-not_active {
|
|
|
413
423
|
:where(.uc-contrast) uc-editor-button-control.uc-not_active,
|
|
414
424
|
:where(.uc-contrast) uc-editor-operation-control.uc-not_active,
|
|
415
425
|
:where(.uc-contrast) uc-editor-crop-button-control.uc-not_active,
|
|
426
|
+
:where(.uc-contrast) uc-editor-aspect-ratio-button-control.uc-not_active,
|
|
416
427
|
:where(.uc-contrast) uc-editor-filter-control.uc-not_active {
|
|
417
428
|
--idle-background: transparent;
|
|
418
429
|
--hover-background: var(--uc-secondary);
|
|
@@ -424,6 +435,7 @@ uc-editor-filter-control.uc-not_active {
|
|
|
424
435
|
uc-editor-button-control > button::before,
|
|
425
436
|
uc-editor-operation-control > button::before,
|
|
426
437
|
uc-editor-crop-button-control > button::before,
|
|
438
|
+
uc-editor-aspect-ratio-button-control > button::before,
|
|
427
439
|
uc-editor-filter-control > button::before {
|
|
428
440
|
position: absolute;
|
|
429
441
|
content: '';
|
|
@@ -440,6 +452,7 @@ uc-editor-filter-control > button::before {
|
|
|
440
452
|
uc-editor-button-control > button .uc-title,
|
|
441
453
|
uc-editor-operation-control > button .uc-title,
|
|
442
454
|
uc-editor-crop-button-control > button .uc-title,
|
|
455
|
+
uc-editor-aspect-ratio-button-control > button .uc-title,
|
|
443
456
|
uc-editor-filter-control > button .uc-title {
|
|
444
457
|
padding-right: var(--cldtr-gap-mid-1);
|
|
445
458
|
font-size: 0.7em;
|
|
@@ -450,6 +463,7 @@ uc-editor-filter-control > button .uc-title {
|
|
|
450
463
|
uc-editor-button-control > button uc-icon,
|
|
451
464
|
uc-editor-operation-control > button uc-icon,
|
|
452
465
|
uc-editor-crop-button-control > button uc-icon,
|
|
466
|
+
uc-editor-aspect-ratio-button-control > button uc-icon,
|
|
453
467
|
uc-editor-filter-control > button uc-icon {
|
|
454
468
|
pointer-events: none;
|
|
455
469
|
}
|
|
@@ -643,6 +657,15 @@ uc-editor-toolbar > .uc-toolbar-container > .uc-sub-toolbar {
|
|
|
643
657
|
visibility var(--transition-duration-3) ease-in-out;
|
|
644
658
|
}
|
|
645
659
|
|
|
660
|
+
.uc-sub-toolbar > .uc-list-aspect-ratio-container > .uc-list-aspect-ratio {
|
|
661
|
+
display: grid;
|
|
662
|
+
grid-auto-flow: column;
|
|
663
|
+
justify-content: center;
|
|
664
|
+
align-items: center;
|
|
665
|
+
gap: 6px;
|
|
666
|
+
height: var(--size-panel-heading);
|
|
667
|
+
}
|
|
668
|
+
|
|
646
669
|
uc-editor-toolbar > .uc-toolbar-container > .uc-sub-toolbar.uc-sub-toolbar--visible {
|
|
647
670
|
transform: translateY(0px);
|
|
648
671
|
opacity: 1;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CloudImageEditorBlock } from "./CloudImageEditorBlock.js";
|
|
2
2
|
export { CropFrame } from "./CropFrame.js";
|
|
3
3
|
export { EditorCropButtonControl } from "./EditorCropButtonControl.js";
|
|
4
|
+
export { EditorAspectRatioButtonControl } from "./EditorAspectRatioButtonControl.js";
|
|
4
5
|
export { EditorFilterControl } from "./EditorFilterControl.js";
|
|
5
6
|
export { EditorOperationControl } from "./EditorOperationControl.js";
|
|
6
7
|
export { EditorImageCropper } from "./EditorImageCropper.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CloudImageEditorBlock } from './CloudImageEditorBlock.js';
|
|
2
2
|
export { CropFrame } from './CropFrame.js';
|
|
3
3
|
export { EditorCropButtonControl } from './EditorCropButtonControl.js';
|
|
4
|
+
export { EditorAspectRatioButtonControl } from './EditorAspectRatioButtonControl.js';
|
|
4
5
|
export { EditorFilterControl } from './EditorFilterControl.js';
|
|
5
6
|
export { EditorOperationControl } from './EditorOperationControl.js';
|
|
6
7
|
export { EditorImageCropper } from './EditorImageCropper.js';
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export function parseCropPreset(cropPreset: import("../../../../types/exported.d.ts").ConfigType["cropPreset"]):
|
|
1
|
+
export function parseCropPreset(cropPreset: import("../../../../types/exported.d.ts").ConfigType["cropPreset"]): ({
|
|
2
|
+
id: string;
|
|
3
|
+
_active: boolean;
|
|
4
|
+
type: string;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
} | undefined)[];
|
|
2
8
|
//# sourceMappingURL=parseCropPreset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseCropPreset.d.ts","sourceRoot":"","sources":["parseCropPreset.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseCropPreset.d.ts","sourceRoot":"","sources":["parseCropPreset.js"],"names":[],"mappings":"AAMO,4CADK,OAAO,iCAAiC,EAAE,UAAU,CAAC,YAAY,CAAC;;;;;;iBAe7E"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
import { UID } from '@symbiotejs/symbiote';
|
|
4
|
+
import { stringToArray } from '../../../../utils/stringToArray.js';
|
|
5
|
+
|
|
3
6
|
/** @param {import('../../../../types/exported.d.ts').ConfigType['cropPreset']} cropPreset */
|
|
4
7
|
export const parseCropPreset = (cropPreset) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (!
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const list = stringToArray(cropPreset);
|
|
9
|
+
|
|
10
|
+
if (!list) return [];
|
|
11
|
+
|
|
12
|
+
return list.map((it, index) => {
|
|
13
|
+
const [w, h] = it.split(':').map(Number);
|
|
14
|
+
if (!Number.isFinite(w) || !Number.isFinite(h)) {
|
|
15
|
+
console.error(`Invalid crop preset: ${it}`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
/** @type {import('../types.js').CropAspectRatio} */
|
|
19
|
+
return { id: UID.generate(), _active: index === 0, type: 'aspect-ratio', width: w, height: h };
|
|
20
|
+
});
|
|
14
21
|
};
|
|
@@ -9,7 +9,6 @@ export function initState(fnCtx: import("./CloudImageEditorBlock.js").CloudImage
|
|
|
9
9
|
'*imageSize': null;
|
|
10
10
|
/** @type {import('./types.js').Transformations} */
|
|
11
11
|
'*editorTransformations': import("./types.js").Transformations;
|
|
12
|
-
/** @type {import('./types.js').CropPresetList} */
|
|
13
12
|
'*cropPresetList': import("./types.js").CropPresetList;
|
|
14
13
|
'*tabList': ("crop" | "tuning" | "filters")[];
|
|
15
14
|
'*tabId': "crop";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["state.js"],"names":[],"mappings":"AAQA,gFAAgF;AAChF,iCADY,OAAO,4BAA4B,EAAE,qBAAqB;;;;;;;;IAUlE,mDAAmD;8BAAxC,OAAO,YAAY,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["state.js"],"names":[],"mappings":"AAQA,gFAAgF;AAChF,iCADY,OAAO,4BAA4B,EAAE,qBAAqB;;;;;;;;IAUlE,mDAAmD;8BAAxC,OAAO,YAAY,EAAE,eAAe;uBAEjB,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;IAkCjE,oEAAoE;mCAAxD,OAAO,YAAY,EAAE,eAAe;;EAoCnD"}
|
|
@@ -18,8 +18,7 @@ export function initState(fnCtx) {
|
|
|
18
18
|
'*imageSize': null,
|
|
19
19
|
/** @type {import('./types.js').Transformations} */
|
|
20
20
|
'*editorTransformations': {},
|
|
21
|
-
/** @type {import('./types.js').CropPresetList} */
|
|
22
|
-
'*cropPresetList': [],
|
|
21
|
+
'*cropPresetList': /** @type {import('./types.js').CropPresetList} */ ([]),
|
|
23
22
|
'*tabList': ALL_TABS,
|
|
24
23
|
'*tabId': TabId.CROP,
|
|
25
24
|
|