@elementor/editor-elements 4.2.0-beta2 → 4.3.0-1000
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.d.mts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +310 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +291 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/children-dependencies/bind-settings-reconcile.ts +147 -0
- package/src/children-dependencies/index.ts +4 -0
- package/src/children-dependencies/reconcile-initial-children.ts +59 -0
- package/src/children-dependencies/stash.ts +40 -0
- package/src/children-dependencies/types.ts +20 -0
- package/src/children-dependencies/utils.ts +44 -0
- package/src/index.ts +12 -0
- package/src/sync/get-element-icon.ts +14 -0
- package/src/sync/get-element-title.ts +48 -0
- package/src/sync/resolve-insert-index.ts +34 -0
- package/src/sync/types.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ELEMENT_STYLE_CHANGE_EVENT: () => ELEMENT_STYLE_CHANGE_EVENT,
|
|
24
24
|
addModelToParent: () => addModelToParent,
|
|
25
|
+
bindSettingsReconcile: () => bindSettingsReconcile,
|
|
25
26
|
createElement: () => createElement,
|
|
26
27
|
createElementStyle: () => createElementStyle,
|
|
27
28
|
createElements: () => createElements,
|
|
@@ -30,6 +31,7 @@ __export(index_exports, {
|
|
|
30
31
|
dropElement: () => dropElement,
|
|
31
32
|
duplicateElement: () => duplicateElement,
|
|
32
33
|
duplicateElements: () => duplicateElements,
|
|
34
|
+
evaluateWhen: () => evaluateWhen,
|
|
33
35
|
findChildRecursive: () => findChildRecursive,
|
|
34
36
|
findModelInDocument: () => findModelInDocument,
|
|
35
37
|
generateElementId: () => generateElementId,
|
|
@@ -41,11 +43,13 @@ __export(index_exports, {
|
|
|
41
43
|
getCurrentDocumentId: () => getCurrentDocumentId,
|
|
42
44
|
getElementChildrenWithFallback: () => getElementChildren,
|
|
43
45
|
getElementEditorSettings: () => getElementEditorSettings,
|
|
46
|
+
getElementIcon: () => getElementIcon,
|
|
44
47
|
getElementInteractions: () => getElementInteractions,
|
|
45
48
|
getElementLabel: () => getElementLabel,
|
|
46
49
|
getElementSetting: () => getElementSetting,
|
|
47
50
|
getElementSettings: () => getElementSettings,
|
|
48
51
|
getElementStyles: () => getElementStyles,
|
|
52
|
+
getElementTitle: () => getElementTitle,
|
|
49
53
|
getElementType: () => getElementType,
|
|
50
54
|
getElements: () => getElements,
|
|
51
55
|
getLinkInLinkRestriction: () => getLinkInLinkRestriction,
|
|
@@ -55,10 +59,12 @@ __export(index_exports, {
|
|
|
55
59
|
moveElement: () => moveElement,
|
|
56
60
|
moveElements: () => moveElements,
|
|
57
61
|
playElementInteractions: () => playElementInteractions,
|
|
62
|
+
reconcileInitialChildren: () => reconcileInitialChildren,
|
|
58
63
|
removeElements: () => removeElements,
|
|
59
64
|
removeModelFromParent: () => removeModelFromParent,
|
|
60
65
|
replaceElement: () => replaceElement,
|
|
61
66
|
resolveContainer: () => resolveContainer,
|
|
67
|
+
resolveInsertIndex: () => resolveInsertIndex,
|
|
62
68
|
selectElement: () => selectElement,
|
|
63
69
|
shouldCreateNewLocalStyle: () => shouldCreateNewLocalStyle,
|
|
64
70
|
styleRerenderEvents: () => styleRerenderEvents,
|
|
@@ -74,9 +80,6 @@ __export(index_exports, {
|
|
|
74
80
|
});
|
|
75
81
|
module.exports = __toCommonJS(index_exports);
|
|
76
82
|
|
|
77
|
-
// src/hooks/use-element-children.ts
|
|
78
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
79
|
-
|
|
80
83
|
// src/sync/get-container.ts
|
|
81
84
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
82
85
|
function getContainer(id) {
|
|
@@ -92,6 +95,250 @@ var selectElement = (elementId) => {
|
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
|
|
98
|
+
// src/sync/resolve-element.ts
|
|
99
|
+
function isConnected(container) {
|
|
100
|
+
if (!container) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!container.view?.el) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return container.view.el.isConnected;
|
|
107
|
+
}
|
|
108
|
+
function resolveContainer(container, id) {
|
|
109
|
+
const looked = container.lookup?.();
|
|
110
|
+
if (isConnected(looked)) {
|
|
111
|
+
return looked;
|
|
112
|
+
}
|
|
113
|
+
const byId = getContainer(id);
|
|
114
|
+
if (isConnected(byId)) {
|
|
115
|
+
return byId;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function getDocumentUtils() {
|
|
120
|
+
return window.$e?.components?.get?.("document")?.utils;
|
|
121
|
+
}
|
|
122
|
+
function findModelInDocument(id) {
|
|
123
|
+
return getDocumentUtils()?.findModelById?.(id) ?? null;
|
|
124
|
+
}
|
|
125
|
+
function addModelToParent(parentId, childData, options) {
|
|
126
|
+
return getDocumentUtils()?.addModelToParent?.(parentId, childData, options) ?? false;
|
|
127
|
+
}
|
|
128
|
+
function removeModelFromParent(parentId, childId) {
|
|
129
|
+
return getDocumentUtils()?.removeModelFromParent?.(parentId, childId) ?? false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/sync/resolve-insert-index.ts
|
|
133
|
+
function resolveInsertIndex(position, elements) {
|
|
134
|
+
const lastIndex = elements.length;
|
|
135
|
+
switch (position.kind) {
|
|
136
|
+
case "first":
|
|
137
|
+
return 0;
|
|
138
|
+
case "last":
|
|
139
|
+
return lastIndex;
|
|
140
|
+
case "index": {
|
|
141
|
+
const index = typeof position.value === "number" ? position.value : lastIndex;
|
|
142
|
+
return Math.max(0, Math.min(index, lastIndex));
|
|
143
|
+
}
|
|
144
|
+
case "after_type": {
|
|
145
|
+
const anchor = elements.findIndex((element) => element.elType === position.value);
|
|
146
|
+
return anchor >= 0 ? anchor + 1 : lastIndex;
|
|
147
|
+
}
|
|
148
|
+
case "before_type": {
|
|
149
|
+
const anchor = elements.findIndex((element) => element.elType === position.value);
|
|
150
|
+
return anchor >= 0 ? anchor : lastIndex;
|
|
151
|
+
}
|
|
152
|
+
default:
|
|
153
|
+
return lastIndex;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/children-dependencies/stash.ts
|
|
158
|
+
var import_session = require("@elementor/session");
|
|
159
|
+
var STASH_KEY_PREFIX = "elementor/editor-state";
|
|
160
|
+
var STASH_KEY_SEGMENT = "children-deps";
|
|
161
|
+
function createChildrenStash() {
|
|
162
|
+
return {
|
|
163
|
+
get(elementId, childType) {
|
|
164
|
+
return (0, import_session.getSessionStorageItem)(buildStashKey(elementId, childType));
|
|
165
|
+
},
|
|
166
|
+
save(elementId, childType, data) {
|
|
167
|
+
(0, import_session.setSessionStorageItem)(buildStashKey(elementId, childType), data);
|
|
168
|
+
},
|
|
169
|
+
clear(elementId, childType) {
|
|
170
|
+
(0, import_session.removeSessionStorageItem)(buildStashKey(elementId, childType));
|
|
171
|
+
},
|
|
172
|
+
clearAllForElement(elementId) {
|
|
173
|
+
const prefix = buildElementStashPrefix(elementId);
|
|
174
|
+
for (let index = sessionStorage.length - 1; index >= 0; index--) {
|
|
175
|
+
const key = sessionStorage.key(index);
|
|
176
|
+
if (key?.startsWith(prefix)) {
|
|
177
|
+
(0, import_session.removeSessionStorageItem)(key);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function buildStashKey(elementId, childType) {
|
|
184
|
+
return `${STASH_KEY_PREFIX}/${elementId}/${STASH_KEY_SEGMENT}/${childType}`;
|
|
185
|
+
}
|
|
186
|
+
function buildElementStashPrefix(elementId) {
|
|
187
|
+
return `${STASH_KEY_PREFIX}/${elementId}/${STASH_KEY_SEGMENT}/`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/children-dependencies/utils.ts
|
|
191
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
192
|
+
|
|
193
|
+
// src/sync/generate-element-id.ts
|
|
194
|
+
var generateElementId = () => {
|
|
195
|
+
const extendedWindow = window;
|
|
196
|
+
return extendedWindow.elementorCommon?.helpers?.getUniqueId?.() ?? `el-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/children-dependencies/utils.ts
|
|
200
|
+
function evaluateWhen(when, settings) {
|
|
201
|
+
return (0, import_editor_props.isDependencyMet)(when, settings).isMet;
|
|
202
|
+
}
|
|
203
|
+
function ensureModelId(model) {
|
|
204
|
+
const { skipDefaultChildren: _skipDefaultChildren, ...rest } = model;
|
|
205
|
+
return rest.id ? rest : { ...rest, id: generateElementId() };
|
|
206
|
+
}
|
|
207
|
+
function resolveChildModelData(elementId, rule, stash) {
|
|
208
|
+
const stashed = rule.stash ? stash.get(elementId, rule.child_type) : void 0;
|
|
209
|
+
const modelData = ensureModelId(
|
|
210
|
+
stashed ?? rule.default_model ?? { elType: rule.child_type }
|
|
211
|
+
);
|
|
212
|
+
return { modelData, wasStashed: Boolean(stashed) };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/children-dependencies/bind-settings-reconcile.ts
|
|
216
|
+
function bindSettingsReconcile({ model, elementConfig }) {
|
|
217
|
+
const stash = createChildrenStash();
|
|
218
|
+
const rules = elementConfig?.children_dependencies;
|
|
219
|
+
if (!rules?.length) {
|
|
220
|
+
return () => {
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const settingsModel = model.get("settings");
|
|
224
|
+
const elementId = model.get("id");
|
|
225
|
+
if (!settingsModel?.on || !settingsModel?.off || !elementId) {
|
|
226
|
+
return () => {
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const lastMet = /* @__PURE__ */ new Map();
|
|
230
|
+
rules.forEach((rule) => {
|
|
231
|
+
lastMet.set(rule.child_type, evaluateWhen(rule.when, settingsModel.toJSON()));
|
|
232
|
+
});
|
|
233
|
+
const onChange = () => {
|
|
234
|
+
const currentSettings = settingsModel.toJSON();
|
|
235
|
+
rules.forEach((rule) => {
|
|
236
|
+
const previous = lastMet.get(rule.child_type) ?? false;
|
|
237
|
+
const current = evaluateWhen(rule.when, currentSettings);
|
|
238
|
+
if (previous === current) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
lastMet.set(rule.child_type, current);
|
|
242
|
+
if (current) {
|
|
243
|
+
attachChildFromRule(elementId, rule, stash);
|
|
244
|
+
} else {
|
|
245
|
+
detachChildFromRule(elementId, rule, stash);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
settingsModel.on("change", onChange);
|
|
250
|
+
return () => {
|
|
251
|
+
settingsModel.off?.("change", onChange);
|
|
252
|
+
stash.clearAllForElement(elementId);
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function attachChildFromRule(parentId, rule, stash) {
|
|
256
|
+
const parent = getContainer(parentId) ?? void 0;
|
|
257
|
+
const currentChildren = getDirectChildData(parent);
|
|
258
|
+
const alreadyPresent = currentChildren.some((child) => child.elType === rule.child_type);
|
|
259
|
+
if (alreadyPresent) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const { modelData, wasStashed } = resolveChildModelData(parentId, rule, stash);
|
|
263
|
+
const insertAt = resolveInsertIndex(rule.position, currentChildren);
|
|
264
|
+
const attached = addModelToParent(parentId, modelData, { at: insertAt });
|
|
265
|
+
if (!attached) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (wasStashed) {
|
|
269
|
+
stash.clear(parentId, rule.child_type);
|
|
270
|
+
}
|
|
271
|
+
requestNavigatorRefresh(parentId);
|
|
272
|
+
}
|
|
273
|
+
function detachChildFromRule(parentId, rule, stash) {
|
|
274
|
+
const parent = getContainer(parentId) ?? void 0;
|
|
275
|
+
const child = parent?.children?.find((candidate) => candidate.model.get("elType") === rule.child_type);
|
|
276
|
+
if (!child) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const childSnapshot = child.model.toJSON();
|
|
280
|
+
const removed = removeModelFromParent(parentId, child.id);
|
|
281
|
+
if (!removed) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (rule.stash) {
|
|
285
|
+
stash.save(parentId, rule.child_type, childSnapshot);
|
|
286
|
+
}
|
|
287
|
+
requestNavigatorRefresh(parentId);
|
|
288
|
+
}
|
|
289
|
+
function requestNavigatorRefresh(parentId) {
|
|
290
|
+
if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
window.dispatchEvent(
|
|
294
|
+
new CustomEvent("elementor/navigator/refresh-children", {
|
|
295
|
+
detail: { elementId: parentId }
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
function getDirectChildData(parent) {
|
|
300
|
+
return (parent?.children ?? []).map((child) => child.model.toJSON());
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/children-dependencies/reconcile-initial-children.ts
|
|
304
|
+
function reconcileInitialChildren({
|
|
305
|
+
elementId,
|
|
306
|
+
elementConfig,
|
|
307
|
+
attributes
|
|
308
|
+
}) {
|
|
309
|
+
const stash = createChildrenStash();
|
|
310
|
+
const rules = elementConfig?.children_dependencies;
|
|
311
|
+
if (!rules?.length) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const elements = [...attributes.elements ?? []];
|
|
315
|
+
const settings = attributes.settings ?? {};
|
|
316
|
+
rules.forEach((rule) => {
|
|
317
|
+
const isMet = evaluateWhen(rule.when, settings);
|
|
318
|
+
const existingIndex = elements.findIndex((element) => element.elType === rule.child_type);
|
|
319
|
+
const isPresent = existingIndex >= 0;
|
|
320
|
+
if (isMet && !isPresent) {
|
|
321
|
+
const { modelData, wasStashed } = resolveChildModelData(elementId, rule, stash);
|
|
322
|
+
const insertAt = resolveInsertIndex(rule.position, elements);
|
|
323
|
+
elements.splice(insertAt, 0, modelData);
|
|
324
|
+
if (wasStashed) {
|
|
325
|
+
stash.clear(elementId, rule.child_type);
|
|
326
|
+
}
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (!isMet && isPresent) {
|
|
330
|
+
const [removed] = elements.splice(existingIndex, 1);
|
|
331
|
+
if (rule.stash && removed) {
|
|
332
|
+
stash.save(elementId, rule.child_type, removed);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
attributes.elements = elements;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/hooks/use-element-children.ts
|
|
340
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
341
|
+
|
|
95
342
|
// src/sync/model-utils.ts
|
|
96
343
|
function findChildRecursive(model, predicate) {
|
|
97
344
|
const childModels = model.get("elements") ?? [];
|
|
@@ -318,40 +565,6 @@ function deleteElement({ container, options = {} }) {
|
|
|
318
565
|
});
|
|
319
566
|
}
|
|
320
567
|
|
|
321
|
-
// src/sync/resolve-element.ts
|
|
322
|
-
function isConnected(container) {
|
|
323
|
-
if (!container) {
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
if (!container.view?.el) {
|
|
327
|
-
return true;
|
|
328
|
-
}
|
|
329
|
-
return container.view.el.isConnected;
|
|
330
|
-
}
|
|
331
|
-
function resolveContainer(container, id) {
|
|
332
|
-
const looked = container.lookup?.();
|
|
333
|
-
if (isConnected(looked)) {
|
|
334
|
-
return looked;
|
|
335
|
-
}
|
|
336
|
-
const byId = getContainer(id);
|
|
337
|
-
if (isConnected(byId)) {
|
|
338
|
-
return byId;
|
|
339
|
-
}
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
function getDocumentUtils() {
|
|
343
|
-
return window.$e?.components?.get?.("document")?.utils;
|
|
344
|
-
}
|
|
345
|
-
function findModelInDocument(id) {
|
|
346
|
-
return getDocumentUtils()?.findModelById?.(id) ?? null;
|
|
347
|
-
}
|
|
348
|
-
function addModelToParent(parentId, childData, options) {
|
|
349
|
-
return getDocumentUtils()?.addModelToParent?.(parentId, childData, options) ?? false;
|
|
350
|
-
}
|
|
351
|
-
function removeModelFromParent(parentId, childId) {
|
|
352
|
-
return getDocumentUtils()?.removeModelFromParent?.(parentId, childId) ?? false;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
568
|
// src/sync/create-elements.ts
|
|
356
569
|
var createElements = ({
|
|
357
570
|
elements,
|
|
@@ -556,12 +769,6 @@ var duplicateElements = ({
|
|
|
556
769
|
return undoableDuplicate({ elementIds });
|
|
557
770
|
};
|
|
558
771
|
|
|
559
|
-
// src/sync/generate-element-id.ts
|
|
560
|
-
var generateElementId = () => {
|
|
561
|
-
const extendedWindow = window;
|
|
562
|
-
return extendedWindow.elementorCommon?.helpers?.getUniqueId?.() ?? `el-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
772
|
// src/sync/get-current-document-container.ts
|
|
566
773
|
function getCurrentDocumentContainer() {
|
|
567
774
|
const extendedWindow = window;
|
|
@@ -578,29 +785,39 @@ function getCurrentDocumentId() {
|
|
|
578
785
|
}
|
|
579
786
|
}
|
|
580
787
|
|
|
788
|
+
// src/sync/get-element-icon.ts
|
|
789
|
+
function getElementIcon(elementId) {
|
|
790
|
+
const container = getContainer(elementId);
|
|
791
|
+
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
792
|
+
if (!type) {
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
return getWidgetsCache()?.[type]?.icon ?? null;
|
|
796
|
+
}
|
|
797
|
+
|
|
581
798
|
// src/errors.ts
|
|
582
|
-
var
|
|
583
|
-
var ElementNotFoundError = (0,
|
|
799
|
+
var import_utils4 = require("@elementor/utils");
|
|
800
|
+
var ElementNotFoundError = (0, import_utils4.createError)({
|
|
584
801
|
code: "element_not_found",
|
|
585
802
|
message: "Element not found."
|
|
586
803
|
});
|
|
587
|
-
var StyleNotFoundError = (0,
|
|
804
|
+
var StyleNotFoundError = (0, import_utils4.createError)({
|
|
588
805
|
code: "style_not_found",
|
|
589
806
|
message: "Style not found."
|
|
590
807
|
});
|
|
591
|
-
var ElementTypeNotExistsError = (0,
|
|
808
|
+
var ElementTypeNotExistsError = (0, import_utils4.createError)({
|
|
592
809
|
code: "element_type_not_exists",
|
|
593
810
|
message: "Element type does not exist."
|
|
594
811
|
});
|
|
595
|
-
var ElementLabelNotExistsError = (0,
|
|
812
|
+
var ElementLabelNotExistsError = (0, import_utils4.createError)({
|
|
596
813
|
code: "element_label_not_exists",
|
|
597
814
|
message: "Element label does not exist."
|
|
598
815
|
});
|
|
599
|
-
var ElementParentNotFoundError = (0,
|
|
816
|
+
var ElementParentNotFoundError = (0, import_utils4.createError)({
|
|
600
817
|
code: "element_parent_not_found",
|
|
601
818
|
message: "Element parent not found."
|
|
602
819
|
});
|
|
603
|
-
var ElementIndexNotFoundError = (0,
|
|
820
|
+
var ElementIndexNotFoundError = (0, import_utils4.createError)({
|
|
604
821
|
code: "element_index_not_found",
|
|
605
822
|
message: "Element index not found."
|
|
606
823
|
});
|
|
@@ -622,6 +839,37 @@ function getElementLabel(elementId) {
|
|
|
622
839
|
return label;
|
|
623
840
|
}
|
|
624
841
|
|
|
842
|
+
// src/sync/get-element-title.ts
|
|
843
|
+
function extractString(value) {
|
|
844
|
+
if (typeof value === "string") {
|
|
845
|
+
return value || null;
|
|
846
|
+
}
|
|
847
|
+
if (value && typeof value === "object" && "value" in value && typeof value.value === "string") {
|
|
848
|
+
return value.value || null;
|
|
849
|
+
}
|
|
850
|
+
return null;
|
|
851
|
+
}
|
|
852
|
+
function getElementTitle(elementId) {
|
|
853
|
+
const editorSettings = getElementEditorSettings(elementId);
|
|
854
|
+
const editorTitle = extractString(editorSettings?.title);
|
|
855
|
+
if (editorTitle) {
|
|
856
|
+
return editorTitle;
|
|
857
|
+
}
|
|
858
|
+
const legacyTitle = extractString(getElementSetting(elementId, "_title"));
|
|
859
|
+
if (legacyTitle) {
|
|
860
|
+
return legacyTitle;
|
|
861
|
+
}
|
|
862
|
+
const presetTitle = extractString(getElementSetting(elementId, "presetTitle"));
|
|
863
|
+
if (presetTitle) {
|
|
864
|
+
return presetTitle;
|
|
865
|
+
}
|
|
866
|
+
try {
|
|
867
|
+
return getElementLabel(elementId);
|
|
868
|
+
} catch {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
625
873
|
// src/sync/get-element-styles.ts
|
|
626
874
|
var getElementStyles = (elementID) => {
|
|
627
875
|
const container = getContainer(elementID);
|
|
@@ -1075,11 +1323,11 @@ var styleRerenderEvents = [
|
|
|
1075
1323
|
];
|
|
1076
1324
|
|
|
1077
1325
|
// src/styles/create-element-style.ts
|
|
1078
|
-
var
|
|
1326
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1079
1327
|
var import_editor_styles = require("@elementor/editor-styles");
|
|
1080
1328
|
|
|
1081
1329
|
// src/styles/mutate-element-styles.ts
|
|
1082
|
-
var
|
|
1330
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
1083
1331
|
var import_editor_v1_adapters18 = require("@elementor/editor-v1-adapters");
|
|
1084
1332
|
function mutateElementStyles(elementId, mutator) {
|
|
1085
1333
|
const container = getContainer(elementId);
|
|
@@ -1131,7 +1379,7 @@ function clearRemovedClasses(container, { oldIds, newIds }) {
|
|
|
1131
1379
|
function getClassesProps(container) {
|
|
1132
1380
|
return Object.entries(container.settings.toJSON()).filter((prop) => {
|
|
1133
1381
|
const [, value] = prop;
|
|
1134
|
-
return
|
|
1382
|
+
return import_editor_props2.classesPropTypeUtil.isValid(value);
|
|
1135
1383
|
});
|
|
1136
1384
|
}
|
|
1137
1385
|
function notifyChanges() {
|
|
@@ -1170,7 +1418,7 @@ function createElementStyle({
|
|
|
1170
1418
|
}
|
|
1171
1419
|
function addStyleToClassesProp(elementId, classesProp, styleId) {
|
|
1172
1420
|
const base = getElementSetting(elementId, classesProp);
|
|
1173
|
-
const classesPropValue =
|
|
1421
|
+
const classesPropValue = import_editor_props3.classesPropTypeUtil.create(
|
|
1174
1422
|
(prev) => {
|
|
1175
1423
|
return [...prev ?? [], styleId];
|
|
1176
1424
|
},
|
|
@@ -1197,7 +1445,7 @@ function deleteElementStyle(elementId, styleId) {
|
|
|
1197
1445
|
}
|
|
1198
1446
|
|
|
1199
1447
|
// src/styles/update-element-style.ts
|
|
1200
|
-
var
|
|
1448
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
1201
1449
|
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
1202
1450
|
function updateElementStyle(args) {
|
|
1203
1451
|
mutateElementStyles(args.elementId, (styles) => {
|
|
@@ -1208,7 +1456,7 @@ function updateElementStyle(args) {
|
|
|
1208
1456
|
const variant = (0, import_editor_styles2.getVariantByMeta)(style, args.meta);
|
|
1209
1457
|
const customCss = ("custom_css" in args ? args.custom_css : variant?.custom_css) ?? null;
|
|
1210
1458
|
if (variant) {
|
|
1211
|
-
variant.props = (0,
|
|
1459
|
+
variant.props = (0, import_editor_props4.mergeProps)(variant.props, args.props);
|
|
1212
1460
|
variant.custom_css = customCss?.raw ? customCss : null;
|
|
1213
1461
|
} else {
|
|
1214
1462
|
style.variants.push({ meta: args.meta, props: args.props, custom_css: customCss });
|
|
@@ -1250,6 +1498,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1250
1498
|
0 && (module.exports = {
|
|
1251
1499
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1252
1500
|
addModelToParent,
|
|
1501
|
+
bindSettingsReconcile,
|
|
1253
1502
|
createElement,
|
|
1254
1503
|
createElementStyle,
|
|
1255
1504
|
createElements,
|
|
@@ -1258,6 +1507,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1258
1507
|
dropElement,
|
|
1259
1508
|
duplicateElement,
|
|
1260
1509
|
duplicateElements,
|
|
1510
|
+
evaluateWhen,
|
|
1261
1511
|
findChildRecursive,
|
|
1262
1512
|
findModelInDocument,
|
|
1263
1513
|
generateElementId,
|
|
@@ -1269,11 +1519,13 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1269
1519
|
getCurrentDocumentId,
|
|
1270
1520
|
getElementChildrenWithFallback,
|
|
1271
1521
|
getElementEditorSettings,
|
|
1522
|
+
getElementIcon,
|
|
1272
1523
|
getElementInteractions,
|
|
1273
1524
|
getElementLabel,
|
|
1274
1525
|
getElementSetting,
|
|
1275
1526
|
getElementSettings,
|
|
1276
1527
|
getElementStyles,
|
|
1528
|
+
getElementTitle,
|
|
1277
1529
|
getElementType,
|
|
1278
1530
|
getElements,
|
|
1279
1531
|
getLinkInLinkRestriction,
|
|
@@ -1283,10 +1535,12 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1283
1535
|
moveElement,
|
|
1284
1536
|
moveElements,
|
|
1285
1537
|
playElementInteractions,
|
|
1538
|
+
reconcileInitialChildren,
|
|
1286
1539
|
removeElements,
|
|
1287
1540
|
removeModelFromParent,
|
|
1288
1541
|
replaceElement,
|
|
1289
1542
|
resolveContainer,
|
|
1543
|
+
resolveInsertIndex,
|
|
1290
1544
|
selectElement,
|
|
1291
1545
|
shouldCreateNewLocalStyle,
|
|
1292
1546
|
styleRerenderEvents,
|