@elementor/editor-global-classes 4.1.0-838 → 4.1.0-beta1
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 +88 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/components/global-styles-import-listener.tsx +4 -15
- 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/src/save-global-classes.tsx +4 -1
package/dist/index.js
CHANGED
|
@@ -844,10 +844,12 @@ function calculateChanges(state, initialData) {
|
|
|
844
844
|
const initialDataIds = Object.keys(initialData.items);
|
|
845
845
|
const { order: stateOrder } = state;
|
|
846
846
|
const { order: initialDataOrder } = initialData;
|
|
847
|
+
const stateOrderIdSet = new Set(stateOrder);
|
|
848
|
+
const deleted = initialDataOrder.filter((id2) => !stateOrderIdSet.has(id2));
|
|
847
849
|
const order = stateOrder.join(";") !== initialDataOrder.join(";");
|
|
848
850
|
return {
|
|
849
851
|
added: stateIds.filter((id2) => !initialDataIds.includes(id2)),
|
|
850
|
-
deleted
|
|
852
|
+
deleted,
|
|
851
853
|
modified: stateIds.filter((id2) => {
|
|
852
854
|
return id2 in initialData.items && (0, import_utils4.hash)(state.items[id2]) !== (0, import_utils4.hash)(initialData.items[id2]);
|
|
853
855
|
}),
|
|
@@ -2666,11 +2668,11 @@ var initClassesResource = (classesMcpEntry, canvasMcpEntry) => {
|
|
|
2666
2668
|
// src/init.ts
|
|
2667
2669
|
var import_editor = require("@elementor/editor");
|
|
2668
2670
|
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
2669
|
-
var
|
|
2671
|
+
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
2670
2672
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
2671
2673
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
2672
2674
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
2673
|
-
var
|
|
2675
|
+
var import_store31 = require("@elementor/store");
|
|
2674
2676
|
|
|
2675
2677
|
// src/components/class-manager/class-manager-button.tsx
|
|
2676
2678
|
var React20 = __toESM(require("react"));
|
|
@@ -2818,17 +2820,8 @@ var import_store28 = require("@elementor/store");
|
|
|
2818
2820
|
function GlobalStylesImportListener() {
|
|
2819
2821
|
const dispatch7 = (0, import_store28.__useDispatch)();
|
|
2820
2822
|
(0, import_react11.useEffect)(() => {
|
|
2821
|
-
const handleGlobalStylesImported = (
|
|
2822
|
-
|
|
2823
|
-
if (importedClasses?.items && importedClasses?.order) {
|
|
2824
|
-
const { items } = importedClasses;
|
|
2825
|
-
dispatch7(
|
|
2826
|
-
slice.actions.mergeExistingClasses({
|
|
2827
|
-
preview: items,
|
|
2828
|
-
frontend: items
|
|
2829
|
-
})
|
|
2830
|
-
);
|
|
2831
|
-
}
|
|
2823
|
+
const handleGlobalStylesImported = () => {
|
|
2824
|
+
loadCurrentDocumentClasses();
|
|
2832
2825
|
};
|
|
2833
2826
|
window.addEventListener(import_editor_canvas.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2834
2827
|
return () => {
|
|
@@ -2883,24 +2876,15 @@ function PopulateStore() {
|
|
|
2883
2876
|
// src/mcp-integration/mcp-apply-unapply-global-classes.ts
|
|
2884
2877
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
2885
2878
|
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
2879
|
|
|
2903
|
-
|
|
2880
|
+
// src/mcp-integration/apply-global-class-guide-prompt.ts
|
|
2881
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2882
|
+
var APPLY_GLOBAL_CLASS_GUIDE_URI = "elementor://global-classes/tools/apply-global-class-guide";
|
|
2883
|
+
var generateApplyGlobalClassGuidePrompt = () => {
|
|
2884
|
+
const prompt = (0, import_editor_mcp.toolPrompts)("apply-global-class");
|
|
2885
|
+
prompt.description("Apply a global class to an element, enabling consistent styling through your design system.");
|
|
2886
|
+
prompt.instruction(
|
|
2887
|
+
`## When to use this tool:
|
|
2904
2888
|
**ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
|
|
2905
2889
|
- After using "build-compositions" tool, apply semantic classes to the created elements
|
|
2906
2890
|
- When applying consistent typography styles (heading-primary, text-body, etc.)
|
|
@@ -2909,18 +2893,59 @@ function initMcpApplyUnapplyGlobalClasses(server) {
|
|
|
2909
2893
|
|
|
2910
2894
|
**DO NOT use this tool** for:
|
|
2911
2895
|
- 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
|
-
|
|
2896
|
+
- Layout-specific properties (those should remain inline in stylesConfig)`
|
|
2897
|
+
);
|
|
2898
|
+
prompt.instruction(
|
|
2899
|
+
`## Prerequisites:
|
|
2915
2900
|
- **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
|
|
2916
2901
|
- **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
|
|
2917
2902
|
- 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
|
-
|
|
2903
|
+
- Make sure you have the correct class ID that you want to apply`
|
|
2904
|
+
);
|
|
2905
|
+
prompt.instruction(
|
|
2906
|
+
`## Best Practices:
|
|
2921
2907
|
1. Apply multiple classes to a single element if needed (typography + color + spacing)
|
|
2922
2908
|
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")
|
|
2909
|
+
3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`
|
|
2910
|
+
);
|
|
2911
|
+
return prompt.prompt();
|
|
2912
|
+
};
|
|
2913
|
+
|
|
2914
|
+
// src/mcp-integration/mcp-apply-unapply-global-classes.ts
|
|
2915
|
+
function initMcpApplyUnapplyGlobalClasses(server) {
|
|
2916
|
+
const { addTool, resource } = server;
|
|
2917
|
+
const applyGlobalClassGuideText = generateApplyGlobalClassGuidePrompt();
|
|
2918
|
+
resource(
|
|
2919
|
+
"apply-global-class-guide",
|
|
2920
|
+
APPLY_GLOBAL_CLASS_GUIDE_URI,
|
|
2921
|
+
{
|
|
2922
|
+
description: "Workflow, prerequisites, and best practices for apply-global-class",
|
|
2923
|
+
mimeType: "text/plain",
|
|
2924
|
+
title: "Apply global class tool guide"
|
|
2925
|
+
},
|
|
2926
|
+
async (uri) => ({
|
|
2927
|
+
contents: [{ mimeType: "text/plain", text: applyGlobalClassGuideText, uri: uri.href }]
|
|
2928
|
+
})
|
|
2929
|
+
);
|
|
2930
|
+
addTool({
|
|
2931
|
+
schema: {
|
|
2932
|
+
classId: import_schema.z.string().describe("The ID of the class to apply"),
|
|
2933
|
+
elementId: import_schema.z.string().describe("The ID of the element to which the class will be applied")
|
|
2934
|
+
},
|
|
2935
|
+
outputSchema: {
|
|
2936
|
+
result: import_schema.z.string().describe("Result message indicating the success of the apply operation"),
|
|
2937
|
+
llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!")
|
|
2938
|
+
},
|
|
2939
|
+
name: "apply-global-class",
|
|
2940
|
+
modelPreferences: {
|
|
2941
|
+
intelligencePriority: 0.7,
|
|
2942
|
+
speedPriority: 0.8
|
|
2943
|
+
},
|
|
2944
|
+
description: `Apply a global class to an element for shared design-system styling. Read the full guide at [${APPLY_GLOBAL_CLASS_GUIDE_URI}].`,
|
|
2945
|
+
requiredResources: [
|
|
2946
|
+
{ description: "Apply global class tool guide", uri: APPLY_GLOBAL_CLASS_GUIDE_URI },
|
|
2947
|
+
{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }
|
|
2948
|
+
],
|
|
2924
2949
|
handler: async (params) => {
|
|
2925
2950
|
const { classId, elementId } = params;
|
|
2926
2951
|
const appliedClasses = (0, import_editor_editing_panel.doGetAppliedClasses)(elementId);
|
|
@@ -2931,7 +2956,7 @@ function initMcpApplyUnapplyGlobalClasses(server) {
|
|
|
2931
2956
|
};
|
|
2932
2957
|
}
|
|
2933
2958
|
});
|
|
2934
|
-
|
|
2959
|
+
addTool({
|
|
2935
2960
|
name: "unapply-global-class",
|
|
2936
2961
|
schema: {
|
|
2937
2962
|
classId: import_schema.z.string().describe("The ID of the class to unapply"),
|
|
@@ -2944,21 +2969,8 @@ function initMcpApplyUnapplyGlobalClasses(server) {
|
|
|
2944
2969
|
intelligencePriority: 0.7,
|
|
2945
2970
|
speedPriority: 0.8
|
|
2946
2971
|
},
|
|
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
|
-
`,
|
|
2972
|
+
description: `Unapply a global class from an element by class ID. Resolve class names to IDs via [${GLOBAL_CLASSES_URI}].`,
|
|
2973
|
+
requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
|
|
2962
2974
|
handler: async (params) => {
|
|
2963
2975
|
const { classId, elementId } = params;
|
|
2964
2976
|
const ok = (0, import_editor_editing_panel.doUnapplyClass)(elementId, classId);
|
|
@@ -2999,19 +3011,15 @@ function initMcpApplyGetGlobalClassUsages(reg) {
|
|
|
2999
3011
|
intelligencePriority: 0.6,
|
|
3000
3012
|
speedPriority: 0.8
|
|
3001
3013
|
},
|
|
3002
|
-
description: `Retrieve
|
|
3014
|
+
description: `Retrieve usages of global classes across all Elementor pages. Heavy operation \u2014 scans every page in the site.
|
|
3003
3015
|
|
|
3004
|
-
##
|
|
3005
|
-
-
|
|
3016
|
+
## When to use:
|
|
3017
|
+
- Before deleting or radically changing a class \u2014 to understand cross-page side effects and decide whether to consult the user.
|
|
3018
|
+
- To identify unused global classes for cleanup.
|
|
3006
3019
|
|
|
3007
|
-
## When to use
|
|
3008
|
-
-
|
|
3009
|
-
|
|
3010
|
-
- Before deleting a global class, to ensure it is not in use in any other pages.
|
|
3011
|
-
|
|
3012
|
-
## When NOT to use this tool:
|
|
3013
|
-
- For getting the list of global classes, refer to the resource at uri elementor://global-classes
|
|
3014
|
-
`,
|
|
3020
|
+
## When NOT to use:
|
|
3021
|
+
- To list global classes themselves \u2014 use the global-classes resource instead (this tool returns usages, not the class list).`,
|
|
3022
|
+
requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
|
|
3015
3023
|
outputSchema: globalClassesUsageSchema,
|
|
3016
3024
|
handler: async () => {
|
|
3017
3025
|
const data = await fetchCssClassUsage();
|
|
@@ -3211,15 +3219,7 @@ var initManageGlobalClasses = (reg) => {
|
|
|
3211
3219
|
intelligencePriority: 0.85,
|
|
3212
3220
|
speedPriority: 0.6
|
|
3213
3221
|
},
|
|
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.`,
|
|
3222
|
+
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
3223
|
schema,
|
|
3224
3224
|
outputSchema,
|
|
3225
3225
|
handler
|
|
@@ -3309,16 +3309,6 @@ async function attemptDelete(opts) {
|
|
|
3309
3309
|
|
|
3310
3310
|
// src/mcp-integration/index.ts
|
|
3311
3311
|
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
3312
|
initMcpApplyUnapplyGlobalClasses(reg);
|
|
3323
3313
|
initMcpApplyGetGlobalClassUsages(reg);
|
|
3324
3314
|
initManageGlobalClasses(reg);
|
|
@@ -3333,7 +3323,7 @@ var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
|
3333
3323
|
var import_editor_current_user3 = require("@elementor/editor-current-user");
|
|
3334
3324
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
3335
3325
|
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
3336
|
-
var
|
|
3326
|
+
var import_store29 = require("@elementor/store");
|
|
3337
3327
|
var pendingSave = null;
|
|
3338
3328
|
function syncWithDocumentSave(panelActions) {
|
|
3339
3329
|
const unsubscribe = syncDirtyState();
|
|
@@ -3342,7 +3332,7 @@ function syncWithDocumentSave(panelActions) {
|
|
|
3342
3332
|
return unsubscribe;
|
|
3343
3333
|
}
|
|
3344
3334
|
function syncDirtyState() {
|
|
3345
|
-
return (0,
|
|
3335
|
+
return (0, import_store29.__subscribeWithSelector)(selectIsDirty, () => {
|
|
3346
3336
|
if (!isDirty()) {
|
|
3347
3337
|
return;
|
|
3348
3338
|
}
|
|
@@ -3385,7 +3375,7 @@ function bindBeforeSaveTemplateAction() {
|
|
|
3385
3375
|
}));
|
|
3386
3376
|
}
|
|
3387
3377
|
function isDirty() {
|
|
3388
|
-
return selectIsDirty((0,
|
|
3378
|
+
return selectIsDirty((0, import_store29.__getState)());
|
|
3389
3379
|
}
|
|
3390
3380
|
|
|
3391
3381
|
// src/sync-with-document.tsx
|
|
@@ -3405,7 +3395,7 @@ function SyncWithDocumentSave() {
|
|
|
3405
3395
|
|
|
3406
3396
|
// src/init.ts
|
|
3407
3397
|
function init() {
|
|
3408
|
-
(0,
|
|
3398
|
+
(0, import_store31.__registerSlice)(slice);
|
|
3409
3399
|
if (!(0, import_editor_v1_adapters8.isExperimentActive)("e_editor_design_system_panel")) {
|
|
3410
3400
|
(0, import_editor_panels2.__registerPanel)(panel);
|
|
3411
3401
|
}
|
|
@@ -3445,8 +3435,16 @@ function init() {
|
|
|
3445
3435
|
getThemeColor: (theme) => theme.palette.global.dark
|
|
3446
3436
|
});
|
|
3447
3437
|
initMcpIntegration(
|
|
3448
|
-
(0,
|
|
3449
|
-
|
|
3438
|
+
(0, import_editor_mcp2.getMCPByDomain)("classes", {
|
|
3439
|
+
instructions: "MCP server for management of Elementor global classes",
|
|
3440
|
+
docs: `Everything related to V4 ( Atomic ) global classes.
|
|
3441
|
+
# Global classes
|
|
3442
|
+
- Create/update/delete global classes
|
|
3443
|
+
- Get list of global classes
|
|
3444
|
+
- Get details of a global class
|
|
3445
|
+
`
|
|
3446
|
+
}),
|
|
3447
|
+
(0, import_editor_mcp2.getMCPByDomain)("canvas")
|
|
3450
3448
|
);
|
|
3451
3449
|
}
|
|
3452
3450
|
// Annotate the CommonJS export names for ESM import in node:
|