@elementor/editor-canvas 3.33.0-293 → 3.33.0-295
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 +253 -139
- package/dist/index.mjs +189 -74
- package/package.json +17 -17
- package/src/components/__tests__/elements-overlays.test.tsx +96 -12
- package/src/components/__tests__/inline-editor-overlay.test.tsx +245 -0
- package/src/components/elements-overlays.tsx +33 -10
- package/src/components/inline-editor-overlay.tsx +79 -0
- package/src/components/{element-overlay.tsx → outline-overlay.tsx} +4 -6
- package/src/hooks/use-style-items.ts +0 -1
- package/src/types/element-overlay.ts +18 -0
- package/src/utils/inline-editing-utils.ts +43 -0
package/dist/index.js
CHANGED
|
@@ -92,19 +92,102 @@ var renameClass = (oldClassName, newClassName) => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// src/components/elements-overlays.tsx
|
|
95
|
-
var
|
|
96
|
-
var
|
|
95
|
+
var React3 = __toESM(require("react"));
|
|
96
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
97
97
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
98
98
|
|
|
99
|
-
// src/
|
|
99
|
+
// src/utils/inline-editing-utils.ts
|
|
100
|
+
var import_editor_elements = require("@elementor/editor-elements");
|
|
101
|
+
var WIDGET_PROPERTY_MAP = {
|
|
102
|
+
"e-heading": "title",
|
|
103
|
+
"e-paragraph": "paragraph"
|
|
104
|
+
};
|
|
105
|
+
var getHtmlPropertyName = (container) => {
|
|
106
|
+
const widgetType = container?.model?.get("widgetType") ?? container?.model?.get("elType");
|
|
107
|
+
if (!widgetType) {
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
if (WIDGET_PROPERTY_MAP[widgetType]) {
|
|
111
|
+
return WIDGET_PROPERTY_MAP[widgetType];
|
|
112
|
+
}
|
|
113
|
+
const propsSchema = (0, import_editor_elements.getElementType)(widgetType)?.propsSchema;
|
|
114
|
+
if (!propsSchema) {
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
const entry = Object.entries(propsSchema).find(([, propType]) => propType.key === "html");
|
|
118
|
+
return entry?.[0] ?? "";
|
|
119
|
+
};
|
|
120
|
+
var hasInlineEditableProperty = (containerId) => {
|
|
121
|
+
const container = (0, import_editor_elements.getContainer)(containerId);
|
|
122
|
+
const widgetType = container?.model?.get("widgetType") ?? container?.model?.get("elType");
|
|
123
|
+
if (!widgetType) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return widgetType in WIDGET_PROPERTY_MAP;
|
|
127
|
+
};
|
|
128
|
+
var getInlineEditablePropertyName = (container) => {
|
|
129
|
+
return getHtmlPropertyName(container);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/components/inline-editor-overlay.tsx
|
|
133
|
+
var React2 = __toESM(require("react"));
|
|
134
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
135
|
+
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
136
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
137
|
+
var import_ui2 = require("@elementor/ui");
|
|
138
|
+
var import_utils2 = require("@elementor/utils");
|
|
139
|
+
var import_react6 = require("@floating-ui/react");
|
|
140
|
+
|
|
141
|
+
// src/hooks/use-floating-on-element.ts
|
|
142
|
+
var import_react2 = require("react");
|
|
143
|
+
var import_react3 = require("@floating-ui/react");
|
|
144
|
+
function useFloatingOnElement({ element, isSelected }) {
|
|
145
|
+
const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
|
|
146
|
+
const sizeModifier = 2;
|
|
147
|
+
const { refs, floatingStyles, context } = (0, import_react3.useFloating)({
|
|
148
|
+
// Must be controlled for interactions (like hover) to work.
|
|
149
|
+
open: isOpen || isSelected,
|
|
150
|
+
onOpenChange: setIsOpen,
|
|
151
|
+
whileElementsMounted: import_react3.autoUpdate,
|
|
152
|
+
middleware: [
|
|
153
|
+
// Match the floating element's size to the reference element.
|
|
154
|
+
(0, import_react3.size)(() => {
|
|
155
|
+
return {
|
|
156
|
+
apply({ elements, rects }) {
|
|
157
|
+
Object.assign(elements.floating.style, {
|
|
158
|
+
width: `${rects.reference.width + sizeModifier}px`,
|
|
159
|
+
height: `${rects.reference.height + sizeModifier}px`
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}),
|
|
164
|
+
// Center the floating element on the reference element.
|
|
165
|
+
(0, import_react3.offset)(({ rects }) => -rects.reference.height / 2 - rects.floating.height / 2)
|
|
166
|
+
]
|
|
167
|
+
});
|
|
168
|
+
(0, import_react2.useEffect)(() => {
|
|
169
|
+
refs.setReference(element);
|
|
170
|
+
}, [element, refs]);
|
|
171
|
+
return {
|
|
172
|
+
isVisible: isOpen || isSelected,
|
|
173
|
+
context,
|
|
174
|
+
floating: {
|
|
175
|
+
setRef: refs.setFloating,
|
|
176
|
+
ref: refs.floating,
|
|
177
|
+
styles: floatingStyles
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/components/outline-overlay.tsx
|
|
100
183
|
var React = __toESM(require("react"));
|
|
101
184
|
var import_ui = require("@elementor/ui");
|
|
102
185
|
var import_react5 = require("@floating-ui/react");
|
|
103
186
|
|
|
104
187
|
// src/hooks/use-bind-react-props-to-element.ts
|
|
105
|
-
var
|
|
188
|
+
var import_react4 = require("react");
|
|
106
189
|
function useBindReactPropsToElement(element, getProps) {
|
|
107
|
-
(0,
|
|
190
|
+
(0, import_react4.useEffect)(() => {
|
|
108
191
|
const el = element;
|
|
109
192
|
const { events, attrs } = groupProps(getProps());
|
|
110
193
|
events.forEach(([eventName, listener]) => el.addEventListener(eventName, listener));
|
|
@@ -135,47 +218,6 @@ function groupProps(props) {
|
|
|
135
218
|
);
|
|
136
219
|
}
|
|
137
220
|
|
|
138
|
-
// src/hooks/use-floating-on-element.ts
|
|
139
|
-
var import_react3 = require("react");
|
|
140
|
-
var import_react4 = require("@floating-ui/react");
|
|
141
|
-
function useFloatingOnElement({ element, isSelected }) {
|
|
142
|
-
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
143
|
-
const sizeModifier = 2;
|
|
144
|
-
const { refs, floatingStyles, context } = (0, import_react4.useFloating)({
|
|
145
|
-
// Must be controlled for interactions (like hover) to work.
|
|
146
|
-
open: isOpen || isSelected,
|
|
147
|
-
onOpenChange: setIsOpen,
|
|
148
|
-
whileElementsMounted: import_react4.autoUpdate,
|
|
149
|
-
middleware: [
|
|
150
|
-
// Match the floating element's size to the reference element.
|
|
151
|
-
(0, import_react4.size)(() => {
|
|
152
|
-
return {
|
|
153
|
-
apply({ elements, rects }) {
|
|
154
|
-
Object.assign(elements.floating.style, {
|
|
155
|
-
width: `${rects.reference.width + sizeModifier}px`,
|
|
156
|
-
height: `${rects.reference.height + sizeModifier}px`
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
}),
|
|
161
|
-
// Center the floating element on the reference element.
|
|
162
|
-
(0, import_react4.offset)(({ rects }) => -rects.reference.height / 2 - rects.floating.height / 2)
|
|
163
|
-
]
|
|
164
|
-
});
|
|
165
|
-
(0, import_react3.useEffect)(() => {
|
|
166
|
-
refs.setReference(element);
|
|
167
|
-
}, [element, refs]);
|
|
168
|
-
return {
|
|
169
|
-
isVisible: isOpen || isSelected,
|
|
170
|
-
context,
|
|
171
|
-
floating: {
|
|
172
|
-
setRef: refs.setFloating,
|
|
173
|
-
ref: refs.floating,
|
|
174
|
-
styles: floatingStyles
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
221
|
// src/hooks/use-has-overlapping.ts
|
|
180
222
|
var possibleOverlappingSelectors = [".e-off-canvas"];
|
|
181
223
|
var useHasOverlapping = () => {
|
|
@@ -193,7 +235,7 @@ var useHasOverlapping = () => {
|
|
|
193
235
|
return hasOverlapping;
|
|
194
236
|
};
|
|
195
237
|
|
|
196
|
-
// src/components/
|
|
238
|
+
// src/components/outline-overlay.tsx
|
|
197
239
|
var CANVAS_WRAPPER_ID = "elementor-preview-responsive-wrapper";
|
|
198
240
|
var OverlayBox = (0, import_ui.styled)(import_ui.Box, {
|
|
199
241
|
shouldForwardProp: (prop) => prop !== "isSelected" && prop !== "isSmallerOffset"
|
|
@@ -202,7 +244,7 @@ var OverlayBox = (0, import_ui.styled)(import_ui.Box, {
|
|
|
202
244
|
outlineOffset: isSelected && !isSmallerOffset ? "-2px" : "-1px",
|
|
203
245
|
pointerEvents: "none"
|
|
204
246
|
}));
|
|
205
|
-
|
|
247
|
+
var OutlineOverlay = ({ element, isSelected, id }) => {
|
|
206
248
|
const { context, floating, isVisible } = useFloatingOnElement({ element, isSelected });
|
|
207
249
|
const { getFloatingProps, getReferenceProps } = (0, import_react5.useInteractions)([(0, import_react5.useHover)(context)]);
|
|
208
250
|
const hasOverlapping = useHasOverlapping();
|
|
@@ -220,43 +262,116 @@ function ElementOverlay({ element, isSelected, id }) {
|
|
|
220
262
|
...getFloatingProps()
|
|
221
263
|
}
|
|
222
264
|
));
|
|
223
|
-
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/components/inline-editor-overlay.tsx
|
|
268
|
+
var OVERLAY_Z_INDEX = 1e3;
|
|
269
|
+
var DEBOUNCE_DELAY = 100;
|
|
270
|
+
var InlineEditorOverlay = ({ element, isSelected, id }) => {
|
|
271
|
+
const { floating, isVisible } = useFloatingOnElement({ element, isSelected });
|
|
272
|
+
const propertyName = React2.useMemo(() => {
|
|
273
|
+
const container = (0, import_editor_elements2.getContainer)(id);
|
|
274
|
+
return getInlineEditablePropertyName(container);
|
|
275
|
+
}, [id]);
|
|
276
|
+
const contentProp = (0, import_editor_elements2.useElementSetting)(id, propertyName);
|
|
277
|
+
const value = React2.useMemo(() => import_editor_props.htmlPropTypeUtil.extract(contentProp) || "", [contentProp]);
|
|
278
|
+
const debouncedUpdateRef = React2.useRef(null);
|
|
279
|
+
const lastValueRef = React2.useRef("");
|
|
280
|
+
React2.useEffect(() => {
|
|
281
|
+
debouncedUpdateRef.current = (0, import_utils2.debounce)((newValue) => {
|
|
282
|
+
const textContent = newValue.replace(/<[^>]*>/g, "").trim();
|
|
283
|
+
const valueToSave = textContent === "" ? " " : newValue;
|
|
284
|
+
(0, import_editor_elements2.updateElementSettings)({
|
|
285
|
+
id,
|
|
286
|
+
props: {
|
|
287
|
+
[propertyName]: import_editor_props.htmlPropTypeUtil.create(valueToSave)
|
|
288
|
+
},
|
|
289
|
+
withHistory: true
|
|
290
|
+
});
|
|
291
|
+
}, DEBOUNCE_DELAY);
|
|
292
|
+
return () => {
|
|
293
|
+
debouncedUpdateRef.current?.cancel?.();
|
|
294
|
+
};
|
|
295
|
+
}, [id, propertyName]);
|
|
296
|
+
const handleValueChange = React2.useCallback((newValue) => {
|
|
297
|
+
lastValueRef.current = newValue;
|
|
298
|
+
debouncedUpdateRef.current?.(newValue);
|
|
299
|
+
}, []);
|
|
300
|
+
React2.useEffect(() => {
|
|
301
|
+
if (!isVisible && debouncedUpdateRef.current?.pending?.()) {
|
|
302
|
+
debouncedUpdateRef.current.flush(lastValueRef.current);
|
|
303
|
+
}
|
|
304
|
+
}, [isVisible]);
|
|
305
|
+
if (!isVisible) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
return /* @__PURE__ */ React2.createElement(import_react6.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React2.createElement(
|
|
309
|
+
import_ui2.Box,
|
|
310
|
+
{
|
|
311
|
+
ref: floating.setRef,
|
|
312
|
+
style: {
|
|
313
|
+
...floating.styles,
|
|
314
|
+
zIndex: OVERLAY_Z_INDEX,
|
|
315
|
+
pointerEvents: "auto"
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
/* @__PURE__ */ React2.createElement(import_editor_controls.InlineEditor, { value, setValue: handleValueChange })
|
|
319
|
+
));
|
|
320
|
+
};
|
|
224
321
|
|
|
225
322
|
// src/components/elements-overlays.tsx
|
|
323
|
+
var ELEMENTS_DATA_ATTR = "atomic";
|
|
324
|
+
var overlayRegistry = [
|
|
325
|
+
{
|
|
326
|
+
component: OutlineOverlay,
|
|
327
|
+
shouldRender: () => true
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
component: InlineEditorOverlay,
|
|
331
|
+
shouldRender: ({ id, isSelected }) => isSelected && hasInlineEditableProperty(id) && (0, import_editor_v1_adapters.isExperimentActive)("v4-inline-text-editing")
|
|
332
|
+
}
|
|
333
|
+
];
|
|
226
334
|
function ElementsOverlays() {
|
|
227
|
-
const selected = (0,
|
|
335
|
+
const selected = (0, import_editor_elements3.useSelectedElement)();
|
|
228
336
|
const elements = useElementsDom();
|
|
229
337
|
const currentEditMode = (0, import_editor_v1_adapters.useEditMode)();
|
|
230
338
|
const isEditMode = currentEditMode === "edit";
|
|
231
339
|
const isKitRouteActive = (0, import_editor_v1_adapters.__privateUseIsRouteActive)("panel/global");
|
|
232
340
|
const isActive = isEditMode && !isKitRouteActive;
|
|
233
|
-
|
|
341
|
+
if (!isActive) {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
return elements.map(([id, element]) => {
|
|
345
|
+
const isSelected = selected.element?.id === id;
|
|
346
|
+
return overlayRegistry.map(
|
|
347
|
+
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element, isSelected }) && /* @__PURE__ */ React3.createElement(Overlay, { key: `${id}-${index}`, id, element, isSelected })
|
|
348
|
+
);
|
|
349
|
+
});
|
|
234
350
|
}
|
|
235
|
-
var ELEMENTS_DATA_ATTR = "atomic";
|
|
236
351
|
function useElementsDom() {
|
|
237
352
|
return (0, import_editor_v1_adapters.__privateUseListenTo)(
|
|
238
353
|
[(0, import_editor_v1_adapters.windowEvent)("elementor/editor/element-rendered"), (0, import_editor_v1_adapters.windowEvent)("elementor/editor/element-destroyed")],
|
|
239
354
|
() => {
|
|
240
|
-
return (0,
|
|
355
|
+
return (0, import_editor_elements3.getElements)().filter((el) => ELEMENTS_DATA_ATTR in (el.view?.el?.dataset ?? {})).map((element) => [element.id, element.view?.getDomElement?.()?.get?.(0)]).filter((item) => !!item[1]);
|
|
241
356
|
}
|
|
242
357
|
);
|
|
243
358
|
}
|
|
244
359
|
|
|
245
360
|
// src/components/interactions-renderer.tsx
|
|
246
|
-
var
|
|
361
|
+
var React4 = __toESM(require("react"));
|
|
247
362
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
248
|
-
var
|
|
363
|
+
var import_ui3 = require("@elementor/ui");
|
|
249
364
|
|
|
250
365
|
// src/hooks/use-interactions-items.ts
|
|
251
|
-
var
|
|
366
|
+
var import_react8 = require("react");
|
|
252
367
|
var import_editor_interactions = require("@elementor/editor-interactions");
|
|
253
368
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
254
369
|
|
|
255
370
|
// src/hooks/use-on-mount.ts
|
|
256
|
-
var
|
|
371
|
+
var import_react7 = require("react");
|
|
257
372
|
function useOnMount(cb) {
|
|
258
|
-
const mounted = (0,
|
|
259
|
-
(0,
|
|
373
|
+
const mounted = (0, import_react7.useRef)(false);
|
|
374
|
+
(0, import_react7.useEffect)(() => {
|
|
260
375
|
if (!mounted.current) {
|
|
261
376
|
mounted.current = true;
|
|
262
377
|
cb();
|
|
@@ -266,8 +381,8 @@ function useOnMount(cb) {
|
|
|
266
381
|
|
|
267
382
|
// src/hooks/use-interactions-items.ts
|
|
268
383
|
function useInteractionsItems() {
|
|
269
|
-
const [interactionItems, setInteractionItems] = (0,
|
|
270
|
-
const providerAndSubscribers = (0,
|
|
384
|
+
const [interactionItems, setInteractionItems] = (0, import_react8.useState)({});
|
|
385
|
+
const providerAndSubscribers = (0, import_react8.useMemo)(() => {
|
|
271
386
|
try {
|
|
272
387
|
const providers = import_editor_interactions.interactionsRepository.getProviders();
|
|
273
388
|
const mapped = providers.map((provider) => {
|
|
@@ -284,7 +399,7 @@ function useInteractionsItems() {
|
|
|
284
399
|
return [];
|
|
285
400
|
}
|
|
286
401
|
}, []);
|
|
287
|
-
(0,
|
|
402
|
+
(0, import_react8.useEffect)(() => {
|
|
288
403
|
if (providerAndSubscribers.length === 0) {
|
|
289
404
|
return;
|
|
290
405
|
}
|
|
@@ -315,7 +430,7 @@ function useInteractionsItems() {
|
|
|
315
430
|
});
|
|
316
431
|
});
|
|
317
432
|
});
|
|
318
|
-
return (0,
|
|
433
|
+
return (0, import_react8.useMemo)(() => {
|
|
319
434
|
const result = Object.values(interactionItems).sort(sortByProviderPriority).flatMap(({ items }) => items);
|
|
320
435
|
return result;
|
|
321
436
|
}, [interactionItems]);
|
|
@@ -351,7 +466,7 @@ function InteractionsRenderer() {
|
|
|
351
466
|
return null;
|
|
352
467
|
}
|
|
353
468
|
const interactionsData = JSON.stringify(Array.isArray(interactionItems) ? interactionItems : []);
|
|
354
|
-
return /* @__PURE__ */
|
|
469
|
+
return /* @__PURE__ */ React4.createElement(import_ui3.Portal, { container }, /* @__PURE__ */ React4.createElement(
|
|
355
470
|
"script",
|
|
356
471
|
{
|
|
357
472
|
type: "application/json",
|
|
@@ -367,9 +482,9 @@ function usePortalContainer() {
|
|
|
367
482
|
}
|
|
368
483
|
|
|
369
484
|
// src/components/style-renderer.tsx
|
|
370
|
-
var
|
|
485
|
+
var React5 = __toESM(require("react"));
|
|
371
486
|
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
372
|
-
var
|
|
487
|
+
var import_ui4 = require("@elementor/ui");
|
|
373
488
|
|
|
374
489
|
// src/hooks/use-documents-css-links.ts
|
|
375
490
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
@@ -419,7 +534,7 @@ function getLinkAttrs(el) {
|
|
|
419
534
|
}
|
|
420
535
|
|
|
421
536
|
// src/hooks/use-style-items.ts
|
|
422
|
-
var
|
|
537
|
+
var import_react11 = require("react");
|
|
423
538
|
var import_editor_responsive2 = require("@elementor/editor-responsive");
|
|
424
539
|
var import_editor_styles3 = require("@elementor/editor-styles");
|
|
425
540
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
@@ -457,11 +572,11 @@ function signalizedProcess(signal, steps = []) {
|
|
|
457
572
|
}
|
|
458
573
|
|
|
459
574
|
// src/hooks/use-style-prop-resolver.ts
|
|
460
|
-
var
|
|
575
|
+
var import_react9 = require("react");
|
|
461
576
|
var import_editor_styles = require("@elementor/editor-styles");
|
|
462
577
|
|
|
463
578
|
// src/renderers/create-props-resolver.ts
|
|
464
|
-
var
|
|
579
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
465
580
|
|
|
466
581
|
// src/renderers/multi-props.ts
|
|
467
582
|
var isMultiProps = (propValue) => {
|
|
@@ -499,7 +614,7 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
499
614
|
if (value === null || value === void 0) {
|
|
500
615
|
return null;
|
|
501
616
|
}
|
|
502
|
-
if (!(0,
|
|
617
|
+
if (!(0, import_editor_props2.isTransformable)(value)) {
|
|
503
618
|
return value;
|
|
504
619
|
}
|
|
505
620
|
if (depth > TRANSFORM_DEPTH_LIMIT) {
|
|
@@ -579,7 +694,7 @@ var enqueueFont = (fontFamily, context = "preview") => {
|
|
|
579
694
|
|
|
580
695
|
// src/hooks/use-style-prop-resolver.ts
|
|
581
696
|
function useStylePropResolver() {
|
|
582
|
-
return (0,
|
|
697
|
+
return (0, import_react9.useMemo)(() => {
|
|
583
698
|
return createPropsResolver({
|
|
584
699
|
transformers: styleTransformersRegistry,
|
|
585
700
|
schema: (0, import_editor_styles.getStylesSchema)(),
|
|
@@ -594,20 +709,20 @@ function useStylePropResolver() {
|
|
|
594
709
|
}
|
|
595
710
|
|
|
596
711
|
// src/hooks/use-style-renderer.ts
|
|
597
|
-
var
|
|
712
|
+
var import_react10 = require("react");
|
|
598
713
|
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
599
714
|
|
|
600
715
|
// src/renderers/create-styles-renderer.ts
|
|
601
716
|
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
602
|
-
var
|
|
717
|
+
var import_utils4 = require("@elementor/utils");
|
|
603
718
|
|
|
604
719
|
// src/renderers/errors.ts
|
|
605
|
-
var
|
|
606
|
-
var UnknownStyleTypeError = (0,
|
|
720
|
+
var import_utils3 = require("@elementor/utils");
|
|
721
|
+
var UnknownStyleTypeError = (0, import_utils3.createError)({
|
|
607
722
|
code: "unknown_style_type",
|
|
608
723
|
message: "Unknown style type"
|
|
609
724
|
});
|
|
610
|
-
var UnknownStyleStateError = (0,
|
|
725
|
+
var UnknownStyleStateError = (0, import_utils3.createError)({
|
|
611
726
|
code: "unknown_style_state",
|
|
612
727
|
message: "Unknown style state"
|
|
613
728
|
});
|
|
@@ -684,7 +799,7 @@ async function propsToCss({ props, resolve, signal }) {
|
|
|
684
799
|
}, []).join("");
|
|
685
800
|
}
|
|
686
801
|
function customCssToString(customCss) {
|
|
687
|
-
const decoded = (0,
|
|
802
|
+
const decoded = (0, import_utils4.decodeString)(customCss?.raw || "");
|
|
688
803
|
if (!decoded.trim()) {
|
|
689
804
|
return "";
|
|
690
805
|
}
|
|
@@ -695,7 +810,7 @@ function customCssToString(customCss) {
|
|
|
695
810
|
var SELECTOR_PREFIX = ".elementor";
|
|
696
811
|
function useStyleRenderer(resolve) {
|
|
697
812
|
const breakpoints = (0, import_editor_responsive.useBreakpointsMap)();
|
|
698
|
-
return (0,
|
|
813
|
+
return (0, import_react10.useMemo)(() => {
|
|
699
814
|
return createStylesRenderer({
|
|
700
815
|
selectorPrefix: SELECTOR_PREFIX,
|
|
701
816
|
breakpoints,
|
|
@@ -708,8 +823,8 @@ function useStyleRenderer(resolve) {
|
|
|
708
823
|
function useStyleItems() {
|
|
709
824
|
const resolve = useStylePropResolver();
|
|
710
825
|
const renderStyles = useStyleRenderer(resolve);
|
|
711
|
-
const [styleItems, setStyleItems] = (0,
|
|
712
|
-
const providerAndSubscribers = (0,
|
|
826
|
+
const [styleItems, setStyleItems] = (0, import_react11.useState)({});
|
|
827
|
+
const providerAndSubscribers = (0, import_react11.useMemo)(() => {
|
|
713
828
|
return import_editor_styles_repository2.stylesRepository.getProviders().map((provider) => {
|
|
714
829
|
return {
|
|
715
830
|
provider,
|
|
@@ -721,7 +836,7 @@ function useStyleItems() {
|
|
|
721
836
|
};
|
|
722
837
|
});
|
|
723
838
|
}, [renderStyles]);
|
|
724
|
-
(0,
|
|
839
|
+
(0, import_react11.useEffect)(() => {
|
|
725
840
|
const unsubscribes = providerAndSubscribers.map(
|
|
726
841
|
({ provider, subscriber }) => provider.subscribe(subscriber)
|
|
727
842
|
);
|
|
@@ -736,9 +851,8 @@ function useStyleItems() {
|
|
|
736
851
|
});
|
|
737
852
|
});
|
|
738
853
|
const breakpointsOrder = (0, import_editor_responsive2.getBreakpoints)().map((breakpoint) => breakpoint.id);
|
|
739
|
-
return (0,
|
|
854
|
+
return (0, import_react11.useMemo)(
|
|
740
855
|
() => Object.values(styleItems).sort(sortByProviderPriority2).flatMap(({ items }) => items).sort(sortByStateType).sort(sortByBreakpoint(breakpointsOrder)),
|
|
741
|
-
// eslint-disable-next-line
|
|
742
856
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
743
857
|
[styleItems, breakpointsOrder.join("-")]
|
|
744
858
|
);
|
|
@@ -810,7 +924,7 @@ function StyleRenderer() {
|
|
|
810
924
|
if (!container) {
|
|
811
925
|
return null;
|
|
812
926
|
}
|
|
813
|
-
return /* @__PURE__ */
|
|
927
|
+
return /* @__PURE__ */ React5.createElement(import_ui4.Portal, { container }, styleItems.map((item, i) => /* @__PURE__ */ React5.createElement("style", { key: `${item.id}-${i}-${item.breakpoint}` }, item.value)), linksAttrs.map((attrs) => /* @__PURE__ */ React5.createElement("link", { ...attrs, key: attrs.id })));
|
|
814
928
|
}
|
|
815
929
|
function usePortalContainer2() {
|
|
816
930
|
return (0, import_editor_v1_adapters6.__privateUseListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
@@ -1180,10 +1294,10 @@ var transformSkewTransformer = createTransformer((value) => {
|
|
|
1180
1294
|
});
|
|
1181
1295
|
|
|
1182
1296
|
// src/transformers/styles/transition-transformer.ts
|
|
1183
|
-
var
|
|
1297
|
+
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1184
1298
|
var getAllowedProperties = () => {
|
|
1185
1299
|
const allowedProperties = /* @__PURE__ */ new Set();
|
|
1186
|
-
|
|
1300
|
+
import_editor_controls2.transitionProperties.forEach((category) => {
|
|
1187
1301
|
category.properties.forEach((property) => {
|
|
1188
1302
|
allowedProperties.add(property.value);
|
|
1189
1303
|
});
|
|
@@ -1245,7 +1359,7 @@ function initStyleTransformers() {
|
|
|
1245
1359
|
}
|
|
1246
1360
|
|
|
1247
1361
|
// src/legacy/init-legacy-views.ts
|
|
1248
|
-
var
|
|
1362
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1249
1363
|
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
1250
1364
|
|
|
1251
1365
|
// src/renderers/create-dom-renderer.ts
|
|
@@ -1474,7 +1588,7 @@ function registerElementType(type, elementTypeGenerator) {
|
|
|
1474
1588
|
}
|
|
1475
1589
|
function initLegacyViews() {
|
|
1476
1590
|
(0, import_editor_v1_adapters7.__privateListenTo)((0, import_editor_v1_adapters7.v1ReadyEvent)(), () => {
|
|
1477
|
-
const config = (0,
|
|
1591
|
+
const config = (0, import_editor_elements4.getWidgetsCache)() ?? {};
|
|
1478
1592
|
const legacyWindow = window;
|
|
1479
1593
|
const renderer = createDomRenderer();
|
|
1480
1594
|
Object.entries(config).forEach(([type, element]) => {
|
|
@@ -1495,9 +1609,9 @@ function initLegacyViews() {
|
|
|
1495
1609
|
}
|
|
1496
1610
|
|
|
1497
1611
|
// src/mcp/resources/widgets-schema-resource.ts
|
|
1498
|
-
var
|
|
1612
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1499
1613
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
1500
|
-
var
|
|
1614
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1501
1615
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
1502
1616
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
1503
1617
|
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
@@ -1552,7 +1666,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1552
1666
|
throw new Error(`No styles schema found for category: ${category}`);
|
|
1553
1667
|
}
|
|
1554
1668
|
const cleanedupPropSchema = cleanupPropType(stylesSchema);
|
|
1555
|
-
const asJson =
|
|
1669
|
+
const asJson = import_editor_props3.Schema.propTypeToJsonSchema(cleanedupPropSchema);
|
|
1556
1670
|
return {
|
|
1557
1671
|
contents: [
|
|
1558
1672
|
{
|
|
@@ -1567,7 +1681,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1567
1681
|
"widget-schema-by-type",
|
|
1568
1682
|
new import_editor_mcp.ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
1569
1683
|
list: () => {
|
|
1570
|
-
const cache = (0,
|
|
1684
|
+
const cache = (0, import_editor_elements5.getWidgetsCache)() || {};
|
|
1571
1685
|
const availableWidgets = Object.keys(cache || {}).filter(
|
|
1572
1686
|
(widgetType) => cache[widgetType]?.atomic_props_schema
|
|
1573
1687
|
);
|
|
@@ -1584,7 +1698,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1584
1698
|
},
|
|
1585
1699
|
async (uri, variables) => {
|
|
1586
1700
|
const widgetType = typeof variables.widgetType === "string" ? variables.widgetType : variables.widgetType?.[0];
|
|
1587
|
-
const propSchema = (0,
|
|
1701
|
+
const propSchema = (0, import_editor_elements5.getWidgetsCache)()?.[widgetType]?.atomic_props_schema;
|
|
1588
1702
|
if (!propSchema) {
|
|
1589
1703
|
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
1590
1704
|
}
|
|
@@ -1592,10 +1706,10 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1592
1706
|
const asJson = Object.fromEntries(
|
|
1593
1707
|
Object.entries(cleanedupPropSchema).map(([key, propType]) => [
|
|
1594
1708
|
key,
|
|
1595
|
-
|
|
1709
|
+
import_editor_props3.Schema.propTypeToJsonSchema(propType)
|
|
1596
1710
|
])
|
|
1597
1711
|
);
|
|
1598
|
-
|
|
1712
|
+
import_editor_props3.Schema.nonConfigurablePropKeys.forEach((key) => {
|
|
1599
1713
|
delete asJson[key];
|
|
1600
1714
|
});
|
|
1601
1715
|
return {
|
|
@@ -1654,19 +1768,19 @@ function cleanupPropType(propType) {
|
|
|
1654
1768
|
}
|
|
1655
1769
|
|
|
1656
1770
|
// src/mcp/tools/build-composition/tool.ts
|
|
1657
|
-
var
|
|
1771
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
1658
1772
|
|
|
1659
1773
|
// src/mcp/utils/do-update-element-property.ts
|
|
1660
|
-
var
|
|
1661
|
-
var
|
|
1774
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
1775
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
1662
1776
|
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
1663
1777
|
function resolvePropValue(value, forceKey) {
|
|
1664
|
-
return
|
|
1778
|
+
return import_editor_props4.Schema.adjustLlmPropValueSchema(value, forceKey);
|
|
1665
1779
|
}
|
|
1666
1780
|
var doUpdateElementProperty = (params) => {
|
|
1667
1781
|
const { elementId, propertyName, propertyValue, elementType } = params;
|
|
1668
1782
|
if (propertyName === "_styles") {
|
|
1669
|
-
const elementStyles = (0,
|
|
1783
|
+
const elementStyles = (0, import_editor_elements6.getElementStyles)(elementId) || {};
|
|
1670
1784
|
const propertyMapValue = propertyValue;
|
|
1671
1785
|
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
1672
1786
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -1687,7 +1801,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1687
1801
|
if (stylePropName === "custom_css") {
|
|
1688
1802
|
let customCssValue = propertyMapValue[stylePropName];
|
|
1689
1803
|
if (typeof customCssValue === "object") {
|
|
1690
|
-
customCssValue =
|
|
1804
|
+
customCssValue = import_editor_props4.stringPropTypeUtil.extract(customCssValue) || customCssValue?.value || "";
|
|
1691
1805
|
}
|
|
1692
1806
|
customCss = {
|
|
1693
1807
|
raw: btoa(customCssValue)
|
|
@@ -1700,7 +1814,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1700
1814
|
}
|
|
1701
1815
|
if (propertyRawSchema.kind === "plain") {
|
|
1702
1816
|
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
1703
|
-
const propUtil = (0,
|
|
1817
|
+
const propUtil = (0, import_editor_props4.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
1704
1818
|
if (propUtil) {
|
|
1705
1819
|
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
1706
1820
|
propertyMapValue[stylePropName] = plainValue;
|
|
@@ -1710,7 +1824,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1710
1824
|
});
|
|
1711
1825
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
1712
1826
|
if (!localStyle) {
|
|
1713
|
-
(0,
|
|
1827
|
+
(0, import_editor_elements6.createElementStyle)({
|
|
1714
1828
|
elementId,
|
|
1715
1829
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
1716
1830
|
classesProp: "classes",
|
|
@@ -1724,7 +1838,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1724
1838
|
}
|
|
1725
1839
|
});
|
|
1726
1840
|
} else {
|
|
1727
|
-
(0,
|
|
1841
|
+
(0, import_editor_elements6.updateElementStyle)({
|
|
1728
1842
|
elementId,
|
|
1729
1843
|
styleId: localStyle.id,
|
|
1730
1844
|
meta: {
|
|
@@ -1739,7 +1853,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1739
1853
|
}
|
|
1740
1854
|
return;
|
|
1741
1855
|
}
|
|
1742
|
-
const elementPropSchema = (0,
|
|
1856
|
+
const elementPropSchema = (0, import_editor_elements6.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
1743
1857
|
if (!elementPropSchema) {
|
|
1744
1858
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
1745
1859
|
}
|
|
@@ -1752,7 +1866,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1752
1866
|
);
|
|
1753
1867
|
}
|
|
1754
1868
|
const value = resolvePropValue(propertyValue);
|
|
1755
|
-
(0,
|
|
1869
|
+
(0, import_editor_elements6.updateElementSettings)({
|
|
1756
1870
|
id: elementId,
|
|
1757
1871
|
props: {
|
|
1758
1872
|
[propertyName]: value
|
|
@@ -1909,8 +2023,8 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
1909
2023
|
const errors = [];
|
|
1910
2024
|
const softErrors = [];
|
|
1911
2025
|
const rootContainers = [];
|
|
1912
|
-
const widgetsCache = (0,
|
|
1913
|
-
const documentContainer = (0,
|
|
2026
|
+
const widgetsCache = (0, import_editor_elements7.getWidgetsCache)() || {};
|
|
2027
|
+
const documentContainer = (0, import_editor_elements7.getContainer)("document");
|
|
1914
2028
|
try {
|
|
1915
2029
|
const parser = new DOMParser();
|
|
1916
2030
|
xml = parser.parseFromString(xmlStructure, "application/xml");
|
|
@@ -1925,19 +2039,19 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
1925
2039
|
errors.push(new Error(`Unknown widget type: ${elementTag}`));
|
|
1926
2040
|
}
|
|
1927
2041
|
const isContainer = elementTag === "e-flexbox" || elementTag === "e-div-block";
|
|
1928
|
-
const newElement = isContainer ? (0,
|
|
2042
|
+
const newElement = isContainer ? (0, import_editor_elements7.createElement)({
|
|
1929
2043
|
containerId: containerElement.id,
|
|
1930
2044
|
model: {
|
|
1931
2045
|
elType: elementTag,
|
|
1932
|
-
id: (0,
|
|
2046
|
+
id: (0, import_editor_elements7.generateElementId)()
|
|
1933
2047
|
},
|
|
1934
2048
|
options: { useHistory: false }
|
|
1935
|
-
}) : (0,
|
|
2049
|
+
}) : (0, import_editor_elements7.createElement)({
|
|
1936
2050
|
containerId: containerElement.id,
|
|
1937
2051
|
model: {
|
|
1938
2052
|
elType: "widget",
|
|
1939
2053
|
widgetType: elementTag,
|
|
1940
|
-
id: (0,
|
|
2054
|
+
id: (0, import_editor_elements7.generateElementId)()
|
|
1941
2055
|
},
|
|
1942
2056
|
options: { useHistory: false }
|
|
1943
2057
|
});
|
|
@@ -1994,7 +2108,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
1994
2108
|
}
|
|
1995
2109
|
if (errors.length) {
|
|
1996
2110
|
rootContainers.forEach((rootContainer) => {
|
|
1997
|
-
(0,
|
|
2111
|
+
(0, import_editor_elements7.deleteElement)({
|
|
1998
2112
|
elementId: rootContainer.id,
|
|
1999
2113
|
options: { useHistory: false }
|
|
2000
2114
|
});
|
|
@@ -2196,10 +2310,10 @@ Now that you have this information, ensure you have the schema and try again.`;
|
|
|
2196
2310
|
}
|
|
2197
2311
|
|
|
2198
2312
|
// src/mcp/tools/get-element-config/tool.ts
|
|
2199
|
-
var
|
|
2200
|
-
var
|
|
2313
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
2314
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
2201
2315
|
var import_schema5 = require("@elementor/schema");
|
|
2202
|
-
var
|
|
2316
|
+
var import_utils5 = require("@elementor/utils");
|
|
2203
2317
|
var schema = {
|
|
2204
2318
|
elementId: import_schema5.z.string()
|
|
2205
2319
|
};
|
|
@@ -2217,21 +2331,21 @@ var initGetElementConfigTool = (reg) => {
|
|
|
2217
2331
|
schema,
|
|
2218
2332
|
outputSchema: outputSchema3,
|
|
2219
2333
|
handler: async ({ elementId }) => {
|
|
2220
|
-
const element = (0,
|
|
2334
|
+
const element = (0, import_editor_elements8.getContainer)(elementId);
|
|
2221
2335
|
if (!element) {
|
|
2222
2336
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
2223
2337
|
}
|
|
2224
2338
|
const elementRawSettings = element.settings;
|
|
2225
|
-
const propSchema = (0,
|
|
2339
|
+
const propSchema = (0, import_editor_elements8.getWidgetsCache)()?.[element.model.get("widgetType") || ""]?.atomic_props_schema;
|
|
2226
2340
|
if (!elementRawSettings || !propSchema) {
|
|
2227
2341
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
2228
2342
|
}
|
|
2229
2343
|
const propValues = {};
|
|
2230
2344
|
const stylePropValues = {};
|
|
2231
|
-
|
|
2345
|
+
import_editor_props5.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
2232
2346
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
2233
2347
|
});
|
|
2234
|
-
const elementStyles = (0,
|
|
2348
|
+
const elementStyles = (0, import_editor_elements8.getElementStyles)(elementId) || {};
|
|
2235
2349
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
2236
2350
|
if (localStyle) {
|
|
2237
2351
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -2245,7 +2359,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
2245
2359
|
}
|
|
2246
2360
|
});
|
|
2247
2361
|
if (defaultVariant.custom_css?.raw) {
|
|
2248
|
-
stylePropValues.custom_css = (0,
|
|
2362
|
+
stylePropValues.custom_css = (0, import_utils5.decodeString)(defaultVariant.custom_css.raw, void 0);
|
|
2249
2363
|
}
|
|
2250
2364
|
}
|
|
2251
2365
|
}
|
|
@@ -2315,7 +2429,7 @@ Example of "image" PropValue structure:
|
|
|
2315
2429
|
`;
|
|
2316
2430
|
|
|
2317
2431
|
// src/prevent-link-in-link-commands.ts
|
|
2318
|
-
var
|
|
2432
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
2319
2433
|
var import_editor_notifications = require("@elementor/editor-notifications");
|
|
2320
2434
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
2321
2435
|
var import_i18n = require("@wordpress/i18n");
|
|
@@ -2386,13 +2500,13 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
2386
2500
|
return false;
|
|
2387
2501
|
}
|
|
2388
2502
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
2389
|
-
return src?.id ? (0,
|
|
2503
|
+
return src?.id ? (0, import_editor_elements9.isElementAnchored)(src.id) || !!(0, import_editor_elements9.getAnchoredDescendantId)(src.id) : false;
|
|
2390
2504
|
});
|
|
2391
2505
|
if (!isSourceContainsAnAnchor) {
|
|
2392
2506
|
return false;
|
|
2393
2507
|
}
|
|
2394
2508
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
2395
|
-
return target?.id ? (0,
|
|
2509
|
+
return target?.id ? (0, import_editor_elements9.isElementAnchored)(target.id) || !!(0, import_editor_elements9.getAnchoredAncestorId)(target.id) : false;
|
|
2396
2510
|
});
|
|
2397
2511
|
return isTargetContainsAnAnchor;
|
|
2398
2512
|
}
|
|
@@ -2401,14 +2515,14 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
2401
2515
|
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
2402
2516
|
|
|
2403
2517
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
2404
|
-
var
|
|
2518
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
2405
2519
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
2406
2520
|
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
2407
2521
|
var import_i18n3 = require("@wordpress/i18n");
|
|
2408
2522
|
|
|
2409
2523
|
// src/style-commands/utils.ts
|
|
2410
|
-
var
|
|
2411
|
-
var
|
|
2524
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
2525
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
2412
2526
|
var import_i18n2 = require("@wordpress/i18n");
|
|
2413
2527
|
function hasAtomicWidgets(args) {
|
|
2414
2528
|
const { containers = [args.container] } = args;
|
|
@@ -2426,13 +2540,13 @@ function getClassesProp(container) {
|
|
|
2426
2540
|
return null;
|
|
2427
2541
|
}
|
|
2428
2542
|
const [propKey] = Object.entries(propsSchema).find(
|
|
2429
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
2543
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props6.CLASSES_PROP_KEY
|
|
2430
2544
|
) ?? [];
|
|
2431
2545
|
return propKey ?? null;
|
|
2432
2546
|
}
|
|
2433
2547
|
function getContainerSchema(container) {
|
|
2434
2548
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
2435
|
-
const widgetsCache = (0,
|
|
2549
|
+
const widgetsCache = (0, import_editor_elements10.getWidgetsCache)();
|
|
2436
2550
|
const elementType = widgetsCache?.[type];
|
|
2437
2551
|
return elementType?.atomic_props_schema ?? null;
|
|
2438
2552
|
}
|
|
@@ -2445,7 +2559,7 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
2445
2559
|
}
|
|
2446
2560
|
}
|
|
2447
2561
|
function getTitleForContainers(containers) {
|
|
2448
|
-
return containers.length > 1 ? (0, import_i18n2.__)("Elements", "elementor") : (0,
|
|
2562
|
+
return containers.length > 1 ? (0, import_i18n2.__)("Elements", "elementor") : (0, import_editor_elements10.getElementLabel)(containers[0].id);
|
|
2449
2563
|
}
|
|
2450
2564
|
|
|
2451
2565
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
@@ -2458,7 +2572,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2458
2572
|
if (!classesProp) {
|
|
2459
2573
|
return null;
|
|
2460
2574
|
}
|
|
2461
|
-
const originalStyles = (0,
|
|
2575
|
+
const originalStyles = (0, import_editor_elements11.getElementStyles)(container.id);
|
|
2462
2576
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
2463
2577
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
2464
2578
|
const revertData = {
|
|
@@ -2467,7 +2581,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2467
2581
|
};
|
|
2468
2582
|
if (styleId) {
|
|
2469
2583
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
2470
|
-
(0,
|
|
2584
|
+
(0, import_editor_elements11.updateElementStyle)({
|
|
2471
2585
|
elementId,
|
|
2472
2586
|
styleId,
|
|
2473
2587
|
meta,
|
|
@@ -2478,7 +2592,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2478
2592
|
} else {
|
|
2479
2593
|
const [firstVariant] = newStyle.variants;
|
|
2480
2594
|
const additionalVariants = newStyle.variants.slice(1);
|
|
2481
|
-
revertData.styleId = (0,
|
|
2595
|
+
revertData.styleId = (0, import_editor_elements11.createElementStyle)({
|
|
2482
2596
|
elementId,
|
|
2483
2597
|
classesProp,
|
|
2484
2598
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -2496,7 +2610,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2496
2610
|
return;
|
|
2497
2611
|
}
|
|
2498
2612
|
if (!revertData.originalStyle) {
|
|
2499
|
-
(0,
|
|
2613
|
+
(0, import_editor_elements11.deleteElementStyle)(container.id, revertData.styleId);
|
|
2500
2614
|
return;
|
|
2501
2615
|
}
|
|
2502
2616
|
const classesProp = getClassesProp(container);
|
|
@@ -2505,7 +2619,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2505
2619
|
}
|
|
2506
2620
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
2507
2621
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
2508
|
-
(0,
|
|
2622
|
+
(0, import_editor_elements11.createElementStyle)({
|
|
2509
2623
|
elementId: container.id,
|
|
2510
2624
|
classesProp,
|
|
2511
2625
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -2557,7 +2671,7 @@ function pasteStyles(args, pasteCallback) {
|
|
|
2557
2671
|
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
2558
2672
|
|
|
2559
2673
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
2560
|
-
var
|
|
2674
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
2561
2675
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
2562
2676
|
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
2563
2677
|
var import_i18n4 = require("@wordpress/i18n");
|
|
@@ -2566,9 +2680,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters11.undoable)(
|
|
|
2566
2680
|
do: ({ containers }) => {
|
|
2567
2681
|
return containers.map((container) => {
|
|
2568
2682
|
const elementId = container.model.get("id");
|
|
2569
|
-
const containerStyles = (0,
|
|
2683
|
+
const containerStyles = (0, import_editor_elements12.getElementStyles)(elementId);
|
|
2570
2684
|
Object.keys(containerStyles ?? {}).forEach(
|
|
2571
|
-
(styleId) => (0,
|
|
2685
|
+
(styleId) => (0, import_editor_elements12.deleteElementStyle)(elementId, styleId)
|
|
2572
2686
|
);
|
|
2573
2687
|
return containerStyles;
|
|
2574
2688
|
});
|
|
@@ -2584,7 +2698,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters11.undoable)(
|
|
|
2584
2698
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
2585
2699
|
const [firstVariant] = style.variants;
|
|
2586
2700
|
const additionalVariants = style.variants.slice(1);
|
|
2587
|
-
(0,
|
|
2701
|
+
(0, import_editor_elements12.createElementStyle)({
|
|
2588
2702
|
elementId,
|
|
2589
2703
|
classesProp,
|
|
2590
2704
|
styleId,
|