@elementor/editor-global-classes 4.2.0-841 → 4.2.0-843

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 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 import_editor_mcp = require("@elementor/editor-mcp");
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");
@@ -2828,7 +2828,9 @@ function GlobalStylesImportListener() {
2828
2828
  frontend: items
2829
2829
  })
2830
2830
  );
2831
+ return;
2831
2832
  }
2833
+ void loadCurrentDocumentClasses();
2832
2834
  };
2833
2835
  window.addEventListener(import_editor_canvas.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
2834
2836
  return () => {
@@ -2883,24 +2885,15 @@ function PopulateStore() {
2883
2885
  // src/mcp-integration/mcp-apply-unapply-global-classes.ts
2884
2886
  var import_editor_editing_panel = require("@elementor/editor-editing-panel");
2885
2887
  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
2888
 
2903
- ## When to use this tool:
2889
+ // src/mcp-integration/apply-global-class-guide-prompt.ts
2890
+ var import_editor_mcp = require("@elementor/editor-mcp");
2891
+ var APPLY_GLOBAL_CLASS_GUIDE_URI = "elementor://global-classes/tools/apply-global-class-guide";
2892
+ var generateApplyGlobalClassGuidePrompt = () => {
2893
+ const prompt = (0, import_editor_mcp.toolPrompts)("apply-global-class");
2894
+ prompt.description("Apply a global class to an element, enabling consistent styling through your design system.");
2895
+ prompt.instruction(
2896
+ `## When to use this tool:
2904
2897
  **ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
2905
2898
  - After using "build-compositions" tool, apply semantic classes to the created elements
2906
2899
  - When applying consistent typography styles (heading-primary, text-body, etc.)
@@ -2909,18 +2902,59 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2909
2902
 
2910
2903
  **DO NOT use this tool** for:
2911
2904
  - 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
- ## Prerequisites:
2905
+ - Layout-specific properties (those should remain inline in stylesConfig)`
2906
+ );
2907
+ prompt.instruction(
2908
+ `## Prerequisites:
2915
2909
  - **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
2916
2910
  - **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
2917
2911
  - 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
- ## Best Practices:
2912
+ - Make sure you have the correct class ID that you want to apply`
2913
+ );
2914
+ prompt.instruction(
2915
+ `## Best Practices:
2921
2916
  1. Apply multiple classes to a single element if needed (typography + color + spacing)
2922
2917
  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")`,
2918
+ 3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`
2919
+ );
2920
+ return prompt.prompt();
2921
+ };
2922
+
2923
+ // src/mcp-integration/mcp-apply-unapply-global-classes.ts
2924
+ function initMcpApplyUnapplyGlobalClasses(server) {
2925
+ const { addTool, resource } = server;
2926
+ const applyGlobalClassGuideText = generateApplyGlobalClassGuidePrompt();
2927
+ resource(
2928
+ "apply-global-class-guide",
2929
+ APPLY_GLOBAL_CLASS_GUIDE_URI,
2930
+ {
2931
+ description: "Workflow, prerequisites, and best practices for apply-global-class",
2932
+ mimeType: "text/plain",
2933
+ title: "Apply global class tool guide"
2934
+ },
2935
+ async (uri) => ({
2936
+ contents: [{ mimeType: "text/plain", text: applyGlobalClassGuideText, uri: uri.href }]
2937
+ })
2938
+ );
2939
+ addTool({
2940
+ schema: {
2941
+ classId: import_schema.z.string().describe("The ID of the class to apply"),
2942
+ elementId: import_schema.z.string().describe("The ID of the element to which the class will be applied")
2943
+ },
2944
+ outputSchema: {
2945
+ result: import_schema.z.string().describe("Result message indicating the success of the apply operation"),
2946
+ llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!")
2947
+ },
2948
+ name: "apply-global-class",
2949
+ modelPreferences: {
2950
+ intelligencePriority: 0.7,
2951
+ speedPriority: 0.8
2952
+ },
2953
+ description: `Apply a global class to an element for shared design-system styling. Read the full guide at [${APPLY_GLOBAL_CLASS_GUIDE_URI}].`,
2954
+ requiredResources: [
2955
+ { description: "Apply global class tool guide", uri: APPLY_GLOBAL_CLASS_GUIDE_URI },
2956
+ { description: "Global classes list", uri: GLOBAL_CLASSES_URI }
2957
+ ],
2924
2958
  handler: async (params) => {
2925
2959
  const { classId, elementId } = params;
2926
2960
  const appliedClasses = (0, import_editor_editing_panel.doGetAppliedClasses)(elementId);
@@ -2931,7 +2965,7 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2931
2965
  };
2932
2966
  }
2933
2967
  });
2934
- server.addTool({
2968
+ addTool({
2935
2969
  name: "unapply-global-class",
2936
2970
  schema: {
2937
2971
  classId: import_schema.z.string().describe("The ID of the class to unapply"),
@@ -2944,21 +2978,8 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2944
2978
  intelligencePriority: 0.7,
2945
2979
  speedPriority: 0.8
2946
2980
  },
2947
- description: `Unapply a (global) class from the current element
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
- `,
2981
+ description: `Unapply a global class from an element by class ID. Resolve class names to IDs via [${GLOBAL_CLASSES_URI}].`,
2982
+ requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
2962
2983
  handler: async (params) => {
2963
2984
  const { classId, elementId } = params;
2964
2985
  const ok = (0, import_editor_editing_panel.doUnapplyClass)(elementId, classId);
@@ -2999,19 +3020,15 @@ function initMcpApplyGetGlobalClassUsages(reg) {
2999
3020
  intelligencePriority: 0.6,
3000
3021
  speedPriority: 0.8
3001
3022
  },
3002
- description: `Retrieve the usages of global-classes ACROSS PAGES designed by Elementor editor.
3003
-
3004
- ## Prerequisites: CRITICAL
3005
- - The list of global classes and their applid values is available at resource uri elementor://global-classes
3023
+ description: `Retrieve usages of global classes across all Elementor pages. Heavy operation \u2014 scans every page in the site.
3006
3024
 
3007
- ## When to use this tool:
3008
- - When a user requests to see where a specific global class is being used across the site.
3009
- - When you need to manage or clean up unused global classes.
3010
- - Before deleting a global class, to ensure it is not in use in any other pages.
3025
+ ## When to use:
3026
+ - Before deleting or radically changing a class \u2014 to understand cross-page side effects and decide whether to consult the user.
3027
+ - To identify unused global classes for cleanup.
3011
3028
 
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
- `,
3029
+ ## When NOT to use:
3030
+ - To list global classes themselves \u2014 use the global-classes resource instead (this tool returns usages, not the class list).`,
3031
+ requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
3015
3032
  outputSchema: globalClassesUsageSchema,
3016
3033
  handler: async () => {
3017
3034
  const data = await fetchCssClassUsage();
@@ -3211,15 +3228,7 @@ var initManageGlobalClasses = (reg) => {
3211
3228
  intelligencePriority: 0.85,
3212
3229
  speedPriority: 0.6
3213
3230
  },
3214
- description: `Manages global classes (create/modify) in Elementor editor. Check [elementor://global-classes] and style schemas first.
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.`,
3231
+ 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
3232
  schema,
3224
3233
  outputSchema,
3225
3234
  handler
@@ -3309,16 +3318,6 @@ async function attemptDelete(opts) {
3309
3318
 
3310
3319
  // src/mcp-integration/index.ts
3311
3320
  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
3321
  initMcpApplyUnapplyGlobalClasses(reg);
3323
3322
  initMcpApplyGetGlobalClassUsages(reg);
3324
3323
  initManageGlobalClasses(reg);
@@ -3445,8 +3444,16 @@ function init() {
3445
3444
  getThemeColor: (theme) => theme.palette.global.dark
3446
3445
  });
3447
3446
  initMcpIntegration(
3448
- (0, import_editor_mcp.getMCPByDomain)("classes", { instructions: "MCP server for management of Elementor global classes" }),
3449
- (0, import_editor_mcp.getMCPByDomain)("canvas")
3447
+ (0, import_editor_mcp2.getMCPByDomain)("classes", {
3448
+ instructions: "MCP server for management of Elementor global classes",
3449
+ docs: `Everything related to V4 ( Atomic ) global classes.
3450
+ # Global classes
3451
+ - Create/update/delete global classes
3452
+ - Get list of global classes
3453
+ - Get details of a global class
3454
+ `
3455
+ }),
3456
+ (0, import_editor_mcp2.getMCPByDomain)("canvas")
3450
3457
  );
3451
3458
  }
3452
3459
  // Annotate the CommonJS export names for ESM import in node: