@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-global-classes",
3
- "version": "4.2.0-841",
3
+ "version": "4.2.0-843",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,29 +39,29 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.2.0-841",
43
- "@elementor/editor-current-user": "4.2.0-841",
44
- "@elementor/editor-documents": "4.2.0-841",
45
- "@elementor/editor-editing-panel": "4.2.0-841",
46
- "@elementor/editor-mcp": "4.2.0-841",
47
- "@elementor/editor-panels": "4.2.0-841",
48
- "@elementor/editor-props": "4.2.0-841",
49
- "@elementor/editor-variables": "4.2.0-841",
50
- "@elementor/editor-styles": "4.2.0-841",
51
- "@elementor/editor-canvas": "4.2.0-841",
52
- "@elementor/editor-styles-repository": "4.2.0-841",
53
- "@elementor/editor-ui": "4.2.0-841",
54
- "@elementor/editor-v1-adapters": "4.2.0-841",
55
- "@elementor/http-client": "4.2.0-841",
42
+ "@elementor/editor": "4.2.0-843",
43
+ "@elementor/editor-current-user": "4.2.0-843",
44
+ "@elementor/editor-documents": "4.2.0-843",
45
+ "@elementor/editor-editing-panel": "4.2.0-843",
46
+ "@elementor/editor-mcp": "4.2.0-843",
47
+ "@elementor/editor-panels": "4.2.0-843",
48
+ "@elementor/editor-props": "4.2.0-843",
49
+ "@elementor/editor-variables": "4.2.0-843",
50
+ "@elementor/editor-styles": "4.2.0-843",
51
+ "@elementor/editor-canvas": "4.2.0-843",
52
+ "@elementor/editor-styles-repository": "4.2.0-843",
53
+ "@elementor/editor-ui": "4.2.0-843",
54
+ "@elementor/editor-v1-adapters": "4.2.0-843",
55
+ "@elementor/http-client": "4.2.0-843",
56
56
  "@elementor/icons": "~1.75.1",
57
- "@elementor/query": "4.2.0-841",
58
- "@elementor/schema": "4.2.0-841",
59
- "@elementor/store": "4.2.0-841",
57
+ "@elementor/query": "4.2.0-843",
58
+ "@elementor/schema": "4.2.0-843",
59
+ "@elementor/store": "4.2.0-843",
60
60
  "@elementor/ui": "1.37.5",
61
- "@elementor/utils": "4.2.0-841",
61
+ "@elementor/utils": "4.2.0-843",
62
62
  "@tanstack/react-virtual": "^3.13.24",
63
63
  "@wordpress/i18n": "^5.13.0",
64
- "@elementor/events": "4.2.0-841"
64
+ "@elementor/events": "4.2.0-843"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^18.3.1",
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
2
2
  import { GLOBAL_STYLES_IMPORTED_EVENT, type ImportedGlobalStylesPayload } from '@elementor/editor-canvas';
3
3
  import { __useDispatch as useDispatch } from '@elementor/store';
4
4
 
5
+ import { loadCurrentDocumentClasses } from '../load-document-classes';
5
6
  import { slice } from '../store';
6
7
 
7
8
  export function GlobalStylesImportListener() {
@@ -20,7 +21,11 @@ export function GlobalStylesImportListener() {
20
21
  frontend: items,
21
22
  } )
22
23
  );
24
+
25
+ return;
23
26
  }
27
+
28
+ void loadCurrentDocumentClasses();
24
29
  };
25
30
 
26
31
  window.addEventListener( GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported as EventListener );
package/src/init.ts CHANGED
@@ -74,7 +74,15 @@ export function init() {
74
74
  } );
75
75
 
76
76
  initMcpIntegration(
77
- getMCPByDomain( 'classes', { instructions: 'MCP server for management of Elementor global classes' } ),
77
+ getMCPByDomain( 'classes', {
78
+ instructions: 'MCP server for management of Elementor global classes',
79
+ docs: `Everything related to V4 ( Atomic ) global classes.
80
+ # Global classes
81
+ - Create/update/delete global classes
82
+ - Get list of global classes
83
+ - Get details of a global class
84
+ `,
85
+ } ),
78
86
  getMCPByDomain( 'canvas' )
79
87
  );
80
88
  }
@@ -0,0 +1,39 @@
1
+ import { toolPrompts } from '@elementor/editor-mcp';
2
+
3
+ export const APPLY_GLOBAL_CLASS_GUIDE_URI = 'elementor://global-classes/tools/apply-global-class-guide';
4
+
5
+ export const generateApplyGlobalClassGuidePrompt = () => {
6
+ const prompt = toolPrompts( 'apply-global-class' );
7
+
8
+ prompt.description( 'Apply a global class to an element, enabling consistent styling through your design system.' );
9
+
10
+ prompt.instruction(
11
+ `## When to use this tool:
12
+ **ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
13
+ - After using "build-compositions" tool, apply semantic classes to the created elements
14
+ - When applying consistent typography styles (heading-primary, text-body, etc.)
15
+ - When applying theme colors or brand styles (bg-brand, button-cta, etc.)
16
+ - When ensuring spacing consistency (spacing-section-large, etc.)
17
+
18
+ **DO NOT use this tool** for:
19
+ - Elements that don't share styles with other elements (use inline styles instead)
20
+ - Layout-specific properties (those should remain inline in stylesConfig)`
21
+ );
22
+
23
+ prompt.instruction(
24
+ `## Prerequisites:
25
+ - **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
26
+ - **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
27
+ - Ensure you have the most up-to-date list of classes applied to the element to avoid duplicates
28
+ - Make sure you have the correct class ID that you want to apply`
29
+ );
30
+
31
+ prompt.instruction(
32
+ `## Best Practices:
33
+ 1. Apply multiple classes to a single element if needed (typography + color + spacing)
34
+ 2. After applying, the tool will remind you to remove duplicate inline styles from elementConfig
35
+ 3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`
36
+ );
37
+
38
+ return prompt.prompt();
39
+ };
@@ -6,16 +6,6 @@ import initMcpApplyGetGlobalClassUsages from './mcp-get-global-class-usages';
6
6
  import { initManageGlobalClasses } from './mcp-manage-global-classes';
7
7
 
8
8
  export const initMcpIntegration = ( reg: MCPRegistryEntry, canvasMcpEntry: MCPRegistryEntry ) => {
9
- const { setMCPDescription } = reg;
10
- setMCPDescription(
11
- `Everything related to V4 ( Atomic ) global classes.
12
- # Global classes
13
- - Create/update/delete global classes
14
- - Get list of global classes
15
- - Get details of a global class
16
- - Get details of a global class
17
- `
18
- );
19
9
  initMcpApplyUnapplyGlobalClasses( reg );
20
10
  initMcpApplyGetGlobalClassUsages( reg );
21
11
  initManageGlobalClasses( reg );
@@ -2,8 +2,27 @@ import { doApplyClasses, doGetAppliedClasses, doUnapplyClass } from '@elementor/
2
2
  import { type MCPRegistryEntry } from '@elementor/editor-mcp';
3
3
  import { z } from '@elementor/schema';
4
4
 
5
+ import { APPLY_GLOBAL_CLASS_GUIDE_URI, generateApplyGlobalClassGuidePrompt } from './apply-global-class-guide-prompt';
6
+ import { GLOBAL_CLASSES_URI } from './classes-resource';
7
+
5
8
  export default function initMcpApplyUnapplyGlobalClasses( server: MCPRegistryEntry ) {
6
- server.addTool( {
9
+ const { addTool, resource } = server;
10
+ const applyGlobalClassGuideText = generateApplyGlobalClassGuidePrompt();
11
+
12
+ resource(
13
+ 'apply-global-class-guide',
14
+ APPLY_GLOBAL_CLASS_GUIDE_URI,
15
+ {
16
+ description: 'Workflow, prerequisites, and best practices for apply-global-class',
17
+ mimeType: 'text/plain',
18
+ title: 'Apply global class tool guide',
19
+ },
20
+ async ( uri ) => ( {
21
+ contents: [ { mimeType: 'text/plain', text: applyGlobalClassGuideText, uri: uri.href } ],
22
+ } )
23
+ );
24
+
25
+ addTool( {
7
26
  schema: {
8
27
  classId: z.string().describe( 'The ID of the class to apply' ),
9
28
  elementId: z.string().describe( 'The ID of the element to which the class will be applied' ),
@@ -19,29 +38,11 @@ export default function initMcpApplyUnapplyGlobalClasses( server: MCPRegistryEnt
19
38
  intelligencePriority: 0.7,
20
39
  speedPriority: 0.8,
21
40
  },
22
- description: `Apply a global class to an element, enabling consistent styling through your design system.
23
-
24
- ## When to use this tool:
25
- **ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:
26
- - After using "build-compositions" tool, apply semantic classes to the created elements
27
- - When applying consistent typography styles (heading-primary, text-body, etc.)
28
- - When applying theme colors or brand styles (bg-brand, button-cta, etc.)
29
- - When ensuring spacing consistency (spacing-section-large, etc.)
30
-
31
- **DO NOT use this tool** for:
32
- - Elements that don't share styles with other elements (use inline styles instead)
33
- - Layout-specific properties (those should remain inline in stylesConfig)
34
-
35
- ## Prerequisites:
36
- - **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource
37
- - **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool
38
- - Ensure you have the most up-to-date list of classes applied to the element to avoid duplicates
39
- - Make sure you have the correct class ID that you want to apply
40
-
41
- ## Best Practices:
42
- 1. Apply multiple classes to a single element if needed (typography + color + spacing)
43
- 2. After applying, the tool will remind you to remove duplicate inline styles from elementConfig
44
- 3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`,
41
+ description: `Apply a global class to an element for shared design-system styling. Read the full guide at [${ APPLY_GLOBAL_CLASS_GUIDE_URI }].`,
42
+ requiredResources: [
43
+ { description: 'Apply global class tool guide', uri: APPLY_GLOBAL_CLASS_GUIDE_URI },
44
+ { description: 'Global classes list', uri: GLOBAL_CLASSES_URI },
45
+ ],
45
46
  handler: async ( params ) => {
46
47
  const { classId, elementId } = params;
47
48
  const appliedClasses = doGetAppliedClasses( elementId );
@@ -54,7 +55,7 @@ export default function initMcpApplyUnapplyGlobalClasses( server: MCPRegistryEnt
54
55
  },
55
56
  } );
56
57
 
57
- server.addTool( {
58
+ addTool( {
58
59
  name: 'unapply-global-class',
59
60
  schema: {
60
61
  classId: z.string().describe( 'The ID of the class to unapply' ),
@@ -67,21 +68,8 @@ export default function initMcpApplyUnapplyGlobalClasses( server: MCPRegistryEnt
67
68
  intelligencePriority: 0.7,
68
69
  speedPriority: 0.8,
69
70
  },
70
- description: `Unapply a (global) class from the current element
71
-
72
- ## When to use this tool:
73
- - When a user requests to unapply a global class or a class from an element in the Elementor editor.
74
- - When you need to remove a specific class from an element's applied classes.
75
-
76
- ## Prerequisites:
77
- - Ensure you have the most up-to-date list of classes applied to the element to avoid errors.
78
- The list is available at always up-to-date resource 'elementor://global-classes'.
79
- - Make sure you have the correct class ID that you want to unapply.
80
-
81
- <note>
82
- 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
83
- </note>
84
- `,
71
+ description: `Unapply a global class from an element by class ID. Resolve class names to IDs via [${ GLOBAL_CLASSES_URI }].`,
72
+ requiredResources: [ { description: 'Global classes list', uri: GLOBAL_CLASSES_URI } ],
85
73
  handler: async ( params ) => {
86
74
  const { classId, elementId } = params;
87
75
  const ok = doUnapplyClass( elementId, classId );
@@ -3,6 +3,7 @@ import { z } from '@elementor/schema';
3
3
 
4
4
  import { fetchCssClassUsage } from '../../service/css-class-usage-service';
5
5
  import { type CssClassUsageContent, type EnhancedCssClassUsageContent } from '../components/css-class-usage/types';
6
+ import { GLOBAL_CLASSES_URI } from './classes-resource';
6
7
 
7
8
  export default function initMcpApplyGetGlobalClassUsages( reg: MCPRegistryEntry ) {
8
9
  const { addTool } = reg;
@@ -32,19 +33,15 @@ export default function initMcpApplyGetGlobalClassUsages( reg: MCPRegistryEntry
32
33
  intelligencePriority: 0.6,
33
34
  speedPriority: 0.8,
34
35
  },
35
- description: `Retrieve the usages of global-classes ACROSS PAGES designed by Elementor editor.
36
+ description: `Retrieve usages of global classes across all Elementor pages. Heavy operation — scans every page in the site.
36
37
 
37
- ## Prerequisites: CRITICAL
38
- - The list of global classes and their applid values is available at resource uri elementor://global-classes
38
+ ## When to use:
39
+ - Before deleting or radically changing a class to understand cross-page side effects and decide whether to consult the user.
40
+ - To identify unused global classes for cleanup.
39
41
 
40
- ## When to use this tool:
41
- - When a user requests to see where a specific global class is being used across the site.
42
- - When you need to manage or clean up unused global classes.
43
- - Before deleting a global class, to ensure it is not in use in any other pages.
44
-
45
- ## When NOT to use this tool:
46
- - For getting the list of global classes, refer to the resource at uri elementor://global-classes
47
- `,
42
+ ## When NOT to use:
43
+ - To list global classes themselves use the global-classes resource instead (this tool returns usages, not the class list).`,
44
+ requiredResources: [ { description: 'Global classes list', uri: GLOBAL_CLASSES_URI } ],
48
45
  outputSchema: globalClassesUsageSchema,
49
46
  handler: async () => {
50
47
  const data = await fetchCssClassUsage();
@@ -213,15 +213,7 @@ export const initManageGlobalClasses = ( reg: MCPRegistryEntry ) => {
213
213
  intelligencePriority: 0.85,
214
214
  speedPriority: 0.6,
215
215
  },
216
- description: `Manages global classes (create/modify) in Elementor editor. Check [elementor://global-classes] and style schemas first.
217
-
218
- 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.
219
- MODIFY: Requires classId, props. Get classId from [elementor://global-classes] resource.
220
-
221
- Naming pattern: [element-type]-[purpose/variant]-[modifier]
222
- DO NOT create global classes for: one-off styles, layout-specific properties.
223
-
224
- Use style schema at [elementor://styles/schema/{category}] for valid props. Errors include exact schema mismatch details.`,
216
+ 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.`,
225
217
  schema,
226
218
  outputSchema,
227
219
  handler,