@elementor/editor-global-classes 4.2.0-840 → 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.mjs CHANGED
@@ -2937,24 +2937,15 @@ function PopulateStore() {
2937
2937
  // src/mcp-integration/mcp-apply-unapply-global-classes.ts
2938
2938
  import { doApplyClasses, doGetAppliedClasses, doUnapplyClass } from "@elementor/editor-editing-panel";
2939
2939
  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
2940
 
2957
- ## When to use this tool:
2941
+ // src/mcp-integration/apply-global-class-guide-prompt.ts
2942
+ import { toolPrompts } from "@elementor/editor-mcp";
2943
+ var APPLY_GLOBAL_CLASS_GUIDE_URI = "elementor://global-classes/tools/apply-global-class-guide";
2944
+ var generateApplyGlobalClassGuidePrompt = () => {
2945
+ const prompt = toolPrompts("apply-global-class");
2946
+ prompt.description("Apply a global class to an element, enabling consistent styling through your design system.");
2947
+ prompt.instruction(
2948
+ `## When to use this tool:
2958
2949
  **ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
2959
2950
  - After using "build-compositions" tool, apply semantic classes to the created elements
2960
2951
  - When applying consistent typography styles (heading-primary, text-body, etc.)
@@ -2963,18 +2954,59 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2963
2954
 
2964
2955
  **DO NOT use this tool** for:
2965
2956
  - 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:
2957
+ - Layout-specific properties (those should remain inline in stylesConfig)`
2958
+ );
2959
+ prompt.instruction(
2960
+ `## Prerequisites:
2969
2961
  - **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
2970
2962
  - **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
2971
2963
  - 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:
2964
+ - Make sure you have the correct class ID that you want to apply`
2965
+ );
2966
+ prompt.instruction(
2967
+ `## Best Practices:
2975
2968
  1. Apply multiple classes to a single element if needed (typography + color + spacing)
2976
2969
  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")`,
2970
+ 3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`
2971
+ );
2972
+ return prompt.prompt();
2973
+ };
2974
+
2975
+ // src/mcp-integration/mcp-apply-unapply-global-classes.ts
2976
+ function initMcpApplyUnapplyGlobalClasses(server) {
2977
+ const { addTool, resource } = server;
2978
+ const applyGlobalClassGuideText = generateApplyGlobalClassGuidePrompt();
2979
+ resource(
2980
+ "apply-global-class-guide",
2981
+ APPLY_GLOBAL_CLASS_GUIDE_URI,
2982
+ {
2983
+ description: "Workflow, prerequisites, and best practices for apply-global-class",
2984
+ mimeType: "text/plain",
2985
+ title: "Apply global class tool guide"
2986
+ },
2987
+ async (uri) => ({
2988
+ contents: [{ mimeType: "text/plain", text: applyGlobalClassGuideText, uri: uri.href }]
2989
+ })
2990
+ );
2991
+ addTool({
2992
+ schema: {
2993
+ classId: z.string().describe("The ID of the class to apply"),
2994
+ elementId: z.string().describe("The ID of the element to which the class will be applied")
2995
+ },
2996
+ outputSchema: {
2997
+ result: z.string().describe("Result message indicating the success of the apply operation"),
2998
+ llm_instructions: z.string().describe("Instructions what to do next, Important to follow these instructions!")
2999
+ },
3000
+ name: "apply-global-class",
3001
+ modelPreferences: {
3002
+ intelligencePriority: 0.7,
3003
+ speedPriority: 0.8
3004
+ },
3005
+ description: `Apply a global class to an element for shared design-system styling. Read the full guide at [${APPLY_GLOBAL_CLASS_GUIDE_URI}].`,
3006
+ requiredResources: [
3007
+ { description: "Apply global class tool guide", uri: APPLY_GLOBAL_CLASS_GUIDE_URI },
3008
+ { description: "Global classes list", uri: GLOBAL_CLASSES_URI }
3009
+ ],
2978
3010
  handler: async (params) => {
2979
3011
  const { classId, elementId } = params;
2980
3012
  const appliedClasses = doGetAppliedClasses(elementId);
@@ -2985,7 +3017,7 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2985
3017
  };
2986
3018
  }
2987
3019
  });
2988
- server.addTool({
3020
+ addTool({
2989
3021
  name: "unapply-global-class",
2990
3022
  schema: {
2991
3023
  classId: z.string().describe("The ID of the class to unapply"),
@@ -2998,21 +3030,8 @@ function initMcpApplyUnapplyGlobalClasses(server) {
2998
3030
  intelligencePriority: 0.7,
2999
3031
  speedPriority: 0.8
3000
3032
  },
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
- `,
3033
+ description: `Unapply a global class from an element by class ID. Resolve class names to IDs via [${GLOBAL_CLASSES_URI}].`,
3034
+ requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
3016
3035
  handler: async (params) => {
3017
3036
  const { classId, elementId } = params;
3018
3037
  const ok = doUnapplyClass(elementId, classId);
@@ -3053,19 +3072,15 @@ function initMcpApplyGetGlobalClassUsages(reg) {
3053
3072
  intelligencePriority: 0.6,
3054
3073
  speedPriority: 0.8
3055
3074
  },
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
3075
+ description: `Retrieve usages of global classes across all Elementor pages. Heavy operation \u2014 scans every page in the site.
3060
3076
 
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.
3077
+ ## When to use:
3078
+ - Before deleting or radically changing a class \u2014 to understand cross-page side effects and decide whether to consult the user.
3079
+ - To identify unused global classes for cleanup.
3065
3080
 
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
- `,
3081
+ ## When NOT to use:
3082
+ - To list global classes themselves \u2014 use the global-classes resource instead (this tool returns usages, not the class list).`,
3083
+ requiredResources: [{ description: "Global classes list", uri: GLOBAL_CLASSES_URI }],
3069
3084
  outputSchema: globalClassesUsageSchema,
3070
3085
  handler: async () => {
3071
3086
  const data = await fetchCssClassUsage();
@@ -3265,15 +3280,7 @@ var initManageGlobalClasses = (reg) => {
3265
3280
  intelligencePriority: 0.85,
3266
3281
  speedPriority: 0.6
3267
3282
  },
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.`,
3283
+ 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
3284
  schema,
3278
3285
  outputSchema,
3279
3286
  handler
@@ -3363,16 +3370,6 @@ async function attemptDelete(opts) {
3363
3370
 
3364
3371
  // src/mcp-integration/index.ts
3365
3372
  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
3373
  initMcpApplyUnapplyGlobalClasses(reg);
3377
3374
  initMcpApplyGetGlobalClassUsages(reg);
3378
3375
  initManageGlobalClasses(reg);
@@ -3499,7 +3496,15 @@ function init() {
3499
3496
  getThemeColor: (theme) => theme.palette.global.dark
3500
3497
  });
3501
3498
  initMcpIntegration(
3502
- getMCPByDomain("classes", { instructions: "MCP server for management of Elementor global classes" }),
3499
+ getMCPByDomain("classes", {
3500
+ instructions: "MCP server for management of Elementor global classes",
3501
+ docs: `Everything related to V4 ( Atomic ) global classes.
3502
+ # Global classes
3503
+ - Create/update/delete global classes
3504
+ - Get list of global classes
3505
+ - Get details of a global class
3506
+ `
3507
+ }),
3503
3508
  getMCPByDomain("canvas")
3504
3509
  );
3505
3510
  }