@elementor/editor-components 3.35.0-356 → 3.35.0-357
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 +299 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +297 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
- package/src/api.ts +27 -5
- package/src/components/create-component-form/utils/replace-element-with-component.ts +4 -0
- package/src/mcp/save-as-component-tool.ts +333 -29
- package/src/store/actions/create-unpublished-component.ts +9 -6
- package/src/store/store.ts +5 -1
- package/src/sync/create-components-before-save.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/init.ts
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
|
-
var
|
|
39
|
+
var import_editor_canvas7 = require("@elementor/editor-canvas");
|
|
40
40
|
var import_editor_documents10 = require("@elementor/editor-documents");
|
|
41
41
|
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
42
42
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
@@ -97,7 +97,8 @@ var apiClient = {
|
|
|
97
97
|
{
|
|
98
98
|
componentIds
|
|
99
99
|
}
|
|
100
|
-
).then((res) => res.data.data)
|
|
100
|
+
).then((res) => res.data.data),
|
|
101
|
+
validate: async (payload) => await (0, import_http_client.httpService)().post(`${BASE_URL}/create-validate`, payload).then((res) => res.data)
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
// src/store/thunks.ts
|
|
@@ -197,7 +198,11 @@ var selectComponents = (0, import_store2.__createSelector)(
|
|
|
197
198
|
selectData,
|
|
198
199
|
selectUnpublishedData,
|
|
199
200
|
(data, unpublishedData) => [
|
|
200
|
-
...unpublishedData.map((item) => ({
|
|
201
|
+
...unpublishedData.map((item) => ({
|
|
202
|
+
uid: item.uid,
|
|
203
|
+
name: item.name,
|
|
204
|
+
overridableProps: item.overridableProps
|
|
205
|
+
})),
|
|
201
206
|
...data
|
|
202
207
|
]
|
|
203
208
|
);
|
|
@@ -850,7 +855,8 @@ var createComponentModel = (component) => {
|
|
|
850
855
|
value: component.id ?? component.uid
|
|
851
856
|
}
|
|
852
857
|
}
|
|
853
|
-
}
|
|
858
|
+
},
|
|
859
|
+
overridable_props: component.overridableProps
|
|
854
860
|
},
|
|
855
861
|
editor_settings: {
|
|
856
862
|
title: component.name,
|
|
@@ -1123,25 +1129,25 @@ var import_i18n8 = require("@wordpress/i18n");
|
|
|
1123
1129
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
1124
1130
|
var import_store21 = require("@elementor/store");
|
|
1125
1131
|
var import_utils2 = require("@elementor/utils");
|
|
1126
|
-
function createUnpublishedComponent(name, element, eventData) {
|
|
1127
|
-
const
|
|
1128
|
-
const componentBase = { uid, name };
|
|
1132
|
+
function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
|
|
1133
|
+
const generatedUid = uid ?? (0, import_utils2.generateUniqueId)("component");
|
|
1134
|
+
const componentBase = { uid: generatedUid, name, overridableProps };
|
|
1129
1135
|
(0, import_store21.__dispatch)(
|
|
1130
1136
|
slice.actions.addUnpublished({
|
|
1131
1137
|
...componentBase,
|
|
1132
1138
|
elements: [element]
|
|
1133
1139
|
})
|
|
1134
1140
|
);
|
|
1135
|
-
(0, import_store21.__dispatch)(slice.actions.addCreatedThisSession(
|
|
1141
|
+
(0, import_store21.__dispatch)(slice.actions.addCreatedThisSession(generatedUid));
|
|
1136
1142
|
replaceElementWithComponent(element, componentBase);
|
|
1137
1143
|
trackComponentEvent({
|
|
1138
1144
|
action: "created",
|
|
1139
|
-
component_uid:
|
|
1145
|
+
component_uid: generatedUid,
|
|
1140
1146
|
component_name: name,
|
|
1141
1147
|
...eventData
|
|
1142
1148
|
});
|
|
1143
1149
|
(0, import_editor_v1_adapters3.__privateRunCommand)("document/save/auto");
|
|
1144
|
-
return
|
|
1150
|
+
return generatedUid;
|
|
1145
1151
|
}
|
|
1146
1152
|
|
|
1147
1153
|
// src/components/create-component-form/hooks/use-form.ts
|
|
@@ -2280,72 +2286,320 @@ function isPropAllowed(bind) {
|
|
|
2280
2286
|
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
2281
2287
|
|
|
2282
2288
|
// src/mcp/save-as-component-tool.ts
|
|
2289
|
+
var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
2283
2290
|
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
2284
2291
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2292
|
+
var import_http_client2 = require("@elementor/http-client");
|
|
2285
2293
|
var import_schema6 = require("@elementor/schema");
|
|
2294
|
+
var import_utils5 = require("@elementor/utils");
|
|
2286
2295
|
var InputSchema = {
|
|
2287
2296
|
element_id: import_schema6.z.string().describe(
|
|
2288
2297
|
'The unique identifier of the element to save as a component. Use the "list-elements" tool to find available element IDs in the current document.'
|
|
2289
2298
|
),
|
|
2290
|
-
component_name: import_schema6.z.string().describe("The name for the new component. Should be descriptive and unique among existing components.")
|
|
2299
|
+
component_name: import_schema6.z.string().describe("The name for the new component. Should be descriptive and unique among existing components."),
|
|
2300
|
+
overridable_props: import_schema6.z.object({
|
|
2301
|
+
props: import_schema6.z.record(
|
|
2302
|
+
import_schema6.z.object({
|
|
2303
|
+
elementId: import_schema6.z.string().describe("The id of the child element that you want to override its settings"),
|
|
2304
|
+
propKey: import_schema6.z.string().describe(
|
|
2305
|
+
'The property key of the child element that you want to override its settings (e.g., "text", "url", "tag"). To get the available propKeys for an element, use the "get-element-type-config" tool.'
|
|
2306
|
+
)
|
|
2307
|
+
})
|
|
2308
|
+
)
|
|
2309
|
+
}).optional().describe(
|
|
2310
|
+
'Overridable properties configuration. Specify which CHILD element properties can be customized. Only elementId and propKey are required; To get the available propKeys for a child element you must use the "get-element-type-config" tool.'
|
|
2311
|
+
)
|
|
2291
2312
|
};
|
|
2292
2313
|
var OutputSchema = {
|
|
2293
2314
|
message: import_schema6.z.string().optional().describe("Additional information about the operation result"),
|
|
2294
2315
|
component_uid: import_schema6.z.string().optional().describe("The unique identifier of the newly created component (only present on success)")
|
|
2295
2316
|
};
|
|
2296
|
-
var VALID_ELEMENT_TYPES = ["e-div-block", "e-flexbox", "e-tabs"];
|
|
2297
2317
|
var ERROR_MESSAGES = {
|
|
2298
2318
|
ELEMENT_NOT_FOUND: "Element not found. Use 'list-elements' to get valid element IDs.",
|
|
2299
|
-
ELEMENT_NOT_ONE_OF_TYPES: `Element is not one of the following types: ${
|
|
2319
|
+
ELEMENT_NOT_ONE_OF_TYPES: (validTypes) => `Element is not one of the following types: ${validTypes.join(", ")}`,
|
|
2300
2320
|
ELEMENT_IS_LOCKED: "Cannot save a locked element as a component."
|
|
2301
2321
|
};
|
|
2302
2322
|
var handleSaveAsComponent = async (params) => {
|
|
2303
|
-
const { element_id: elementId, component_name: componentName } = params;
|
|
2323
|
+
const { element_id: elementId, component_name: componentName, overridable_props: overridablePropsInput } = params;
|
|
2324
|
+
const validElementTypes = getValidElementTypes();
|
|
2304
2325
|
const container = (0, import_editor_elements7.getContainer)(elementId);
|
|
2305
2326
|
if (!container) {
|
|
2306
2327
|
throw new Error(ERROR_MESSAGES.ELEMENT_NOT_FOUND);
|
|
2307
2328
|
}
|
|
2308
2329
|
const elType = container.model.get("elType");
|
|
2309
|
-
if (!
|
|
2310
|
-
throw new Error(ERROR_MESSAGES.ELEMENT_NOT_ONE_OF_TYPES);
|
|
2330
|
+
if (!validElementTypes.includes(elType)) {
|
|
2331
|
+
throw new Error(ERROR_MESSAGES.ELEMENT_NOT_ONE_OF_TYPES(validElementTypes));
|
|
2311
2332
|
}
|
|
2312
2333
|
const element = container.model.toJSON({ remove: ["default"] });
|
|
2313
2334
|
if (element?.isLocked) {
|
|
2314
2335
|
throw new Error(ERROR_MESSAGES.ELEMENT_IS_LOCKED);
|
|
2315
2336
|
}
|
|
2316
|
-
const
|
|
2337
|
+
const overridableProps = overridablePropsInput ? enrichOverridableProps(overridablePropsInput, element) : void 0;
|
|
2338
|
+
if (overridableProps) {
|
|
2339
|
+
updateElementDataWithOverridableProps(element, overridableProps);
|
|
2340
|
+
}
|
|
2341
|
+
const uid = (0, import_utils5.generateUniqueId)("component");
|
|
2342
|
+
try {
|
|
2343
|
+
await apiClient.validate({
|
|
2344
|
+
items: [
|
|
2345
|
+
{ uid, title: componentName, elements: [element], settings: { overridable_props: overridableProps } }
|
|
2346
|
+
]
|
|
2347
|
+
});
|
|
2348
|
+
} catch (error) {
|
|
2349
|
+
if (error instanceof import_http_client2.AxiosError) {
|
|
2350
|
+
throw new Error(error.response?.data.messge);
|
|
2351
|
+
}
|
|
2352
|
+
throw new Error("Unknown error");
|
|
2353
|
+
}
|
|
2354
|
+
createUnpublishedComponent(componentName, element, null, overridableProps, uid);
|
|
2317
2355
|
return {
|
|
2318
2356
|
status: "ok",
|
|
2319
2357
|
message: `Component "${componentName}" created successfully.`,
|
|
2320
2358
|
component_uid: uid
|
|
2321
2359
|
};
|
|
2322
2360
|
};
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2361
|
+
function enrichOverridableProps(input, rootElement) {
|
|
2362
|
+
const enrichedProps = {};
|
|
2363
|
+
const defaultGroupId = (0, import_utils5.generateUniqueId)("group");
|
|
2364
|
+
Object.entries(input.props).forEach(([, prop]) => {
|
|
2365
|
+
const { elementId, propKey } = prop;
|
|
2366
|
+
const element = findElementById(rootElement, elementId);
|
|
2367
|
+
if (!element) {
|
|
2368
|
+
throw new Error(`Element with ID "${elementId}" not found in component`);
|
|
2369
|
+
}
|
|
2370
|
+
const elType = element.elType;
|
|
2371
|
+
const widgetType = element.widgetType || element.elType;
|
|
2372
|
+
const elementType = (0, import_editor_elements7.getElementType)(widgetType);
|
|
2373
|
+
if (!elementType) {
|
|
2374
|
+
throw new Error(
|
|
2375
|
+
`Element type "${widgetType}" is not atomic or does not have a settings schema. Cannot expose property "${propKey}" for element "${elementId}".`
|
|
2376
|
+
);
|
|
2377
|
+
}
|
|
2378
|
+
if (!elementType.propsSchema[propKey]) {
|
|
2379
|
+
const availableProps = Object.keys(elementType.propsSchema).join(", ");
|
|
2380
|
+
throw new Error(
|
|
2381
|
+
`Property "${propKey}" does not exist in element "${elementId}" (type: ${widgetType}). Available properties: ${availableProps}`
|
|
2382
|
+
);
|
|
2383
|
+
}
|
|
2384
|
+
const overrideKey = (0, import_utils5.generateUniqueId)("prop");
|
|
2385
|
+
const originValue = element.settings?.[propKey] ? element.settings[propKey] : elementType.propsSchema[propKey].default ?? null;
|
|
2386
|
+
const label = generateLabel(propKey);
|
|
2387
|
+
enrichedProps[overrideKey] = {
|
|
2388
|
+
overrideKey,
|
|
2389
|
+
label,
|
|
2390
|
+
elementId,
|
|
2391
|
+
propKey,
|
|
2392
|
+
elType,
|
|
2393
|
+
widgetType,
|
|
2394
|
+
originValue,
|
|
2395
|
+
groupId: defaultGroupId
|
|
2396
|
+
};
|
|
2397
|
+
});
|
|
2398
|
+
return {
|
|
2399
|
+
props: enrichedProps,
|
|
2400
|
+
groups: {
|
|
2401
|
+
items: {
|
|
2402
|
+
[defaultGroupId]: {
|
|
2403
|
+
id: defaultGroupId,
|
|
2404
|
+
label: "Default",
|
|
2405
|
+
props: Object.keys(enrichedProps)
|
|
2406
|
+
}
|
|
2407
|
+
},
|
|
2408
|
+
order: [defaultGroupId]
|
|
2409
|
+
}
|
|
2410
|
+
};
|
|
2411
|
+
}
|
|
2412
|
+
function updateElementDataWithOverridableProps(rootElement, overridableProps) {
|
|
2413
|
+
Object.values(overridableProps.props).forEach((prop) => {
|
|
2414
|
+
const element = findElementById(rootElement, prop.elementId);
|
|
2415
|
+
if (!element || !element.settings) {
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
element.settings[prop.propKey] = {
|
|
2419
|
+
$$type: "overridable",
|
|
2420
|
+
value: {
|
|
2421
|
+
override_key: prop.overrideKey,
|
|
2422
|
+
origin_value: prop.originValue
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
});
|
|
2426
|
+
}
|
|
2427
|
+
function findElementById(root, targetId) {
|
|
2428
|
+
if (root.id === targetId) {
|
|
2429
|
+
return root;
|
|
2430
|
+
}
|
|
2431
|
+
if (root.elements) {
|
|
2432
|
+
for (const child of root.elements) {
|
|
2433
|
+
const found = findElementById(child, targetId);
|
|
2434
|
+
if (found) {
|
|
2435
|
+
return found;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
return null;
|
|
2440
|
+
}
|
|
2441
|
+
function generateLabel(propKey) {
|
|
2442
|
+
const uniqueId = (0, import_utils5.generateUniqueId)("prop");
|
|
2443
|
+
return `${uniqueId} - ${propKey}`;
|
|
2444
|
+
}
|
|
2445
|
+
function getValidElementTypes() {
|
|
2446
|
+
const types = (0, import_editor_elements7.getWidgetsCache)();
|
|
2447
|
+
if (!types) {
|
|
2448
|
+
return [];
|
|
2449
|
+
}
|
|
2450
|
+
return Object.entries(types).reduce((acc, [type, value]) => {
|
|
2451
|
+
if (!value.atomic_props_schema || !value.show_in_panel || value.elType === "widget") {
|
|
2452
|
+
return acc;
|
|
2453
|
+
}
|
|
2454
|
+
acc.push(type);
|
|
2455
|
+
return acc;
|
|
2456
|
+
}, []);
|
|
2457
|
+
}
|
|
2458
|
+
var generatePrompt = () => {
|
|
2459
|
+
const saveAsComponentPrompt = (0, import_editor_mcp.toolPrompts)("save-as-component");
|
|
2460
|
+
saveAsComponentPrompt.description(`
|
|
2461
|
+
Save an existing element as a reusable component in the Elementor editor.
|
|
2462
|
+
|
|
2463
|
+
# When to use this tool
|
|
2464
|
+
Use this tool when the user wants to:
|
|
2465
|
+
- Create a reusable component from an existing element structure
|
|
2466
|
+
- Make specific child element properties customizable in component instances
|
|
2467
|
+
- Build a library of reusable design patterns
|
|
2468
|
+
|
|
2469
|
+
# When NOT to use this tool
|
|
2470
|
+
- Element is already a component (widgetType: 'e-component')
|
|
2471
|
+
- Element is locked
|
|
2472
|
+
- Element is not an atomic element (atomic_props_schema is not defined)
|
|
2473
|
+
- Element elType is a 'widget'
|
|
2474
|
+
|
|
2475
|
+
# **CRITICAL - REQUIRED RESOURCES (Must read before using this tool)**
|
|
2476
|
+
1. [${import_editor_canvas6.DOCUMENT_STRUCTURE_URI}]
|
|
2477
|
+
**MANDATORY** - Required to understand the document structure and identify child elements for overridable properties.
|
|
2478
|
+
Use this resource to find element IDs and understand the element hierarchy.
|
|
2479
|
+
|
|
2480
|
+
2. [${import_editor_canvas6.WIDGET_SCHEMA_URI}]
|
|
2481
|
+
**MANDATORY** - Required to understand which properties are available for each widget type.
|
|
2482
|
+
Use this to identify available propKeys in the atomic_props_schema for child elements.
|
|
2483
|
+
|
|
2484
|
+
# Instructions - MUST FOLLOW IN ORDER
|
|
2485
|
+
## Step 1: Identify the Target Element
|
|
2486
|
+
1. Read the [${import_editor_canvas6.DOCUMENT_STRUCTURE_URI}] resource to understand the document structure
|
|
2487
|
+
2. Locate the element you want to save as a component by its element_id
|
|
2488
|
+
3. Verify the element type is a valid element type
|
|
2489
|
+
4. Ensure the element is not locked and is not already a component
|
|
2490
|
+
|
|
2491
|
+
## Step 2: Define Overridable Properties
|
|
2492
|
+
Do this step to make child element properties customizable.
|
|
2493
|
+
Skip that step ONLY if the user explicitly requests to not make any properties customizable.
|
|
2494
|
+
|
|
2495
|
+
1. **Identify Child Elements**
|
|
2496
|
+
- Use the [${import_editor_canvas6.DOCUMENT_STRUCTURE_URI}] resource to find all child elements
|
|
2497
|
+
- Note the elementId and widgetType/elType of each child element you want to customize
|
|
2498
|
+
|
|
2499
|
+
2. **Find Available Properties**
|
|
2500
|
+
- Use the [${import_editor_canvas6.WIDGET_SCHEMA_URI}] resource to find the child element's widget type schema
|
|
2501
|
+
- Review the atomic_props_schema to find available propKeys (ONLY use top-level props)
|
|
2502
|
+
- Common propKeys include: "text", "url", "tag", "size", etc.
|
|
2503
|
+
- Use only the top level properties, do not use nested properties.
|
|
2504
|
+
|
|
2505
|
+
3. **Build the overridable_props Object**
|
|
2506
|
+
- For each property you want to make overridable, add an entry:
|
|
2507
|
+
\`{ "elementId": "<child-element-id>", "propKey": "<property-key>" }\`
|
|
2508
|
+
- Group all entries under the "props" object
|
|
2509
|
+
|
|
2510
|
+
## Step 3: Execute the Tool
|
|
2511
|
+
Call the tool with:
|
|
2512
|
+
- element_id: The ID of the parent element to save as component
|
|
2513
|
+
- component_name: A descriptive name for the component
|
|
2514
|
+
- overridable_props: (Optional) The properties configuration from Step 2
|
|
2515
|
+
|
|
2516
|
+
# CONSTRAINTS
|
|
2517
|
+
- NEVER try to override properties of the parent element itself - ONLY child elements
|
|
2518
|
+
- NEVER use invalid propKeys - always verify against the widget's atomic_props_schema in [${import_editor_canvas6.WIDGET_SCHEMA_URI}]
|
|
2519
|
+
- Property keys must exist in the child element's atomic_props_schema
|
|
2520
|
+
- Element IDs must exist within the target element's children
|
|
2521
|
+
- When tool execution fails, read the error message and adjust accordingly
|
|
2522
|
+
- The element being saved must not be inside another component
|
|
2523
|
+
`);
|
|
2524
|
+
saveAsComponentPrompt.parameter(
|
|
2525
|
+
"element_id",
|
|
2526
|
+
`**MANDATORY** The unique identifier of the element to save as a component.
|
|
2527
|
+
Use the [${import_editor_canvas6.DOCUMENT_STRUCTURE_URI}] resource to find available element IDs.`
|
|
2528
|
+
);
|
|
2529
|
+
saveAsComponentPrompt.parameter(
|
|
2530
|
+
"component_name",
|
|
2531
|
+
`**MANDATORY** A descriptive name for the new component.
|
|
2532
|
+
Should be unique and clearly describe the component's purpose (e.g., "Hero Section", "Feature Card").`
|
|
2533
|
+
);
|
|
2534
|
+
saveAsComponentPrompt.parameter(
|
|
2535
|
+
"overridable_props",
|
|
2536
|
+
`**OPTIONAL** Configuration for which child element properties can be customized in component instances.
|
|
2334
2537
|
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2538
|
+
Structure:
|
|
2539
|
+
\`\`\`json
|
|
2540
|
+
{
|
|
2541
|
+
"props": {
|
|
2542
|
+
"<unique-key>": {
|
|
2543
|
+
"elementId": "<child-element-id>",
|
|
2544
|
+
"propKey": "<property-key>"
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
\`\`\`
|
|
2339
2549
|
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2550
|
+
To populate this correctly:
|
|
2551
|
+
1. Use [${import_editor_canvas6.DOCUMENT_STRUCTURE_URI}] to find child element IDs and their widgetType
|
|
2552
|
+
2. Use [${import_editor_canvas6.WIDGET_SCHEMA_URI}] to find the atomic_props_schema for each child element's widgetType
|
|
2553
|
+
3. Only include properties you want to be customizable in component instances
|
|
2554
|
+
4. Common propKeys: "text", "url", "tag", "size", "align", etc.`
|
|
2555
|
+
);
|
|
2556
|
+
saveAsComponentPrompt.example(`
|
|
2557
|
+
Basic component without overridable properties:
|
|
2558
|
+
\`\`\`json
|
|
2559
|
+
{
|
|
2560
|
+
"element_id": "abc123",
|
|
2561
|
+
"component_name": "Hero Section"
|
|
2562
|
+
}
|
|
2563
|
+
\`\`\`
|
|
2343
2564
|
|
|
2344
|
-
|
|
2565
|
+
Component with overridable properties:
|
|
2345
2566
|
\`\`\`json
|
|
2346
|
-
{
|
|
2567
|
+
{
|
|
2568
|
+
"element_id": "abc123",
|
|
2569
|
+
"component_name": "Feature Card",
|
|
2570
|
+
"overridable_props": {
|
|
2571
|
+
"props": {
|
|
2572
|
+
"heading-text": {
|
|
2573
|
+
"elementId": "heading-123",
|
|
2574
|
+
"propKey": "text"
|
|
2575
|
+
},
|
|
2576
|
+
"button-text": {
|
|
2577
|
+
"elementId": "button-456",
|
|
2578
|
+
"propKey": "text"
|
|
2579
|
+
},
|
|
2580
|
+
"button-link": {
|
|
2581
|
+
"elementId": "button-456",
|
|
2582
|
+
"propKey": "url"
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2347
2587
|
\`\`\`
|
|
2348
|
-
|
|
2588
|
+
`);
|
|
2589
|
+
saveAsComponentPrompt.instruction(
|
|
2590
|
+
`After successful creation, the component will be available in the components library and can be inserted into any page or template.`
|
|
2591
|
+
);
|
|
2592
|
+
saveAsComponentPrompt.instruction(
|
|
2593
|
+
`When overridable properties are defined, component instances will show customization controls for those specific properties in the editing panel.`
|
|
2594
|
+
);
|
|
2595
|
+
return saveAsComponentPrompt.prompt();
|
|
2596
|
+
};
|
|
2597
|
+
var initSaveAsComponentTool = () => {
|
|
2598
|
+
return (0, import_editor_mcp.getMCPByDomain)("components").addTool({
|
|
2599
|
+
name: "save-as-component",
|
|
2600
|
+
schema: InputSchema,
|
|
2601
|
+
outputSchema: OutputSchema,
|
|
2602
|
+
description: generatePrompt(),
|
|
2349
2603
|
handler: handleSaveAsComponent
|
|
2350
2604
|
});
|
|
2351
2605
|
};
|
|
@@ -2418,7 +2672,8 @@ async function createComponentsBeforeSave({
|
|
|
2418
2672
|
unpublishedComponents.map((component) => ({
|
|
2419
2673
|
id: uidToComponentId.get(component.uid),
|
|
2420
2674
|
name: component.name,
|
|
2421
|
-
uid: component.uid
|
|
2675
|
+
uid: component.uid,
|
|
2676
|
+
overridableProps: component.overridableProps ? component.overridableProps : void 0
|
|
2422
2677
|
}))
|
|
2423
2678
|
)
|
|
2424
2679
|
);
|
|
@@ -2433,7 +2688,8 @@ async function createComponents(components, status) {
|
|
|
2433
2688
|
items: components.map((component) => ({
|
|
2434
2689
|
uid: component.uid,
|
|
2435
2690
|
title: component.name,
|
|
2436
|
-
elements: component.elements
|
|
2691
|
+
elements: component.elements,
|
|
2692
|
+
settings: component.overridableProps ? { overridable_props: component.overridableProps } : void 0
|
|
2437
2693
|
}))
|
|
2438
2694
|
});
|
|
2439
2695
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -2558,7 +2814,7 @@ var beforeSave = ({ container, status }) => {
|
|
|
2558
2814
|
function init() {
|
|
2559
2815
|
import_editor_styles_repository2.stylesRepository.register(componentsStylesProvider);
|
|
2560
2816
|
(0, import_store50.__registerSlice)(slice);
|
|
2561
|
-
(0,
|
|
2817
|
+
(0, import_editor_canvas7.registerElementType)(
|
|
2562
2818
|
TYPE,
|
|
2563
2819
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
2564
2820
|
);
|
|
@@ -2614,8 +2870,8 @@ function init() {
|
|
|
2614
2870
|
condition: (_, elementType) => elementType.key === "e-component",
|
|
2615
2871
|
component: InstanceEditingPanel
|
|
2616
2872
|
});
|
|
2617
|
-
|
|
2618
|
-
|
|
2873
|
+
import_editor_canvas7.settingsTransformersRegistry.register("component-instance", componentInstanceTransformer);
|
|
2874
|
+
import_editor_canvas7.settingsTransformersRegistry.register("overridable", componentOverridableTransformer);
|
|
2619
2875
|
initMcp();
|
|
2620
2876
|
}
|
|
2621
2877
|
// Annotate the CommonJS export names for ESM import in node:
|