@elementor/editor-canvas 4.3.0-967 → 4.3.0-968

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
@@ -2641,11 +2641,11 @@ function getVal2(val) {
2641
2641
  var transformOriginTransformer = createTransformer((value) => {
2642
2642
  const x = getVal2(value.x);
2643
2643
  const y = getVal2(value.y);
2644
- const z4 = getVal2(value.z);
2645
- if (x === DEFAULT_XY && y === DEFAULT_XY && z4 === DEFAULT_Z) {
2644
+ const z5 = getVal2(value.z);
2645
+ if (x === DEFAULT_XY && y === DEFAULT_XY && z5 === DEFAULT_Z) {
2646
2646
  return null;
2647
2647
  }
2648
- return `${x} ${y} ${z4}`;
2648
+ return `${x} ${y} ${z5}`;
2649
2649
  });
2650
2650
 
2651
2651
  // src/transformers/styles/transform-rotate-transformer.ts
@@ -5911,21 +5911,62 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
5911
5911
  }`;
5912
5912
  }
5913
5913
 
5914
+ // src/mcp/tools/create-element/tool.ts
5915
+ var import_editor_documents4 = require("@elementor/editor-documents");
5916
+ var import_http_client2 = require("@elementor/http-client");
5917
+ var import_schema5 = require("@elementor/schema");
5918
+ var MCP_PROXY_URL = "elementor/v1/mcp-proxy";
5919
+ var initCreateElementTool = (reg) => {
5920
+ const { addTool } = reg;
5921
+ addTool({
5922
+ name: "create-element",
5923
+ description: "Insert a new element into the current Elementor document via the server-side MCP ability. The document is saved as a draft. Reload the editor after calling this tool to see the result.",
5924
+ schema: {
5925
+ elementType: import_schema5.z.string().describe("Registry identifier of the element to create, e.g. 'e-heading', 'e-flexbox'."),
5926
+ parentId: import_schema5.z.string().optional().describe("ID of the parent container. Omit or pass 'document' to insert at the document root.")
5927
+ },
5928
+ outputSchema: {
5929
+ elementId: import_schema5.z.string(),
5930
+ previewUrl: import_schema5.z.string(),
5931
+ version: import_schema5.z.string()
5932
+ },
5933
+ handler: async ({ elementType, parentId }) => {
5934
+ const document2 = (0, import_editor_documents4.getCurrentDocument)();
5935
+ if (!document2?.id) {
5936
+ throw new Error("No active document found.");
5937
+ }
5938
+ const { data } = await (0, import_http_client2.httpService)().post(MCP_PROXY_URL, {
5939
+ tool: "create-element",
5940
+ input: {
5941
+ parent_id: parentId ?? "document",
5942
+ element: { type: elementType },
5943
+ post_id: document2.id
5944
+ }
5945
+ });
5946
+ return {
5947
+ elementId: data.data.element_id,
5948
+ previewUrl: data.data.preview_url,
5949
+ version: data.data.version
5950
+ };
5951
+ }
5952
+ });
5953
+ };
5954
+
5914
5955
  // src/mcp/tools/get-element-config/tool.ts
5915
5956
  var import_editor_elements18 = require("@elementor/editor-elements");
5916
5957
  var import_editor_props10 = require("@elementor/editor-props");
5917
- var import_schema5 = require("@elementor/schema");
5958
+ var import_schema6 = require("@elementor/schema");
5918
5959
  var schema = {
5919
- elementId: import_schema5.z.string()
5960
+ elementId: import_schema6.z.string()
5920
5961
  };
5921
5962
  var outputSchema3 = {
5922
- properties: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
5923
- style: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
5924
- childElements: import_schema5.z.array(
5925
- import_schema5.z.object({
5926
- id: import_schema5.z.string(),
5927
- elementType: import_schema5.z.string(),
5928
- childElements: import_schema5.z.array(import_schema5.z.any()).describe("An array of child element IDs, when applicable, same structure recursively")
5963
+ properties: import_schema6.z.record(import_schema6.z.string(), import_schema6.z.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
5964
+ style: import_schema6.z.record(import_schema6.z.string(), import_schema6.z.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
5965
+ childElements: import_schema6.z.array(
5966
+ import_schema6.z.object({
5967
+ id: import_schema6.z.string(),
5968
+ elementType: import_schema6.z.string(),
5969
+ childElements: import_schema6.z.array(import_schema6.z.any()).describe("An array of child element IDs, when applicable, same structure recursively")
5929
5970
  })
5930
5971
  ).describe("An array of child element IDs, when applicable, with recursive structure")
5931
5972
  };
@@ -6017,6 +6058,7 @@ var initCanvasMcp = (reg) => {
6017
6058
  initBuildCompositionsTool(reg);
6018
6059
  initGetElementConfigTool(reg);
6019
6060
  initConfigureElementTool(reg);
6061
+ initCreateElementTool(reg);
6020
6062
  initBreakpointsResource(reg);
6021
6063
  };
6022
6064
 
package/dist/index.mjs CHANGED
@@ -2595,11 +2595,11 @@ function getVal2(val) {
2595
2595
  var transformOriginTransformer = createTransformer((value) => {
2596
2596
  const x = getVal2(value.x);
2597
2597
  const y = getVal2(value.y);
2598
- const z4 = getVal2(value.z);
2599
- if (x === DEFAULT_XY && y === DEFAULT_XY && z4 === DEFAULT_Z) {
2598
+ const z5 = getVal2(value.z);
2599
+ if (x === DEFAULT_XY && y === DEFAULT_XY && z5 === DEFAULT_Z) {
2600
2600
  return null;
2601
2601
  }
2602
- return `${x} ${y} ${z4}`;
2602
+ return `${x} ${y} ${z5}`;
2603
2603
  });
2604
2604
 
2605
2605
  // src/transformers/styles/transform-rotate-transformer.ts
@@ -5896,21 +5896,62 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
5896
5896
  }`;
5897
5897
  }
5898
5898
 
5899
+ // src/mcp/tools/create-element/tool.ts
5900
+ import { getCurrentDocument as getCurrentDocument2 } from "@elementor/editor-documents";
5901
+ import { httpService as httpService2 } from "@elementor/http-client";
5902
+ import { z as z3 } from "@elementor/schema";
5903
+ var MCP_PROXY_URL = "elementor/v1/mcp-proxy";
5904
+ var initCreateElementTool = (reg) => {
5905
+ const { addTool } = reg;
5906
+ addTool({
5907
+ name: "create-element",
5908
+ description: "Insert a new element into the current Elementor document via the server-side MCP ability. The document is saved as a draft. Reload the editor after calling this tool to see the result.",
5909
+ schema: {
5910
+ elementType: z3.string().describe("Registry identifier of the element to create, e.g. 'e-heading', 'e-flexbox'."),
5911
+ parentId: z3.string().optional().describe("ID of the parent container. Omit or pass 'document' to insert at the document root.")
5912
+ },
5913
+ outputSchema: {
5914
+ elementId: z3.string(),
5915
+ previewUrl: z3.string(),
5916
+ version: z3.string()
5917
+ },
5918
+ handler: async ({ elementType, parentId }) => {
5919
+ const document2 = getCurrentDocument2();
5920
+ if (!document2?.id) {
5921
+ throw new Error("No active document found.");
5922
+ }
5923
+ const { data } = await httpService2().post(MCP_PROXY_URL, {
5924
+ tool: "create-element",
5925
+ input: {
5926
+ parent_id: parentId ?? "document",
5927
+ element: { type: elementType },
5928
+ post_id: document2.id
5929
+ }
5930
+ });
5931
+ return {
5932
+ elementId: data.data.element_id,
5933
+ previewUrl: data.data.preview_url,
5934
+ version: data.data.version
5935
+ };
5936
+ }
5937
+ });
5938
+ };
5939
+
5899
5940
  // src/mcp/tools/get-element-config/tool.ts
5900
5941
  import { getContainer as getContainer7, getElementStyles as getElementStyles2, getWidgetsCache as getWidgetsCache11 } from "@elementor/editor-elements";
5901
5942
  import { Schema as Schema5 } from "@elementor/editor-props";
5902
- import { z as z3 } from "@elementor/schema";
5943
+ import { z as z4 } from "@elementor/schema";
5903
5944
  var schema = {
5904
- elementId: z3.string()
5945
+ elementId: z4.string()
5905
5946
  };
5906
5947
  var outputSchema3 = {
5907
- properties: z3.record(z3.string(), z3.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
5908
- style: z3.record(z3.string(), z3.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
5909
- childElements: z3.array(
5910
- z3.object({
5911
- id: z3.string(),
5912
- elementType: z3.string(),
5913
- childElements: z3.array(z3.any()).describe("An array of child element IDs, when applicable, same structure recursively")
5948
+ properties: z4.record(z4.string(), z4.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
5949
+ style: z4.record(z4.string(), z4.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
5950
+ childElements: z4.array(
5951
+ z4.object({
5952
+ id: z4.string(),
5953
+ elementType: z4.string(),
5954
+ childElements: z4.array(z4.any()).describe("An array of child element IDs, when applicable, same structure recursively")
5914
5955
  })
5915
5956
  ).describe("An array of child element IDs, when applicable, with recursive structure")
5916
5957
  };
@@ -6002,6 +6043,7 @@ var initCanvasMcp = (reg) => {
6002
6043
  initBuildCompositionsTool(reg);
6003
6044
  initGetElementConfigTool(reg);
6004
6045
  initConfigureElementTool(reg);
6046
+ initCreateElementTool(reg);
6005
6047
  initBreakpointsResource(reg);
6006
6048
  };
6007
6049
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-canvas",
3
3
  "description": "Elementor Editor Canvas",
4
- "version": "4.3.0-967",
4
+ "version": "4.3.0-968",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -37,26 +37,26 @@
37
37
  "react-dom": "^18.3.1"
38
38
  },
39
39
  "dependencies": {
40
- "@elementor/editor": "4.3.0-967",
41
- "@elementor/editor-controls": "4.3.0-967",
42
- "@elementor/editor-documents": "4.3.0-967",
43
- "@elementor/editor-elements": "4.3.0-967",
44
- "@elementor/editor-interactions": "4.3.0-967",
45
- "@elementor/editor-mcp": "4.3.0-967",
46
- "@elementor/editor-notifications": "4.3.0-967",
47
- "@elementor/editor-props": "4.3.0-967",
48
- "@elementor/editor-responsive": "4.3.0-967",
49
- "@elementor/editor-styles": "4.3.0-967",
50
- "@elementor/editor-styles-repository": "4.3.0-967",
51
- "@elementor/editor-ui": "4.3.0-967",
52
- "@elementor/editor-v1-adapters": "4.3.0-967",
53
- "@elementor/events": "4.3.0-967",
54
- "@elementor/http-client": "4.3.0-967",
55
- "@elementor/schema": "4.3.0-967",
56
- "@elementor/twing": "4.3.0-967",
40
+ "@elementor/editor": "4.3.0-968",
41
+ "@elementor/editor-controls": "4.3.0-968",
42
+ "@elementor/editor-documents": "4.3.0-968",
43
+ "@elementor/editor-elements": "4.3.0-968",
44
+ "@elementor/editor-interactions": "4.3.0-968",
45
+ "@elementor/editor-mcp": "4.3.0-968",
46
+ "@elementor/editor-notifications": "4.3.0-968",
47
+ "@elementor/editor-props": "4.3.0-968",
48
+ "@elementor/editor-responsive": "4.3.0-968",
49
+ "@elementor/editor-styles": "4.3.0-968",
50
+ "@elementor/editor-styles-repository": "4.3.0-968",
51
+ "@elementor/editor-ui": "4.3.0-968",
52
+ "@elementor/editor-v1-adapters": "4.3.0-968",
53
+ "@elementor/events": "4.3.0-968",
54
+ "@elementor/http-client": "4.3.0-968",
55
+ "@elementor/schema": "4.3.0-968",
56
+ "@elementor/twing": "4.3.0-968",
57
57
  "@elementor/ui": "1.37.5",
58
- "@elementor/utils": "4.3.0-967",
59
- "@elementor/wp-media": "4.3.0-967",
58
+ "@elementor/utils": "4.3.0-968",
59
+ "@elementor/wp-media": "4.3.0-968",
60
60
  "@floating-ui/react": "^0.27.5",
61
61
  "@wordpress/i18n": "^5.13.0",
62
62
  "dompurify": "^3.2.6"
@@ -11,6 +11,7 @@ import { initSelectedElementResource } from './resources/selected-element-resour
11
11
  import { initWidgetsSchemaResource } from './resources/widgets-schema-resource';
12
12
  import { initBuildCompositionsTool } from './tools/build-composition/tool';
13
13
  import { initConfigureElementTool } from './tools/configure-element/tool';
14
+ import { initCreateElementTool } from './tools/create-element/tool';
14
15
  import { initGetElementConfigTool } from './tools/get-element-config/tool';
15
16
  import { getDynamicTagNamesByCategories } from './utils/resolve-dynamic-tag';
16
17
 
@@ -29,5 +30,6 @@ export const initCanvasMcp = ( reg: MCPRegistryEntry ) => {
29
30
  initBuildCompositionsTool( reg );
30
31
  initGetElementConfigTool( reg );
31
32
  initConfigureElementTool( reg );
33
+ initCreateElementTool( reg );
32
34
  initBreakpointsResource( reg );
33
35
  };
@@ -0,0 +1,61 @@
1
+ import { getCurrentDocument } from '@elementor/editor-documents';
2
+ import { type MCPRegistryEntry } from '@elementor/editor-mcp';
3
+ import { type HttpResponse, httpService } from '@elementor/http-client';
4
+ import { z } from '@elementor/schema';
5
+
6
+ const MCP_PROXY_URL = 'elementor/v1/mcp-proxy';
7
+
8
+ type CreateElementResponse = {
9
+ success: boolean;
10
+ post_id: number;
11
+ element_id: string;
12
+ version: string;
13
+ preview_url: string;
14
+ };
15
+
16
+ export const initCreateElementTool = ( reg: MCPRegistryEntry ) => {
17
+ const { addTool } = reg;
18
+
19
+ addTool( {
20
+ name: 'create-element',
21
+ description:
22
+ 'Insert a new element into the current Elementor document via the server-side MCP ability. ' +
23
+ 'The document is saved as a draft. Reload the editor after calling this tool to see the result.',
24
+ schema: {
25
+ elementType: z
26
+ .string()
27
+ .describe( "Registry identifier of the element to create, e.g. 'e-heading', 'e-flexbox'." ),
28
+ parentId: z
29
+ .string()
30
+ .optional()
31
+ .describe( "ID of the parent container. Omit or pass 'document' to insert at the document root." ),
32
+ },
33
+ outputSchema: {
34
+ elementId: z.string(),
35
+ previewUrl: z.string(),
36
+ version: z.string(),
37
+ },
38
+ handler: async ( { elementType, parentId } ) => {
39
+ const document = getCurrentDocument();
40
+
41
+ if ( ! document?.id ) {
42
+ throw new Error( 'No active document found.' );
43
+ }
44
+
45
+ const { data } = await httpService().post< HttpResponse< CreateElementResponse > >( MCP_PROXY_URL, {
46
+ tool: 'create-element',
47
+ input: {
48
+ parent_id: parentId ?? 'document',
49
+ element: { type: elementType },
50
+ post_id: document.id,
51
+ },
52
+ } );
53
+
54
+ return {
55
+ elementId: data.data.element_id,
56
+ previewUrl: data.data.preview_url,
57
+ version: data.data.version,
58
+ };
59
+ },
60
+ } );
61
+ };