@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.mjs CHANGED
@@ -2882,7 +2882,9 @@ function GlobalStylesImportListener() {
2882
2882
  frontend: items
2883
2883
  })
2884
2884
  );
2885
+ return;
2885
2886
  }
2887
+ void loadCurrentDocumentClasses();
2886
2888
  };
2887
2889
  window.addEventListener(GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
2888
2890
  return () => {
@@ -2937,24 +2939,15 @@ function PopulateStore() {
2937
2939
  // src/mcp-integration/mcp-apply-unapply-global-classes.ts
2938
2940
  import { doApplyClasses, doGetAppliedClasses, doUnapplyClass } from "@elementor/editor-editing-panel";
2939
2941
  import { z } from "@elementor/schema";
2940
- function initMcpApplyUnapplyGlobalClasses(server) {
2941
- server.addTool({
2942
- schema: {
2943
- classId: z.string().describe("The ID of the class to apply"),
2944
- elementId: z.string().describe("The ID of the element to which the class will be applied")
2945
- },
2946
- outputSchema: {
2947
- result: z.string().describe("Result message indicating the success of the apply operation"),
2948
- llm_instructions: z.string().describe("Instructions what to do next, Important to follow these instructions!")
2949
- },
2950
- name: "apply-global-class",
2951
- modelPreferences: {
2952
- intelligencePriority: 0.7,
2953
- speedPriority: 0.8
2954
- },
2955
- description: `Apply a global class to an element, enabling consistent styling through your design system.
2956
2942
 
2957
- ## When to use this tool:
2943
+ // src/mcp-integration/apply-global-class-guide-prompt.ts
2944
+ import { toolPrompts } from "@elementor/editor-mcp";
2945
+ var APPLY_GLOBAL_CLASS_GUIDE_URI = "elementor://global-classes/tools/apply-global-class-guide";
2946
+ var generateApplyGlobalClassGuidePrompt = () => {
2947
+ const prompt = toolPrompts("apply-global-class");
2948
+ prompt.description("Apply a global class to an element, enabling consistent styling through your design system.");
2949
+ prompt.instruction(
2950
+ `## When to use this tool:
2958
2951
  **ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
2959
2952
  - After using "build-compositions" tool, apply semantic classes to the created elements
2960
2953
  - When applying consistent typography styles (heading-primary, text-body, etc.)
@@ -2963,18 +2956,59 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2963
2956
 
2964
2957
  **DO NOT use this tool** for:
2965
2958
  - Elements that don't share styles with other elements (use inline styles instead)
2966
- - Layout-specific properties (those should remain inline in stylesConfig)
2967
-
2968
- ## Prerequisites:
2959
+ - Layout-specific properties (those should remain inline in stylesConfig)`
2960
+ );
2961
+ prompt.instruction(
2962
+ `## Prerequisites:
2969
2963
  - **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
2970
2964
  - **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
2971
2965
  - Ensure you have the most up-to-date list of classes applied to the element to avoid duplicates
2972
- - Make sure you have the correct class ID that you want to apply
2973
-
2974
- ## Best Practices:
2966
+ - Make sure you have the correct class ID that you want to apply`
2967
+ );
2968
+ prompt.instruction(
2969
+ `## Best Practices:
2975
2970
  1. Apply multiple classes to a single element if needed (typography + color + spacing)
2976
2971
  2. After applying, the tool will remind you to remove duplicate inline styles from elementConfig
2977
- 3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`,
2972
+ 3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`
2973
+ );
2974
+ return prompt.prompt();
2975
+ };
2976
+
2977
+ // src/mcp-integration/mcp-apply-unapply-global-classes.ts
2978
+ function initMcpApplyUnapplyGlobalClasses(server) {
2979
+ const { addTool, resource } = server;
2980
+ const applyGlobalClassGuideText = generateApplyGlobalClassGuidePrompt();
2981
+ resource(
2982
+ "apply-global-class-guide",
2983
+ APPLY_GLOBAL_CLASS_GUIDE_URI,
2984
+ {
2985
+ description: "Workflow, prerequisites, and best practices for apply-global-class",
2986
+ mimeType: "text/plain",
2987
+ title: "Apply global class tool guide"
2988
+ },
2989
+ async (uri) => ({
2990
+ contents: [{ mimeType: "text/plain", text: applyGlobalClassGuideText, uri: uri.href }]
2991
+ })
2992
+ );
2993
+ addTool({
2994
+ schema: {
2995
+ classId: z.string().describe("The ID of the class to apply"),
2996
+ elementId: z.string().describe("The ID of the element to which the class will be applied")
2997
+ },
2998
+ outputSchema: {
2999
+ result: z.string().describe("Result message indicating the success of the apply operation"),
3000
+ llm_instructions: z.string().describe("Instructions what to do next, Important to follow these instructions!")
3001
+ },
3002
+ name: "apply-global-class",
3003
+ modelPreferences: {
3004
+ intelligencePriority: 0.7,
3005
+ speedPriority: 0.8
3006
+ },
3007
+ description: `Apply a global class to an element for shared design-system styling. Read the full guide at [${APPLY_GLOBAL_CLASS_GUIDE_URI}].`,
3008
+ requiredResources: [
3009
+ { description: "Apply global class tool guide", uri: APPLY_GLOBAL_CLASS_GUIDE_URI },
3010
+ { description: "Global classes list", uri: GLOBAL_CLASSES_URI }
3011
+ ],
2978
3012
  handler: async (params) => {
2979
3013
  const { classId, elementId } = params;
2980
3014
  const appliedClasses = doGetAppliedClasses(elementId);
@@ -2985,7 +3019,7 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2985
3019
  };
2986
3020
  }
2987
3021
  });
2988
- server.addTool({
3022
+ addTool({
2989
3023
  name: "unapply-global-class",
2990
3024
  schema: {
2991
3025
  classId: z.string().describe("The ID of the class to unapply"),
@@ -2998,21 +3032,8 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2998
3032
  intelligencePriority: 0.7,
2999
3033
  speedPriority: 0.8
3000
3034
  },
3001
- description: `Unapply a (global) class from the current element
3002
-
3003
- ## When to use this tool:
3004
- - When a user requests to unapply a global class or a class from an element in the Elementor editor.
3005
- - When you need to remove a specific class from an element's applied classes.
3006
-
3007
- ## Prerequisites:
3008
- - Ensure you have the most up-to-date list of classes applied to the element to avoid errors.
3009
- The list is available at always up-to-date resource 'elementor://global-classes'.
3010
- - Make sure you have the correct class ID that you want to unapply.
3011
-
3012
- <note>
3013
- 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
3014
- </note>
3015
- `,
3035
+ description: `Unapply a global class from an element by class ID. Resolve class names to IDs via [${GLOBAL_CLASSES_URI}].`,
3036
+ requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
3016
3037
  handler: async (params) => {
3017
3038
  const { classId, elementId } = params;
3018
3039
  const ok = doUnapplyClass(elementId, classId);
@@ -3053,19 +3074,15 @@ function initMcpApplyGetGlobalClassUsages(reg) {
3053
3074
  intelligencePriority: 0.6,
3054
3075
  speedPriority: 0.8
3055
3076
  },
3056
- description: `Retrieve the usages of global-classes ACROSS PAGES designed by Elementor editor.
3057
-
3058
- ## Prerequisites: CRITICAL
3059
- - The list of global classes and their applid values is available at resource uri elementor://global-classes
3077
+ description: `Retrieve usages of global classes across all Elementor pages. Heavy operation \u2014 scans every page in the site.
3060
3078
 
3061
- ## When to use this tool:
3062
- - When a user requests to see where a specific global class is being used across the site.
3063
- - When you need to manage or clean up unused global classes.
3064
- - Before deleting a global class, to ensure it is not in use in any other pages.
3079
+ ## When to use:
3080
+ - Before deleting or radically changing a class \u2014 to understand cross-page side effects and decide whether to consult the user.
3081
+ - To identify unused global classes for cleanup.
3065
3082
 
3066
- ## When NOT to use this tool:
3067
- - For getting the list of global classes, refer to the resource at uri elementor://global-classes
3068
- `,
3083
+ ## When NOT to use:
3084
+ - To list global classes themselves \u2014 use the global-classes resource instead (this tool returns usages, not the class list).`,
3085
+ requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
3069
3086
  outputSchema: globalClassesUsageSchema,
3070
3087
  handler: async () => {
3071
3088
  const data = await fetchCssClassUsage();
@@ -3265,15 +3282,7 @@ var initManageGlobalClasses = (reg) => {
3265
3282
  intelligencePriority: 0.85,
3266
3283
  speedPriority: 0.6
3267
3284
  },
3268
- description: `Manages global classes (create/modify) in Elementor editor. Check [elementor://global-classes] and style schemas first.
3269
-
3270
- 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.
3271
- MODIFY: Requires classId, props. Get classId from [elementor://global-classes] resource.
3272
-
3273
- Naming pattern: [element-type]-[purpose/variant]-[modifier]
3274
- DO NOT create global classes for: one-off styles, layout-specific properties.
3275
-
3276
- Use style schema at [elementor://styles/schema/{category}] for valid props. Errors include exact schema mismatch details.`,
3285
+ 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.`,
3277
3286
  schema,
3278
3287
  outputSchema,
3279
3288
  handler
@@ -3363,16 +3372,6 @@ async function attemptDelete(opts) {
3363
3372
 
3364
3373
  // src/mcp-integration/index.ts
3365
3374
  var initMcpIntegration = (reg, canvasMcpEntry) => {
3366
- const { setMCPDescription } = reg;
3367
- setMCPDescription(
3368
- `Everything related to V4 ( Atomic ) global classes.
3369
- # Global classes
3370
- - Create/update/delete global classes
3371
- - Get list of global classes
3372
- - Get details of a global class
3373
- - Get details of a global class
3374
- `
3375
- );
3376
3375
  initMcpApplyUnapplyGlobalClasses(reg);
3377
3376
  initMcpApplyGetGlobalClassUsages(reg);
3378
3377
  initManageGlobalClasses(reg);
@@ -3499,7 +3498,15 @@ function init() {
3499
3498
  getThemeColor: (theme) => theme.palette.global.dark
3500
3499
  });
3501
3500
  initMcpIntegration(
3502
- getMCPByDomain("classes", { instructions: "MCP server for management of Elementor global classes" }),
3501
+ getMCPByDomain("classes", {
3502
+ instructions: "MCP server for management of Elementor global classes",
3503
+ docs: `Everything related to V4 ( Atomic ) global classes.
3504
+ # Global classes
3505
+ - Create/update/delete global classes
3506
+ - Get list of global classes
3507
+ - Get details of a global class
3508
+ `
3509
+ }),
3503
3510
  getMCPByDomain("canvas")
3504
3511
  );
3505
3512
  }