@elementor/editor-canvas 3.35.0-472 → 3.35.0-473
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/dist/index.js +41 -12
- package/dist/index.mjs +37 -8
- package/package.json +18 -18
- package/src/style-commands/__tests__/paste-style.test.ts +703 -470
- package/src/style-commands/paste-style.ts +47 -10
package/dist/index.js
CHANGED
|
@@ -3442,6 +3442,8 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
3442
3442
|
}
|
|
3443
3443
|
|
|
3444
3444
|
// src/style-commands/paste-style.ts
|
|
3445
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3446
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
3445
3447
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
3446
3448
|
|
|
3447
3449
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
@@ -3578,30 +3580,57 @@ function initPasteStyleCommand() {
|
|
|
3578
3580
|
(e) => pasteStyles(e.args, pasteElementStyleCommand)
|
|
3579
3581
|
);
|
|
3580
3582
|
}
|
|
3581
|
-
function pasteStyles(args,
|
|
3583
|
+
function pasteStyles(args, pasteLocalStyle) {
|
|
3582
3584
|
const { containers = [args.container], storageKey } = args;
|
|
3585
|
+
const atomicContainers = containers.filter(isAtomicWidget);
|
|
3586
|
+
if (!atomicContainers.length) {
|
|
3587
|
+
return;
|
|
3588
|
+
}
|
|
3583
3589
|
const clipboardElements = getClipboardElements(storageKey);
|
|
3584
3590
|
const [clipboardElement] = clipboardElements ?? [];
|
|
3585
|
-
|
|
3591
|
+
const clipboardContainer = (0, import_editor_elements13.getContainer)(clipboardElement.id);
|
|
3592
|
+
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
3586
3593
|
return;
|
|
3587
3594
|
}
|
|
3588
3595
|
const elementStyles = clipboardElement.styles;
|
|
3589
3596
|
const elementStyle = Object.values(elementStyles ?? {})[0];
|
|
3590
|
-
|
|
3591
|
-
|
|
3597
|
+
const classesSetting = getClassesWithoutLocalStyle(clipboardContainer, elementStyle);
|
|
3598
|
+
if (classesSetting.length) {
|
|
3599
|
+
pasteClasses(atomicContainers, classesSetting);
|
|
3592
3600
|
}
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
return;
|
|
3601
|
+
if (elementStyle) {
|
|
3602
|
+
pasteLocalStyle({ containers: atomicContainers, newStyle: elementStyle });
|
|
3596
3603
|
}
|
|
3597
|
-
|
|
3604
|
+
}
|
|
3605
|
+
function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
3606
|
+
const classesProp = getClassesProp(clipboardContainer);
|
|
3607
|
+
if (!classesProp) {
|
|
3608
|
+
return [];
|
|
3609
|
+
}
|
|
3610
|
+
const classesSetting = (0, import_editor_elements13.getElementSetting)(clipboardContainer.id, classesProp);
|
|
3611
|
+
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
3612
|
+
}
|
|
3613
|
+
function pasteClasses(containers, classes) {
|
|
3614
|
+
containers.forEach((container) => {
|
|
3615
|
+
const classesProp = getClassesProp(container);
|
|
3616
|
+
if (!classesProp) {
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
const classesSetting = (0, import_editor_elements13.getElementSetting)(container.id, classesProp);
|
|
3620
|
+
const currentClasses = import_editor_props9.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
3621
|
+
const newClasses = import_editor_props9.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
3622
|
+
(0, import_editor_elements13.updateElementSettings)({
|
|
3623
|
+
id: container.id,
|
|
3624
|
+
props: { [classesProp]: newClasses }
|
|
3625
|
+
});
|
|
3626
|
+
});
|
|
3598
3627
|
}
|
|
3599
3628
|
|
|
3600
3629
|
// src/style-commands/reset-style.ts
|
|
3601
3630
|
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
3602
3631
|
|
|
3603
3632
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
3604
|
-
var
|
|
3633
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
3605
3634
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
3606
3635
|
var import_editor_v1_adapters14 = require("@elementor/editor-v1-adapters");
|
|
3607
3636
|
var import_i18n5 = require("@wordpress/i18n");
|
|
@@ -3610,9 +3639,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters14.undoable)(
|
|
|
3610
3639
|
do: ({ containers }) => {
|
|
3611
3640
|
return containers.map((container) => {
|
|
3612
3641
|
const elementId = container.model.get("id");
|
|
3613
|
-
const containerStyles = (0,
|
|
3642
|
+
const containerStyles = (0, import_editor_elements14.getElementStyles)(elementId);
|
|
3614
3643
|
Object.keys(containerStyles ?? {}).forEach(
|
|
3615
|
-
(styleId) => (0,
|
|
3644
|
+
(styleId) => (0, import_editor_elements14.deleteElementStyle)(elementId, styleId)
|
|
3616
3645
|
);
|
|
3617
3646
|
return containerStyles;
|
|
3618
3647
|
});
|
|
@@ -3628,7 +3657,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters14.undoable)(
|
|
|
3628
3657
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
3629
3658
|
const [firstVariant] = style.variants;
|
|
3630
3659
|
const additionalVariants = style.variants.slice(1);
|
|
3631
|
-
(0,
|
|
3660
|
+
(0, import_editor_elements14.createElementStyle)({
|
|
3632
3661
|
elementId,
|
|
3633
3662
|
classesProp,
|
|
3634
3663
|
styleId,
|
package/dist/index.mjs
CHANGED
|
@@ -3433,6 +3433,8 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
3433
3433
|
}
|
|
3434
3434
|
|
|
3435
3435
|
// src/style-commands/paste-style.ts
|
|
3436
|
+
import { getContainer as getContainer5, getElementSetting, updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
3437
|
+
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
3436
3438
|
import {
|
|
3437
3439
|
__privateListenTo as listenTo2,
|
|
3438
3440
|
blockCommand as blockCommand2,
|
|
@@ -3578,23 +3580,50 @@ function initPasteStyleCommand() {
|
|
|
3578
3580
|
(e) => pasteStyles(e.args, pasteElementStyleCommand)
|
|
3579
3581
|
);
|
|
3580
3582
|
}
|
|
3581
|
-
function pasteStyles(args,
|
|
3583
|
+
function pasteStyles(args, pasteLocalStyle) {
|
|
3582
3584
|
const { containers = [args.container], storageKey } = args;
|
|
3585
|
+
const atomicContainers = containers.filter(isAtomicWidget);
|
|
3586
|
+
if (!atomicContainers.length) {
|
|
3587
|
+
return;
|
|
3588
|
+
}
|
|
3583
3589
|
const clipboardElements = getClipboardElements(storageKey);
|
|
3584
3590
|
const [clipboardElement] = clipboardElements ?? [];
|
|
3585
|
-
|
|
3591
|
+
const clipboardContainer = getContainer5(clipboardElement.id);
|
|
3592
|
+
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
3586
3593
|
return;
|
|
3587
3594
|
}
|
|
3588
3595
|
const elementStyles = clipboardElement.styles;
|
|
3589
3596
|
const elementStyle = Object.values(elementStyles ?? {})[0];
|
|
3590
|
-
|
|
3591
|
-
|
|
3597
|
+
const classesSetting = getClassesWithoutLocalStyle(clipboardContainer, elementStyle);
|
|
3598
|
+
if (classesSetting.length) {
|
|
3599
|
+
pasteClasses(atomicContainers, classesSetting);
|
|
3592
3600
|
}
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
return;
|
|
3601
|
+
if (elementStyle) {
|
|
3602
|
+
pasteLocalStyle({ containers: atomicContainers, newStyle: elementStyle });
|
|
3596
3603
|
}
|
|
3597
|
-
|
|
3604
|
+
}
|
|
3605
|
+
function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
3606
|
+
const classesProp = getClassesProp(clipboardContainer);
|
|
3607
|
+
if (!classesProp) {
|
|
3608
|
+
return [];
|
|
3609
|
+
}
|
|
3610
|
+
const classesSetting = getElementSetting(clipboardContainer.id, classesProp);
|
|
3611
|
+
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
3612
|
+
}
|
|
3613
|
+
function pasteClasses(containers, classes) {
|
|
3614
|
+
containers.forEach((container) => {
|
|
3615
|
+
const classesProp = getClassesProp(container);
|
|
3616
|
+
if (!classesProp) {
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
const classesSetting = getElementSetting(container.id, classesProp);
|
|
3620
|
+
const currentClasses = classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
3621
|
+
const newClasses = classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
3622
|
+
updateElementSettings2({
|
|
3623
|
+
id: container.id,
|
|
3624
|
+
props: { [classesProp]: newClasses }
|
|
3625
|
+
});
|
|
3626
|
+
});
|
|
3598
3627
|
}
|
|
3599
3628
|
|
|
3600
3629
|
// src/style-commands/reset-style.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "3.35.0-
|
|
4
|
+
"version": "3.35.0-473",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "3.35.0-
|
|
41
|
-
"@elementor/editor-controls": "3.35.0-
|
|
42
|
-
"@elementor/editor-documents": "3.35.0-
|
|
43
|
-
"@elementor/editor-elements": "3.35.0-
|
|
44
|
-
"@elementor/editor-interactions": "3.35.0-
|
|
45
|
-
"@elementor/editor-mcp": "3.35.0-
|
|
46
|
-
"@elementor/editor-notifications": "3.35.0-
|
|
47
|
-
"@elementor/editor-props": "3.35.0-
|
|
48
|
-
"@elementor/editor-responsive": "3.35.0-
|
|
49
|
-
"@elementor/editor-styles": "3.35.0-
|
|
50
|
-
"@elementor/editor-styles-repository": "3.35.0-
|
|
51
|
-
"@elementor/editor-ui": "3.35.0-
|
|
52
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
53
|
-
"@elementor/schema": "3.35.0-
|
|
54
|
-
"@elementor/twing": "3.35.0-
|
|
40
|
+
"@elementor/editor": "3.35.0-473",
|
|
41
|
+
"@elementor/editor-controls": "3.35.0-473",
|
|
42
|
+
"@elementor/editor-documents": "3.35.0-473",
|
|
43
|
+
"@elementor/editor-elements": "3.35.0-473",
|
|
44
|
+
"@elementor/editor-interactions": "3.35.0-473",
|
|
45
|
+
"@elementor/editor-mcp": "3.35.0-473",
|
|
46
|
+
"@elementor/editor-notifications": "3.35.0-473",
|
|
47
|
+
"@elementor/editor-props": "3.35.0-473",
|
|
48
|
+
"@elementor/editor-responsive": "3.35.0-473",
|
|
49
|
+
"@elementor/editor-styles": "3.35.0-473",
|
|
50
|
+
"@elementor/editor-styles-repository": "3.35.0-473",
|
|
51
|
+
"@elementor/editor-ui": "3.35.0-473",
|
|
52
|
+
"@elementor/editor-v1-adapters": "3.35.0-473",
|
|
53
|
+
"@elementor/schema": "3.35.0-473",
|
|
54
|
+
"@elementor/twing": "3.35.0-473",
|
|
55
55
|
"@elementor/ui": "1.36.17",
|
|
56
|
-
"@elementor/utils": "3.35.0-
|
|
57
|
-
"@elementor/wp-media": "3.35.0-
|
|
56
|
+
"@elementor/utils": "3.35.0-473",
|
|
57
|
+
"@elementor/wp-media": "3.35.0-473",
|
|
58
58
|
"@floating-ui/react": "^0.27.5",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0"
|
|
60
60
|
},
|