@elementor/editor-canvas 4.0.0-manual → 4.0.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/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +127 -78
- package/dist/index.mjs +92 -43
- package/package.json +18 -18
- package/src/hooks/__tests__/use-style-items.test.ts +57 -0
- package/src/hooks/use-style-items.ts +2 -2
- package/src/index.ts +1 -1
- package/src/legacy/create-nested-templated-element-type.ts +15 -2
- package/src/legacy/create-templated-element-type.ts +8 -0
- package/src/legacy/types.ts +3 -1
- package/src/mcp/canvas-mcp.ts +5 -7
- package/src/mcp/resources/breakpoints-resource.ts +11 -4
- package/src/mcp/resources/document-structure-resource.ts +18 -13
- package/src/mcp/tools/build-composition/schema.ts +1 -1
- package/src/mcp/tools/build-composition/tool.ts +5 -1
- package/src/mcp/utils/__tests__/get-composition-target-container.test.ts +59 -0
- package/src/mcp/utils/get-composition-target-container.ts +15 -0
- package/src/renderers/__tests__/create-styles-renderer.test.ts +117 -0
- package/src/renderers/create-styles-renderer.ts +13 -3
- package/src/style-commands/__tests__/paste-style.test.ts +5 -3
- package/src/style-commands/__tests__/reset-style.test.ts +3 -3
- package/src/style-commands/paste-style.ts +7 -1
- package/src/style-commands/reset-style.ts +1 -1
- package/src/style-commands/undoable-actions/paste-element-style.ts +1 -1
- package/src/style-commands/undoable-actions/reset-element-style.ts +1 -1
- package/src/transformers/styles/__tests__/size-transformer.test.ts +24 -0
- package/src/transformers/styles/size-transformer.ts +3 -0
- /package/src/{style-commands/utils.ts → utils/command-utils.ts} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -164,6 +164,7 @@ type BackboneCollection<Model extends object> = {
|
|
|
164
164
|
};
|
|
165
165
|
type ElementModel = {
|
|
166
166
|
id: string;
|
|
167
|
+
originId?: string;
|
|
167
168
|
elType: string;
|
|
168
169
|
settings: BackboneModel<Props>;
|
|
169
170
|
editor_settings: Record<string, unknown>;
|
|
@@ -183,13 +184,18 @@ type ContextMenuGroup = {
|
|
|
183
184
|
name: string;
|
|
184
185
|
actions: ContextMenuAction[];
|
|
185
186
|
};
|
|
187
|
+
type ContextMenuEventData = {
|
|
188
|
+
location: string;
|
|
189
|
+
secondaryLocation: string;
|
|
190
|
+
trigger: string;
|
|
191
|
+
};
|
|
186
192
|
type ContextMenuAction = {
|
|
187
193
|
name: string;
|
|
188
194
|
icon: string;
|
|
189
195
|
title: string | (() => string);
|
|
190
196
|
shortcut?: string;
|
|
191
197
|
isEnabled: () => boolean;
|
|
192
|
-
callback: (_: unknown, eventData:
|
|
198
|
+
callback: (_: unknown, eventData: ContextMenuEventData) => void;
|
|
193
199
|
};
|
|
194
200
|
type ReplacementSettings = {
|
|
195
201
|
getSetting: (key: string) => unknown;
|
|
@@ -336,4 +342,4 @@ declare const UnknownStyleStateError: {
|
|
|
336
342
|
isError(error: unknown): error is Error;
|
|
337
343
|
};
|
|
338
344
|
|
|
339
|
-
export { type AnyTransformer, BREAKPOINTS_SCHEMA_URI, type BackboneModel, type BackboneModelConstructor, type ContextMenuAction, type CreateNestedTemplatedElementTypeOptions, type CreateTemplatedElementTypeOptions, DOCUMENT_STRUCTURE_URI, type ElementModel, ElementType, ElementView, type LegacyWindow, type NamespacedRenderContext, type NestedTemplatedElementConfig, type PropsResolver, type RenderContext, type ReplacementSettings, STYLE_SCHEMA_URI, type TransformerOptions, UnknownStyleStateError, UnknownStyleTypeError, WIDGET_SCHEMA_URI, canBeNestedTemplated, createNestedTemplatedElementType, createNestedTemplatedElementView, createPropsResolver, createTemplatedElementView, createTransformer, createTransformersRegistry, endDragElementFromPanel, init, isAtomicWidget, registerElementType, registerModelExtensions, settingsTransformersRegistry, startDragElementFromPanel, styleTransformersRegistry, stylesInheritanceTransformersRegistry };
|
|
345
|
+
export { type AnyTransformer, BREAKPOINTS_SCHEMA_URI, type BackboneModel, type BackboneModelConstructor, type ContextMenuAction, type ContextMenuEventData, type CreateNestedTemplatedElementTypeOptions, type CreateTemplatedElementTypeOptions, DOCUMENT_STRUCTURE_URI, type ElementModel, ElementType, ElementView, type LegacyWindow, type NamespacedRenderContext, type NestedTemplatedElementConfig, type PropsResolver, type RenderContext, type ReplacementSettings, STYLE_SCHEMA_URI, type TransformerOptions, UnknownStyleStateError, UnknownStyleTypeError, WIDGET_SCHEMA_URI, canBeNestedTemplated, createNestedTemplatedElementType, createNestedTemplatedElementView, createPropsResolver, createTemplatedElementView, createTransformer, createTransformersRegistry, endDragElementFromPanel, init, isAtomicWidget, registerElementType, registerModelExtensions, settingsTransformersRegistry, startDragElementFromPanel, styleTransformersRegistry, stylesInheritanceTransformersRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -164,6 +164,7 @@ type BackboneCollection<Model extends object> = {
|
|
|
164
164
|
};
|
|
165
165
|
type ElementModel = {
|
|
166
166
|
id: string;
|
|
167
|
+
originId?: string;
|
|
167
168
|
elType: string;
|
|
168
169
|
settings: BackboneModel<Props>;
|
|
169
170
|
editor_settings: Record<string, unknown>;
|
|
@@ -183,13 +184,18 @@ type ContextMenuGroup = {
|
|
|
183
184
|
name: string;
|
|
184
185
|
actions: ContextMenuAction[];
|
|
185
186
|
};
|
|
187
|
+
type ContextMenuEventData = {
|
|
188
|
+
location: string;
|
|
189
|
+
secondaryLocation: string;
|
|
190
|
+
trigger: string;
|
|
191
|
+
};
|
|
186
192
|
type ContextMenuAction = {
|
|
187
193
|
name: string;
|
|
188
194
|
icon: string;
|
|
189
195
|
title: string | (() => string);
|
|
190
196
|
shortcut?: string;
|
|
191
197
|
isEnabled: () => boolean;
|
|
192
|
-
callback: (_: unknown, eventData:
|
|
198
|
+
callback: (_: unknown, eventData: ContextMenuEventData) => void;
|
|
193
199
|
};
|
|
194
200
|
type ReplacementSettings = {
|
|
195
201
|
getSetting: (key: string) => unknown;
|
|
@@ -336,4 +342,4 @@ declare const UnknownStyleStateError: {
|
|
|
336
342
|
isError(error: unknown): error is Error;
|
|
337
343
|
};
|
|
338
344
|
|
|
339
|
-
export { type AnyTransformer, BREAKPOINTS_SCHEMA_URI, type BackboneModel, type BackboneModelConstructor, type ContextMenuAction, type CreateNestedTemplatedElementTypeOptions, type CreateTemplatedElementTypeOptions, DOCUMENT_STRUCTURE_URI, type ElementModel, ElementType, ElementView, type LegacyWindow, type NamespacedRenderContext, type NestedTemplatedElementConfig, type PropsResolver, type RenderContext, type ReplacementSettings, STYLE_SCHEMA_URI, type TransformerOptions, UnknownStyleStateError, UnknownStyleTypeError, WIDGET_SCHEMA_URI, canBeNestedTemplated, createNestedTemplatedElementType, createNestedTemplatedElementView, createPropsResolver, createTemplatedElementView, createTransformer, createTransformersRegistry, endDragElementFromPanel, init, isAtomicWidget, registerElementType, registerModelExtensions, settingsTransformersRegistry, startDragElementFromPanel, styleTransformersRegistry, stylesInheritanceTransformersRegistry };
|
|
345
|
+
export { type AnyTransformer, BREAKPOINTS_SCHEMA_URI, type BackboneModel, type BackboneModelConstructor, type ContextMenuAction, type ContextMenuEventData, type CreateNestedTemplatedElementTypeOptions, type CreateTemplatedElementTypeOptions, DOCUMENT_STRUCTURE_URI, type ElementModel, ElementType, ElementView, type LegacyWindow, type NamespacedRenderContext, type NestedTemplatedElementConfig, type PropsResolver, type RenderContext, type ReplacementSettings, STYLE_SCHEMA_URI, type TransformerOptions, UnknownStyleStateError, UnknownStyleTypeError, WIDGET_SCHEMA_URI, canBeNestedTemplated, createNestedTemplatedElementType, createNestedTemplatedElementView, createPropsResolver, createTemplatedElementView, createTransformer, createTransformersRegistry, endDragElementFromPanel, init, isAtomicWidget, registerElementType, registerModelExtensions, settingsTransformersRegistry, startDragElementFromPanel, styleTransformersRegistry, stylesInheritanceTransformersRegistry };
|
package/dist/index.js
CHANGED
|
@@ -59,7 +59,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
59
59
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
60
60
|
var BREAKPOINTS_SCHEMA_URI = "elementor://breakpoints/list";
|
|
61
61
|
var initBreakpointsResource = (reg) => {
|
|
62
|
-
const {
|
|
62
|
+
const { resource, sendResourceUpdated } = reg;
|
|
63
63
|
const getBreakpointsList = () => {
|
|
64
64
|
const { breakpoints } = window.elementor?.config?.responsive || {};
|
|
65
65
|
if (!breakpoints) {
|
|
@@ -83,9 +83,16 @@ var initBreakpointsResource = (reg) => {
|
|
|
83
83
|
}
|
|
84
84
|
]
|
|
85
85
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
resource(
|
|
87
|
+
"breakpoints ",
|
|
88
|
+
BREAKPOINTS_SCHEMA_URI,
|
|
89
|
+
{
|
|
90
|
+
description: "Breakpoints list."
|
|
91
|
+
},
|
|
92
|
+
() => {
|
|
93
|
+
return buildResourceResponse();
|
|
94
|
+
}
|
|
95
|
+
);
|
|
89
96
|
window.addEventListener((0, import_editor_v1_adapters.v1ReadyEvent)().name, () => {
|
|
90
97
|
sendResourceUpdated({
|
|
91
98
|
uri: BREAKPOINTS_SCHEMA_URI,
|
|
@@ -234,7 +241,7 @@ Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
|
234
241
|
|
|
235
242
|
// src/init.tsx
|
|
236
243
|
var import_editor = require("@elementor/editor");
|
|
237
|
-
var
|
|
244
|
+
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
238
245
|
|
|
239
246
|
// src/components/classes-rename.tsx
|
|
240
247
|
var import_react = require("react");
|
|
@@ -833,14 +840,22 @@ var UnknownStyleStateError = (0, import_utils2.createError)({
|
|
|
833
840
|
var SELECTORS_MAP = {
|
|
834
841
|
class: "."
|
|
835
842
|
};
|
|
843
|
+
var DEFAULT_BREAKPOINT = "desktop";
|
|
844
|
+
var DEFAULT_STATE = "normal";
|
|
845
|
+
function getStyleUniqueKey(style) {
|
|
846
|
+
const breakpoint = style.variants[0]?.meta?.breakpoint ?? DEFAULT_BREAKPOINT;
|
|
847
|
+
const state = style.variants[0]?.meta?.state ?? DEFAULT_STATE;
|
|
848
|
+
return `${style.id}-${breakpoint}-${state}`;
|
|
849
|
+
}
|
|
836
850
|
function createStylesRenderer({ resolve, breakpoints, selectorPrefix = "" }) {
|
|
837
851
|
return async ({ styles, signal }) => {
|
|
838
|
-
const
|
|
852
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
839
853
|
const uniqueStyles = styles.filter((style) => {
|
|
840
|
-
|
|
854
|
+
const key = getStyleUniqueKey(style);
|
|
855
|
+
if (seenKeys.has(key)) {
|
|
841
856
|
return false;
|
|
842
857
|
}
|
|
843
|
-
|
|
858
|
+
seenKeys.add(key);
|
|
844
859
|
return true;
|
|
845
860
|
});
|
|
846
861
|
const stylesCssPromises = uniqueStyles.map(async (style) => {
|
|
@@ -1017,7 +1032,7 @@ function createProviderSubscriber2({ provider, renderStyles, setStyleItems, cach
|
|
|
1017
1032
|
}
|
|
1018
1033
|
async function createItems(signal) {
|
|
1019
1034
|
const allStyles = provider.actions.all();
|
|
1020
|
-
const styles = allStyles.reverse().map((style) => {
|
|
1035
|
+
const styles = [...allStyles].reverse().map((style) => {
|
|
1021
1036
|
return {
|
|
1022
1037
|
...style,
|
|
1023
1038
|
cssName: provider.actions.resolveCssName(style.id)
|
|
@@ -1025,7 +1040,7 @@ function createProviderSubscriber2({ provider, renderStyles, setStyleItems, cach
|
|
|
1025
1040
|
});
|
|
1026
1041
|
return renderStyles({ styles: breakToBreakpoints(styles), signal }).then((rendered) => {
|
|
1027
1042
|
rebuildCache(cache, allStyles, rendered);
|
|
1028
|
-
return
|
|
1043
|
+
return getOrderedItems(cache);
|
|
1029
1044
|
});
|
|
1030
1045
|
}
|
|
1031
1046
|
function breakToBreakpoints(styles) {
|
|
@@ -1625,6 +1640,9 @@ var shadowTransformer = createTransformer((value) => {
|
|
|
1625
1640
|
|
|
1626
1641
|
// src/transformers/styles/size-transformer.ts
|
|
1627
1642
|
var sizeTransformer = createTransformer((value) => {
|
|
1643
|
+
if (value.unit === "auto") {
|
|
1644
|
+
return "auto";
|
|
1645
|
+
}
|
|
1628
1646
|
return value.unit === "custom" ? value.size : `${value.size}${value.unit}`;
|
|
1629
1647
|
});
|
|
1630
1648
|
|
|
@@ -2008,6 +2026,7 @@ function createTemplatedElementView({
|
|
|
2008
2026
|
this._lastResolvedSettingsHash = settingsHash;
|
|
2009
2027
|
const context = {
|
|
2010
2028
|
id: this.model.get("id"),
|
|
2029
|
+
interaction_id: this.getInteractionId(),
|
|
2011
2030
|
type,
|
|
2012
2031
|
settings,
|
|
2013
2032
|
base_styles: baseStylesDictionary
|
|
@@ -2042,6 +2061,11 @@ function createTemplatedElementView({
|
|
|
2042
2061
|
_openEditingPanel(options) {
|
|
2043
2062
|
this._doAfterRender(() => super._openEditingPanel(options));
|
|
2044
2063
|
}
|
|
2064
|
+
getInteractionId() {
|
|
2065
|
+
const originId = this.model.get("originId");
|
|
2066
|
+
const id = this.model.get("id");
|
|
2067
|
+
return originId ?? id;
|
|
2068
|
+
}
|
|
2045
2069
|
};
|
|
2046
2070
|
}
|
|
2047
2071
|
|
|
@@ -2074,10 +2098,11 @@ function createNestedTemplatedElementType({
|
|
|
2074
2098
|
}
|
|
2075
2099
|
function buildEditorAttributes(model) {
|
|
2076
2100
|
const id = model.get("id");
|
|
2101
|
+
const originId = model.get("originId");
|
|
2077
2102
|
const cid = model.cid ?? "";
|
|
2078
2103
|
const attrs = {
|
|
2079
2104
|
"data-model-cid": cid,
|
|
2080
|
-
"data-interaction-id": id,
|
|
2105
|
+
"data-interaction-id": originId ?? id,
|
|
2081
2106
|
"x-ignore": "true"
|
|
2082
2107
|
};
|
|
2083
2108
|
return Object.entries(attrs).map(([key, value]) => `${key}="${value}"`).join(" ");
|
|
@@ -2111,6 +2136,9 @@ function createNestedTemplatedElementView({
|
|
|
2111
2136
|
invalidateRenderCache() {
|
|
2112
2137
|
this._lastResolvedSettingsHash = null;
|
|
2113
2138
|
},
|
|
2139
|
+
renderOnChange() {
|
|
2140
|
+
this.render();
|
|
2141
|
+
},
|
|
2114
2142
|
render() {
|
|
2115
2143
|
this._abortController?.abort();
|
|
2116
2144
|
this._abortController = new AbortController();
|
|
@@ -2154,6 +2182,7 @@ function createNestedTemplatedElementView({
|
|
|
2154
2182
|
this._lastResolvedSettingsHash = settingsHash;
|
|
2155
2183
|
const context = {
|
|
2156
2184
|
id: model.get("id"),
|
|
2185
|
+
interaction_id: this.getInteractionId(),
|
|
2157
2186
|
type,
|
|
2158
2187
|
settings,
|
|
2159
2188
|
base_styles: baseStylesDictionary,
|
|
@@ -2283,6 +2312,11 @@ function createNestedTemplatedElementView({
|
|
|
2283
2312
|
},
|
|
2284
2313
|
_openEditingPanel(options) {
|
|
2285
2314
|
this._doAfterRender(() => parentOpenEditingPanel.call(this, options));
|
|
2315
|
+
},
|
|
2316
|
+
getInteractionId() {
|
|
2317
|
+
const originId = this.model.get("originId");
|
|
2318
|
+
const id = this.model.get("id");
|
|
2319
|
+
return originId ?? id;
|
|
2286
2320
|
}
|
|
2287
2321
|
});
|
|
2288
2322
|
}
|
|
@@ -2937,7 +2971,7 @@ function initTabsModelExtensions() {
|
|
|
2937
2971
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
2938
2972
|
var DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
2939
2973
|
var initDocumentStructureResource = (reg) => {
|
|
2940
|
-
const {
|
|
2974
|
+
const { resource, sendResourceUpdated } = reg;
|
|
2941
2975
|
let currentDocumentStructure = null;
|
|
2942
2976
|
const updateDocumentStructure = () => {
|
|
2943
2977
|
const structure = getDocumentStructure();
|
|
@@ -2959,17 +2993,23 @@ var initDocumentStructureResource = (reg) => {
|
|
|
2959
2993
|
updateDocumentStructure
|
|
2960
2994
|
);
|
|
2961
2995
|
updateDocumentStructure();
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2996
|
+
resource(
|
|
2997
|
+
"document-structure",
|
|
2998
|
+
DOCUMENT_STRUCTURE_URI,
|
|
2999
|
+
{
|
|
3000
|
+
description: "Document structure."
|
|
3001
|
+
},
|
|
3002
|
+
async () => {
|
|
3003
|
+
return {
|
|
3004
|
+
contents: [
|
|
3005
|
+
{
|
|
3006
|
+
uri: DOCUMENT_STRUCTURE_URI,
|
|
3007
|
+
text: JSON.stringify(getDocumentStructure(), null, 2)
|
|
3008
|
+
}
|
|
3009
|
+
]
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
);
|
|
2973
3013
|
};
|
|
2974
3014
|
function getDocumentStructure() {
|
|
2975
3015
|
const extendedWindow = window;
|
|
@@ -3009,6 +3049,7 @@ function extractElementData(element) {
|
|
|
3009
3049
|
}
|
|
3010
3050
|
|
|
3011
3051
|
// src/mcp/tools/build-composition/tool.ts
|
|
3052
|
+
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
3012
3053
|
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
3013
3054
|
|
|
3014
3055
|
// src/composition-builder/composition-builder.ts
|
|
@@ -3423,6 +3464,16 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3423
3464
|
}
|
|
3424
3465
|
};
|
|
3425
3466
|
|
|
3467
|
+
// src/mcp/utils/get-composition-target-container.ts
|
|
3468
|
+
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
3469
|
+
function getCompositionTargetContainer(documentContainer, documentType) {
|
|
3470
|
+
const firstChild = documentContainer.children?.[0];
|
|
3471
|
+
if (documentType === import_editor_documents2.COMPONENT_DOCUMENT_TYPE && firstChild) {
|
|
3472
|
+
return firstChild;
|
|
3473
|
+
}
|
|
3474
|
+
return documentContainer;
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3426
3477
|
// src/mcp/tools/build-composition/prompt.ts
|
|
3427
3478
|
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
3428
3479
|
var generatePrompt = () => {
|
|
@@ -3562,36 +3613,36 @@ Note: No height/width specified on any element - flexbox handles layout automati
|
|
|
3562
3613
|
};
|
|
3563
3614
|
|
|
3564
3615
|
// src/mcp/tools/build-composition/schema.ts
|
|
3565
|
-
var
|
|
3616
|
+
var import_schema = require("@elementor/schema");
|
|
3566
3617
|
var inputSchema = {
|
|
3567
|
-
xmlStructure:
|
|
3568
|
-
elementConfig:
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3618
|
+
xmlStructure: import_schema.z.string().describe("The XML structure representing the composition to be built"),
|
|
3619
|
+
elementConfig: import_schema.z.record(
|
|
3620
|
+
import_schema.z.string().describe("The configuration id"),
|
|
3621
|
+
import_schema.z.record(
|
|
3622
|
+
import_schema.z.string().describe("property name"),
|
|
3623
|
+
import_schema.z.any().describe(`The PropValue for the property, refer to ${WIDGET_SCHEMA_URI}`)
|
|
3573
3624
|
)
|
|
3574
3625
|
).describe("A record mapping element IDs to their configuration objects. REQUIRED"),
|
|
3575
|
-
stylesConfig:
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3626
|
+
stylesConfig: import_schema.z.record(
|
|
3627
|
+
import_schema.z.string().describe("The configuration id"),
|
|
3628
|
+
import_schema.z.record(
|
|
3629
|
+
import_schema.z.string().describe("StyleSchema property name"),
|
|
3630
|
+
import_schema.z.any().describe(`The PropValue for the style property. MANDATORY, refer to [${STYLE_SCHEMA_URI}]`)
|
|
3580
3631
|
)
|
|
3581
3632
|
).describe(
|
|
3582
3633
|
`A record mapping element IDs to their styles configuration objects. Use the actual styles schema from [${STYLE_SCHEMA_URI}].`
|
|
3583
3634
|
).default({}),
|
|
3584
|
-
customCSS:
|
|
3585
|
-
|
|
3586
|
-
|
|
3635
|
+
customCSS: import_schema.z.record(
|
|
3636
|
+
import_schema.z.string().describe("The configuration id"),
|
|
3637
|
+
import_schema.z.string().describe("The custom CSS for the element. MANDATORY")
|
|
3587
3638
|
).describe("A record mapping element IDs to their custom CSS.").default({})
|
|
3588
3639
|
};
|
|
3589
3640
|
var outputSchema = {
|
|
3590
|
-
errors:
|
|
3591
|
-
xmlStructure:
|
|
3641
|
+
errors: import_schema.z.string().describe("Error message if the composition building failed").optional(),
|
|
3642
|
+
xmlStructure: import_schema.z.string().describe(
|
|
3592
3643
|
"The built XML structure as a string. Must use this XML after completion of building the composition, it contains real IDs."
|
|
3593
3644
|
).optional(),
|
|
3594
|
-
llm_instructions:
|
|
3645
|
+
llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!").optional()
|
|
3595
3646
|
};
|
|
3596
3647
|
|
|
3597
3648
|
// src/mcp/tools/build-composition/tool.ts
|
|
@@ -3618,6 +3669,8 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3618
3669
|
const errors = [];
|
|
3619
3670
|
const rootContainers = [];
|
|
3620
3671
|
const documentContainer = (0, import_editor_elements10.getContainer)("document");
|
|
3672
|
+
const currentDocument = (0, import_editor_documents3.getCurrentDocument)();
|
|
3673
|
+
const targetContainer = getCompositionTargetContainer(documentContainer, currentDocument?.type.value);
|
|
3621
3674
|
try {
|
|
3622
3675
|
const compositionBuilder = CompositionBuilder.fromXMLString(xmlStructure, {
|
|
3623
3676
|
createElement: import_editor_elements10.createElement,
|
|
@@ -3630,7 +3683,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3630
3683
|
configErrors,
|
|
3631
3684
|
invalidStyles,
|
|
3632
3685
|
rootContainers: generatedRootContainers
|
|
3633
|
-
} = compositionBuilder.build(
|
|
3686
|
+
} = compositionBuilder.build(targetContainer);
|
|
3634
3687
|
rootContainers.push(...generatedRootContainers);
|
|
3635
3688
|
generatedXML = new XMLSerializer().serializeToString(compositionBuilder.getXML());
|
|
3636
3689
|
if (configErrors.length) {
|
|
@@ -3806,23 +3859,23 @@ The $$type property is MANDATORY for every value, it is required to parse the va
|
|
|
3806
3859
|
`;
|
|
3807
3860
|
|
|
3808
3861
|
// src/mcp/tools/configure-element/schema.ts
|
|
3809
|
-
var
|
|
3862
|
+
var import_schema3 = require("@elementor/schema");
|
|
3810
3863
|
var inputSchema2 = {
|
|
3811
|
-
propertiesToChange:
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3864
|
+
propertiesToChange: import_schema3.z.record(
|
|
3865
|
+
import_schema3.z.string().describe("The property name."),
|
|
3866
|
+
import_schema3.z.any().describe(`PropValue, refer to [${WIDGET_SCHEMA_URI}] by correct type, as appears in elementType`),
|
|
3867
|
+
import_schema3.z.any()
|
|
3815
3868
|
).describe("An object record containing property names and their new values to be set on the element"),
|
|
3816
|
-
stylePropertiesToChange:
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3869
|
+
stylePropertiesToChange: import_schema3.z.record(
|
|
3870
|
+
import_schema3.z.string().describe("The style property name"),
|
|
3871
|
+
import_schema3.z.any().describe(`The style PropValue, refer to [${STYLE_SCHEMA_URI}] how to generate values`),
|
|
3872
|
+
import_schema3.z.any()
|
|
3820
3873
|
).describe("An object record containing style property names and their new values to be set on the element").default({}),
|
|
3821
|
-
elementType:
|
|
3822
|
-
elementId:
|
|
3874
|
+
elementType: import_schema3.z.string().describe("The type of the element to retreive the schema"),
|
|
3875
|
+
elementId: import_schema3.z.string().describe("The unique id of the element to configure")
|
|
3823
3876
|
};
|
|
3824
3877
|
var outputSchema2 = {
|
|
3825
|
-
success:
|
|
3878
|
+
success: import_schema3.z.boolean().describe(
|
|
3826
3879
|
"Whether the configuration change was successful, only if propertyName and propertyValue are provided"
|
|
3827
3880
|
)
|
|
3828
3881
|
};
|
|
@@ -3928,18 +3981,18 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
3928
3981
|
// src/mcp/tools/get-element-config/tool.ts
|
|
3929
3982
|
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3930
3983
|
var import_editor_props8 = require("@elementor/editor-props");
|
|
3931
|
-
var
|
|
3984
|
+
var import_schema5 = require("@elementor/schema");
|
|
3932
3985
|
var schema = {
|
|
3933
|
-
elementId:
|
|
3986
|
+
elementId: import_schema5.z.string()
|
|
3934
3987
|
};
|
|
3935
3988
|
var outputSchema3 = {
|
|
3936
|
-
properties:
|
|
3937
|
-
style:
|
|
3938
|
-
childElements:
|
|
3939
|
-
|
|
3940
|
-
id:
|
|
3941
|
-
elementType:
|
|
3942
|
-
childElements:
|
|
3989
|
+
properties: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
|
|
3990
|
+
style: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
|
|
3991
|
+
childElements: import_schema5.z.array(
|
|
3992
|
+
import_schema5.z.object({
|
|
3993
|
+
id: import_schema5.z.string(),
|
|
3994
|
+
elementType: import_schema5.z.string(),
|
|
3995
|
+
childElements: import_schema5.z.array(import_schema5.z.any()).describe("An array of child element IDs, when applicable, same structure recursively")
|
|
3943
3996
|
})
|
|
3944
3997
|
).describe("An array of child element IDs, when applicable, with recursive structure")
|
|
3945
3998
|
};
|
|
@@ -4014,14 +4067,12 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4014
4067
|
var initCanvasMcp = (reg) => {
|
|
4015
4068
|
const { setMCPDescription } = reg;
|
|
4016
4069
|
setMCPDescription(
|
|
4017
|
-
`Everything related to
|
|
4070
|
+
`Everything related to V4 ( Atomic ) canvas.
|
|
4018
4071
|
# Canvas workflow for new compositions
|
|
4019
|
-
-
|
|
4020
|
-
-
|
|
4021
|
-
-
|
|
4022
|
-
|
|
4023
|
-
- Build valid XML with minimal inline styles (layout/positioning only)
|
|
4024
|
-
- Apply global classes to elements`
|
|
4072
|
+
- Configure elements settings and styles
|
|
4073
|
+
- Build compositions/sections out of V4 atomic elements using context aware designs using the website resources
|
|
4074
|
+
- Get and retrieve element configuration values
|
|
4075
|
+
`
|
|
4025
4076
|
);
|
|
4026
4077
|
initWidgetsSchemaResource(reg);
|
|
4027
4078
|
initDocumentStructureResource(reg);
|
|
@@ -4231,13 +4282,7 @@ var import_editor_elements15 = require("@elementor/editor-elements");
|
|
|
4231
4282
|
var import_editor_props10 = require("@elementor/editor-props");
|
|
4232
4283
|
var import_editor_v1_adapters16 = require("@elementor/editor-v1-adapters");
|
|
4233
4284
|
|
|
4234
|
-
// src/
|
|
4235
|
-
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4236
|
-
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
4237
|
-
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
4238
|
-
var import_i18n6 = require("@wordpress/i18n");
|
|
4239
|
-
|
|
4240
|
-
// src/style-commands/utils.ts
|
|
4285
|
+
// src/utils/command-utils.ts
|
|
4241
4286
|
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
4242
4287
|
var import_editor_props9 = require("@elementor/editor-props");
|
|
4243
4288
|
var import_i18n5 = require("@wordpress/i18n");
|
|
@@ -4280,6 +4325,10 @@ function getTitleForContainers(containers) {
|
|
|
4280
4325
|
}
|
|
4281
4326
|
|
|
4282
4327
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
4328
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4329
|
+
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
4330
|
+
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
4331
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
4283
4332
|
var undoablePasteElementStyle = () => (0, import_editor_v1_adapters15.undoable)(
|
|
4284
4333
|
{
|
|
4285
4334
|
do: ({ containers, newStyle }) => {
|
|
@@ -4514,7 +4563,7 @@ function init() {
|
|
|
4514
4563
|
component: ClassesRename
|
|
4515
4564
|
});
|
|
4516
4565
|
initCanvasMcp(
|
|
4517
|
-
(0,
|
|
4566
|
+
(0, import_editor_mcp3.getMCPByDomain)("canvas", {
|
|
4518
4567
|
instructions: mcpDescription
|
|
4519
4568
|
})
|
|
4520
4569
|
);
|