@elementor/editor-canvas 3.33.0-294 → 3.33.0-296
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 -138
- package/dist/index.mjs +189 -73
- 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/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,7 +851,7 @@ 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
856
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
742
857
|
[styleItems, breakpointsOrder.join("-")]
|
|
@@ -809,7 +924,7 @@ function StyleRenderer() {
|
|
|
809
924
|
if (!container) {
|
|
810
925
|
return null;
|
|
811
926
|
}
|
|
812
|
-
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 })));
|
|
813
928
|
}
|
|
814
929
|
function usePortalContainer2() {
|
|
815
930
|
return (0, import_editor_v1_adapters6.__privateUseListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
@@ -1179,10 +1294,10 @@ var transformSkewTransformer = createTransformer((value) => {
|
|
|
1179
1294
|
});
|
|
1180
1295
|
|
|
1181
1296
|
// src/transformers/styles/transition-transformer.ts
|
|
1182
|
-
var
|
|
1297
|
+
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1183
1298
|
var getAllowedProperties = () => {
|
|
1184
1299
|
const allowedProperties = /* @__PURE__ */ new Set();
|
|
1185
|
-
|
|
1300
|
+
import_editor_controls2.transitionProperties.forEach((category) => {
|
|
1186
1301
|
category.properties.forEach((property) => {
|
|
1187
1302
|
allowedProperties.add(property.value);
|
|
1188
1303
|
});
|
|
@@ -1244,7 +1359,7 @@ function initStyleTransformers() {
|
|
|
1244
1359
|
}
|
|
1245
1360
|
|
|
1246
1361
|
// src/legacy/init-legacy-views.ts
|
|
1247
|
-
var
|
|
1362
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1248
1363
|
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
1249
1364
|
|
|
1250
1365
|
// src/renderers/create-dom-renderer.ts
|
|
@@ -1473,7 +1588,7 @@ function registerElementType(type, elementTypeGenerator) {
|
|
|
1473
1588
|
}
|
|
1474
1589
|
function initLegacyViews() {
|
|
1475
1590
|
(0, import_editor_v1_adapters7.__privateListenTo)((0, import_editor_v1_adapters7.v1ReadyEvent)(), () => {
|
|
1476
|
-
const config = (0,
|
|
1591
|
+
const config = (0, import_editor_elements4.getWidgetsCache)() ?? {};
|
|
1477
1592
|
const legacyWindow = window;
|
|
1478
1593
|
const renderer = createDomRenderer();
|
|
1479
1594
|
Object.entries(config).forEach(([type, element]) => {
|
|
@@ -1494,9 +1609,9 @@ function initLegacyViews() {
|
|
|
1494
1609
|
}
|
|
1495
1610
|
|
|
1496
1611
|
// src/mcp/resources/widgets-schema-resource.ts
|
|
1497
|
-
var
|
|
1612
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1498
1613
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
1499
|
-
var
|
|
1614
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1500
1615
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
1501
1616
|
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
1502
1617
|
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
@@ -1551,7 +1666,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1551
1666
|
throw new Error(`No styles schema found for category: ${category}`);
|
|
1552
1667
|
}
|
|
1553
1668
|
const cleanedupPropSchema = cleanupPropType(stylesSchema);
|
|
1554
|
-
const asJson =
|
|
1669
|
+
const asJson = import_editor_props3.Schema.propTypeToJsonSchema(cleanedupPropSchema);
|
|
1555
1670
|
return {
|
|
1556
1671
|
contents: [
|
|
1557
1672
|
{
|
|
@@ -1566,7 +1681,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1566
1681
|
"widget-schema-by-type",
|
|
1567
1682
|
new import_editor_mcp.ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
1568
1683
|
list: () => {
|
|
1569
|
-
const cache = (0,
|
|
1684
|
+
const cache = (0, import_editor_elements5.getWidgetsCache)() || {};
|
|
1570
1685
|
const availableWidgets = Object.keys(cache || {}).filter(
|
|
1571
1686
|
(widgetType) => cache[widgetType]?.atomic_props_schema
|
|
1572
1687
|
);
|
|
@@ -1583,7 +1698,7 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1583
1698
|
},
|
|
1584
1699
|
async (uri, variables) => {
|
|
1585
1700
|
const widgetType = typeof variables.widgetType === "string" ? variables.widgetType : variables.widgetType?.[0];
|
|
1586
|
-
const propSchema = (0,
|
|
1701
|
+
const propSchema = (0, import_editor_elements5.getWidgetsCache)()?.[widgetType]?.atomic_props_schema;
|
|
1587
1702
|
if (!propSchema) {
|
|
1588
1703
|
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
1589
1704
|
}
|
|
@@ -1591,10 +1706,10 @@ The css string must follow standard CSS syntax, with properties and values separ
|
|
|
1591
1706
|
const asJson = Object.fromEntries(
|
|
1592
1707
|
Object.entries(cleanedupPropSchema).map(([key, propType]) => [
|
|
1593
1708
|
key,
|
|
1594
|
-
|
|
1709
|
+
import_editor_props3.Schema.propTypeToJsonSchema(propType)
|
|
1595
1710
|
])
|
|
1596
1711
|
);
|
|
1597
|
-
|
|
1712
|
+
import_editor_props3.Schema.nonConfigurablePropKeys.forEach((key) => {
|
|
1598
1713
|
delete asJson[key];
|
|
1599
1714
|
});
|
|
1600
1715
|
return {
|
|
@@ -1653,19 +1768,19 @@ function cleanupPropType(propType) {
|
|
|
1653
1768
|
}
|
|
1654
1769
|
|
|
1655
1770
|
// src/mcp/tools/build-composition/tool.ts
|
|
1656
|
-
var
|
|
1771
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
1657
1772
|
|
|
1658
1773
|
// src/mcp/utils/do-update-element-property.ts
|
|
1659
|
-
var
|
|
1660
|
-
var
|
|
1774
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
1775
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
1661
1776
|
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
1662
1777
|
function resolvePropValue(value, forceKey) {
|
|
1663
|
-
return
|
|
1778
|
+
return import_editor_props4.Schema.adjustLlmPropValueSchema(value, forceKey);
|
|
1664
1779
|
}
|
|
1665
1780
|
var doUpdateElementProperty = (params) => {
|
|
1666
1781
|
const { elementId, propertyName, propertyValue, elementType } = params;
|
|
1667
1782
|
if (propertyName === "_styles") {
|
|
1668
|
-
const elementStyles = (0,
|
|
1783
|
+
const elementStyles = (0, import_editor_elements6.getElementStyles)(elementId) || {};
|
|
1669
1784
|
const propertyMapValue = propertyValue;
|
|
1670
1785
|
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
1671
1786
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -1686,7 +1801,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1686
1801
|
if (stylePropName === "custom_css") {
|
|
1687
1802
|
let customCssValue = propertyMapValue[stylePropName];
|
|
1688
1803
|
if (typeof customCssValue === "object") {
|
|
1689
|
-
customCssValue =
|
|
1804
|
+
customCssValue = import_editor_props4.stringPropTypeUtil.extract(customCssValue) || customCssValue?.value || "";
|
|
1690
1805
|
}
|
|
1691
1806
|
customCss = {
|
|
1692
1807
|
raw: btoa(customCssValue)
|
|
@@ -1699,7 +1814,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1699
1814
|
}
|
|
1700
1815
|
if (propertyRawSchema.kind === "plain") {
|
|
1701
1816
|
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
1702
|
-
const propUtil = (0,
|
|
1817
|
+
const propUtil = (0, import_editor_props4.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
1703
1818
|
if (propUtil) {
|
|
1704
1819
|
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
1705
1820
|
propertyMapValue[stylePropName] = plainValue;
|
|
@@ -1709,7 +1824,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1709
1824
|
});
|
|
1710
1825
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
1711
1826
|
if (!localStyle) {
|
|
1712
|
-
(0,
|
|
1827
|
+
(0, import_editor_elements6.createElementStyle)({
|
|
1713
1828
|
elementId,
|
|
1714
1829
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
1715
1830
|
classesProp: "classes",
|
|
@@ -1723,7 +1838,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1723
1838
|
}
|
|
1724
1839
|
});
|
|
1725
1840
|
} else {
|
|
1726
|
-
(0,
|
|
1841
|
+
(0, import_editor_elements6.updateElementStyle)({
|
|
1727
1842
|
elementId,
|
|
1728
1843
|
styleId: localStyle.id,
|
|
1729
1844
|
meta: {
|
|
@@ -1738,7 +1853,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1738
1853
|
}
|
|
1739
1854
|
return;
|
|
1740
1855
|
}
|
|
1741
|
-
const elementPropSchema = (0,
|
|
1856
|
+
const elementPropSchema = (0, import_editor_elements6.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
1742
1857
|
if (!elementPropSchema) {
|
|
1743
1858
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
1744
1859
|
}
|
|
@@ -1751,7 +1866,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
1751
1866
|
);
|
|
1752
1867
|
}
|
|
1753
1868
|
const value = resolvePropValue(propertyValue);
|
|
1754
|
-
(0,
|
|
1869
|
+
(0, import_editor_elements6.updateElementSettings)({
|
|
1755
1870
|
id: elementId,
|
|
1756
1871
|
props: {
|
|
1757
1872
|
[propertyName]: value
|
|
@@ -1908,8 +2023,8 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
1908
2023
|
const errors = [];
|
|
1909
2024
|
const softErrors = [];
|
|
1910
2025
|
const rootContainers = [];
|
|
1911
|
-
const widgetsCache = (0,
|
|
1912
|
-
const documentContainer = (0,
|
|
2026
|
+
const widgetsCache = (0, import_editor_elements7.getWidgetsCache)() || {};
|
|
2027
|
+
const documentContainer = (0, import_editor_elements7.getContainer)("document");
|
|
1913
2028
|
try {
|
|
1914
2029
|
const parser = new DOMParser();
|
|
1915
2030
|
xml = parser.parseFromString(xmlStructure, "application/xml");
|
|
@@ -1924,19 +2039,19 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
1924
2039
|
errors.push(new Error(`Unknown widget type: ${elementTag}`));
|
|
1925
2040
|
}
|
|
1926
2041
|
const isContainer = elementTag === "e-flexbox" || elementTag === "e-div-block";
|
|
1927
|
-
const newElement = isContainer ? (0,
|
|
2042
|
+
const newElement = isContainer ? (0, import_editor_elements7.createElement)({
|
|
1928
2043
|
containerId: containerElement.id,
|
|
1929
2044
|
model: {
|
|
1930
2045
|
elType: elementTag,
|
|
1931
|
-
id: (0,
|
|
2046
|
+
id: (0, import_editor_elements7.generateElementId)()
|
|
1932
2047
|
},
|
|
1933
2048
|
options: { useHistory: false }
|
|
1934
|
-
}) : (0,
|
|
2049
|
+
}) : (0, import_editor_elements7.createElement)({
|
|
1935
2050
|
containerId: containerElement.id,
|
|
1936
2051
|
model: {
|
|
1937
2052
|
elType: "widget",
|
|
1938
2053
|
widgetType: elementTag,
|
|
1939
|
-
id: (0,
|
|
2054
|
+
id: (0, import_editor_elements7.generateElementId)()
|
|
1940
2055
|
},
|
|
1941
2056
|
options: { useHistory: false }
|
|
1942
2057
|
});
|
|
@@ -1993,7 +2108,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
1993
2108
|
}
|
|
1994
2109
|
if (errors.length) {
|
|
1995
2110
|
rootContainers.forEach((rootContainer) => {
|
|
1996
|
-
(0,
|
|
2111
|
+
(0, import_editor_elements7.deleteElement)({
|
|
1997
2112
|
elementId: rootContainer.id,
|
|
1998
2113
|
options: { useHistory: false }
|
|
1999
2114
|
});
|
|
@@ -2195,10 +2310,10 @@ Now that you have this information, ensure you have the schema and try again.`;
|
|
|
2195
2310
|
}
|
|
2196
2311
|
|
|
2197
2312
|
// src/mcp/tools/get-element-config/tool.ts
|
|
2198
|
-
var
|
|
2199
|
-
var
|
|
2313
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
2314
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
2200
2315
|
var import_schema5 = require("@elementor/schema");
|
|
2201
|
-
var
|
|
2316
|
+
var import_utils5 = require("@elementor/utils");
|
|
2202
2317
|
var schema = {
|
|
2203
2318
|
elementId: import_schema5.z.string()
|
|
2204
2319
|
};
|
|
@@ -2216,21 +2331,21 @@ var initGetElementConfigTool = (reg) => {
|
|
|
2216
2331
|
schema,
|
|
2217
2332
|
outputSchema: outputSchema3,
|
|
2218
2333
|
handler: async ({ elementId }) => {
|
|
2219
|
-
const element = (0,
|
|
2334
|
+
const element = (0, import_editor_elements8.getContainer)(elementId);
|
|
2220
2335
|
if (!element) {
|
|
2221
2336
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
2222
2337
|
}
|
|
2223
2338
|
const elementRawSettings = element.settings;
|
|
2224
|
-
const propSchema = (0,
|
|
2339
|
+
const propSchema = (0, import_editor_elements8.getWidgetsCache)()?.[element.model.get("widgetType") || ""]?.atomic_props_schema;
|
|
2225
2340
|
if (!elementRawSettings || !propSchema) {
|
|
2226
2341
|
throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
|
|
2227
2342
|
}
|
|
2228
2343
|
const propValues = {};
|
|
2229
2344
|
const stylePropValues = {};
|
|
2230
|
-
|
|
2345
|
+
import_editor_props5.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
2231
2346
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
2232
2347
|
});
|
|
2233
|
-
const elementStyles = (0,
|
|
2348
|
+
const elementStyles = (0, import_editor_elements8.getElementStyles)(elementId) || {};
|
|
2234
2349
|
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
2235
2350
|
if (localStyle) {
|
|
2236
2351
|
const defaultVariant = localStyle.variants.find(
|
|
@@ -2244,7 +2359,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
2244
2359
|
}
|
|
2245
2360
|
});
|
|
2246
2361
|
if (defaultVariant.custom_css?.raw) {
|
|
2247
|
-
stylePropValues.custom_css = (0,
|
|
2362
|
+
stylePropValues.custom_css = (0, import_utils5.decodeString)(defaultVariant.custom_css.raw, void 0);
|
|
2248
2363
|
}
|
|
2249
2364
|
}
|
|
2250
2365
|
}
|
|
@@ -2314,7 +2429,7 @@ Example of "image" PropValue structure:
|
|
|
2314
2429
|
`;
|
|
2315
2430
|
|
|
2316
2431
|
// src/prevent-link-in-link-commands.ts
|
|
2317
|
-
var
|
|
2432
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
2318
2433
|
var import_editor_notifications = require("@elementor/editor-notifications");
|
|
2319
2434
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
2320
2435
|
var import_i18n = require("@wordpress/i18n");
|
|
@@ -2385,13 +2500,13 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
2385
2500
|
return false;
|
|
2386
2501
|
}
|
|
2387
2502
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
2388
|
-
return src?.id ? (0,
|
|
2503
|
+
return src?.id ? (0, import_editor_elements9.isElementAnchored)(src.id) || !!(0, import_editor_elements9.getAnchoredDescendantId)(src.id) : false;
|
|
2389
2504
|
});
|
|
2390
2505
|
if (!isSourceContainsAnAnchor) {
|
|
2391
2506
|
return false;
|
|
2392
2507
|
}
|
|
2393
2508
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
2394
|
-
return target?.id ? (0,
|
|
2509
|
+
return target?.id ? (0, import_editor_elements9.isElementAnchored)(target.id) || !!(0, import_editor_elements9.getAnchoredAncestorId)(target.id) : false;
|
|
2395
2510
|
});
|
|
2396
2511
|
return isTargetContainsAnAnchor;
|
|
2397
2512
|
}
|
|
@@ -2400,14 +2515,14 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
2400
2515
|
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
2401
2516
|
|
|
2402
2517
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
2403
|
-
var
|
|
2518
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
2404
2519
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
2405
2520
|
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
2406
2521
|
var import_i18n3 = require("@wordpress/i18n");
|
|
2407
2522
|
|
|
2408
2523
|
// src/style-commands/utils.ts
|
|
2409
|
-
var
|
|
2410
|
-
var
|
|
2524
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
2525
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
2411
2526
|
var import_i18n2 = require("@wordpress/i18n");
|
|
2412
2527
|
function hasAtomicWidgets(args) {
|
|
2413
2528
|
const { containers = [args.container] } = args;
|
|
@@ -2425,13 +2540,13 @@ function getClassesProp(container) {
|
|
|
2425
2540
|
return null;
|
|
2426
2541
|
}
|
|
2427
2542
|
const [propKey] = Object.entries(propsSchema).find(
|
|
2428
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
2543
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props6.CLASSES_PROP_KEY
|
|
2429
2544
|
) ?? [];
|
|
2430
2545
|
return propKey ?? null;
|
|
2431
2546
|
}
|
|
2432
2547
|
function getContainerSchema(container) {
|
|
2433
2548
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
2434
|
-
const widgetsCache = (0,
|
|
2549
|
+
const widgetsCache = (0, import_editor_elements10.getWidgetsCache)();
|
|
2435
2550
|
const elementType = widgetsCache?.[type];
|
|
2436
2551
|
return elementType?.atomic_props_schema ?? null;
|
|
2437
2552
|
}
|
|
@@ -2444,7 +2559,7 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
2444
2559
|
}
|
|
2445
2560
|
}
|
|
2446
2561
|
function getTitleForContainers(containers) {
|
|
2447
|
-
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);
|
|
2448
2563
|
}
|
|
2449
2564
|
|
|
2450
2565
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
@@ -2457,7 +2572,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2457
2572
|
if (!classesProp) {
|
|
2458
2573
|
return null;
|
|
2459
2574
|
}
|
|
2460
|
-
const originalStyles = (0,
|
|
2575
|
+
const originalStyles = (0, import_editor_elements11.getElementStyles)(container.id);
|
|
2461
2576
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
2462
2577
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
2463
2578
|
const revertData = {
|
|
@@ -2466,7 +2581,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2466
2581
|
};
|
|
2467
2582
|
if (styleId) {
|
|
2468
2583
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
2469
|
-
(0,
|
|
2584
|
+
(0, import_editor_elements11.updateElementStyle)({
|
|
2470
2585
|
elementId,
|
|
2471
2586
|
styleId,
|
|
2472
2587
|
meta,
|
|
@@ -2477,7 +2592,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2477
2592
|
} else {
|
|
2478
2593
|
const [firstVariant] = newStyle.variants;
|
|
2479
2594
|
const additionalVariants = newStyle.variants.slice(1);
|
|
2480
|
-
revertData.styleId = (0,
|
|
2595
|
+
revertData.styleId = (0, import_editor_elements11.createElementStyle)({
|
|
2481
2596
|
elementId,
|
|
2482
2597
|
classesProp,
|
|
2483
2598
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -2495,7 +2610,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2495
2610
|
return;
|
|
2496
2611
|
}
|
|
2497
2612
|
if (!revertData.originalStyle) {
|
|
2498
|
-
(0,
|
|
2613
|
+
(0, import_editor_elements11.deleteElementStyle)(container.id, revertData.styleId);
|
|
2499
2614
|
return;
|
|
2500
2615
|
}
|
|
2501
2616
|
const classesProp = getClassesProp(container);
|
|
@@ -2504,7 +2619,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
2504
2619
|
}
|
|
2505
2620
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
2506
2621
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
2507
|
-
(0,
|
|
2622
|
+
(0, import_editor_elements11.createElementStyle)({
|
|
2508
2623
|
elementId: container.id,
|
|
2509
2624
|
classesProp,
|
|
2510
2625
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -2556,7 +2671,7 @@ function pasteStyles(args, pasteCallback) {
|
|
|
2556
2671
|
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
2557
2672
|
|
|
2558
2673
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
2559
|
-
var
|
|
2674
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
2560
2675
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
2561
2676
|
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
2562
2677
|
var import_i18n4 = require("@wordpress/i18n");
|
|
@@ -2565,9 +2680,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters11.undoable)(
|
|
|
2565
2680
|
do: ({ containers }) => {
|
|
2566
2681
|
return containers.map((container) => {
|
|
2567
2682
|
const elementId = container.model.get("id");
|
|
2568
|
-
const containerStyles = (0,
|
|
2683
|
+
const containerStyles = (0, import_editor_elements12.getElementStyles)(elementId);
|
|
2569
2684
|
Object.keys(containerStyles ?? {}).forEach(
|
|
2570
|
-
(styleId) => (0,
|
|
2685
|
+
(styleId) => (0, import_editor_elements12.deleteElementStyle)(elementId, styleId)
|
|
2571
2686
|
);
|
|
2572
2687
|
return containerStyles;
|
|
2573
2688
|
});
|
|
@@ -2583,7 +2698,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters11.undoable)(
|
|
|
2583
2698
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
2584
2699
|
const [firstVariant] = style.variants;
|
|
2585
2700
|
const additionalVariants = style.variants.slice(1);
|
|
2586
|
-
(0,
|
|
2701
|
+
(0, import_editor_elements12.createElementStyle)({
|
|
2587
2702
|
elementId,
|
|
2588
2703
|
classesProp,
|
|
2589
2704
|
styleId,
|