@elementor/editor-canvas 4.1.0-809 → 4.1.0-810
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +117 -64
- package/dist/index.mjs +74 -16
- package/package.json +18 -18
- package/src/legacy/create-nested-templated-element-type.ts +11 -1
- package/src/legacy/create-pending-element.ts +70 -0
- package/src/legacy/types.ts +5 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V1Element,
|
|
1
|
+
import { V1Element, V1ElementModelProps, V1ElementConfig } from '@elementor/editor-elements';
|
|
2
2
|
import { TwingArrayLoader, TwingEnvironment } from '@elementor/twing';
|
|
3
3
|
import { Root } from 'react-dom/client';
|
|
4
4
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
@@ -89,6 +89,7 @@ declare class ElementView {
|
|
|
89
89
|
map: <T>(callback: (view: ElementView) => T) => T[];
|
|
90
90
|
};
|
|
91
91
|
constructor(...args: unknown[]);
|
|
92
|
+
addElement(data: Partial<V1ElementModelProps>, options?: object): unknown;
|
|
92
93
|
onRender(...args: unknown[]): void;
|
|
93
94
|
onDestroy(...args: unknown[]): void;
|
|
94
95
|
attributes(): Record<string, unknown>;
|
|
@@ -131,6 +132,7 @@ declare class ElementView {
|
|
|
131
132
|
scrollIntoView: boolean;
|
|
132
133
|
}): void;
|
|
133
134
|
once: (event: string, callback: () => void) => void;
|
|
135
|
+
getContainer(): V1Element;
|
|
134
136
|
}
|
|
135
137
|
declare class TemplatedElementView extends ElementView {
|
|
136
138
|
_doAfterRender(callback: () => void): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V1Element,
|
|
1
|
+
import { V1Element, V1ElementModelProps, V1ElementConfig } from '@elementor/editor-elements';
|
|
2
2
|
import { TwingArrayLoader, TwingEnvironment } from '@elementor/twing';
|
|
3
3
|
import { Root } from 'react-dom/client';
|
|
4
4
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
@@ -89,6 +89,7 @@ declare class ElementView {
|
|
|
89
89
|
map: <T>(callback: (view: ElementView) => T) => T[];
|
|
90
90
|
};
|
|
91
91
|
constructor(...args: unknown[]);
|
|
92
|
+
addElement(data: Partial<V1ElementModelProps>, options?: object): unknown;
|
|
92
93
|
onRender(...args: unknown[]): void;
|
|
93
94
|
onDestroy(...args: unknown[]): void;
|
|
94
95
|
attributes(): Record<string, unknown>;
|
|
@@ -131,6 +132,7 @@ declare class ElementView {
|
|
|
131
132
|
scrollIntoView: boolean;
|
|
132
133
|
}): void;
|
|
133
134
|
once: (event: string, callback: () => void) => void;
|
|
135
|
+
getContainer(): V1Element;
|
|
134
136
|
}
|
|
135
137
|
declare class TemplatedElementView extends ElementView {
|
|
136
138
|
_doAfterRender(callback: () => void): void;
|
package/dist/index.js
CHANGED
|
@@ -2001,7 +2001,7 @@ function initStyleTransformers() {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
|
|
2003
2003
|
// src/legacy/init-legacy-views.ts
|
|
2004
|
-
var
|
|
2004
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
2005
2005
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
2006
2006
|
|
|
2007
2007
|
// src/renderers/create-dom-renderer.ts
|
|
@@ -2130,7 +2130,53 @@ function createElementViewClassDeclaration() {
|
|
|
2130
2130
|
}
|
|
2131
2131
|
|
|
2132
2132
|
// src/legacy/create-nested-templated-element-type.ts
|
|
2133
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
2134
|
+
|
|
2135
|
+
// src/legacy/create-pending-element.ts
|
|
2133
2136
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
2137
|
+
function createPendingElement(wrapperView, data, options = {}) {
|
|
2138
|
+
const parentContainer = wrapperView.getContainer();
|
|
2139
|
+
const model = { ...data };
|
|
2140
|
+
if (!model.id) {
|
|
2141
|
+
model.id = (0, import_editor_elements5.generateElementId)();
|
|
2142
|
+
}
|
|
2143
|
+
if (!model.elements) {
|
|
2144
|
+
model.elements = [];
|
|
2145
|
+
}
|
|
2146
|
+
const added = (0, import_editor_elements5.addModelToParent)(parentContainer.id, model, options);
|
|
2147
|
+
if (!added) {
|
|
2148
|
+
return void 0;
|
|
2149
|
+
}
|
|
2150
|
+
const childId = model.id;
|
|
2151
|
+
const childModel = (0, import_editor_elements5.findModelInDocument)(childId);
|
|
2152
|
+
if (!childModel) {
|
|
2153
|
+
return void 0;
|
|
2154
|
+
}
|
|
2155
|
+
const pendingContainer = {
|
|
2156
|
+
id: childId,
|
|
2157
|
+
settings: { get: () => ({}), set: () => ({}), toJSON: () => ({}) },
|
|
2158
|
+
parent: parentContainer,
|
|
2159
|
+
model: childModel,
|
|
2160
|
+
view: void 0,
|
|
2161
|
+
lookup() {
|
|
2162
|
+
return (0, import_editor_elements5.getContainer)(childId) ?? pendingContainer;
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
if (options.edit !== false) {
|
|
2166
|
+
selectChildWhenWrapperRenders(wrapperView, childId);
|
|
2167
|
+
}
|
|
2168
|
+
return { getContainer: () => pendingContainer };
|
|
2169
|
+
}
|
|
2170
|
+
function selectChildWhenWrapperRenders(wrapperView, childId) {
|
|
2171
|
+
wrapperView.once("render", () => {
|
|
2172
|
+
const childContainer = (0, import_editor_elements5.getContainer)(childId);
|
|
2173
|
+
if (childContainer?.model?.trigger) {
|
|
2174
|
+
childContainer.model.trigger("request:edit");
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
wrapperView.model?.trigger?.("request:edit");
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2134
2180
|
|
|
2135
2181
|
// src/legacy/twig-rendering-utils.ts
|
|
2136
2182
|
function setupTwigRenderer({ renderer, element }) {
|
|
@@ -2349,6 +2395,7 @@ function createNestedTemplatedElementView({
|
|
|
2349
2395
|
const AtomicElementBaseView = legacyWindow.elementor.modules.elements.views.createAtomicElementBase(type);
|
|
2350
2396
|
const parentRenderChildren = AtomicElementBaseView.prototype._renderChildren;
|
|
2351
2397
|
const parentOpenEditingPanel = AtomicElementBaseView.prototype._openEditingPanel;
|
|
2398
|
+
const parentAddElement = AtomicElementBaseView.prototype.addElement;
|
|
2352
2399
|
return AtomicElementBaseView.extend({
|
|
2353
2400
|
_abortController: null,
|
|
2354
2401
|
_lastResolvedSettingsHash: null,
|
|
@@ -2388,7 +2435,7 @@ function createNestedTemplatedElementView({
|
|
|
2388
2435
|
this._initAlpine();
|
|
2389
2436
|
});
|
|
2390
2437
|
this.model.trigger("render:complete");
|
|
2391
|
-
window.dispatchEvent(new CustomEvent(
|
|
2438
|
+
window.dispatchEvent(new CustomEvent(import_editor_elements6.ELEMENT_STYLE_CHANGE_EVENT));
|
|
2392
2439
|
},
|
|
2393
2440
|
async _renderTemplate() {
|
|
2394
2441
|
const model = this.model;
|
|
@@ -2548,6 +2595,12 @@ function createNestedTemplatedElementView({
|
|
|
2548
2595
|
_openEditingPanel(options) {
|
|
2549
2596
|
this._doAfterRender(() => parentOpenEditingPanel.call(this, options));
|
|
2550
2597
|
},
|
|
2598
|
+
addElement(data, options) {
|
|
2599
|
+
if (this.isRendered) {
|
|
2600
|
+
return parentAddElement.call(this, data, options);
|
|
2601
|
+
}
|
|
2602
|
+
return createPendingElement(this, data, options);
|
|
2603
|
+
},
|
|
2551
2604
|
getInteractionId() {
|
|
2552
2605
|
const originId = this.model.get("originId");
|
|
2553
2606
|
const id = this.model.get("id");
|
|
@@ -2624,7 +2677,7 @@ var import_client = require("react-dom/client");
|
|
|
2624
2677
|
|
|
2625
2678
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
2626
2679
|
var React6 = __toESM(require("react"));
|
|
2627
|
-
var
|
|
2680
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
2628
2681
|
var import_editor_props4 = require("@elementor/editor-props");
|
|
2629
2682
|
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
2630
2683
|
var import_i18n3 = require("@wordpress/i18n");
|
|
@@ -3000,7 +3053,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3000
3053
|
return INLINE_EDITING_PROPERTY_PER_TYPE[this.type] ?? "";
|
|
3001
3054
|
}
|
|
3002
3055
|
getInlineEditablePropType() {
|
|
3003
|
-
const propSchema = (0,
|
|
3056
|
+
const propSchema = (0, import_editor_elements7.getElementType)(this.type)?.propsSchema;
|
|
3004
3057
|
const propertyName = this.getInlineEditablePropertyName();
|
|
3005
3058
|
return propSchema?.[propertyName] ?? null;
|
|
3006
3059
|
}
|
|
@@ -3034,7 +3087,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3034
3087
|
}
|
|
3035
3088
|
},
|
|
3036
3089
|
{
|
|
3037
|
-
title: (0,
|
|
3090
|
+
title: (0, import_editor_elements7.getElementLabel)(this.id),
|
|
3038
3091
|
// translators: %s is the name of the property that was edited.
|
|
3039
3092
|
subtitle: (0, import_i18n3.__)("%s edited", "elementor").replace(
|
|
3040
3093
|
"%s",
|
|
@@ -3067,7 +3120,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3067
3120
|
(0, import_editor_v1_adapters12.__privateRunCommandSync)(
|
|
3068
3121
|
"document/elements/set-settings",
|
|
3069
3122
|
{
|
|
3070
|
-
container: (0,
|
|
3123
|
+
container: (0, import_editor_elements7.getContainer)(this.id),
|
|
3071
3124
|
settings: {
|
|
3072
3125
|
[key]: value
|
|
3073
3126
|
}
|
|
@@ -3082,7 +3135,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3082
3135
|
return import_editor_props4.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props4.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
3083
3136
|
}
|
|
3084
3137
|
getTagPropType() {
|
|
3085
|
-
const propsSchema = (0,
|
|
3138
|
+
const propsSchema = (0, import_editor_elements7.getElementType)(this.type)?.propsSchema;
|
|
3086
3139
|
if (!propsSchema?.tag) {
|
|
3087
3140
|
return null;
|
|
3088
3141
|
}
|
|
@@ -3242,7 +3295,7 @@ function registerElementType(type, elementTypeGenerator) {
|
|
|
3242
3295
|
}
|
|
3243
3296
|
function initLegacyViews() {
|
|
3244
3297
|
(0, import_editor_v1_adapters13.__privateListenTo)((0, import_editor_v1_adapters13.v1ReadyEvent)(), () => {
|
|
3245
|
-
const widgetsCache = (0,
|
|
3298
|
+
const widgetsCache = (0, import_editor_elements8.getWidgetsCache)() ?? {};
|
|
3246
3299
|
const legacyWindow = window;
|
|
3247
3300
|
const renderer = createDomRenderer();
|
|
3248
3301
|
registerProPromotionTypes(widgetsCache);
|
|
@@ -3386,7 +3439,7 @@ var initAvailableWidgetsResource = (reg) => {
|
|
|
3386
3439
|
};
|
|
3387
3440
|
|
|
3388
3441
|
// src/mcp/resources/document-structure-resource.ts
|
|
3389
|
-
var
|
|
3442
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3390
3443
|
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
3391
3444
|
var DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
3392
3445
|
var initDocumentStructureResource = (reg) => {
|
|
@@ -3451,7 +3504,7 @@ function resolveElementVersion(element) {
|
|
|
3451
3504
|
return "v4";
|
|
3452
3505
|
}
|
|
3453
3506
|
const widgetType = element.model?.attributes?.widgetType;
|
|
3454
|
-
if (widgetType && (0,
|
|
3507
|
+
if (widgetType && (0, import_editor_elements9.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
3455
3508
|
return "v4";
|
|
3456
3509
|
}
|
|
3457
3510
|
return "v3";
|
|
@@ -3647,7 +3700,7 @@ var initGeneralContextResource = (reg) => {
|
|
|
3647
3700
|
};
|
|
3648
3701
|
|
|
3649
3702
|
// src/mcp/resources/selected-element-resource.ts
|
|
3650
|
-
var
|
|
3703
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
3651
3704
|
var import_editor_v1_adapters18 = require("@elementor/editor-v1-adapters");
|
|
3652
3705
|
var SELECTED_ELEMENT_URI = "elementor://context/selected-element";
|
|
3653
3706
|
var initSelectedElementResource = (reg) => {
|
|
@@ -3718,11 +3771,11 @@ function createEmptySelectedElementPayload() {
|
|
|
3718
3771
|
};
|
|
3719
3772
|
}
|
|
3720
3773
|
function readSelectionFromEditor() {
|
|
3721
|
-
const elements = (0,
|
|
3774
|
+
const elements = (0, import_editor_elements10.getSelectedElements)();
|
|
3722
3775
|
if (elements.length !== 1) {
|
|
3723
3776
|
return createEmptySelectedElementPayload();
|
|
3724
3777
|
}
|
|
3725
|
-
const container = (0,
|
|
3778
|
+
const container = (0, import_editor_elements10.getContainer)(elements[0].id);
|
|
3726
3779
|
return buildPayloadFromContainer(container);
|
|
3727
3780
|
}
|
|
3728
3781
|
function buildPayloadFromContainer(container) {
|
|
@@ -3745,7 +3798,7 @@ function resolveElementVersion2(container, widgetType) {
|
|
|
3745
3798
|
if (container.model?.config?.atomic) {
|
|
3746
3799
|
return "v4";
|
|
3747
3800
|
}
|
|
3748
|
-
if (widgetType && (0,
|
|
3801
|
+
if (widgetType && (0, import_editor_elements10.getWidgetsCache)()?.[widgetType]?.atomic_props_schema) {
|
|
3749
3802
|
return "v4";
|
|
3750
3803
|
}
|
|
3751
3804
|
return "v3";
|
|
@@ -3755,7 +3808,7 @@ function getElementProperties(container, widgetType) {
|
|
|
3755
3808
|
if (!settings || typeof settings !== "object") {
|
|
3756
3809
|
return null;
|
|
3757
3810
|
}
|
|
3758
|
-
const widgetConfig = widgetType ? (0,
|
|
3811
|
+
const widgetConfig = widgetType ? (0, import_editor_elements10.getWidgetsCache)()?.[widgetType] : null;
|
|
3759
3812
|
const controls = widgetConfig?.controls;
|
|
3760
3813
|
const filtered = {};
|
|
3761
3814
|
for (const [key, value] of Object.entries(settings)) {
|
|
@@ -3794,13 +3847,13 @@ function getElementDisplayName(container) {
|
|
|
3794
3847
|
|
|
3795
3848
|
// src/mcp/tools/build-composition/tool.ts
|
|
3796
3849
|
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
3797
|
-
var
|
|
3850
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
3798
3851
|
|
|
3799
3852
|
// src/composition-builder/composition-builder.ts
|
|
3800
|
-
var
|
|
3853
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3801
3854
|
|
|
3802
3855
|
// src/mcp/utils/do-update-element-property.ts
|
|
3803
|
-
var
|
|
3856
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3804
3857
|
var import_editor_props6 = require("@elementor/editor-props");
|
|
3805
3858
|
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
3806
3859
|
function resolvePropValue(value, forceKey) {
|
|
@@ -3813,7 +3866,7 @@ function resolvePropValue(value, forceKey) {
|
|
|
3813
3866
|
var doUpdateElementProperty = (params) => {
|
|
3814
3867
|
const { elementId, propertyName, propertyValue, elementType } = params;
|
|
3815
3868
|
if (propertyName === "_styles") {
|
|
3816
|
-
const elementStyles = (0,
|
|
3869
|
+
const elementStyles = (0, import_editor_elements11.getElementStyles)(elementId) || {};
|
|
3817
3870
|
const propertyMapValue = propertyValue;
|
|
3818
3871
|
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
3819
3872
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -3861,7 +3914,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3861
3914
|
delete transformedStyleValues.custom_css;
|
|
3862
3915
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
3863
3916
|
if (!localStyle) {
|
|
3864
|
-
(0,
|
|
3917
|
+
(0, import_editor_elements11.createElementStyle)({
|
|
3865
3918
|
elementId,
|
|
3866
3919
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
3867
3920
|
classesProp: "classes",
|
|
@@ -3875,7 +3928,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3875
3928
|
}
|
|
3876
3929
|
});
|
|
3877
3930
|
} else {
|
|
3878
|
-
(0,
|
|
3931
|
+
(0, import_editor_elements11.updateElementStyle)({
|
|
3879
3932
|
elementId,
|
|
3880
3933
|
styleId: localStyle.id,
|
|
3881
3934
|
meta: {
|
|
@@ -3890,7 +3943,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3890
3943
|
}
|
|
3891
3944
|
return;
|
|
3892
3945
|
}
|
|
3893
|
-
const elementPropSchema = (0,
|
|
3946
|
+
const elementPropSchema = (0, import_editor_elements11.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
3894
3947
|
if (!elementPropSchema) {
|
|
3895
3948
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
3896
3949
|
}
|
|
@@ -3904,7 +3957,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3904
3957
|
}
|
|
3905
3958
|
const propKey = elementPropSchema[propertyName].key;
|
|
3906
3959
|
const value = resolvePropValue(propertyValue, propKey);
|
|
3907
|
-
(0,
|
|
3960
|
+
(0, import_editor_elements11.updateElementSettings)({
|
|
3908
3961
|
id: elementId,
|
|
3909
3962
|
props: {
|
|
3910
3963
|
[propertyName]: value
|
|
@@ -3914,7 +3967,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
3914
3967
|
};
|
|
3915
3968
|
|
|
3916
3969
|
// src/mcp/utils/validate-input.ts
|
|
3917
|
-
var
|
|
3970
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
3918
3971
|
var import_editor_props7 = require("@elementor/editor-props");
|
|
3919
3972
|
var import_editor_styles6 = require("@elementor/editor-styles");
|
|
3920
3973
|
var _widgetsSchema = null;
|
|
@@ -3922,7 +3975,7 @@ var validateInput = {
|
|
|
3922
3975
|
get widgetsSchema() {
|
|
3923
3976
|
if (!_widgetsSchema) {
|
|
3924
3977
|
const schema2 = {};
|
|
3925
|
-
const cache = (0,
|
|
3978
|
+
const cache = (0, import_editor_elements12.getWidgetsCache)();
|
|
3926
3979
|
if (!cache) {
|
|
3927
3980
|
return {};
|
|
3928
3981
|
}
|
|
@@ -4005,10 +4058,10 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
4005
4058
|
elementCusomCSS = {};
|
|
4006
4059
|
rootContainers = [];
|
|
4007
4060
|
api = {
|
|
4008
|
-
createElement:
|
|
4009
|
-
getWidgetsCache:
|
|
4010
|
-
generateElementId:
|
|
4011
|
-
getContainer:
|
|
4061
|
+
createElement: import_editor_elements13.createElement,
|
|
4062
|
+
getWidgetsCache: import_editor_elements13.getWidgetsCache,
|
|
4063
|
+
generateElementId: import_editor_elements13.generateElementId,
|
|
4064
|
+
getContainer: import_editor_elements13.getContainer,
|
|
4012
4065
|
doUpdateElementProperty
|
|
4013
4066
|
};
|
|
4014
4067
|
xml;
|
|
@@ -4449,13 +4502,13 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
4449
4502
|
let generatedXML = "";
|
|
4450
4503
|
const errors = [];
|
|
4451
4504
|
const rootContainers = [];
|
|
4452
|
-
const documentContainer = (0,
|
|
4505
|
+
const documentContainer = (0, import_editor_elements14.getContainer)("document");
|
|
4453
4506
|
const currentDocument = (0, import_editor_documents3.getCurrentDocument)();
|
|
4454
4507
|
const targetContainer = getCompositionTargetContainer(documentContainer, currentDocument?.type.value);
|
|
4455
4508
|
try {
|
|
4456
4509
|
const compositionBuilder = CompositionBuilder.fromXMLString(xmlStructure, {
|
|
4457
|
-
createElement:
|
|
4458
|
-
getWidgetsCache:
|
|
4510
|
+
createElement: import_editor_elements14.createElement,
|
|
4511
|
+
getWidgetsCache: import_editor_elements14.getWidgetsCache
|
|
4459
4512
|
});
|
|
4460
4513
|
compositionBuilder.setElementConfig(elementConfig);
|
|
4461
4514
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
@@ -4483,7 +4536,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
4483
4536
|
}
|
|
4484
4537
|
if (errors.length) {
|
|
4485
4538
|
rootContainers.forEach((rootContainer) => {
|
|
4486
|
-
(0,
|
|
4539
|
+
(0, import_editor_elements14.deleteElement)({
|
|
4487
4540
|
container: rootContainer,
|
|
4488
4541
|
options: { useHistory: false }
|
|
4489
4542
|
});
|
|
@@ -4537,7 +4590,7 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
4537
4590
|
if (doc.querySelector("parsererror")) {
|
|
4538
4591
|
throw new Error("Failed to parse XML string: " + doc);
|
|
4539
4592
|
}
|
|
4540
|
-
const widgetsCache = (0,
|
|
4593
|
+
const widgetsCache = (0, import_editor_elements14.getWidgetsCache)() ?? {};
|
|
4541
4594
|
for (const node of doc.querySelectorAll("*")) {
|
|
4542
4595
|
const type = node.tagName;
|
|
4543
4596
|
const widgetData = widgetsCache[type];
|
|
@@ -4556,7 +4609,7 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
4556
4609
|
}
|
|
4557
4610
|
|
|
4558
4611
|
// src/mcp/tools/configure-element/tool.ts
|
|
4559
|
-
var
|
|
4612
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4560
4613
|
|
|
4561
4614
|
// src/mcp/tools/configure-element/prompt.ts
|
|
4562
4615
|
var configureElementToolPrompt = `Configure an existing element on the page.
|
|
@@ -4696,7 +4749,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
4696
4749
|
speedPriority: 0.7
|
|
4697
4750
|
},
|
|
4698
4751
|
handler: ({ elementId, propertiesToChange, elementType, stylePropertiesToChange }) => {
|
|
4699
|
-
const widgetData = (0,
|
|
4752
|
+
const widgetData = (0, import_editor_elements15.getWidgetsCache)()?.[elementType];
|
|
4700
4753
|
if (!widgetData) {
|
|
4701
4754
|
throw new Error(
|
|
4702
4755
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
@@ -4788,7 +4841,7 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
4788
4841
|
}
|
|
4789
4842
|
|
|
4790
4843
|
// src/mcp/tools/get-element-config/tool.ts
|
|
4791
|
-
var
|
|
4844
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
4792
4845
|
var import_editor_props8 = require("@elementor/editor-props");
|
|
4793
4846
|
var import_schema5 = require("@elementor/schema");
|
|
4794
4847
|
var schema = {
|
|
@@ -4827,12 +4880,12 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4827
4880
|
speedPriority: 0.9
|
|
4828
4881
|
},
|
|
4829
4882
|
handler: async ({ elementId }) => {
|
|
4830
|
-
const element = (0,
|
|
4883
|
+
const element = (0, import_editor_elements16.getContainer)(elementId);
|
|
4831
4884
|
if (!element) {
|
|
4832
4885
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
4833
4886
|
}
|
|
4834
4887
|
const elementType = element.model.get("widgetType") || element.model.get("elType") || "";
|
|
4835
|
-
const widgetData = (0,
|
|
4888
|
+
const widgetData = (0, import_editor_elements16.getWidgetsCache)()?.[elementType];
|
|
4836
4889
|
if (!widgetData) {
|
|
4837
4890
|
throw new Error(
|
|
4838
4891
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
@@ -4844,7 +4897,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4844
4897
|
);
|
|
4845
4898
|
}
|
|
4846
4899
|
const elementRawSettings = element.settings;
|
|
4847
|
-
const propSchema = (0,
|
|
4900
|
+
const propSchema = (0, import_editor_elements16.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4848
4901
|
if (!elementRawSettings || !propSchema) {
|
|
4849
4902
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
4850
4903
|
}
|
|
@@ -4853,7 +4906,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4853
4906
|
import_editor_props8.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
4854
4907
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
4855
4908
|
});
|
|
4856
|
-
const elementStyles = (0,
|
|
4909
|
+
const elementStyles = (0, import_editor_elements16.getElementStyles)(elementId) || {};
|
|
4857
4910
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
4858
4911
|
if (localStyle) {
|
|
4859
4912
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -5020,7 +5073,7 @@ Note: The "size" property controls image resolution/loading, not visual size. Se
|
|
|
5020
5073
|
`;
|
|
5021
5074
|
|
|
5022
5075
|
// src/prevent-link-in-link-commands.ts
|
|
5023
|
-
var
|
|
5076
|
+
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5024
5077
|
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
5025
5078
|
var import_editor_v1_adapters19 = require("@elementor/editor-v1-adapters");
|
|
5026
5079
|
var import_i18n4 = require("@wordpress/i18n");
|
|
@@ -5091,24 +5144,24 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
5091
5144
|
return false;
|
|
5092
5145
|
}
|
|
5093
5146
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
5094
|
-
return src?.id ? (0,
|
|
5147
|
+
return src?.id ? (0, import_editor_elements17.isElementAnchored)(src.id) || !!(0, import_editor_elements17.getAnchoredDescendantId)(src.id) : false;
|
|
5095
5148
|
});
|
|
5096
5149
|
if (!isSourceContainsAnAnchor) {
|
|
5097
5150
|
return false;
|
|
5098
5151
|
}
|
|
5099
5152
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
5100
|
-
return target?.id ? (0,
|
|
5153
|
+
return target?.id ? (0, import_editor_elements17.isElementAnchored)(target.id) || !!(0, import_editor_elements17.getAnchoredAncestorId)(target.id) : false;
|
|
5101
5154
|
});
|
|
5102
5155
|
return isTargetContainsAnAnchor;
|
|
5103
5156
|
}
|
|
5104
5157
|
|
|
5105
5158
|
// src/style-commands/paste-style.ts
|
|
5106
|
-
var
|
|
5159
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
5107
5160
|
var import_editor_props10 = require("@elementor/editor-props");
|
|
5108
5161
|
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
5109
5162
|
|
|
5110
5163
|
// src/utils/command-utils.ts
|
|
5111
|
-
var
|
|
5164
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5112
5165
|
var import_editor_props9 = require("@elementor/editor-props");
|
|
5113
5166
|
var import_i18n5 = require("@wordpress/i18n");
|
|
5114
5167
|
function hasAtomicWidgets(args) {
|
|
@@ -5133,7 +5186,7 @@ function getClassesProp(container) {
|
|
|
5133
5186
|
}
|
|
5134
5187
|
function getContainerSchema(container) {
|
|
5135
5188
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
5136
|
-
const widgetsCache = (0,
|
|
5189
|
+
const widgetsCache = (0, import_editor_elements18.getWidgetsCache)();
|
|
5137
5190
|
const elementType = widgetsCache?.[type];
|
|
5138
5191
|
return elementType?.atomic_props_schema ?? null;
|
|
5139
5192
|
}
|
|
@@ -5146,11 +5199,11 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
5146
5199
|
}
|
|
5147
5200
|
}
|
|
5148
5201
|
function getTitleForContainers(containers) {
|
|
5149
|
-
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0,
|
|
5202
|
+
return containers.length > 1 ? (0, import_i18n5.__)("Elements", "elementor") : (0, import_editor_elements18.getElementLabel)(containers[0].id);
|
|
5150
5203
|
}
|
|
5151
5204
|
|
|
5152
5205
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
5153
|
-
var
|
|
5206
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
5154
5207
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
5155
5208
|
var import_editor_v1_adapters20 = require("@elementor/editor-v1-adapters");
|
|
5156
5209
|
var import_i18n6 = require("@wordpress/i18n");
|
|
@@ -5163,7 +5216,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
|
5163
5216
|
if (!classesProp) {
|
|
5164
5217
|
return null;
|
|
5165
5218
|
}
|
|
5166
|
-
const originalStyles = (0,
|
|
5219
|
+
const originalStyles = (0, import_editor_elements19.getElementStyles)(container.id);
|
|
5167
5220
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
5168
5221
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
5169
5222
|
const revertData = {
|
|
@@ -5172,7 +5225,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
|
5172
5225
|
};
|
|
5173
5226
|
if (styleId) {
|
|
5174
5227
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
5175
|
-
(0,
|
|
5228
|
+
(0, import_editor_elements19.updateElementStyle)({
|
|
5176
5229
|
elementId,
|
|
5177
5230
|
styleId,
|
|
5178
5231
|
meta,
|
|
@@ -5183,7 +5236,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
|
5183
5236
|
} else {
|
|
5184
5237
|
const [firstVariant] = newStyle.variants;
|
|
5185
5238
|
const additionalVariants = newStyle.variants.slice(1);
|
|
5186
|
-
revertData.styleId = (0,
|
|
5239
|
+
revertData.styleId = (0, import_editor_elements19.createElementStyle)({
|
|
5187
5240
|
elementId,
|
|
5188
5241
|
classesProp,
|
|
5189
5242
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -5201,7 +5254,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
|
5201
5254
|
return;
|
|
5202
5255
|
}
|
|
5203
5256
|
if (!revertData.originalStyle) {
|
|
5204
|
-
(0,
|
|
5257
|
+
(0, import_editor_elements19.deleteElementStyle)(container.id, revertData.styleId);
|
|
5205
5258
|
return;
|
|
5206
5259
|
}
|
|
5207
5260
|
const classesProp = getClassesProp(container);
|
|
@@ -5210,7 +5263,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters20.undoable)(
|
|
|
5210
5263
|
}
|
|
5211
5264
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
5212
5265
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
5213
|
-
(0,
|
|
5266
|
+
(0, import_editor_elements19.createElementStyle)({
|
|
5214
5267
|
elementId: container.id,
|
|
5215
5268
|
classesProp,
|
|
5216
5269
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -5247,7 +5300,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
5247
5300
|
}
|
|
5248
5301
|
const clipboardElements = getClipboardElements(storageKey);
|
|
5249
5302
|
const [clipboardElement] = clipboardElements ?? [];
|
|
5250
|
-
const clipboardContainer = (0,
|
|
5303
|
+
const clipboardContainer = (0, import_editor_elements20.getContainer)(clipboardElement.id);
|
|
5251
5304
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
5252
5305
|
return;
|
|
5253
5306
|
}
|
|
@@ -5266,7 +5319,7 @@ function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
|
5266
5319
|
if (!classesProp) {
|
|
5267
5320
|
return [];
|
|
5268
5321
|
}
|
|
5269
|
-
const classesSetting = (0,
|
|
5322
|
+
const classesSetting = (0, import_editor_elements20.getElementSetting)(clipboardContainer.id, classesProp);
|
|
5270
5323
|
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
5271
5324
|
}
|
|
5272
5325
|
function pasteClasses(containers, classes) {
|
|
@@ -5275,10 +5328,10 @@ function pasteClasses(containers, classes) {
|
|
|
5275
5328
|
if (!classesProp) {
|
|
5276
5329
|
return;
|
|
5277
5330
|
}
|
|
5278
|
-
const classesSetting = (0,
|
|
5331
|
+
const classesSetting = (0, import_editor_elements20.getElementSetting)(container.id, classesProp);
|
|
5279
5332
|
const currentClasses = import_editor_props10.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
5280
5333
|
const newClasses = import_editor_props10.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
5281
|
-
(0,
|
|
5334
|
+
(0, import_editor_elements20.updateElementSettings)({
|
|
5282
5335
|
id: container.id,
|
|
5283
5336
|
props: { [classesProp]: newClasses }
|
|
5284
5337
|
});
|
|
@@ -5289,7 +5342,7 @@ function pasteClasses(containers, classes) {
|
|
|
5289
5342
|
var import_editor_v1_adapters23 = require("@elementor/editor-v1-adapters");
|
|
5290
5343
|
|
|
5291
5344
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
5292
|
-
var
|
|
5345
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
5293
5346
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
5294
5347
|
var import_editor_v1_adapters22 = require("@elementor/editor-v1-adapters");
|
|
5295
5348
|
var import_i18n7 = require("@wordpress/i18n");
|
|
@@ -5298,9 +5351,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters22.undoable)(
|
|
|
5298
5351
|
do: ({ containers }) => {
|
|
5299
5352
|
return containers.map((container) => {
|
|
5300
5353
|
const elementId = container.model.get("id");
|
|
5301
|
-
const containerStyles = (0,
|
|
5354
|
+
const containerStyles = (0, import_editor_elements21.getElementStyles)(elementId);
|
|
5302
5355
|
Object.keys(containerStyles ?? {}).forEach(
|
|
5303
|
-
(styleId) => (0,
|
|
5356
|
+
(styleId) => (0, import_editor_elements21.deleteElementStyle)(elementId, styleId)
|
|
5304
5357
|
);
|
|
5305
5358
|
return containerStyles;
|
|
5306
5359
|
});
|
|
@@ -5316,7 +5369,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters22.undoable)(
|
|
|
5316
5369
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
5317
5370
|
const [firstVariant] = style.variants;
|
|
5318
5371
|
const additionalVariants = style.variants.slice(1);
|
|
5319
|
-
(0,
|
|
5372
|
+
(0, import_editor_elements21.createElementStyle)({
|
|
5320
5373
|
elementId,
|
|
5321
5374
|
classesProp,
|
|
5322
5375
|
styleId,
|
|
@@ -5441,10 +5494,10 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
5441
5494
|
};
|
|
5442
5495
|
|
|
5443
5496
|
// src/utils/after-render.ts
|
|
5444
|
-
var
|
|
5497
|
+
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
5445
5498
|
function doAfterRender(elementIds, callback) {
|
|
5446
5499
|
const pending = elementIds.map((elementId) => {
|
|
5447
|
-
const view = (0,
|
|
5500
|
+
const view = (0, import_editor_elements22.getContainer)(elementId)?.view;
|
|
5448
5501
|
if (!view || !hasDoAfterRender(view)) {
|
|
5449
5502
|
return void 0;
|
|
5450
5503
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2097,6 +2097,57 @@ function createElementViewClassDeclaration() {
|
|
|
2097
2097
|
// src/legacy/create-nested-templated-element-type.ts
|
|
2098
2098
|
import { ELEMENT_STYLE_CHANGE_EVENT } from "@elementor/editor-elements";
|
|
2099
2099
|
|
|
2100
|
+
// src/legacy/create-pending-element.ts
|
|
2101
|
+
import {
|
|
2102
|
+
addModelToParent,
|
|
2103
|
+
findModelInDocument,
|
|
2104
|
+
generateElementId,
|
|
2105
|
+
getContainer
|
|
2106
|
+
} from "@elementor/editor-elements";
|
|
2107
|
+
function createPendingElement(wrapperView, data, options = {}) {
|
|
2108
|
+
const parentContainer = wrapperView.getContainer();
|
|
2109
|
+
const model = { ...data };
|
|
2110
|
+
if (!model.id) {
|
|
2111
|
+
model.id = generateElementId();
|
|
2112
|
+
}
|
|
2113
|
+
if (!model.elements) {
|
|
2114
|
+
model.elements = [];
|
|
2115
|
+
}
|
|
2116
|
+
const added = addModelToParent(parentContainer.id, model, options);
|
|
2117
|
+
if (!added) {
|
|
2118
|
+
return void 0;
|
|
2119
|
+
}
|
|
2120
|
+
const childId = model.id;
|
|
2121
|
+
const childModel = findModelInDocument(childId);
|
|
2122
|
+
if (!childModel) {
|
|
2123
|
+
return void 0;
|
|
2124
|
+
}
|
|
2125
|
+
const pendingContainer = {
|
|
2126
|
+
id: childId,
|
|
2127
|
+
settings: { get: () => ({}), set: () => ({}), toJSON: () => ({}) },
|
|
2128
|
+
parent: parentContainer,
|
|
2129
|
+
model: childModel,
|
|
2130
|
+
view: void 0,
|
|
2131
|
+
lookup() {
|
|
2132
|
+
return getContainer(childId) ?? pendingContainer;
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
if (options.edit !== false) {
|
|
2136
|
+
selectChildWhenWrapperRenders(wrapperView, childId);
|
|
2137
|
+
}
|
|
2138
|
+
return { getContainer: () => pendingContainer };
|
|
2139
|
+
}
|
|
2140
|
+
function selectChildWhenWrapperRenders(wrapperView, childId) {
|
|
2141
|
+
wrapperView.once("render", () => {
|
|
2142
|
+
const childContainer = getContainer(childId);
|
|
2143
|
+
if (childContainer?.model?.trigger) {
|
|
2144
|
+
childContainer.model.trigger("request:edit");
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
wrapperView.model?.trigger?.("request:edit");
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2100
2151
|
// src/legacy/twig-rendering-utils.ts
|
|
2101
2152
|
function setupTwigRenderer({ renderer, element }) {
|
|
2102
2153
|
const templateKey = element.twig_main_template;
|
|
@@ -2314,6 +2365,7 @@ function createNestedTemplatedElementView({
|
|
|
2314
2365
|
const AtomicElementBaseView = legacyWindow.elementor.modules.elements.views.createAtomicElementBase(type);
|
|
2315
2366
|
const parentRenderChildren = AtomicElementBaseView.prototype._renderChildren;
|
|
2316
2367
|
const parentOpenEditingPanel = AtomicElementBaseView.prototype._openEditingPanel;
|
|
2368
|
+
const parentAddElement = AtomicElementBaseView.prototype.addElement;
|
|
2317
2369
|
return AtomicElementBaseView.extend({
|
|
2318
2370
|
_abortController: null,
|
|
2319
2371
|
_lastResolvedSettingsHash: null,
|
|
@@ -2513,6 +2565,12 @@ function createNestedTemplatedElementView({
|
|
|
2513
2565
|
_openEditingPanel(options) {
|
|
2514
2566
|
this._doAfterRender(() => parentOpenEditingPanel.call(this, options));
|
|
2515
2567
|
},
|
|
2568
|
+
addElement(data, options) {
|
|
2569
|
+
if (this.isRendered) {
|
|
2570
|
+
return parentAddElement.call(this, data, options);
|
|
2571
|
+
}
|
|
2572
|
+
return createPendingElement(this, data, options);
|
|
2573
|
+
},
|
|
2516
2574
|
getInteractionId() {
|
|
2517
2575
|
const originId = this.model.get("originId");
|
|
2518
2576
|
const id = this.model.get("id");
|
|
@@ -2589,7 +2647,7 @@ import { createRoot } from "react-dom/client";
|
|
|
2589
2647
|
|
|
2590
2648
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
2591
2649
|
import * as React6 from "react";
|
|
2592
|
-
import { getContainer, getElementLabel, getElementType as getElementType2 } from "@elementor/editor-elements";
|
|
2650
|
+
import { getContainer as getContainer2, getElementLabel, getElementType as getElementType2 } from "@elementor/editor-elements";
|
|
2593
2651
|
import {
|
|
2594
2652
|
htmlV3PropTypeUtil as htmlV3PropTypeUtil2,
|
|
2595
2653
|
parseHtmlChildren,
|
|
@@ -3036,7 +3094,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3036
3094
|
runCommandSync(
|
|
3037
3095
|
"document/elements/set-settings",
|
|
3038
3096
|
{
|
|
3039
|
-
container:
|
|
3097
|
+
container: getContainer2(this.id),
|
|
3040
3098
|
settings: {
|
|
3041
3099
|
[key]: value
|
|
3042
3100
|
}
|
|
@@ -3618,7 +3676,7 @@ var initGeneralContextResource = (reg) => {
|
|
|
3618
3676
|
};
|
|
3619
3677
|
|
|
3620
3678
|
// src/mcp/resources/selected-element-resource.ts
|
|
3621
|
-
import { getContainer as
|
|
3679
|
+
import { getContainer as getContainer3, getSelectedElements, getWidgetsCache as getWidgetsCache5 } from "@elementor/editor-elements";
|
|
3622
3680
|
import {
|
|
3623
3681
|
__privateListenTo as listenTo4,
|
|
3624
3682
|
commandEndEvent as commandEndEvent7
|
|
@@ -3696,7 +3754,7 @@ function readSelectionFromEditor() {
|
|
|
3696
3754
|
if (elements.length !== 1) {
|
|
3697
3755
|
return createEmptySelectedElementPayload();
|
|
3698
3756
|
}
|
|
3699
|
-
const container =
|
|
3757
|
+
const container = getContainer3(elements[0].id);
|
|
3700
3758
|
return buildPayloadFromContainer(container);
|
|
3701
3759
|
}
|
|
3702
3760
|
function buildPayloadFromContainer(container) {
|
|
@@ -3771,15 +3829,15 @@ import { getCurrentDocument } from "@elementor/editor-documents";
|
|
|
3771
3829
|
import {
|
|
3772
3830
|
createElement as createElement8,
|
|
3773
3831
|
deleteElement,
|
|
3774
|
-
getContainer as
|
|
3832
|
+
getContainer as getContainer5,
|
|
3775
3833
|
getWidgetsCache as getWidgetsCache9
|
|
3776
3834
|
} from "@elementor/editor-elements";
|
|
3777
3835
|
|
|
3778
3836
|
// src/composition-builder/composition-builder.ts
|
|
3779
3837
|
import {
|
|
3780
3838
|
createElement as createElement7,
|
|
3781
|
-
generateElementId,
|
|
3782
|
-
getContainer as
|
|
3839
|
+
generateElementId as generateElementId2,
|
|
3840
|
+
getContainer as getContainer4,
|
|
3783
3841
|
getWidgetsCache as getWidgetsCache8
|
|
3784
3842
|
} from "@elementor/editor-elements";
|
|
3785
3843
|
|
|
@@ -3997,8 +4055,8 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3997
4055
|
api = {
|
|
3998
4056
|
createElement: createElement7,
|
|
3999
4057
|
getWidgetsCache: getWidgetsCache8,
|
|
4000
|
-
generateElementId,
|
|
4001
|
-
getContainer:
|
|
4058
|
+
generateElementId: generateElementId2,
|
|
4059
|
+
getContainer: getContainer4,
|
|
4002
4060
|
doUpdateElementProperty
|
|
4003
4061
|
};
|
|
4004
4062
|
xml;
|
|
@@ -4439,7 +4497,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
4439
4497
|
let generatedXML = "";
|
|
4440
4498
|
const errors = [];
|
|
4441
4499
|
const rootContainers = [];
|
|
4442
|
-
const documentContainer =
|
|
4500
|
+
const documentContainer = getContainer5("document");
|
|
4443
4501
|
const currentDocument = getCurrentDocument();
|
|
4444
4502
|
const targetContainer = getCompositionTargetContainer(documentContainer, currentDocument?.type.value);
|
|
4445
4503
|
try {
|
|
@@ -4778,7 +4836,7 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
4778
4836
|
}
|
|
4779
4837
|
|
|
4780
4838
|
// src/mcp/tools/get-element-config/tool.ts
|
|
4781
|
-
import { getContainer as
|
|
4839
|
+
import { getContainer as getContainer6, getElementStyles as getElementStyles2, getWidgetsCache as getWidgetsCache11 } from "@elementor/editor-elements";
|
|
4782
4840
|
import { Schema as Schema4 } from "@elementor/editor-props";
|
|
4783
4841
|
import { z as z3 } from "@elementor/schema";
|
|
4784
4842
|
var schema = {
|
|
@@ -4817,7 +4875,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4817
4875
|
speedPriority: 0.9
|
|
4818
4876
|
},
|
|
4819
4877
|
handler: async ({ elementId }) => {
|
|
4820
|
-
const element =
|
|
4878
|
+
const element = getContainer6(elementId);
|
|
4821
4879
|
if (!element) {
|
|
4822
4880
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
4823
4881
|
}
|
|
@@ -5097,7 +5155,7 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
5097
5155
|
}
|
|
5098
5156
|
|
|
5099
5157
|
// src/style-commands/paste-style.ts
|
|
5100
|
-
import { getContainer as
|
|
5158
|
+
import { getContainer as getContainer7, getElementSetting, updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
5101
5159
|
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
5102
5160
|
import {
|
|
5103
5161
|
__privateListenTo as listenTo5,
|
|
@@ -5250,7 +5308,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
5250
5308
|
}
|
|
5251
5309
|
const clipboardElements = getClipboardElements(storageKey);
|
|
5252
5310
|
const [clipboardElement] = clipboardElements ?? [];
|
|
5253
|
-
const clipboardContainer =
|
|
5311
|
+
const clipboardContainer = getContainer7(clipboardElement.id);
|
|
5254
5312
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
5255
5313
|
return;
|
|
5256
5314
|
}
|
|
@@ -5448,10 +5506,10 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
5448
5506
|
};
|
|
5449
5507
|
|
|
5450
5508
|
// src/utils/after-render.ts
|
|
5451
|
-
import { getContainer as
|
|
5509
|
+
import { getContainer as getContainer8 } from "@elementor/editor-elements";
|
|
5452
5510
|
function doAfterRender(elementIds, callback) {
|
|
5453
5511
|
const pending = elementIds.map((elementId) => {
|
|
5454
|
-
const view =
|
|
5512
|
+
const view = getContainer8(elementId)?.view;
|
|
5455
5513
|
if (!view || !hasDoAfterRender(view)) {
|
|
5456
5514
|
return void 0;
|
|
5457
5515
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.1.0-
|
|
4
|
+
"version": "4.1.0-810",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,25 +37,25 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.1.0-
|
|
40
|
+
"@elementor/editor": "4.1.0-810",
|
|
41
41
|
"dompurify": "^3.2.6",
|
|
42
|
-
"@elementor/editor-controls": "4.1.0-
|
|
43
|
-
"@elementor/editor-documents": "4.1.0-
|
|
44
|
-
"@elementor/editor-elements": "4.1.0-
|
|
45
|
-
"@elementor/editor-interactions": "4.1.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.1.0-
|
|
47
|
-
"@elementor/editor-notifications": "4.1.0-
|
|
48
|
-
"@elementor/editor-props": "4.1.0-
|
|
49
|
-
"@elementor/editor-responsive": "4.1.0-
|
|
50
|
-
"@elementor/editor-styles": "4.1.0-
|
|
51
|
-
"@elementor/editor-styles-repository": "4.1.0-
|
|
52
|
-
"@elementor/editor-ui": "4.1.0-
|
|
53
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
54
|
-
"@elementor/schema": "4.1.0-
|
|
55
|
-
"@elementor/twing": "4.1.0-
|
|
42
|
+
"@elementor/editor-controls": "4.1.0-810",
|
|
43
|
+
"@elementor/editor-documents": "4.1.0-810",
|
|
44
|
+
"@elementor/editor-elements": "4.1.0-810",
|
|
45
|
+
"@elementor/editor-interactions": "4.1.0-810",
|
|
46
|
+
"@elementor/editor-mcp": "4.1.0-810",
|
|
47
|
+
"@elementor/editor-notifications": "4.1.0-810",
|
|
48
|
+
"@elementor/editor-props": "4.1.0-810",
|
|
49
|
+
"@elementor/editor-responsive": "4.1.0-810",
|
|
50
|
+
"@elementor/editor-styles": "4.1.0-810",
|
|
51
|
+
"@elementor/editor-styles-repository": "4.1.0-810",
|
|
52
|
+
"@elementor/editor-ui": "4.1.0-810",
|
|
53
|
+
"@elementor/editor-v1-adapters": "4.1.0-810",
|
|
54
|
+
"@elementor/schema": "4.1.0-810",
|
|
55
|
+
"@elementor/twing": "4.1.0-810",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.1.0-
|
|
58
|
-
"@elementor/wp-media": "4.1.0-
|
|
57
|
+
"@elementor/utils": "4.1.0-810",
|
|
58
|
+
"@elementor/wp-media": "4.1.0-810",
|
|
59
59
|
"@floating-ui/react": "^0.27.5",
|
|
60
60
|
"@wordpress/i18n": "^5.13.0"
|
|
61
61
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ELEMENT_STYLE_CHANGE_EVENT } from '@elementor/editor-elements';
|
|
1
|
+
import { ELEMENT_STYLE_CHANGE_EVENT, type V1ElementModelProps } from '@elementor/editor-elements';
|
|
2
2
|
|
|
3
3
|
import { type DomRenderer } from '../renderers/create-dom-renderer';
|
|
4
4
|
import { signalizedProcess } from '../utils/signalized-process';
|
|
5
|
+
import { createPendingElement } from './create-pending-element';
|
|
5
6
|
import { canBeTemplated, type TemplatedElementConfig } from './create-templated-element-type';
|
|
6
7
|
import {
|
|
7
8
|
createAfterRender,
|
|
@@ -101,6 +102,7 @@ export function createNestedTemplatedElementView( {
|
|
|
101
102
|
const AtomicElementBaseView = legacyWindow.elementor.modules.elements.views.createAtomicElementBase( type );
|
|
102
103
|
const parentRenderChildren = AtomicElementBaseView.prototype._renderChildren;
|
|
103
104
|
const parentOpenEditingPanel = AtomicElementBaseView.prototype._openEditingPanel;
|
|
105
|
+
const parentAddElement = AtomicElementBaseView.prototype.addElement;
|
|
104
106
|
|
|
105
107
|
return AtomicElementBaseView.extend( {
|
|
106
108
|
_abortController: null as AbortController | null,
|
|
@@ -381,6 +383,14 @@ export function createNestedTemplatedElementView( {
|
|
|
381
383
|
this._doAfterRender( () => parentOpenEditingPanel.call( this, options ) );
|
|
382
384
|
},
|
|
383
385
|
|
|
386
|
+
addElement( data: Partial< V1ElementModelProps >, options?: { edit?: boolean; at?: number } ) {
|
|
387
|
+
if ( this.isRendered ) {
|
|
388
|
+
return parentAddElement.call( this, data, options );
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return createPendingElement( this, data, options );
|
|
392
|
+
},
|
|
393
|
+
|
|
384
394
|
getInteractionId() {
|
|
385
395
|
const originId = this.model.get( 'originId' );
|
|
386
396
|
const id = this.model.get( 'id' );
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addModelToParent,
|
|
3
|
+
findModelInDocument,
|
|
4
|
+
generateElementId,
|
|
5
|
+
getContainer,
|
|
6
|
+
type V1Element,
|
|
7
|
+
type V1ElementModelProps,
|
|
8
|
+
} from '@elementor/editor-elements';
|
|
9
|
+
|
|
10
|
+
import { type ElementView } from './types';
|
|
11
|
+
|
|
12
|
+
export function createPendingElement(
|
|
13
|
+
wrapperView: ElementView,
|
|
14
|
+
data: Partial< V1ElementModelProps >,
|
|
15
|
+
options: { edit?: boolean; at?: number } = {}
|
|
16
|
+
): { getContainer: () => V1Element } | undefined {
|
|
17
|
+
const parentContainer = wrapperView.getContainer();
|
|
18
|
+
const model: Partial< V1ElementModelProps > = { ...data };
|
|
19
|
+
|
|
20
|
+
if ( ! model.id ) {
|
|
21
|
+
model.id = generateElementId();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if ( ! model.elements ) {
|
|
25
|
+
model.elements = [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const added = addModelToParent( parentContainer.id, model as V1ElementModelProps, options );
|
|
29
|
+
|
|
30
|
+
if ( ! added ) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const childId = model.id;
|
|
35
|
+
const childModel = findModelInDocument( childId );
|
|
36
|
+
|
|
37
|
+
if ( ! childModel ) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const pendingContainer: V1Element = {
|
|
42
|
+
id: childId,
|
|
43
|
+
settings: { get: () => ( {} ), set: () => ( {} ), toJSON: () => ( {} ) } as V1Element[ 'settings' ],
|
|
44
|
+
parent: parentContainer,
|
|
45
|
+
model: childModel as V1Element[ 'model' ],
|
|
46
|
+
view: undefined,
|
|
47
|
+
lookup() {
|
|
48
|
+
return getContainer( childId ) ?? pendingContainer;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if ( options.edit !== false ) {
|
|
53
|
+
selectChildWhenWrapperRenders( wrapperView, childId );
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { getContainer: () => pendingContainer };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function selectChildWhenWrapperRenders( wrapperView: ElementView, childId: string ): void {
|
|
60
|
+
wrapperView.once( 'render', () => {
|
|
61
|
+
const childContainer = getContainer( childId );
|
|
62
|
+
|
|
63
|
+
if ( childContainer?.model?.trigger ) {
|
|
64
|
+
childContainer.model.trigger( 'request:edit' );
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
wrapperView.model?.trigger?.( 'request:edit' );
|
|
69
|
+
} );
|
|
70
|
+
}
|
package/src/legacy/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Root } from 'react-dom/client';
|
|
2
|
-
import { type V1Element } from '@elementor/editor-elements';
|
|
2
|
+
import { type V1Element, type V1ElementModelProps } from '@elementor/editor-elements';
|
|
3
3
|
import { type Props, type PropValue } from '@elementor/editor-props';
|
|
4
4
|
|
|
5
5
|
export type RenderContext< T = unknown > = Record< string, T >;
|
|
@@ -89,6 +89,8 @@ export declare class ElementView {
|
|
|
89
89
|
|
|
90
90
|
constructor( ...args: unknown[] );
|
|
91
91
|
|
|
92
|
+
addElement( data: Partial< V1ElementModelProps >, options?: object ): unknown;
|
|
93
|
+
|
|
92
94
|
onRender( ...args: unknown[] ): void;
|
|
93
95
|
|
|
94
96
|
onDestroy( ...args: unknown[] ): void;
|
|
@@ -163,6 +165,8 @@ export declare class ElementView {
|
|
|
163
165
|
_openEditingPanel( options?: { scrollIntoView: boolean } ): void;
|
|
164
166
|
|
|
165
167
|
once: ( event: string, callback: () => void ) => void;
|
|
168
|
+
|
|
169
|
+
getContainer(): V1Element;
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
export declare class TemplatedElementView extends ElementView {
|