@uploadcare/file-uploader 1.20.0-rc.2 → 1.20.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/Block.d.ts +2 -11
- package/abstract/Block.d.ts.map +1 -1
- package/abstract/Block.js +3 -29
- package/abstract/CTX.d.ts +2 -2
- package/abstract/CTX.d.ts.map +1 -1
- package/abstract/CTX.js +1 -1
- package/abstract/{managers/LocaleManager.d.ts → LocaleManager.d.ts} +8 -8
- package/abstract/{managers/LocaleManager.d.ts.map → LocaleManager.d.ts.map} +1 -1
- package/abstract/{managers/LocaleManager.js → LocaleManager.js} +8 -8
- package/abstract/{managers/ModalManager.d.ts → ModalManager.d.ts} +7 -7
- package/abstract/{managers/ModalManager.d.ts.map → ModalManager.d.ts.map} +1 -1
- package/abstract/{managers/ModalManager.js → ModalManager.js} +3 -3
- package/abstract/SecureUploadsManager.d.ts +22 -0
- package/abstract/{managers/SecureUploadsManager.d.ts.map → SecureUploadsManager.d.ts.map} +1 -1
- package/abstract/{managers/SecureUploadsManager.js → SecureUploadsManager.js} +5 -5
- package/abstract/SolutionBlock.d.ts +1 -1
- package/abstract/UploaderBlock.d.ts +3 -3
- package/abstract/UploaderBlock.d.ts.map +1 -1
- package/abstract/UploaderBlock.js +10 -3
- package/abstract/{managers/ValidationManager.d.ts → ValidationManager.d.ts} +7 -7
- package/abstract/{managers/ValidationManager.d.ts.map → ValidationManager.d.ts.map} +1 -1
- package/abstract/{managers/ValidationManager.js → ValidationManager.js} +14 -14
- package/abstract/{managers/a11y.d.ts → a11y.d.ts} +2 -2
- package/abstract/a11y.d.ts.map +1 -0
- package/abstract/{managers/a11y.js → a11y.js} +1 -1
- package/abstract/l10nProcessor.js +1 -1
- package/blocks/CameraSource/CameraSource.d.ts +1 -1
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts +1 -0
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.js +19 -5
- package/blocks/CloudImageEditor/src/CropFrame.js +3 -3
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts +11 -0
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.js +130 -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 +2 -8
- package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorFilterControl.js +1 -7
- package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorImageCropper.js +2 -3
- package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +1 -1
- package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorOperationControl.js +3 -9
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +15 -8
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorToolbar.js +68 -25
- package/blocks/CloudImageEditor/src/css/common.css +39 -7
- 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 +2 -1
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.js +74 -8
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.test.d.ts +2 -0
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.test.d.ts.map +1 -0
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.test.js +35 -0
- package/blocks/CloudImageEditor/src/state.d.ts +1 -1
- package/blocks/CloudImageEditor/src/state.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/state.js +2 -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/toolbar-constants.d.ts +0 -1
- package/blocks/CloudImageEditor/src/toolbar-constants.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/toolbar-constants.js +0 -2
- package/blocks/CloudImageEditor/src/types.d.ts +2 -0
- package/blocks/CloudImageEditor/src/types.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/types.js +9 -1
- package/blocks/Config/initialConfig.d.ts.map +1 -1
- package/blocks/Config/initialConfig.js +0 -2
- package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
- package/blocks/Config/normalizeConfigValue.js +0 -2
- package/blocks/DropArea/DropArea.d.ts +1 -1
- package/blocks/ExternalSource/ExternalSource.d.ts +1 -1
- package/blocks/FileItem/FileItem.d.ts +1 -1
- package/blocks/FileItem/FileItem.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.js +0 -16
- package/blocks/Modal/Modal.d.ts +6 -6
- package/blocks/Modal/Modal.d.ts.map +1 -1
- package/blocks/Modal/Modal.js +12 -10
- package/blocks/SimpleBtn/SimpleBtn.d.ts +1 -1
- package/blocks/SourceBtn/SourceBtn.d.ts +1 -1
- package/blocks/Thumb/Thumb.d.ts +1 -1
- package/blocks/UploadCtxProvider/EventEmitter.d.ts +4 -17
- package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
- package/blocks/UploadCtxProvider/EventEmitter.js +2 -14
- package/blocks/UploadList/UploadList.d.ts +1 -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/env.d.ts +1 -1
- package/env.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.ssr.d.ts +17 -3
- package/index.ssr.d.ts.map +1 -1
- package/index.ssr.js +35 -11
- package/locales/file-uploader/ar.d.ts +4 -0
- package/locales/file-uploader/ar.js +5 -0
- package/locales/file-uploader/az.d.ts +4 -0
- package/locales/file-uploader/az.js +5 -0
- package/locales/file-uploader/ca.d.ts +4 -0
- package/locales/file-uploader/ca.js +6 -0
- package/locales/file-uploader/cs.d.ts +4 -0
- package/locales/file-uploader/cs.js +6 -0
- package/locales/file-uploader/da.d.ts +4 -0
- package/locales/file-uploader/da.js +6 -0
- package/locales/file-uploader/de.d.ts +4 -0
- package/locales/file-uploader/de.js +6 -0
- package/locales/file-uploader/el.d.ts +4 -0
- package/locales/file-uploader/el.js +6 -0
- package/locales/file-uploader/en.d.ts +4 -0
- package/locales/file-uploader/en.js +5 -0
- package/locales/file-uploader/es.d.ts +4 -0
- package/locales/file-uploader/es.js +6 -0
- package/locales/file-uploader/et.d.ts +4 -0
- package/locales/file-uploader/et.js +6 -0
- package/locales/file-uploader/fi.d.ts +4 -0
- package/locales/file-uploader/fi.js +6 -0
- package/locales/file-uploader/fr.d.ts +4 -0
- package/locales/file-uploader/fr.js +6 -0
- package/locales/file-uploader/he.d.ts +4 -0
- package/locales/file-uploader/he.js +6 -0
- package/locales/file-uploader/hy.d.ts +4 -0
- package/locales/file-uploader/hy.js +5 -0
- package/locales/file-uploader/is.d.ts +4 -0
- package/locales/file-uploader/is.js +6 -0
- package/locales/file-uploader/it.d.ts +4 -0
- package/locales/file-uploader/it.js +6 -0
- package/locales/file-uploader/ja.d.ts +4 -0
- package/locales/file-uploader/ja.js +6 -0
- package/locales/file-uploader/ka.d.ts +4 -0
- package/locales/file-uploader/ka.js +6 -0
- package/locales/file-uploader/kk.d.ts +4 -0
- package/locales/file-uploader/kk.js +6 -0
- package/locales/file-uploader/ko.d.ts +4 -0
- package/locales/file-uploader/ko.js +6 -0
- package/locales/file-uploader/lv.d.ts +4 -0
- package/locales/file-uploader/lv.js +6 -0
- package/locales/file-uploader/nb.d.ts +4 -0
- package/locales/file-uploader/nb.js +6 -0
- package/locales/file-uploader/nl.d.ts +4 -0
- package/locales/file-uploader/nl.js +6 -0
- package/locales/file-uploader/pl.d.ts +4 -0
- package/locales/file-uploader/pl.js +6 -0
- package/locales/file-uploader/pt.d.ts +4 -0
- package/locales/file-uploader/pt.js +6 -0
- package/locales/file-uploader/ro.d.ts +4 -0
- package/locales/file-uploader/ro.js +6 -0
- package/locales/file-uploader/ru.d.ts +4 -0
- package/locales/file-uploader/ru.js +6 -0
- package/locales/file-uploader/sk.d.ts +4 -0
- package/locales/file-uploader/sk.js +6 -0
- package/locales/file-uploader/sr.d.ts +4 -0
- package/locales/file-uploader/sr.js +6 -0
- package/locales/file-uploader/sv.d.ts +4 -0
- package/locales/file-uploader/sv.js +6 -0
- package/locales/file-uploader/tr.d.ts +4 -0
- package/locales/file-uploader/tr.js +6 -0
- package/locales/file-uploader/uk.d.ts +4 -0
- package/locales/file-uploader/uk.js +6 -0
- package/locales/file-uploader/vi.d.ts +4 -0
- package/locales/file-uploader/vi.js +6 -0
- package/locales/file-uploader/zh-TW.d.ts +4 -0
- package/locales/file-uploader/zh-TW.js +6 -0
- package/locales/file-uploader/zh.d.ts +4 -0
- package/locales/file-uploader/zh.js +6 -0
- package/package.json +2 -5
- package/solutions/cloud-image-editor/CloudImageEditor.d.ts +0 -34
- package/solutions/cloud-image-editor/CloudImageEditor.d.ts.map +1 -1
- package/solutions/cloud-image-editor/CloudImageEditor.js +0 -12
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts +1 -2
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
- package/solutions/file-uploader/inline/FileUploaderInline.js +0 -4
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +9 -10
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
- package/solutions/file-uploader/minimal/FileUploaderMinimal.js +3 -7
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +1 -2
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
- package/solutions/file-uploader/regular/FileUploaderRegular.js +0 -4
- package/types/events.d.ts +1 -1
- package/types/exported.d.ts +52 -54
- package/types/jsx.d.ts +2 -0
- package/utils/parseCdnUrl.d.ts.map +1 -1
- package/utils/parseCdnUrl.js +4 -1
- package/utils/parseCdnUrl.test.js +13 -0
- package/utils/validators/collection/validateCollectionUploadError.d.ts +2 -2
- package/utils/validators/collection/validateCollectionUploadError.d.ts.map +1 -1
- package/utils/validators/collection/validateCollectionUploadError.js +1 -1
- package/utils/validators/collection/validateMultiple.d.ts +2 -2
- package/utils/validators/collection/validateMultiple.d.ts.map +1 -1
- package/utils/validators/collection/validateMultiple.js +1 -1
- package/utils/validators/file/validateFileType.d.ts +2 -2
- package/utils/validators/file/validateFileType.d.ts.map +1 -1
- package/utils/validators/file/validateFileType.js +1 -1
- package/utils/validators/file/validateIsImage.d.ts +2 -2
- package/utils/validators/file/validateIsImage.d.ts.map +1 -1
- package/utils/validators/file/validateIsImage.js +1 -1
- package/utils/validators/file/validateMaxSizeLimit.d.ts +2 -2
- package/utils/validators/file/validateMaxSizeLimit.d.ts.map +1 -1
- package/utils/validators/file/validateMaxSizeLimit.js +1 -1
- package/utils/validators/file/validateUploadError.d.ts +2 -2
- package/utils/validators/file/validateUploadError.d.ts.map +1 -1
- package/utils/validators/file/validateUploadError.js +1 -1
- 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
- package/web/uc-img.min.js +1 -1
- package/abstract/managers/SecureUploadsManager.d.ts +0 -22
- package/abstract/managers/TelemetryManager.d.ts +0 -66
- package/abstract/managers/TelemetryManager.d.ts.map +0 -1
- package/abstract/managers/TelemetryManager.js +0 -202
- package/abstract/managers/a11y.d.ts.map +0 -1
- package/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts +0 -11
- package/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts.map +0 -1
- package/blocks/CloudImageEditor/src/utils/parseFilterValue.js +0 -11
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { TRANSPARENT_PIXEL_SRC } from '../../../utils/transparentPixelSrc.js';
|
|
11
11
|
import { debounce } from '../../utils/debounce.js';
|
|
12
12
|
import { classNames } from './lib/classNames.js';
|
|
13
|
-
import { parseCropPreset } from './lib/parseCropPreset.js';
|
|
13
|
+
import { getClosestAspectRatio, parseCropPreset } from './lib/parseCropPreset.js';
|
|
14
14
|
import { parseTabs } from './lib/parseTabs.js';
|
|
15
15
|
import { operationsToTransformations, transformationsToOperations } from './lib/transformationUtils.js';
|
|
16
16
|
import { initState } from './state.js';
|
|
@@ -161,10 +161,6 @@ export class CloudImageEditorBlock extends Block {
|
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
this.sub('cropPreset', (val) => {
|
|
165
|
-
this.$['*cropPresetList'] = parseCropPreset(val);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
164
|
this.sub(
|
|
169
165
|
'tabs',
|
|
170
166
|
/** @param {string} val */ (val) => {
|
|
@@ -216,6 +212,24 @@ export class CloudImageEditorBlock extends Block {
|
|
|
216
212
|
|
|
217
213
|
this.sub('uuid', (val) => val && this.updateImage());
|
|
218
214
|
this.sub('cdnUrl', (val) => val && this.updateImage());
|
|
215
|
+
|
|
216
|
+
this.sub('cropPreset', (val) => {
|
|
217
|
+
const list = parseCropPreset(val);
|
|
218
|
+
let closest = null;
|
|
219
|
+
|
|
220
|
+
if (this.$.cdnUrl) {
|
|
221
|
+
const operations = extractOperations(this.$.cdnUrl);
|
|
222
|
+
const transformations = operationsToTransformations(operations);
|
|
223
|
+
|
|
224
|
+
if (Array.isArray(transformations?.crop?.dimensions)) {
|
|
225
|
+
const [w, h] = transformations?.crop?.dimensions;
|
|
226
|
+
closest = getClosestAspectRatio(w, h, list, 0.1);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this.$['*cropPresetList'] = list;
|
|
231
|
+
this.$['*currentAspectRatio'] = closest ?? list?.[0] ?? null;
|
|
232
|
+
});
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
|
|
@@ -394,8 +394,8 @@ 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.$['*
|
|
397
|
+
|
|
398
|
+
const cropPreset = this.$['*currentAspectRatio'];
|
|
399
399
|
const aspectRatio = cropPreset ? cropPreset.width / cropPreset.height : undefined;
|
|
400
400
|
|
|
401
401
|
if (direction === '') {
|
|
@@ -518,7 +518,7 @@ export class CropFrame extends Block {
|
|
|
518
518
|
this._createBackdrop();
|
|
519
519
|
this._createFrame();
|
|
520
520
|
|
|
521
|
-
this.sub('*imageBox', () => {
|
|
521
|
+
this.sub('*imageBox', (value) => {
|
|
522
522
|
this._resizeBackdrop();
|
|
523
523
|
window.requestAnimationFrame(() => {
|
|
524
524
|
this._render();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class EditorFreeformButtonControl extends EditorButtonControl {
|
|
2
|
+
handleClick(): void;
|
|
3
|
+
}
|
|
4
|
+
export class EditorAspectRatioButtonControl extends EditorButtonControl {
|
|
5
|
+
_aspectRatio: import("./types.js").CropAspectRatio | undefined;
|
|
6
|
+
handleClick(): void;
|
|
7
|
+
/** @param {import('./types.js').CropAspectRatio} value */
|
|
8
|
+
_renderRectBasedOnAspectRatio(value: import("./types.js").CropAspectRatio): void;
|
|
9
|
+
}
|
|
10
|
+
import { EditorButtonControl } from './EditorButtonControl.js';
|
|
11
|
+
//# sourceMappingURL=EditorAspectRatioButtonControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorAspectRatioButtonControl.d.ts","sourceRoot":"","sources":["EditorAspectRatioButtonControl.js"],"names":[],"mappings":"AAyBA;IAoBE,oBAEC;CACF;AAED;IA4BQ,+DAAyB;IAqB/B,oBAMC;IAED,0DAA0D;IAC1D,qCADY,OAAO,YAAY,EAAE,eAAe,QAqB/C;CACF;oCA9HmC,0BAA0B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
|
|
3
|
+
import { createSvgNode } from './crop-utils.js';
|
|
4
|
+
import { EditorButtonControl } from './EditorButtonControl.js';
|
|
5
|
+
|
|
6
|
+
const SIZE_RECT_FIXED = 12;
|
|
7
|
+
const SIZE_SVG_WRAPPER = 16;
|
|
8
|
+
|
|
9
|
+
/** @param {import('./types.js').CropAspectRatio} value */
|
|
10
|
+
const getAdjustResolutions = (value) => {
|
|
11
|
+
let width = 12;
|
|
12
|
+
let height = 12;
|
|
13
|
+
const adjustResolutions = value.width / value.height;
|
|
14
|
+
|
|
15
|
+
if (adjustResolutions >= 1) {
|
|
16
|
+
width = SIZE_RECT_FIXED;
|
|
17
|
+
height = Math.round((SIZE_RECT_FIXED * value.height) / value.width);
|
|
18
|
+
} else {
|
|
19
|
+
height = SIZE_RECT_FIXED;
|
|
20
|
+
width = Math.round((SIZE_RECT_FIXED * value.width) / value.height);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return { width, height };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export class EditorFreeformButtonControl extends EditorButtonControl {
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
initCallback() {
|
|
32
|
+
super.initCallback();
|
|
33
|
+
|
|
34
|
+
this.$['icon'] = 'freeform';
|
|
35
|
+
this.$['on.click'] = this.handleClick.bind(this);
|
|
36
|
+
this.$.active = !!this.$['*currentAspectRatio'];
|
|
37
|
+
|
|
38
|
+
this.sub('*currentAspectRatio', (opt) => {
|
|
39
|
+
const value = opt.hasFreeform ? this.l10n('custom') : `${opt.width}:${opt.height}`;
|
|
40
|
+
this.$['title'] = this.l10n('crop-to-shape', { value });
|
|
41
|
+
|
|
42
|
+
this.bindL10n('title-prop', () => this.$['title']);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
handleClick() {
|
|
47
|
+
this.$['*showListAspectRatio'] = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class EditorAspectRatioButtonControl extends EditorButtonControl {
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
|
|
55
|
+
this.init$ = {
|
|
56
|
+
...this.init$,
|
|
57
|
+
active: false,
|
|
58
|
+
once: false,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
initCallback() {
|
|
62
|
+
super.initCallback();
|
|
63
|
+
|
|
64
|
+
this.defineAccessor(
|
|
65
|
+
'aspectRatio',
|
|
66
|
+
/** @param {import('./types.js').CropAspectRatio} value */ (value) => {
|
|
67
|
+
if (!value) return;
|
|
68
|
+
|
|
69
|
+
const isFreeform = !!value.hasFreeform;
|
|
70
|
+
const name = this.l10n(isFreeform ? 'custom' : value.type).toLowerCase();
|
|
71
|
+
|
|
72
|
+
this.$['icon'] = isFreeform ? 'freeform' : value.type;
|
|
73
|
+
this.$['title'] = isFreeform ? this.l10n('custom') : `${value.width}:${value.height}`;
|
|
74
|
+
|
|
75
|
+
if (!isFreeform) {
|
|
76
|
+
this._renderRectBasedOnAspectRatio(value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this._aspectRatio = value;
|
|
80
|
+
|
|
81
|
+
this.bindL10n('title-prop', () => {
|
|
82
|
+
const val = isFreeform ? '' : `${value.width}:${value.height}`;
|
|
83
|
+
return this.l10n('a11y-cloud-editor-apply-aspect-ratio', {
|
|
84
|
+
name,
|
|
85
|
+
value: val,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
this.sub('*currentAspectRatio', (opt) => {
|
|
92
|
+
this.$.active =
|
|
93
|
+
(opt && opt.id === this._aspectRatio?.id) ||
|
|
94
|
+
(opt?.width === this._aspectRatio?.width && opt?.height === this._aspectRatio?.height);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
this.$['on.click'] = this.handleClick.bind(this);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
handleClick() {
|
|
101
|
+
if (this.$['*currentAspectRatio']?.id === this._aspectRatio?.id) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.$['*currentAspectRatio'] = this._aspectRatio;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** @param {import('./types.js').CropAspectRatio} value */
|
|
109
|
+
_renderRectBasedOnAspectRatio(value) {
|
|
110
|
+
const { width, height } = getAdjustResolutions(value);
|
|
111
|
+
|
|
112
|
+
const rect = createSvgNode('rect', {
|
|
113
|
+
'stroke-linejoin': 'round',
|
|
114
|
+
fill: 'none',
|
|
115
|
+
stroke: 'currentColor',
|
|
116
|
+
'stroke-width': 1.2,
|
|
117
|
+
'fill-rule': 'evenodd',
|
|
118
|
+
x: (SIZE_SVG_WRAPPER - width) / 2,
|
|
119
|
+
y: (SIZE_SVG_WRAPPER - height) / 2,
|
|
120
|
+
width,
|
|
121
|
+
height,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const svgEl = this.ref['icon-el']?.ref?.svg;
|
|
125
|
+
|
|
126
|
+
if (!svgEl) return;
|
|
127
|
+
svgEl.innerHTML = '';
|
|
128
|
+
svgEl.appendChild(rect);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -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(),
|
|
@@ -35,16 +36,9 @@ export class EditorCropButtonControl extends EditorButtonControl {
|
|
|
35
36
|
);
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
this.$['on.click'] = (
|
|
39
|
+
this.$['on.click'] = () => {
|
|
39
40
|
let prev = this.$['*cropperEl'].getValue(this._operation);
|
|
40
41
|
let next = nextValue(this._operation, prev);
|
|
41
|
-
|
|
42
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
43
|
-
operation: this._operation,
|
|
44
|
-
next,
|
|
45
|
-
prev,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
42
|
this.$['*cropperEl'].setValue(this._operation, next);
|
|
49
43
|
};
|
|
50
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorFilterControl.d.ts","sourceRoot":"","sources":["EditorFilterControl.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorFilterControl.d.ts","sourceRoot":"","sources":["EditorFilterControl.js"],"names":[],"mappings":"AAOA;IAeE,sBA2BC;IAED;;;OAGG;IACH,2BAHW,yBAAyB,EAAE,YAC3B,oBAAoB,iBAuB9B;IAfG,yCAA4B;IAoC1B,+BAA0B;IAC1B,4BAAqB;IAYzB,4CAEE;IAGF,kBAA+B;CAgDlC;;;;oCAjKmC,0BAA0B"}
|
|
@@ -4,7 +4,6 @@ import { EditorButtonControl } from './EditorButtonControl.js';
|
|
|
4
4
|
import { FAKE_ORIGINAL_FILTER } from './EditorSlider.js';
|
|
5
5
|
import { COMMON_OPERATIONS, transformationsToOperations } from './lib/transformationUtils.js';
|
|
6
6
|
import { preloadImage } from '../../utils/preloadImage.js';
|
|
7
|
-
import { parseFilterValue } from './utils/parseFilterValue.js';
|
|
8
7
|
|
|
9
8
|
export class EditorFilterControl extends EditorButtonControl {
|
|
10
9
|
constructor() {
|
|
@@ -80,8 +79,7 @@ export class EditorFilterControl extends EditorButtonControl {
|
|
|
80
79
|
initCallback() {
|
|
81
80
|
super.initCallback();
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
this.$['on.click'] = (e) => {
|
|
82
|
+
this.$['on.click'] = () => {
|
|
85
83
|
if (!this.$.active) {
|
|
86
84
|
this.$['*sliderEl'].setOperation(this._operation, this._filter);
|
|
87
85
|
this.$['*sliderEl'].apply();
|
|
@@ -90,10 +88,6 @@ export class EditorFilterControl extends EditorButtonControl {
|
|
|
90
88
|
this.$['*showSlider'] = true;
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
94
|
-
operation: parseFilterValue(this.$['*operationTooltip']),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
91
|
this.$['*currentFilter'] = this._filter;
|
|
98
92
|
};
|
|
99
93
|
|
|
@@ -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,mBAoDC;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;;;;;UA3gBa,OAAO;YACP,OAAO;;;sBApBC,4BAA4B"}
|
|
@@ -189,8 +189,7 @@ export class EditorImageCropper extends Block {
|
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
const cropPreset = this.$['*cropPresetList']?.[0];
|
|
192
|
+
const cropPreset = this.$['*currentAspectRatio'];
|
|
194
193
|
const cropAspectRatio = cropPreset ? cropPreset.width / cropPreset.height : undefined;
|
|
195
194
|
|
|
196
195
|
if (
|
|
@@ -526,7 +525,7 @@ export class EditorImageCropper extends Block {
|
|
|
526
525
|
}
|
|
527
526
|
});
|
|
528
527
|
|
|
529
|
-
this.sub('*
|
|
528
|
+
this.sub('*currentAspectRatio', () => {
|
|
530
529
|
this._alignCrop();
|
|
531
530
|
});
|
|
532
531
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorOperationControl.d.ts","sourceRoot":"","sources":["EditorOperationControl.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorOperationControl.d.ts","sourceRoot":"","sources":["EditorOperationControl.js"],"names":[],"mappings":"AAGA;IACE;;;OAGG;IACH,mBAAgB;CAmCjB;oCA3CmC,0BAA0B"}
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
//@ts-check
|
|
2
1
|
import { EditorButtonControl } from './EditorButtonControl.js';
|
|
3
2
|
import { COLOR_OPERATIONS_CONFIG } from './toolbar-constants.js';
|
|
4
|
-
import { parseFilterValue } from './utils/parseFilterValue.js';
|
|
5
3
|
|
|
6
4
|
export class EditorOperationControl extends EditorButtonControl {
|
|
7
5
|
/**
|
|
8
6
|
* @private
|
|
9
|
-
* @type {
|
|
7
|
+
* @type {String}
|
|
10
8
|
*/
|
|
11
9
|
_operation = '';
|
|
12
10
|
|
|
13
11
|
initCallback() {
|
|
14
12
|
super.initCallback();
|
|
15
13
|
|
|
16
|
-
this.$['on.click'] = (
|
|
14
|
+
this.$['on.click'] = (e) => {
|
|
17
15
|
this.$['*sliderEl'].setOperation(this._operation);
|
|
18
16
|
this.$['*showSlider'] = true;
|
|
19
17
|
this.$['*currentOperation'] = this._operation;
|
|
20
|
-
|
|
21
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
22
|
-
operation: parseFilterValue(this.$['*operationTooltip']),
|
|
23
|
-
});
|
|
24
18
|
};
|
|
25
19
|
|
|
26
|
-
this.defineAccessor('operation', (
|
|
20
|
+
this.defineAccessor('operation', (operation) => {
|
|
27
21
|
if (operation) {
|
|
28
22
|
this._operation = operation;
|
|
29
23
|
this.$['icon'] = operation;
|
|
@@ -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;
|
|
@@ -40,14 +43,10 @@ export class EditorToolbar extends Block {
|
|
|
40
43
|
hidden: string;
|
|
41
44
|
visible: string;
|
|
42
45
|
};
|
|
43
|
-
|
|
44
|
-
'on.
|
|
45
|
-
|
|
46
|
-
'on.
|
|
47
|
-
/** @param {MouseEvent} e */
|
|
48
|
-
'on.applySlider': (e: MouseEvent) => void;
|
|
49
|
-
/** @param {MouseEvent} e */
|
|
50
|
-
'on.cancelSlider': (e: MouseEvent) => void;
|
|
46
|
+
'on.cancel': () => void;
|
|
47
|
+
'on.apply': () => void;
|
|
48
|
+
'on.applySlider': () => void;
|
|
49
|
+
'on.cancelSlider': () => void;
|
|
51
50
|
/** @param {MouseEvent} e */
|
|
52
51
|
'on.clickTab': (e: MouseEvent) => void;
|
|
53
52
|
tab_role: string;
|
|
@@ -76,6 +75,13 @@ export class EditorToolbar extends Block {
|
|
|
76
75
|
* @param {String} operation
|
|
77
76
|
*/
|
|
78
77
|
private _createToggleControl;
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
* @param {import('./types.js').CropAspectRatio} config
|
|
81
|
+
*/
|
|
82
|
+
private _createAspectRatioConrol;
|
|
83
|
+
_createFreeformConrol(): EditorFreeformButtonControl;
|
|
84
|
+
_clearListAspectRatio(): void;
|
|
79
85
|
/**
|
|
80
86
|
* @private
|
|
81
87
|
* @param {String} tabId
|
|
@@ -110,4 +116,5 @@ export namespace EditorToolbar {
|
|
|
110
116
|
let template: string;
|
|
111
117
|
}
|
|
112
118
|
import { Block } from '../../../abstract/Block.js';
|
|
119
|
+
import { EditorFreeformButtonControl } from './EditorAspectRatioButtonControl.js';
|
|
113
120
|
//# sourceMappingURL=EditorToolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorToolbar.d.ts","sourceRoot":"","sources":["EditorToolbar.js"],"names":[],"mappings":"AA4DA;IAII
|
|
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,uBAUC;IAED;;;OAGG;IACH,gCAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,iCAKC;IAED,qDAGC;IAED,8BAEC;IAED;;;OAGG;IACH,4BAwDC;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;;;;sBAjdqB,4BAA4B;4CAE0B,qCAAqC"}
|
|
@@ -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, EditorFreeformButtonControl } 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';
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
TabId,
|
|
16
17
|
} from './toolbar-constants.js';
|
|
17
18
|
import { viewerImageSrc } from './util.js';
|
|
18
|
-
import { parseFilterValue } from './utils/parseFilterValue.js';
|
|
19
19
|
|
|
20
20
|
/** @param {String} id */
|
|
21
21
|
function renderTabToggle(id) {
|
|
@@ -65,9 +65,12 @@ export class EditorToolbar extends Block {
|
|
|
65
65
|
this.init$ = {
|
|
66
66
|
...this.init$,
|
|
67
67
|
'*sliderEl': null,
|
|
68
|
+
'*listAspectRatioEl': null,
|
|
68
69
|
/** @type {import('./types.js').LoadingOperations} */
|
|
69
70
|
'*loadingOperations': new Map(),
|
|
70
71
|
'*showSlider': false,
|
|
72
|
+
'*showListAspectRatio': false,
|
|
73
|
+
hideSliderOrList: false,
|
|
71
74
|
'*currentFilter': FAKE_ORIGINAL_FILTER,
|
|
72
75
|
'*currentOperation': null,
|
|
73
76
|
showLoader: false,
|
|
@@ -105,36 +108,18 @@ export class EditorToolbar extends Block {
|
|
|
105
108
|
hidden: 'uc-tab-toggles--hidden',
|
|
106
109
|
visible: 'uc-tab-toggles--visible',
|
|
107
110
|
},
|
|
108
|
-
|
|
109
|
-
'on.cancel': (e) => {
|
|
110
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
111
|
-
action: 'cancel',
|
|
112
|
-
});
|
|
113
|
-
|
|
111
|
+
'on.cancel': () => {
|
|
114
112
|
this._cancelPreload?.();
|
|
115
113
|
this.$['*on.cancel']();
|
|
116
114
|
},
|
|
117
|
-
|
|
118
|
-
'on.apply': (e) => {
|
|
119
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
120
|
-
action: 'apply',
|
|
121
|
-
});
|
|
115
|
+
'on.apply': () => {
|
|
122
116
|
this.$['*on.apply'](this.$['*editorTransformations']);
|
|
123
117
|
},
|
|
124
|
-
|
|
125
|
-
'on.applySlider': (e) => {
|
|
126
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
127
|
-
action: 'apply-slider',
|
|
128
|
-
operation: parseFilterValue(this.$['*operationTooltip']),
|
|
129
|
-
});
|
|
118
|
+
'on.applySlider': () => {
|
|
130
119
|
this.ref['slider-el'].apply();
|
|
131
120
|
this._onSliderClose();
|
|
132
121
|
},
|
|
133
|
-
|
|
134
|
-
'on.cancelSlider': (e) => {
|
|
135
|
-
this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
|
|
136
|
-
action: 'cancel-slider',
|
|
137
|
-
});
|
|
122
|
+
'on.cancelSlider': () => {
|
|
138
123
|
this.ref['slider-el'].cancel();
|
|
139
124
|
this._onSliderClose();
|
|
140
125
|
},
|
|
@@ -142,7 +127,6 @@ export class EditorToolbar extends Block {
|
|
|
142
127
|
'on.clickTab': (e) => {
|
|
143
128
|
const id = /** @type {HTMLElement} */ (e.currentTarget).getAttribute('data-id');
|
|
144
129
|
if (id) {
|
|
145
|
-
this.telemetryManager.sendEventCloudImageEditor(e, id);
|
|
146
130
|
this._activateTab(id, { fromViewer: false });
|
|
147
131
|
}
|
|
148
132
|
},
|
|
@@ -165,6 +149,11 @@ export class EditorToolbar extends Block {
|
|
|
165
149
|
/** @private */
|
|
166
150
|
_onSliderClose() {
|
|
167
151
|
this.$['*showSlider'] = false;
|
|
152
|
+
|
|
153
|
+
if (this.$['*tabId'] === TabId.CROP) {
|
|
154
|
+
this.$['*showListAspectRatio'] = false;
|
|
155
|
+
}
|
|
156
|
+
|
|
168
157
|
if (this.$['*tabId'] === TabId.TUNING) {
|
|
169
158
|
this.ref['tooltip-el'].classList.toggle('uc-info-tooltip_visible', false);
|
|
170
159
|
}
|
|
@@ -203,6 +192,26 @@ export class EditorToolbar extends Block {
|
|
|
203
192
|
return el;
|
|
204
193
|
}
|
|
205
194
|
|
|
195
|
+
/**
|
|
196
|
+
* @private
|
|
197
|
+
* @param {import('./types.js').CropAspectRatio} config
|
|
198
|
+
*/
|
|
199
|
+
_createAspectRatioConrol(config) {
|
|
200
|
+
const el = new EditorAspectRatioButtonControl();
|
|
201
|
+
// @ts-expect-error TODO: fix
|
|
202
|
+
el.aspectRatio = config;
|
|
203
|
+
return el;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
_createFreeformConrol() {
|
|
207
|
+
const el = new EditorFreeformButtonControl();
|
|
208
|
+
return el;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
_clearListAspectRatio() {
|
|
212
|
+
this.$['*listAspectRatioEl'].innerHTML = '';
|
|
213
|
+
}
|
|
214
|
+
|
|
206
215
|
/**
|
|
207
216
|
* @private
|
|
208
217
|
* @param {String} tabId
|
|
@@ -211,7 +220,27 @@ export class EditorToolbar extends Block {
|
|
|
211
220
|
let listEl = this.ref[`controls-list-${tabId}`];
|
|
212
221
|
let fr = document.createDocumentFragment();
|
|
213
222
|
|
|
223
|
+
this._clearListAspectRatio();
|
|
224
|
+
|
|
214
225
|
if (tabId === TabId.CROP) {
|
|
226
|
+
const hasFreeformAspectRatio = this.$['*cropPresetList'].length >= 3;
|
|
227
|
+
|
|
228
|
+
if (hasFreeformAspectRatio) {
|
|
229
|
+
const el = this._createFreeformConrol();
|
|
230
|
+
fr.appendChild(el);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
this.$['*cropPresetList'].forEach(
|
|
234
|
+
/** @param {import('./types.js').CropAspectRatio} it */ (it) => {
|
|
235
|
+
let el = this._createAspectRatioConrol(it);
|
|
236
|
+
fr.appendChild(el);
|
|
237
|
+
|
|
238
|
+
if (hasFreeformAspectRatio) {
|
|
239
|
+
this.$['*listAspectRatioEl'].appendChild(el);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
|
|
215
244
|
this.$.cropOperations.forEach(
|
|
216
245
|
/** @param {string} operation */ (operation) => {
|
|
217
246
|
let el = this._createToggleControl(operation);
|
|
@@ -347,6 +376,7 @@ export class EditorToolbar extends Block {
|
|
|
347
376
|
super.initCallback();
|
|
348
377
|
|
|
349
378
|
this.$['*sliderEl'] = this.ref['slider-el'];
|
|
379
|
+
this.$['*listAspectRatioEl'] = this.ref['list-el'];
|
|
350
380
|
|
|
351
381
|
this.sub('*imageSize', (imageSize) => {
|
|
352
382
|
if (imageSize) {
|
|
@@ -405,6 +435,14 @@ export class EditorToolbar extends Block {
|
|
|
405
435
|
this.sub('*showSlider', (showSlider) => {
|
|
406
436
|
this.$['presence.subToolbar'] = showSlider;
|
|
407
437
|
this.$['presence.mainToolbar'] = !showSlider;
|
|
438
|
+
|
|
439
|
+
this.$.hideSliderOrList = true;
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
this.sub('*showListAspectRatio', (show) => {
|
|
443
|
+
this.$['presence.subToolbar'] = show;
|
|
444
|
+
this.$['presence.mainToolbar'] = !show;
|
|
445
|
+
this.$.hideSliderOrList = false;
|
|
408
446
|
});
|
|
409
447
|
|
|
410
448
|
this.sub('*tabList', (tabList) => {
|
|
@@ -425,6 +463,7 @@ export class EditorToolbar extends Block {
|
|
|
425
463
|
|
|
426
464
|
destroyCallback() {
|
|
427
465
|
this.$['*showSlider'] = false;
|
|
466
|
+
this.$['*showListAspectRatio'] = false;
|
|
428
467
|
}
|
|
429
468
|
}
|
|
430
469
|
|
|
@@ -459,9 +498,13 @@ EditorToolbar.template = /* HTML */ `
|
|
|
459
498
|
class="uc-sub-toolbar"
|
|
460
499
|
set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles"
|
|
461
500
|
>
|
|
462
|
-
<div class="uc-slider">
|
|
501
|
+
<div class="uc-slider" set="@hidden:!hideSliderOrList">
|
|
463
502
|
<uc-editor-slider ref="slider-el"></uc-editor-slider>
|
|
464
503
|
</div>
|
|
504
|
+
|
|
505
|
+
<div set="@hidden:hideSliderOrList" class="uc-list-aspect-ratio-container">
|
|
506
|
+
<div class="uc-list-aspect-ratio" ref="list-el"></div>
|
|
507
|
+
</div>
|
|
465
508
|
<div class="uc-controls-row">
|
|
466
509
|
<uc-btn-ui theme="secondary" set="onclick: on.cancelSlider" l10n="@text:cancel"> </uc-btn-ui>
|
|
467
510
|
<uc-btn-ui theme="primary" set="onclick: on.applySlider" l10n="@text:apply"> </uc-btn-ui>
|