@elementor/editor-canvas 4.0.0-621 → 4.0.0-manual
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 +203 -182
- package/dist/index.mjs +166 -145
- package/package.json +18 -18
- package/src/composition-builder/composition-builder.ts +31 -2
- package/src/mcp/canvas-mcp.ts +8 -1
- package/src/mcp/resources/best-practices.ts +159 -0
- package/src/mcp/resources/widgets-schema-resource.ts +7 -1
- package/src/mcp/tools/build-composition/prompt.ts +110 -134
- package/src/mcp/tools/build-composition/schema.ts +8 -1
- package/src/mcp/tools/build-composition/tool.ts +4 -4
package/dist/index.js
CHANGED
|
@@ -114,7 +114,13 @@ Prefer using "em" and "rem" values for text-related sizes, padding and spacing.
|
|
|
114
114
|
This flexboxes are by default "flex" with "stretch" alignment. To ensure proper layout, define the "justify-content" and "align-items" as in the schema.
|
|
115
115
|
|
|
116
116
|
When applicable for styles, apply style PropValues using the ${STYLE_SCHEMA_URI}.
|
|
117
|
-
The css string must follow standard CSS syntax, with properties and values separated by semicolons, no selectors, or nesting rules allowed
|
|
117
|
+
The css string must follow standard CSS syntax, with properties and values separated by semicolons, no selectors, or nesting rules allowed.
|
|
118
|
+
|
|
119
|
+
** CRITICAL - VARIABLES **
|
|
120
|
+
When using global variables, ensure that the variables are defined in the ${"elementor://global-variables"} resource.
|
|
121
|
+
Variables from the user context ARE NOT SUPPORTED AND WILL RESOLVE IN ERROR.
|
|
122
|
+
|
|
123
|
+
`
|
|
118
124
|
}
|
|
119
125
|
]
|
|
120
126
|
};
|
|
@@ -228,7 +234,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
228
234
|
|
|
229
235
|
// src/init.tsx
|
|
230
236
|
var import_editor = require("@elementor/editor");
|
|
231
|
-
var
|
|
237
|
+
var import_editor_mcp4 = require("@elementor/editor-mcp");
|
|
232
238
|
|
|
233
239
|
// src/components/classes-rename.tsx
|
|
234
240
|
var import_react = require("react");
|
|
@@ -3211,6 +3217,7 @@ var validateInput = {
|
|
|
3211
3217
|
var CompositionBuilder = class _CompositionBuilder {
|
|
3212
3218
|
elementConfig = {};
|
|
3213
3219
|
elementStylesConfig = {};
|
|
3220
|
+
elementCusomCSS = {};
|
|
3214
3221
|
rootContainers = [];
|
|
3215
3222
|
containerElements = [];
|
|
3216
3223
|
api = {
|
|
@@ -3234,11 +3241,12 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3234
3241
|
});
|
|
3235
3242
|
}
|
|
3236
3243
|
constructor(opts) {
|
|
3237
|
-
const { api = {}, elementConfig = {}, stylesConfig = {}, xml } = opts;
|
|
3244
|
+
const { api = {}, elementConfig = {}, stylesConfig = {}, customCSS = {}, xml } = opts;
|
|
3238
3245
|
this.xml = xml;
|
|
3239
3246
|
Object.assign(this.api, api);
|
|
3240
3247
|
this.setElementConfig(elementConfig);
|
|
3241
3248
|
this.setStylesConfig(stylesConfig);
|
|
3249
|
+
this.setCustomCSS(customCSS);
|
|
3242
3250
|
}
|
|
3243
3251
|
setElementConfig(config) {
|
|
3244
3252
|
this.elementConfig = config;
|
|
@@ -3246,6 +3254,9 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3246
3254
|
setStylesConfig(config) {
|
|
3247
3255
|
this.elementStylesConfig = config;
|
|
3248
3256
|
}
|
|
3257
|
+
setCustomCSS(config) {
|
|
3258
|
+
this.elementCusomCSS = config;
|
|
3259
|
+
}
|
|
3249
3260
|
getXML() {
|
|
3250
3261
|
return this.xml;
|
|
3251
3262
|
}
|
|
@@ -3261,7 +3272,10 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3261
3272
|
container: targetContainer,
|
|
3262
3273
|
model: {
|
|
3263
3274
|
elType: elementTag,
|
|
3264
|
-
id: (0, import_editor_elements9.generateElementId)()
|
|
3275
|
+
id: (0, import_editor_elements9.generateElementId)(),
|
|
3276
|
+
editor_settings: {
|
|
3277
|
+
title: node.getAttribute("configuration-id") ?? void 0
|
|
3278
|
+
}
|
|
3265
3279
|
},
|
|
3266
3280
|
options: { useHistory: false }
|
|
3267
3281
|
}) : this.api.createElement({
|
|
@@ -3269,7 +3283,10 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3269
3283
|
model: {
|
|
3270
3284
|
elType: "widget",
|
|
3271
3285
|
widgetType: elementTag,
|
|
3272
|
-
id: (0, import_editor_elements9.generateElementId)()
|
|
3286
|
+
id: (0, import_editor_elements9.generateElementId)(),
|
|
3287
|
+
editor_settings: {
|
|
3288
|
+
title: node.getAttribute("configuration-id") ?? void 0
|
|
3289
|
+
}
|
|
3273
3290
|
},
|
|
3274
3291
|
options: { useHistory: false }
|
|
3275
3292
|
});
|
|
@@ -3310,9 +3327,9 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3310
3327
|
applyStyles() {
|
|
3311
3328
|
const errors = [];
|
|
3312
3329
|
const invalidStyles = {};
|
|
3313
|
-
const validStylesPropValues = {};
|
|
3314
3330
|
for (const [styleId, styleConfig] of Object.entries(this.elementStylesConfig)) {
|
|
3315
3331
|
const { element, node } = this.matchNodeByConfigId(styleId);
|
|
3332
|
+
const validStylesPropValues = {};
|
|
3316
3333
|
for (const [styleName, stylePropValue] of Object.entries(styleConfig)) {
|
|
3317
3334
|
const { valid, errors: validationErrors } = validateInput.validateStyles({
|
|
3318
3335
|
[styleName]: stylePropValue
|
|
@@ -3326,14 +3343,30 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
3326
3343
|
} else {
|
|
3327
3344
|
validStylesPropValues[styleName] = stylePropValue;
|
|
3328
3345
|
}
|
|
3346
|
+
}
|
|
3347
|
+
if (Object.keys(validStylesPropValues).length === 0) {
|
|
3348
|
+
continue;
|
|
3349
|
+
}
|
|
3350
|
+
try {
|
|
3329
3351
|
this.api.doUpdateElementProperty({
|
|
3330
3352
|
elementId: element.id,
|
|
3331
3353
|
propertyName: "_styles",
|
|
3332
3354
|
propertyValue: validStylesPropValues,
|
|
3333
3355
|
elementType: node.tagName
|
|
3334
3356
|
});
|
|
3357
|
+
} catch (error) {
|
|
3358
|
+
errors.push(String(error));
|
|
3335
3359
|
}
|
|
3336
3360
|
}
|
|
3361
|
+
for (const [customCSSId, customCSS] of Object.entries(this.elementCusomCSS)) {
|
|
3362
|
+
const { element, node } = this.matchNodeByConfigId(customCSSId);
|
|
3363
|
+
this.api.doUpdateElementProperty({
|
|
3364
|
+
elementId: element.id,
|
|
3365
|
+
propertyName: "_styles",
|
|
3366
|
+
propertyValue: { custom_css: customCSS },
|
|
3367
|
+
elementType: node.tagName
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3337
3370
|
return {
|
|
3338
3371
|
errors,
|
|
3339
3372
|
invalidStyles
|
|
@@ -3395,187 +3428,170 @@ var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
|
3395
3428
|
var generatePrompt = () => {
|
|
3396
3429
|
const buildCompositionsToolPrompt = (0, import_editor_mcp2.toolPrompts)("build-compositions");
|
|
3397
3430
|
buildCompositionsToolPrompt.description(`
|
|
3398
|
-
#
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
4. Build valid XML with minimal inline styles (layout/positioning only)
|
|
3412
|
-
5. Avoid duplicating styles that should be global classes
|
|
3413
|
-
|
|
3414
|
-
## Phase 3: Apply Classes
|
|
3415
|
-
6. Use "apply-global-class" tool to apply global classes to elements
|
|
3416
|
-
|
|
3417
|
-
# CORE INSTRUCTIONS
|
|
3418
|
-
|
|
3419
|
-
**Structure:**
|
|
3420
|
-
- Build valid XML using allowed widget tags (e.g., \`<e-button configuration-id="btn1"></e-button>\`)
|
|
3421
|
-
- Containers only: "e-flexbox", "e-div-block", "e-tabs"
|
|
3422
|
-
- Every element MUST have unique "configuration-id" attribute
|
|
3431
|
+
# RESOURCES (Read before use)
|
|
3432
|
+
- [elementor://global-classes] - Check FIRST for reusable classes
|
|
3433
|
+
- [elementor://global-variables] - ONLY use variables defined here
|
|
3434
|
+
|
|
3435
|
+
# WORKFLOW
|
|
3436
|
+
1. Check/create global classes via "create-global-class" tool
|
|
3437
|
+
2. Build composition (THIS TOOL) - minimal inline styles
|
|
3438
|
+
3. Apply classes via "apply-global-class" tool
|
|
3439
|
+
|
|
3440
|
+
# XML STRUCTURE
|
|
3441
|
+
- Use widget tags: \`<e-button configuration-id="btn1"></e-button>\`
|
|
3442
|
+
- Containers: "e-flexbox", "e-div-block", "e-tabs"
|
|
3443
|
+
- Every element needs unique "configuration-id"
|
|
3423
3444
|
- No attributes, classes, IDs, or text nodes in XML
|
|
3424
3445
|
|
|
3425
|
-
|
|
3426
|
-
- Map
|
|
3427
|
-
-
|
|
3428
|
-
-
|
|
3429
|
-
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
**
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
-
|
|
3474
|
-
-
|
|
3475
|
-
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
-
|
|
3480
|
-
-
|
|
3481
|
-
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
-
|
|
3489
|
-
-
|
|
3490
|
-
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3446
|
+
# CONFIGURATION
|
|
3447
|
+
- Map configuration-id \u2192 elementConfig (props) + stylesConfig (layout only)
|
|
3448
|
+
- All PropValues require \`$$type\` matching schema
|
|
3449
|
+
- NO LINKS in configuration
|
|
3450
|
+
- Retry on errors up to 10x
|
|
3451
|
+
|
|
3452
|
+
Note about configuration ids: These names are visible to the end-user, make sure they make sense, related and relevant.
|
|
3453
|
+
|
|
3454
|
+
# DESIGN PHILOSOPHY: CONTEXT-DRIVEN CREATIVITY
|
|
3455
|
+
|
|
3456
|
+
**Use the user's context aggressively.** Business type, brand personality, target audience, and purpose should drive every design decision. A law firm needs gravitas; a children's app needs playfulness. Don't default to generic.
|
|
3457
|
+
|
|
3458
|
+
## SIZING: DEFAULT IS NO SIZE (CRITICAL)
|
|
3459
|
+
|
|
3460
|
+
**DO NOT specify height or width unless you have a specific visual reason.**
|
|
3461
|
+
|
|
3462
|
+
Flexbox and CSS already handle sizing automatically:
|
|
3463
|
+
- Containers grow to fit their content
|
|
3464
|
+
- Flex children distribute space via flex properties, not width/height
|
|
3465
|
+
- Text elements size to their content
|
|
3466
|
+
|
|
3467
|
+
WHEN TO SPECIFY SIZE:
|
|
3468
|
+
- min-height on ROOT section for viewport-spanning hero (use min-height, NOT height)
|
|
3469
|
+
- max-width for contained content areas (e.g., max-width: 60rem)
|
|
3470
|
+
- Explicit aspect ratios for media containers
|
|
3471
|
+
|
|
3472
|
+
NEVER SPECIFY:
|
|
3473
|
+
- height on nested containers (causes overflow)
|
|
3474
|
+
- width on flex children (use flex-basis or gap instead)
|
|
3475
|
+
- 100vh on anything except root-level sections
|
|
3476
|
+
- Any size "just to be safe" - if unsure, OMIT IT
|
|
3477
|
+
|
|
3478
|
+
vh units are VIEWPORT-relative. Nested 100vh inside 100vh = 200vh overflow.
|
|
3479
|
+
|
|
3480
|
+
GOOD: \`<e-flexbox>content naturally sizes</e-flexbox>\`
|
|
3481
|
+
BAD: \`<e-flexbox style="height:100vh"><e-div-block style="height:100vh">overflow</e-div-block></e-flexbox>\`
|
|
3482
|
+
|
|
3483
|
+
## Layout Variety (Break the Template)
|
|
3484
|
+
- AVOID: Full-width 100vh hero \u2192 three columns \u2192 testimonials \u2192 CTA (every AI does this)
|
|
3485
|
+
- VARY heights: Use auto-height sections with generous padding (6rem+). Let content breathe
|
|
3486
|
+
- VARY widths: Not everything spans full width. Use contained sections (max-width: 960px) mixed with edge-to-edge
|
|
3487
|
+
- ASYMMETRIC grids: 2:1, 1:3, offset layouts. Avoid equal column widths
|
|
3488
|
+
- Negative space as design element: Large margins create focus and sophistication
|
|
3489
|
+
- Break alignment intentionally: Offset headings, overlapping elements, broken grids
|
|
3490
|
+
|
|
3491
|
+
## Visual Depth & Effects
|
|
3492
|
+
- Layer elements: Overlapping cards, text over images, floating elements
|
|
3493
|
+
- Subtle shadows with color tint (not pure black): \`box-shadow: 0 20px 60px rgba(<brand-color-here>, 0.15)\`
|
|
3494
|
+
- Gradient overlays on images for text readability
|
|
3495
|
+
- Border radius variation: Mix sharp (0) and soft (1rem+) corners purposefully
|
|
3496
|
+
- Backdrop blur for glassmorphism where appropriate
|
|
3497
|
+
- Micro-interactions via CSS: hover transforms, transitions (0.3s ease)
|
|
3498
|
+
|
|
3499
|
+
## Typography with Character
|
|
3500
|
+
- Display fonts for headlines (from user's brand or contextually appropriate)
|
|
3501
|
+
- Size contrast: 4rem+ headlines vs 1rem body. Make hierarchy unmistakable
|
|
3502
|
+
- Letter-spacing: Tight for large headlines (-0.02em), loose for small caps (0.1em)
|
|
3503
|
+
- Line-height: Tight for headlines (1.1), generous for body (1.6-1.8)
|
|
3504
|
+
- Text decoration: Underlines, highlights, gradient text for emphasis
|
|
3505
|
+
|
|
3506
|
+
## Color with Purpose
|
|
3507
|
+
- Extract palette from user context (brand colors, industry norms, mood)
|
|
3508
|
+
- 60-30-10 rule: dominant, secondary, accent
|
|
3509
|
+
- Tinted neutrals over pure grays: warm (#faf8f5, #2d2a26) or cool (#f5f7fa, #1e2430)
|
|
3510
|
+
- Color blocking: Large colored sections create visual rhythm
|
|
3511
|
+
- Gradient directions: Diagonal (135deg, 225deg) feel more dynamic than vertical
|
|
3512
|
+
|
|
3513
|
+
## Spacing Strategy
|
|
3514
|
+
- Section padding: 6rem-10rem vertical, creating breathing room
|
|
3515
|
+
- Rhythm variation: Tight groups (2rem) with generous gaps between (6rem)
|
|
3516
|
+
- Use rem/em exclusively for responsive scaling
|
|
3517
|
+
- Generous padding on CTAs: min 1rem 2.5rem
|
|
3518
|
+
|
|
3519
|
+
# HARD CONSTRAINTS
|
|
3520
|
+
- Variables ONLY from [elementor://global-variables] (others throw errors)
|
|
3521
|
+
- Avoid SVG widgets unless assets are pre-uploaded
|
|
3522
|
+
- Check \`llm_guidance\` in widget schemas
|
|
3523
|
+
|
|
3524
|
+
# PARAMETERS
|
|
3493
3525
|
- **xmlStructure**: Valid XML with configuration-id attributes
|
|
3494
|
-
- **elementConfig**:
|
|
3495
|
-
- **stylesConfig**:
|
|
3526
|
+
- **elementConfig**: configuration-id \u2192 widget PropValues
|
|
3527
|
+
- **stylesConfig**: configuration-id \u2192 style PropValues (layout only)
|
|
3528
|
+
- **customCSS**: configuration-id \u2192 CSS rules (no selectors, semicolon-separated)
|
|
3496
3529
|
`);
|
|
3497
3530
|
buildCompositionsToolPrompt.example(`
|
|
3498
|
-
|
|
3531
|
+
Section with heading + button (NO explicit heights - content sizes naturally):
|
|
3499
3532
|
{
|
|
3500
|
-
xmlStructure: "<e-flexbox configuration-id="
|
|
3533
|
+
xmlStructure: "<e-flexbox configuration-id="Main Section"><e-heading configuration-id="Section Title"></e-heading><e-button configuration-id="Call to Action"></e-button></e-flexbox>",
|
|
3501
3534
|
elementConfig: {
|
|
3502
|
-
"
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
},
|
|
3535
|
+
"section1": { "tag": { "$$type": "string", "value": "section" } }
|
|
3536
|
+
},
|
|
3537
|
+
customCSS: {
|
|
3538
|
+
"Section Title": "padding: 6rem 4rem; background: linear-gradient(135deg, #faf8f5 0%, #f0ebe4 100%);"
|
|
3507
3539
|
},
|
|
3508
3540
|
stylesConfig: {
|
|
3509
|
-
"
|
|
3510
|
-
"font-size": {
|
|
3511
|
-
|
|
3512
|
-
"value": {
|
|
3513
|
-
"size": { "$$type": "number", "value": 24 },
|
|
3514
|
-
"unit": { "$$type": "string", "value": "px" }
|
|
3515
|
-
}
|
|
3516
|
-
},
|
|
3517
|
-
"color": {
|
|
3518
|
-
"$$type": "color",
|
|
3519
|
-
"value": { "$$type": "string", "value": "#333" }
|
|
3520
|
-
}
|
|
3541
|
+
"Section Title": {
|
|
3542
|
+
"font-size": { "$$type": "size", "value": { "size": { "$$type": "number", "value": 3.5 }, "unit": { "$$type": "string", "value": "rem" } } },
|
|
3543
|
+
"color": { "$$type": "color", "value": { "$$type": "string", "value": "#2d2a26" } }
|
|
3521
3544
|
}
|
|
3522
|
-
}
|
|
3545
|
+
}
|
|
3523
3546
|
}
|
|
3547
|
+
Note: No height/width specified on any element - flexbox handles layout automatically.
|
|
3524
3548
|
`);
|
|
3525
3549
|
buildCompositionsToolPrompt.parameter(
|
|
3526
3550
|
"xmlStructure",
|
|
3527
|
-
|
|
3528
|
-
);
|
|
3529
|
-
buildCompositionsToolPrompt.parameter(
|
|
3530
|
-
"elementConfig",
|
|
3531
|
-
`**MANDATORY** A record mapping configuration IDs to their corresponding configuration objects, defining the PropValues for each element created.`
|
|
3551
|
+
`Valid XML structure with custom elementor tags and configuration-id attributes.`
|
|
3532
3552
|
);
|
|
3553
|
+
buildCompositionsToolPrompt.parameter("elementConfig", `Record mapping configuration IDs to widget PropValues.`);
|
|
3533
3554
|
buildCompositionsToolPrompt.parameter(
|
|
3534
3555
|
"stylesConfig",
|
|
3535
|
-
|
|
3556
|
+
`Record mapping configuration IDs to style PropValues (layout/positioning only).`
|
|
3536
3557
|
);
|
|
3537
3558
|
buildCompositionsToolPrompt.instruction(
|
|
3538
|
-
`
|
|
3539
|
-
You should use these IDs as reference for further configuration, styling or changing elements later on.`
|
|
3540
|
-
);
|
|
3541
|
-
buildCompositionsToolPrompt.instruction(
|
|
3542
|
-
`**CRITICAL WORKFLOW REMINDER**:
|
|
3543
|
-
1. FIRST: Create reusable global classes for typography, colors, spacing patterns using "create-global-class" tool
|
|
3544
|
-
2. SECOND: Use THIS tool with minimal inline styles (only layout & unique properties)
|
|
3545
|
-
3. THIRD: Apply global classes to elements using "apply-global-class" tool
|
|
3546
|
-
|
|
3547
|
-
This ensures maximum reusability and consistency across your design system. ALWAYS check [elementor://global-classes] for existing classes before creating new ones.`
|
|
3559
|
+
`Element IDs in the returned XML represent actual widgets. Use these IDs for subsequent styling or configuration changes.`
|
|
3548
3560
|
);
|
|
3549
3561
|
return buildCompositionsToolPrompt.prompt();
|
|
3550
3562
|
};
|
|
3551
3563
|
|
|
3552
3564
|
// src/mcp/tools/build-composition/schema.ts
|
|
3553
|
-
var
|
|
3565
|
+
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
3554
3566
|
var inputSchema = {
|
|
3555
|
-
xmlStructure:
|
|
3556
|
-
elementConfig:
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3567
|
+
xmlStructure: import_editor_mcp3.zod.string().describe("The XML structure representing the composition to be built"),
|
|
3568
|
+
elementConfig: import_editor_mcp3.zod.record(
|
|
3569
|
+
import_editor_mcp3.zod.string().describe("The configuration id"),
|
|
3570
|
+
import_editor_mcp3.zod.record(
|
|
3571
|
+
import_editor_mcp3.zod.string().describe("property name"),
|
|
3572
|
+
import_editor_mcp3.zod.any().describe(`The PropValue for the property, refer to ${WIDGET_SCHEMA_URI}`)
|
|
3561
3573
|
)
|
|
3562
3574
|
).describe("A record mapping element IDs to their configuration objects. REQUIRED"),
|
|
3563
|
-
stylesConfig:
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3575
|
+
stylesConfig: import_editor_mcp3.zod.record(
|
|
3576
|
+
import_editor_mcp3.zod.string().describe("The configuration id"),
|
|
3577
|
+
import_editor_mcp3.zod.record(
|
|
3578
|
+
import_editor_mcp3.zod.string().describe("StyleSchema property name"),
|
|
3579
|
+
import_editor_mcp3.zod.any().describe(`The PropValue for the style property. MANDATORY, refer to [${STYLE_SCHEMA_URI}]`)
|
|
3568
3580
|
)
|
|
3569
3581
|
).describe(
|
|
3570
3582
|
`A record mapping element IDs to their styles configuration objects. Use the actual styles schema from [${STYLE_SCHEMA_URI}].`
|
|
3571
|
-
).default({})
|
|
3583
|
+
).default({}),
|
|
3584
|
+
customCSS: import_editor_mcp3.zod.record(
|
|
3585
|
+
import_editor_mcp3.zod.string().describe("The configuration id"),
|
|
3586
|
+
import_editor_mcp3.zod.string().describe("The custom CSS for the element. MANDATORY")
|
|
3587
|
+
).describe("A record mapping element IDs to their custom CSS.").default({})
|
|
3572
3588
|
};
|
|
3573
3589
|
var outputSchema = {
|
|
3574
|
-
errors:
|
|
3575
|
-
xmlStructure:
|
|
3590
|
+
errors: import_editor_mcp3.zod.string().describe("Error message if the composition building failed").optional(),
|
|
3591
|
+
xmlStructure: import_editor_mcp3.zod.string().describe(
|
|
3576
3592
|
"The built XML structure as a string. Must use this XML after completion of building the composition, it contains real IDs."
|
|
3577
3593
|
).optional(),
|
|
3578
|
-
llm_instructions:
|
|
3594
|
+
llm_instructions: import_editor_mcp3.zod.string().describe("Instructions what to do next, Important to follow these instructions!").optional()
|
|
3579
3595
|
};
|
|
3580
3596
|
|
|
3581
3597
|
// src/mcp/tools/build-composition/tool.ts
|
|
@@ -3597,7 +3613,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3597
3613
|
hints: [{ name: "claude-sonnet-4-5" }]
|
|
3598
3614
|
},
|
|
3599
3615
|
handler: async (params) => {
|
|
3600
|
-
const { xmlStructure, elementConfig, stylesConfig } = params;
|
|
3616
|
+
const { xmlStructure, elementConfig, stylesConfig, customCSS } = params;
|
|
3601
3617
|
let generatedXML = "";
|
|
3602
3618
|
const errors = [];
|
|
3603
3619
|
const rootContainers = [];
|
|
@@ -3609,17 +3625,18 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3609
3625
|
});
|
|
3610
3626
|
compositionBuilder.setElementConfig(elementConfig);
|
|
3611
3627
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
3628
|
+
compositionBuilder.setCustomCSS(customCSS);
|
|
3612
3629
|
const {
|
|
3613
3630
|
configErrors,
|
|
3614
3631
|
invalidStyles,
|
|
3615
3632
|
rootContainers: generatedRootContainers
|
|
3616
3633
|
} = compositionBuilder.build(documentContainer);
|
|
3634
|
+
rootContainers.push(...generatedRootContainers);
|
|
3617
3635
|
generatedXML = new XMLSerializer().serializeToString(compositionBuilder.getXML());
|
|
3618
3636
|
if (configErrors.length) {
|
|
3619
3637
|
errors.push(...configErrors.map((e) => new Error(e)));
|
|
3620
3638
|
throw new Error("Configuration errors occurred during composition building.");
|
|
3621
3639
|
}
|
|
3622
|
-
rootContainers.push(...generatedRootContainers);
|
|
3623
3640
|
Object.entries(invalidStyles).forEach(([elementId, rawCssRules]) => {
|
|
3624
3641
|
const customCss = {
|
|
3625
3642
|
value: rawCssRules.join(";\n")
|
|
@@ -3668,10 +3685,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
3668
3685
|
|
|
3669
3686
|
${errorMessages.join(
|
|
3670
3687
|
"\n\n"
|
|
3671
|
-
)}
|
|
3672
|
-
|
|
3673
|
-
"Missing $$type" errors indicate that the configuration objects are invalid. Try again and apply **ALL** object entries with correct $$type.
|
|
3674
|
-
Now that you have these errors, fix them and try again. Errors regarding configuration objects, please check against the PropType schemas`;
|
|
3688
|
+
)}`;
|
|
3675
3689
|
throw new Error(errorText);
|
|
3676
3690
|
}
|
|
3677
3691
|
return {
|
|
@@ -3792,23 +3806,23 @@ The $$type property is MANDATORY for every value, it is required to parse the va
|
|
|
3792
3806
|
`;
|
|
3793
3807
|
|
|
3794
3808
|
// src/mcp/tools/configure-element/schema.ts
|
|
3795
|
-
var
|
|
3809
|
+
var import_schema2 = require("@elementor/schema");
|
|
3796
3810
|
var inputSchema2 = {
|
|
3797
|
-
propertiesToChange:
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3811
|
+
propertiesToChange: import_schema2.z.record(
|
|
3812
|
+
import_schema2.z.string().describe("The property name."),
|
|
3813
|
+
import_schema2.z.any().describe(`PropValue, refer to [${WIDGET_SCHEMA_URI}] by correct type, as appears in elementType`),
|
|
3814
|
+
import_schema2.z.any()
|
|
3801
3815
|
).describe("An object record containing property names and their new values to be set on the element"),
|
|
3802
|
-
stylePropertiesToChange:
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3816
|
+
stylePropertiesToChange: import_schema2.z.record(
|
|
3817
|
+
import_schema2.z.string().describe("The style property name"),
|
|
3818
|
+
import_schema2.z.any().describe(`The style PropValue, refer to [${STYLE_SCHEMA_URI}] how to generate values`),
|
|
3819
|
+
import_schema2.z.any()
|
|
3806
3820
|
).describe("An object record containing style property names and their new values to be set on the element").default({}),
|
|
3807
|
-
elementType:
|
|
3808
|
-
elementId:
|
|
3821
|
+
elementType: import_schema2.z.string().describe("The type of the element to retreive the schema"),
|
|
3822
|
+
elementId: import_schema2.z.string().describe("The unique id of the element to configure")
|
|
3809
3823
|
};
|
|
3810
3824
|
var outputSchema2 = {
|
|
3811
|
-
success:
|
|
3825
|
+
success: import_schema2.z.boolean().describe(
|
|
3812
3826
|
"Whether the configuration change was successful, only if propertyName and propertyValue are provided"
|
|
3813
3827
|
)
|
|
3814
3828
|
};
|
|
@@ -3914,18 +3928,18 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
3914
3928
|
// src/mcp/tools/get-element-config/tool.ts
|
|
3915
3929
|
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3916
3930
|
var import_editor_props8 = require("@elementor/editor-props");
|
|
3917
|
-
var
|
|
3931
|
+
var import_schema4 = require("@elementor/schema");
|
|
3918
3932
|
var schema = {
|
|
3919
|
-
elementId:
|
|
3933
|
+
elementId: import_schema4.z.string()
|
|
3920
3934
|
};
|
|
3921
3935
|
var outputSchema3 = {
|
|
3922
|
-
properties:
|
|
3923
|
-
style:
|
|
3924
|
-
childElements:
|
|
3925
|
-
|
|
3926
|
-
id:
|
|
3927
|
-
elementType:
|
|
3928
|
-
childElements:
|
|
3936
|
+
properties: import_schema4.z.record(import_schema4.z.string(), import_schema4.z.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
|
|
3937
|
+
style: import_schema4.z.record(import_schema4.z.string(), import_schema4.z.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
|
|
3938
|
+
childElements: import_schema4.z.array(
|
|
3939
|
+
import_schema4.z.object({
|
|
3940
|
+
id: import_schema4.z.string(),
|
|
3941
|
+
elementType: import_schema4.z.string(),
|
|
3942
|
+
childElements: import_schema4.z.array(import_schema4.z.any()).describe("An array of child element IDs, when applicable, same structure recursively")
|
|
3929
3943
|
})
|
|
3930
3944
|
).describe("An array of child element IDs, when applicable, with recursive structure")
|
|
3931
3945
|
};
|
|
@@ -4000,7 +4014,14 @@ var initGetElementConfigTool = (reg) => {
|
|
|
4000
4014
|
var initCanvasMcp = (reg) => {
|
|
4001
4015
|
const { setMCPDescription } = reg;
|
|
4002
4016
|
setMCPDescription(
|
|
4003
|
-
|
|
4017
|
+
`Everything related to creative design, layout, styling and building the pages, specifically element of type "widget".
|
|
4018
|
+
# Canvas workflow for new compositions
|
|
4019
|
+
- Check existing global variables
|
|
4020
|
+
- Check existing global classes
|
|
4021
|
+
- Create missing global variables
|
|
4022
|
+
- Create reusable global classes
|
|
4023
|
+
- Build valid XML with minimal inline styles (layout/positioning only)
|
|
4024
|
+
- Apply global classes to elements`
|
|
4004
4025
|
);
|
|
4005
4026
|
initWidgetsSchemaResource(reg);
|
|
4006
4027
|
initDocumentStructureResource(reg);
|
|
@@ -4493,7 +4514,7 @@ function init() {
|
|
|
4493
4514
|
component: ClassesRename
|
|
4494
4515
|
});
|
|
4495
4516
|
initCanvasMcp(
|
|
4496
|
-
(0,
|
|
4517
|
+
(0, import_editor_mcp4.getMCPByDomain)("canvas", {
|
|
4497
4518
|
instructions: mcpDescription
|
|
4498
4519
|
})
|
|
4499
4520
|
);
|