@elementor/editor-global-classes 4.2.0-841 → 4.2.0-842
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 +78 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/init.ts +9 -1
- package/src/mcp-integration/apply-global-class-guide-prompt.ts +39 -0
- package/src/mcp-integration/index.ts +0 -10
- package/src/mcp-integration/mcp-apply-unapply-global-classes.ts +28 -40
- package/src/mcp-integration/mcp-get-global-class-usages.ts +8 -11
- package/src/mcp-integration/mcp-manage-global-classes.ts +1 -9
package/dist/index.js
CHANGED
|
@@ -2666,7 +2666,7 @@ var initClassesResource = (classesMcpEntry, canvasMcpEntry) => {
|
|
|
2666
2666
|
// src/init.ts
|
|
2667
2667
|
var import_editor = require("@elementor/editor");
|
|
2668
2668
|
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
2669
|
-
var
|
|
2669
|
+
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
2670
2670
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
2671
2671
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
2672
2672
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
@@ -2883,24 +2883,15 @@ function PopulateStore() {
|
|
|
2883
2883
|
// src/mcp-integration/mcp-apply-unapply-global-classes.ts
|
|
2884
2884
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
2885
2885
|
var import_schema = require("@elementor/schema");
|
|
2886
|
-
function initMcpApplyUnapplyGlobalClasses(server) {
|
|
2887
|
-
server.addTool({
|
|
2888
|
-
schema: {
|
|
2889
|
-
classId: import_schema.z.string().describe("The ID of the class to apply"),
|
|
2890
|
-
elementId: import_schema.z.string().describe("The ID of the element to which the class will be applied")
|
|
2891
|
-
},
|
|
2892
|
-
outputSchema: {
|
|
2893
|
-
result: import_schema.z.string().describe("Result message indicating the success of the apply operation"),
|
|
2894
|
-
llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!")
|
|
2895
|
-
},
|
|
2896
|
-
name: "apply-global-class",
|
|
2897
|
-
modelPreferences: {
|
|
2898
|
-
intelligencePriority: 0.7,
|
|
2899
|
-
speedPriority: 0.8
|
|
2900
|
-
},
|
|
2901
|
-
description: `Apply a global class to an element, enabling consistent styling through your design system.
|
|
2902
2886
|
|
|
2903
|
-
|
|
2887
|
+
// src/mcp-integration/apply-global-class-guide-prompt.ts
|
|
2888
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2889
|
+
var APPLY_GLOBAL_CLASS_GUIDE_URI = "elementor://global-classes/tools/apply-global-class-guide";
|
|
2890
|
+
var generateApplyGlobalClassGuidePrompt = () => {
|
|
2891
|
+
const prompt = (0, import_editor_mcp.toolPrompts)("apply-global-class");
|
|
2892
|
+
prompt.description("Apply a global class to an element, enabling consistent styling through your design system.");
|
|
2893
|
+
prompt.instruction(
|
|
2894
|
+
`## When to use this tool:
|
|
2904
2895
|
**ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
|
|
2905
2896
|
- After using "build-compositions" tool, apply semantic classes to the created elements
|
|
2906
2897
|
- When applying consistent typography styles (heading-primary, text-body, etc.)
|
|
@@ -2909,18 +2900,59 @@ function initMcpApplyUnapplyGlobalClasses(server) {
|
|
|
2909
2900
|
|
|
2910
2901
|
**DO NOT use this tool** for:
|
|
2911
2902
|
- Elements that don't share styles with other elements (use inline styles instead)
|
|
2912
|
-
- Layout-specific properties (those should remain inline in stylesConfig)
|
|
2913
|
-
|
|
2914
|
-
|
|
2903
|
+
- Layout-specific properties (those should remain inline in stylesConfig)`
|
|
2904
|
+
);
|
|
2905
|
+
prompt.instruction(
|
|
2906
|
+
`## Prerequisites:
|
|
2915
2907
|
- **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
|
|
2916
2908
|
- **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
|
|
2917
2909
|
- Ensure you have the most up-to-date list of classes applied to the element to avoid duplicates
|
|
2918
|
-
- Make sure you have the correct class ID that you want to apply
|
|
2919
|
-
|
|
2920
|
-
|
|
2910
|
+
- Make sure you have the correct class ID that you want to apply`
|
|
2911
|
+
);
|
|
2912
|
+
prompt.instruction(
|
|
2913
|
+
`## Best Practices:
|
|
2921
2914
|
1. Apply multiple classes to a single element if needed (typography + color + spacing)
|
|
2922
2915
|
2. After applying, the tool will remind you to remove duplicate inline styles from elementConfig
|
|
2923
|
-
3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")
|
|
2916
|
+
3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`
|
|
2917
|
+
);
|
|
2918
|
+
return prompt.prompt();
|
|
2919
|
+
};
|
|
2920
|
+
|
|
2921
|
+
// src/mcp-integration/mcp-apply-unapply-global-classes.ts
|
|
2922
|
+
function initMcpApplyUnapplyGlobalClasses(server) {
|
|
2923
|
+
const { addTool, resource } = server;
|
|
2924
|
+
const applyGlobalClassGuideText = generateApplyGlobalClassGuidePrompt();
|
|
2925
|
+
resource(
|
|
2926
|
+
"apply-global-class-guide",
|
|
2927
|
+
APPLY_GLOBAL_CLASS_GUIDE_URI,
|
|
2928
|
+
{
|
|
2929
|
+
description: "Workflow, prerequisites, and best practices for apply-global-class",
|
|
2930
|
+
mimeType: "text/plain",
|
|
2931
|
+
title: "Apply global class tool guide"
|
|
2932
|
+
},
|
|
2933
|
+
async (uri) => ({
|
|
2934
|
+
contents: [{ mimeType: "text/plain", text: applyGlobalClassGuideText, uri: uri.href }]
|
|
2935
|
+
})
|
|
2936
|
+
);
|
|
2937
|
+
addTool({
|
|
2938
|
+
schema: {
|
|
2939
|
+
classId: import_schema.z.string().describe("The ID of the class to apply"),
|
|
2940
|
+
elementId: import_schema.z.string().describe("The ID of the element to which the class will be applied")
|
|
2941
|
+
},
|
|
2942
|
+
outputSchema: {
|
|
2943
|
+
result: import_schema.z.string().describe("Result message indicating the success of the apply operation"),
|
|
2944
|
+
llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!")
|
|
2945
|
+
},
|
|
2946
|
+
name: "apply-global-class",
|
|
2947
|
+
modelPreferences: {
|
|
2948
|
+
intelligencePriority: 0.7,
|
|
2949
|
+
speedPriority: 0.8
|
|
2950
|
+
},
|
|
2951
|
+
description: `Apply a global class to an element for shared design-system styling. Read the full guide at [${APPLY_GLOBAL_CLASS_GUIDE_URI}].`,
|
|
2952
|
+
requiredResources: [
|
|
2953
|
+
{ description: "Apply global class tool guide", uri: APPLY_GLOBAL_CLASS_GUIDE_URI },
|
|
2954
|
+
{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }
|
|
2955
|
+
],
|
|
2924
2956
|
handler: async (params) => {
|
|
2925
2957
|
const { classId, elementId } = params;
|
|
2926
2958
|
const appliedClasses = (0, import_editor_editing_panel.doGetAppliedClasses)(elementId);
|
|
@@ -2931,7 +2963,7 @@ function initMcpApplyUnapplyGlobalClasses(server) {
|
|
|
2931
2963
|
};
|
|
2932
2964
|
}
|
|
2933
2965
|
});
|
|
2934
|
-
|
|
2966
|
+
addTool({
|
|
2935
2967
|
name: "unapply-global-class",
|
|
2936
2968
|
schema: {
|
|
2937
2969
|
classId: import_schema.z.string().describe("The ID of the class to unapply"),
|
|
@@ -2944,21 +2976,8 @@ function initMcpApplyUnapplyGlobalClasses(server) {
|
|
|
2944
2976
|
intelligencePriority: 0.7,
|
|
2945
2977
|
speedPriority: 0.8
|
|
2946
2978
|
},
|
|
2947
|
-
description: `Unapply a
|
|
2948
|
-
|
|
2949
|
-
## When to use this tool:
|
|
2950
|
-
- When a user requests to unapply a global class or a class from an element in the Elementor editor.
|
|
2951
|
-
- When you need to remove a specific class from an element's applied classes.
|
|
2952
|
-
|
|
2953
|
-
## Prerequisites:
|
|
2954
|
-
- Ensure you have the most up-to-date list of classes applied to the element to avoid errors.
|
|
2955
|
-
The list is available at always up-to-date resource 'elementor://global-classes'.
|
|
2956
|
-
- Make sure you have the correct class ID that you want to unapply.
|
|
2957
|
-
|
|
2958
|
-
<note>
|
|
2959
|
-
If the user want to unapply a class by it's name and not ID, retrieve the id from the list, available at uri elementor://global-classes
|
|
2960
|
-
</note>
|
|
2961
|
-
`,
|
|
2979
|
+
description: `Unapply a global class from an element by class ID. Resolve class names to IDs via [${GLOBAL_CLASSES_URI}].`,
|
|
2980
|
+
requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
|
|
2962
2981
|
handler: async (params) => {
|
|
2963
2982
|
const { classId, elementId } = params;
|
|
2964
2983
|
const ok = (0, import_editor_editing_panel.doUnapplyClass)(elementId, classId);
|
|
@@ -2999,19 +3018,15 @@ function initMcpApplyGetGlobalClassUsages(reg) {
|
|
|
2999
3018
|
intelligencePriority: 0.6,
|
|
3000
3019
|
speedPriority: 0.8
|
|
3001
3020
|
},
|
|
3002
|
-
description: `Retrieve
|
|
3003
|
-
|
|
3004
|
-
## Prerequisites: CRITICAL
|
|
3005
|
-
- The list of global classes and their applid values is available at resource uri elementor://global-classes
|
|
3021
|
+
description: `Retrieve usages of global classes across all Elementor pages. Heavy operation \u2014 scans every page in the site.
|
|
3006
3022
|
|
|
3007
|
-
## When to use
|
|
3008
|
-
-
|
|
3009
|
-
-
|
|
3010
|
-
- Before deleting a global class, to ensure it is not in use in any other pages.
|
|
3023
|
+
## When to use:
|
|
3024
|
+
- Before deleting or radically changing a class \u2014 to understand cross-page side effects and decide whether to consult the user.
|
|
3025
|
+
- To identify unused global classes for cleanup.
|
|
3011
3026
|
|
|
3012
|
-
## When NOT to use
|
|
3013
|
-
-
|
|
3014
|
-
|
|
3027
|
+
## When NOT to use:
|
|
3028
|
+
- To list global classes themselves \u2014 use the global-classes resource instead (this tool returns usages, not the class list).`,
|
|
3029
|
+
requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
|
|
3015
3030
|
outputSchema: globalClassesUsageSchema,
|
|
3016
3031
|
handler: async () => {
|
|
3017
3032
|
const data = await fetchCssClassUsage();
|
|
@@ -3211,15 +3226,7 @@ var initManageGlobalClasses = (reg) => {
|
|
|
3211
3226
|
intelligencePriority: 0.85,
|
|
3212
3227
|
speedPriority: 0.6
|
|
3213
3228
|
},
|
|
3214
|
-
description: `
|
|
3215
|
-
|
|
3216
|
-
CREATE: Requires globalClassName, props. Use semantic naming (heading-primary, button-cta, text-muted). Check existing classes to avoid duplicates. ALWAYS create global classes BEFORE compositions for reusable styles.
|
|
3217
|
-
MODIFY: Requires classId, props. Get classId from [elementor://global-classes] resource.
|
|
3218
|
-
|
|
3219
|
-
Naming pattern: [element-type]-[purpose/variant]-[modifier]
|
|
3220
|
-
DO NOT create global classes for: one-off styles, layout-specific properties.
|
|
3221
|
-
|
|
3222
|
-
Use style schema at [elementor://styles/schema/{category}] for valid props. Errors include exact schema mismatch details.`,
|
|
3229
|
+
description: `Create or modify global classes for reusable design-system styling. Class names must reflect purpose (e.g. heading-primary, button-cta). Create classes BEFORE compositions. Do NOT create classes for one-off styles or layout-specific properties.`,
|
|
3223
3230
|
schema,
|
|
3224
3231
|
outputSchema,
|
|
3225
3232
|
handler
|
|
@@ -3309,16 +3316,6 @@ async function attemptDelete(opts) {
|
|
|
3309
3316
|
|
|
3310
3317
|
// src/mcp-integration/index.ts
|
|
3311
3318
|
var initMcpIntegration = (reg, canvasMcpEntry) => {
|
|
3312
|
-
const { setMCPDescription } = reg;
|
|
3313
|
-
setMCPDescription(
|
|
3314
|
-
`Everything related to V4 ( Atomic ) global classes.
|
|
3315
|
-
# Global classes
|
|
3316
|
-
- Create/update/delete global classes
|
|
3317
|
-
- Get list of global classes
|
|
3318
|
-
- Get details of a global class
|
|
3319
|
-
- Get details of a global class
|
|
3320
|
-
`
|
|
3321
|
-
);
|
|
3322
3319
|
initMcpApplyUnapplyGlobalClasses(reg);
|
|
3323
3320
|
initMcpApplyGetGlobalClassUsages(reg);
|
|
3324
3321
|
initManageGlobalClasses(reg);
|
|
@@ -3445,8 +3442,16 @@ function init() {
|
|
|
3445
3442
|
getThemeColor: (theme) => theme.palette.global.dark
|
|
3446
3443
|
});
|
|
3447
3444
|
initMcpIntegration(
|
|
3448
|
-
(0,
|
|
3449
|
-
|
|
3445
|
+
(0, import_editor_mcp2.getMCPByDomain)("classes", {
|
|
3446
|
+
instructions: "MCP server for management of Elementor global classes",
|
|
3447
|
+
docs: `Everything related to V4 ( Atomic ) global classes.
|
|
3448
|
+
# Global classes
|
|
3449
|
+
- Create/update/delete global classes
|
|
3450
|
+
- Get list of global classes
|
|
3451
|
+
- Get details of a global class
|
|
3452
|
+
`
|
|
3453
|
+
}),
|
|
3454
|
+
(0, import_editor_mcp2.getMCPByDomain)("canvas")
|
|
3450
3455
|
);
|
|
3451
3456
|
}
|
|
3452
3457
|
// Annotate the CommonJS export names for ESM import in node:
|