@elementor/editor-elements 4.0.0-543 → 4.0.0-545
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 +40 -36
- package/dist/index.d.ts +40 -36
- package/dist/index.js +174 -183
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +174 -182
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/hooks/use-element-children.ts +1 -1
- package/src/index.ts +2 -8
- package/src/sync/create-element.ts +3 -10
- package/src/sync/create-elements.ts +42 -35
- package/src/sync/delete-element.ts +5 -12
- package/src/sync/duplicate-element.ts +4 -12
- package/src/sync/duplicate-elements.ts +40 -44
- package/src/sync/{get-model.ts → model-utils.ts} +8 -22
- package/src/sync/move-element.ts +13 -15
- package/src/sync/move-elements.ts +73 -51
- package/src/sync/remove-elements.ts +37 -29
- package/src/sync/replace-element.ts +20 -21
- package/src/sync/types.ts +1 -0
- package/src/sync/update-element-editor-settings.ts +1 -5
- package/src/sync/update-element-interactions.ts +1 -5
- package/src/sync/update-element-settings.ts +4 -0
package/dist/index.mjs
CHANGED
|
@@ -16,22 +16,7 @@ var selectElement = (elementId) => {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
// src/sync/
|
|
20
|
-
function getModel(id, parentModel) {
|
|
21
|
-
const extendedWindow = window;
|
|
22
|
-
const container = extendedWindow.elementor?.getContainer?.(id) ?? null;
|
|
23
|
-
if (container) {
|
|
24
|
-
return { model: container.model };
|
|
25
|
-
}
|
|
26
|
-
if (parentModel) {
|
|
27
|
-
const childModels = parentModel.get("elements") ?? [];
|
|
28
|
-
const model = childModels.find((m) => m.get("id") === id);
|
|
29
|
-
if (model) {
|
|
30
|
-
return { model };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
19
|
+
// src/sync/model-utils.ts
|
|
35
20
|
function findChildRecursive(model, predicate) {
|
|
36
21
|
const childModels = model.get("elements") ?? [];
|
|
37
22
|
for (const childModel of childModels) {
|
|
@@ -229,11 +214,7 @@ function useSelectedElement() {
|
|
|
229
214
|
|
|
230
215
|
// src/sync/create-element.ts
|
|
231
216
|
import { __privateRunCommandSync as runCommandSync } from "@elementor/editor-v1-adapters";
|
|
232
|
-
function createElement({
|
|
233
|
-
const container = getContainer(containerId);
|
|
234
|
-
if (!container) {
|
|
235
|
-
throw new Error(`Container with ID "${containerId}" not found`);
|
|
236
|
-
}
|
|
217
|
+
function createElement({ container, model, options }) {
|
|
237
218
|
return runCommandSync("document/elements/create", {
|
|
238
219
|
container,
|
|
239
220
|
model,
|
|
@@ -247,14 +228,7 @@ import { __ } from "@wordpress/i18n";
|
|
|
247
228
|
|
|
248
229
|
// src/sync/delete-element.ts
|
|
249
230
|
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
250
|
-
function deleteElement({
|
|
251
|
-
elementId,
|
|
252
|
-
options = {}
|
|
253
|
-
}) {
|
|
254
|
-
const container = getContainer(elementId);
|
|
255
|
-
if (!container) {
|
|
256
|
-
throw new Error(`Element with ID "${elementId}" not found`);
|
|
257
|
-
}
|
|
231
|
+
function deleteElement({ container, options = {} }) {
|
|
258
232
|
return runCommand2("document/elements/delete", {
|
|
259
233
|
container,
|
|
260
234
|
options
|
|
@@ -271,48 +245,54 @@ var createElements = ({
|
|
|
271
245
|
{
|
|
272
246
|
do: ({ elements: elementsParam }) => {
|
|
273
247
|
const createdElements = [];
|
|
274
|
-
elementsParam.forEach((
|
|
275
|
-
const
|
|
248
|
+
elementsParam.forEach(({ container, options, ...elementParams }) => {
|
|
249
|
+
const parentContainer = container.lookup?.() ?? container;
|
|
250
|
+
if (!parentContainer) {
|
|
251
|
+
throw new Error("Parent container not found");
|
|
252
|
+
}
|
|
276
253
|
const element = createElement({
|
|
254
|
+
container: parentContainer,
|
|
277
255
|
...elementParams,
|
|
278
256
|
options: { ...options, useHistory: false }
|
|
279
257
|
});
|
|
280
|
-
const elementId = element.id;
|
|
281
258
|
createdElements.push({
|
|
282
|
-
|
|
259
|
+
container: element,
|
|
260
|
+
parentContainer,
|
|
283
261
|
model: element.model?.toJSON() || {},
|
|
284
|
-
|
|
285
|
-
...createParams
|
|
286
|
-
}
|
|
262
|
+
options
|
|
287
263
|
});
|
|
288
264
|
});
|
|
289
265
|
return { createdElements };
|
|
290
266
|
},
|
|
291
267
|
undo: (_, { createdElements }) => {
|
|
292
|
-
[...createdElements].reverse().forEach(({
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
268
|
+
[...createdElements].reverse().forEach(({ container }) => {
|
|
269
|
+
const freshContainer = container.lookup?.();
|
|
270
|
+
if (freshContainer) {
|
|
271
|
+
deleteElement({
|
|
272
|
+
container: freshContainer,
|
|
273
|
+
options: { useHistory: false }
|
|
274
|
+
});
|
|
275
|
+
}
|
|
297
276
|
});
|
|
298
277
|
},
|
|
299
278
|
redo: (_, { createdElements }) => {
|
|
300
279
|
const newElements = [];
|
|
301
|
-
createdElements.forEach(({
|
|
280
|
+
createdElements.forEach(({ parentContainer, model, options }) => {
|
|
281
|
+
const freshParent = parentContainer.lookup?.();
|
|
282
|
+
if (!freshParent) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
302
285
|
const element = createElement({
|
|
303
|
-
|
|
286
|
+
container: freshParent,
|
|
304
287
|
model,
|
|
305
|
-
options: { ...
|
|
288
|
+
options: { ...options, useHistory: false }
|
|
289
|
+
});
|
|
290
|
+
newElements.push({
|
|
291
|
+
container: element,
|
|
292
|
+
parentContainer: freshParent,
|
|
293
|
+
model: element.model.toJSON(),
|
|
294
|
+
options
|
|
306
295
|
});
|
|
307
|
-
const elementId = element.id;
|
|
308
|
-
const container = getContainer(elementId);
|
|
309
|
-
if (container) {
|
|
310
|
-
newElements.push({
|
|
311
|
-
elementId,
|
|
312
|
-
model: container.model.toJSON(),
|
|
313
|
-
createParams
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
296
|
});
|
|
317
297
|
return { createdElements: newElements };
|
|
318
298
|
}
|
|
@@ -341,15 +321,11 @@ function dropElement({ containerId, model, options }) {
|
|
|
341
321
|
|
|
342
322
|
// src/sync/duplicate-element.ts
|
|
343
323
|
import { __privateRunCommandSync as runCommandSync3 } from "@elementor/editor-v1-adapters";
|
|
344
|
-
function duplicateElement({
|
|
345
|
-
const
|
|
346
|
-
if (!elementToDuplicate) {
|
|
347
|
-
throw new Error(`Element with ID "${elementId}" not found`);
|
|
348
|
-
}
|
|
349
|
-
const currentIndex = elementToDuplicate.view?._index ?? 0;
|
|
324
|
+
function duplicateElement({ element, options = {} }) {
|
|
325
|
+
const currentIndex = element.view?._index ?? 0;
|
|
350
326
|
const insertPosition = options.clone !== false ? currentIndex + 1 : void 0;
|
|
351
327
|
return runCommandSync3("document/elements/duplicate", {
|
|
352
|
-
container:
|
|
328
|
+
container: element,
|
|
353
329
|
options: { at: insertPosition, edit: false, ...options }
|
|
354
330
|
});
|
|
355
331
|
}
|
|
@@ -368,59 +344,56 @@ var duplicateElements = ({
|
|
|
368
344
|
{
|
|
369
345
|
do: ({ elementIds: elementIdsToDuplicate }) => {
|
|
370
346
|
onDuplicateElements?.();
|
|
371
|
-
const duplicatedElements =
|
|
347
|
+
const duplicatedElements = [];
|
|
348
|
+
elementIdsToDuplicate.forEach((elementId) => {
|
|
372
349
|
const originalContainer = getContainer(elementId);
|
|
373
|
-
if (originalContainer?.parent) {
|
|
374
|
-
|
|
375
|
-
elementId,
|
|
376
|
-
options: { useHistory: false }
|
|
377
|
-
});
|
|
378
|
-
acc.push({
|
|
379
|
-
id: duplicatedElement.id,
|
|
380
|
-
model: duplicatedElement.model.toJSON(),
|
|
381
|
-
originalElementId: elementId,
|
|
382
|
-
modelToRestore: duplicatedElement.model.toJSON(),
|
|
383
|
-
parentContainerId: duplicatedElement.parent?.id,
|
|
384
|
-
at: duplicatedElement.view?._index
|
|
385
|
-
});
|
|
350
|
+
if (!originalContainer?.parent) {
|
|
351
|
+
return;
|
|
386
352
|
}
|
|
387
|
-
|
|
388
|
-
|
|
353
|
+
const duplicatedElement = duplicateElement({
|
|
354
|
+
element: originalContainer,
|
|
355
|
+
options: { useHistory: false }
|
|
356
|
+
});
|
|
357
|
+
if (!duplicatedElement.parent) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
duplicatedElements.push({
|
|
361
|
+
container: duplicatedElement,
|
|
362
|
+
parentContainer: duplicatedElement.parent,
|
|
363
|
+
model: duplicatedElement.model.toJSON(),
|
|
364
|
+
at: duplicatedElement.view?._index
|
|
365
|
+
});
|
|
366
|
+
});
|
|
389
367
|
return { duplicatedElements };
|
|
390
368
|
},
|
|
391
369
|
undo: (_, { duplicatedElements }) => {
|
|
392
370
|
onRestoreElements?.();
|
|
393
|
-
[...duplicatedElements].reverse().forEach(({
|
|
371
|
+
[...duplicatedElements].reverse().forEach(({ container }) => {
|
|
394
372
|
deleteElement({
|
|
395
|
-
|
|
373
|
+
container,
|
|
396
374
|
options: { useHistory: false }
|
|
397
375
|
});
|
|
398
376
|
});
|
|
399
377
|
},
|
|
400
378
|
redo: (_, { duplicatedElements: previousElements }) => {
|
|
401
379
|
onDuplicateElements?.();
|
|
402
|
-
const duplicatedElements =
|
|
403
|
-
|
|
380
|
+
const duplicatedElements = [];
|
|
381
|
+
previousElements.forEach(({ parentContainer, model, at }) => {
|
|
382
|
+
const freshParent = parentContainer.lookup?.();
|
|
383
|
+
if (freshParent) {
|
|
404
384
|
const createdElement = createElement({
|
|
405
|
-
|
|
406
|
-
model
|
|
407
|
-
options: {
|
|
408
|
-
useHistory: false,
|
|
409
|
-
clone: false,
|
|
410
|
-
at: previousElement.at
|
|
411
|
-
}
|
|
385
|
+
container: freshParent,
|
|
386
|
+
model,
|
|
387
|
+
options: { useHistory: false, clone: false, at }
|
|
412
388
|
});
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
parentContainerId: previousElement.parentContainerId,
|
|
419
|
-
at: previousElement.at
|
|
389
|
+
duplicatedElements.push({
|
|
390
|
+
container: createdElement,
|
|
391
|
+
parentContainer: freshParent,
|
|
392
|
+
model,
|
|
393
|
+
at
|
|
420
394
|
});
|
|
421
395
|
}
|
|
422
|
-
|
|
423
|
-
}, []);
|
|
396
|
+
});
|
|
424
397
|
return { duplicatedElements };
|
|
425
398
|
}
|
|
426
399
|
},
|
|
@@ -519,25 +492,23 @@ function getElements(root) {
|
|
|
519
492
|
}
|
|
520
493
|
|
|
521
494
|
// src/sync/move-element.ts
|
|
522
|
-
function moveElement({
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
if (!
|
|
526
|
-
throw new Error(`Element
|
|
495
|
+
function moveElement({ element, targetContainer, options = {} }) {
|
|
496
|
+
const resolvedElement = element.lookup?.();
|
|
497
|
+
const resolvedTarget = targetContainer.lookup?.();
|
|
498
|
+
if (!resolvedElement) {
|
|
499
|
+
throw new Error(`Element not found: ${element.id}`);
|
|
527
500
|
}
|
|
528
|
-
if (!
|
|
529
|
-
throw new Error(`Target container
|
|
501
|
+
if (!resolvedTarget) {
|
|
502
|
+
throw new Error(`Target container not found: ${targetContainer.id}`);
|
|
530
503
|
}
|
|
531
|
-
const modelToRecreate =
|
|
504
|
+
const modelToRecreate = resolvedElement.model.toJSON();
|
|
532
505
|
deleteElement({
|
|
533
|
-
|
|
534
|
-
// prevent inner history from being created
|
|
506
|
+
container: resolvedElement,
|
|
535
507
|
options: { ...options, useHistory: false }
|
|
536
508
|
});
|
|
537
509
|
const newContainer = createElement({
|
|
538
|
-
|
|
510
|
+
container: resolvedTarget,
|
|
539
511
|
model: modelToRecreate,
|
|
540
|
-
// prevent inner history from being created
|
|
541
512
|
options: { edit: false, ...options, useHistory: false }
|
|
542
513
|
});
|
|
543
514
|
return newContainer;
|
|
@@ -558,39 +529,46 @@ var moveElements = ({
|
|
|
558
529
|
do: ({ moves }) => {
|
|
559
530
|
const movedElements = [];
|
|
560
531
|
onMoveElements?.();
|
|
561
|
-
moves.forEach((
|
|
562
|
-
const
|
|
563
|
-
const
|
|
564
|
-
if (!
|
|
565
|
-
throw new Error(
|
|
532
|
+
moves.forEach(({ element, targetContainer, options }) => {
|
|
533
|
+
const sourceElement = element.lookup?.() ?? element;
|
|
534
|
+
const target = targetContainer.lookup?.() ?? targetContainer;
|
|
535
|
+
if (!sourceElement) {
|
|
536
|
+
throw new Error("Element not found");
|
|
537
|
+
}
|
|
538
|
+
if (!target) {
|
|
539
|
+
throw new Error("Target container not found");
|
|
540
|
+
}
|
|
541
|
+
if (!sourceElement.parent) {
|
|
542
|
+
throw new Error("Element has no parent container");
|
|
566
543
|
}
|
|
567
|
-
const
|
|
568
|
-
const originalIndex =
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
};
|
|
574
|
-
const element = moveElement({
|
|
575
|
-
...move,
|
|
576
|
-
options: { ...move.options, useHistory: false }
|
|
544
|
+
const originalContainer = sourceElement.parent;
|
|
545
|
+
const originalIndex = originalContainer.children?.indexOf(sourceElement) ?? -1;
|
|
546
|
+
const newElement = moveElement({
|
|
547
|
+
element: sourceElement,
|
|
548
|
+
targetContainer: target,
|
|
549
|
+
options: { ...options, useHistory: false }
|
|
577
550
|
});
|
|
578
551
|
movedElements.push({
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
552
|
+
element: newElement,
|
|
553
|
+
originalContainer,
|
|
554
|
+
originalIndex,
|
|
555
|
+
targetContainer: target,
|
|
556
|
+
options
|
|
583
557
|
});
|
|
584
558
|
});
|
|
585
559
|
return { movedElements };
|
|
586
560
|
},
|
|
587
561
|
undo: (_, { movedElements }) => {
|
|
588
562
|
onRestoreElements?.();
|
|
589
|
-
[...movedElements].reverse().forEach(({
|
|
590
|
-
const
|
|
563
|
+
[...movedElements].reverse().forEach(({ element, originalContainer, originalIndex }) => {
|
|
564
|
+
const freshElement = element.lookup?.();
|
|
565
|
+
const freshOriginalContainer = originalContainer.lookup?.();
|
|
566
|
+
if (!freshElement || !freshOriginalContainer) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
591
569
|
moveElement({
|
|
592
|
-
|
|
593
|
-
|
|
570
|
+
element: freshElement,
|
|
571
|
+
targetContainer: freshOriginalContainer,
|
|
594
572
|
options: {
|
|
595
573
|
useHistory: false,
|
|
596
574
|
at: originalIndex >= 0 ? originalIndex : void 0
|
|
@@ -601,16 +579,24 @@ var moveElements = ({
|
|
|
601
579
|
redo: (_, { movedElements }) => {
|
|
602
580
|
const newMovedElements = [];
|
|
603
581
|
onMoveElements?.();
|
|
604
|
-
movedElements.forEach(({
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
582
|
+
movedElements.forEach(({ element, originalContainer, originalIndex, targetContainer, options }) => {
|
|
583
|
+
const freshElement = element.lookup?.();
|
|
584
|
+
const freshOriginalContainer = originalContainer.lookup?.();
|
|
585
|
+
const freshTarget = targetContainer.lookup?.();
|
|
586
|
+
if (!freshElement || !freshOriginalContainer || !freshTarget) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const newElement = moveElement({
|
|
590
|
+
element: freshElement,
|
|
591
|
+
targetContainer: freshTarget,
|
|
592
|
+
options: { ...options, useHistory: false }
|
|
608
593
|
});
|
|
609
594
|
newMovedElements.push({
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
595
|
+
element: newElement,
|
|
596
|
+
originalContainer: freshOriginalContainer,
|
|
597
|
+
originalIndex,
|
|
598
|
+
targetContainer: freshTarget,
|
|
599
|
+
options
|
|
614
600
|
});
|
|
615
601
|
});
|
|
616
602
|
return { movedElements: newMovedElements };
|
|
@@ -640,48 +626,58 @@ var removeElements = ({
|
|
|
640
626
|
const removedElements = [];
|
|
641
627
|
elementIdsParam.forEach((elementId) => {
|
|
642
628
|
const container = getContainer(elementId);
|
|
643
|
-
if (container) {
|
|
644
|
-
const model = container.model.toJSON();
|
|
645
|
-
const parent = container.parent;
|
|
646
|
-
const at = container.view?._index ?? 0;
|
|
629
|
+
if (container?.parent) {
|
|
647
630
|
removedElements.push({
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
at
|
|
631
|
+
container,
|
|
632
|
+
parent: container.parent,
|
|
633
|
+
model: container.model.toJSON(),
|
|
634
|
+
at: container.view?._index ?? 0
|
|
652
635
|
});
|
|
653
636
|
}
|
|
654
637
|
});
|
|
655
638
|
onRemoveElements?.();
|
|
656
|
-
|
|
639
|
+
removedElements.forEach(({ container }) => {
|
|
657
640
|
deleteElement({
|
|
658
|
-
|
|
641
|
+
container,
|
|
659
642
|
options: { useHistory: false }
|
|
660
643
|
});
|
|
661
644
|
});
|
|
662
|
-
return {
|
|
645
|
+
return { removedElements };
|
|
663
646
|
},
|
|
664
647
|
undo: (_, { removedElements }) => {
|
|
665
648
|
onRestoreElements?.();
|
|
666
|
-
[...removedElements].reverse().forEach(({
|
|
667
|
-
|
|
649
|
+
[...removedElements].reverse().forEach(({ parent, model, at }) => {
|
|
650
|
+
const freshParent = parent.lookup?.();
|
|
651
|
+
if (freshParent) {
|
|
668
652
|
createElement({
|
|
669
|
-
|
|
653
|
+
container: freshParent,
|
|
670
654
|
model,
|
|
671
655
|
options: { useHistory: false, at }
|
|
672
656
|
});
|
|
673
657
|
}
|
|
674
658
|
});
|
|
675
659
|
},
|
|
676
|
-
redo: (_, {
|
|
660
|
+
redo: (_, { removedElements }) => {
|
|
677
661
|
onRemoveElements?.();
|
|
678
|
-
|
|
662
|
+
const newRemovedElements = [];
|
|
663
|
+
removedElements.forEach(({ container, parent, model, at }) => {
|
|
664
|
+
const freshContainer = container.lookup?.();
|
|
665
|
+
const freshParent = parent.lookup?.();
|
|
666
|
+
if (!freshContainer || !freshParent) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
679
669
|
deleteElement({
|
|
680
|
-
|
|
670
|
+
container: freshContainer,
|
|
681
671
|
options: { useHistory: false }
|
|
682
672
|
});
|
|
673
|
+
newRemovedElements.push({
|
|
674
|
+
container: freshContainer,
|
|
675
|
+
parent: freshParent,
|
|
676
|
+
model,
|
|
677
|
+
at
|
|
678
|
+
});
|
|
683
679
|
});
|
|
684
|
-
return {
|
|
680
|
+
return { removedElements: newRemovedElements };
|
|
685
681
|
}
|
|
686
682
|
},
|
|
687
683
|
{
|
|
@@ -694,42 +690,42 @@ var removeElements = ({
|
|
|
694
690
|
|
|
695
691
|
// src/sync/replace-element.ts
|
|
696
692
|
var replaceElement = async ({ currentElement, newElement, withHistory = true }) => {
|
|
697
|
-
const
|
|
693
|
+
const currentElementContainer = getContainer(currentElement.id);
|
|
694
|
+
if (!currentElementContainer) {
|
|
695
|
+
throw new ElementNotFoundError({ context: { elementId: currentElement.id } });
|
|
696
|
+
}
|
|
697
|
+
const { container, index } = getNewElementContainer(currentElementContainer, newElement);
|
|
698
698
|
const newElementInstance = createElement({
|
|
699
|
-
|
|
699
|
+
container,
|
|
700
700
|
model: newElement,
|
|
701
701
|
options: { at: index, useHistory: withHistory }
|
|
702
702
|
});
|
|
703
|
-
await deleteElement({
|
|
703
|
+
await deleteElement({ container: currentElementContainer, options: { useHistory: withHistory } });
|
|
704
704
|
return newElementInstance;
|
|
705
705
|
};
|
|
706
|
-
function getNewElementContainer(
|
|
707
|
-
const currentElementContainer = getContainer(currentElement.id);
|
|
708
|
-
if (!currentElementContainer) {
|
|
709
|
-
throw new ElementNotFoundError({ context: { elementId: currentElement.id } });
|
|
710
|
-
}
|
|
706
|
+
function getNewElementContainer(currentElementContainer, newElement) {
|
|
711
707
|
const { parent } = currentElementContainer;
|
|
712
708
|
if (!parent) {
|
|
713
|
-
throw new ElementParentNotFoundError({ context: { elementId:
|
|
709
|
+
throw new ElementParentNotFoundError({ context: { elementId: currentElementContainer.id } });
|
|
714
710
|
}
|
|
715
711
|
const elementIndex = currentElementContainer.view?._index ?? 0;
|
|
716
712
|
if (elementIndex === -1) {
|
|
717
|
-
throw new ElementIndexNotFoundError({ context: { elementId:
|
|
713
|
+
throw new ElementIndexNotFoundError({ context: { elementId: currentElementContainer.id } });
|
|
718
714
|
}
|
|
719
|
-
let
|
|
715
|
+
let location = { container: parent, index: elementIndex };
|
|
720
716
|
if (parent.id === "document" && newElement.elType === "widget") {
|
|
721
|
-
|
|
717
|
+
location = createWrapperForWidget(parent, elementIndex);
|
|
722
718
|
}
|
|
723
|
-
return
|
|
719
|
+
return location;
|
|
724
720
|
}
|
|
725
721
|
var DEFAULT_CONTAINER_TYPE = "e-flexbox";
|
|
726
|
-
function createWrapperForWidget(
|
|
722
|
+
function createWrapperForWidget(parent, elementIndex) {
|
|
727
723
|
const container = createElement({
|
|
728
|
-
|
|
724
|
+
container: parent,
|
|
729
725
|
model: { elType: DEFAULT_CONTAINER_TYPE },
|
|
730
726
|
options: { at: elementIndex, useHistory: false }
|
|
731
727
|
});
|
|
732
|
-
return {
|
|
728
|
+
return { container, index: 0 };
|
|
733
729
|
}
|
|
734
730
|
|
|
735
731
|
// src/sync/update-element-editor-settings.ts
|
|
@@ -744,16 +740,16 @@ var updateElementEditorSettings = ({
|
|
|
744
740
|
}
|
|
745
741
|
const editorSettings = element.model.get("editor_settings") ?? {};
|
|
746
742
|
element.model.set("editor_settings", { ...editorSettings, ...settings });
|
|
747
|
-
|
|
743
|
+
runCommandSync4("document/save/set-is-modified", { status: true }, { internal: true });
|
|
748
744
|
};
|
|
749
|
-
function setDocumentModifiedStatus(status) {
|
|
750
|
-
runCommandSync4("document/save/set-is-modified", { status }, { internal: true });
|
|
751
|
-
}
|
|
752
745
|
|
|
753
746
|
// src/sync/update-element-settings.ts
|
|
754
747
|
import { __privateRunCommandSync as runCommandSync5 } from "@elementor/editor-v1-adapters";
|
|
755
748
|
var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
756
749
|
const container = getContainer(id);
|
|
750
|
+
if (!container) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
757
753
|
const args = {
|
|
758
754
|
container,
|
|
759
755
|
settings: { ...props }
|
|
@@ -1068,16 +1064,13 @@ var updateElementInteractions = ({
|
|
|
1068
1064
|
}
|
|
1069
1065
|
element.model.set("interactions", interactions);
|
|
1070
1066
|
window.dispatchEvent(new CustomEvent("elementor/element/update_interactions"));
|
|
1071
|
-
|
|
1067
|
+
runCommandSync7("document/save/set-is-modified", { status: true }, { internal: true });
|
|
1072
1068
|
};
|
|
1073
1069
|
var playElementInteractions = (elementId, interactionId) => {
|
|
1074
1070
|
window.top?.dispatchEvent(
|
|
1075
1071
|
new CustomEvent("atomic/play_interactions", { detail: { elementId, interactionId } })
|
|
1076
1072
|
);
|
|
1077
1073
|
};
|
|
1078
|
-
function setDocumentModifiedStatus2(status) {
|
|
1079
|
-
runCommandSync7("document/save/set-is-modified", { status }, { internal: true });
|
|
1080
|
-
}
|
|
1081
1074
|
export {
|
|
1082
1075
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1083
1076
|
createElement,
|
|
@@ -1106,7 +1099,6 @@ export {
|
|
|
1106
1099
|
getElementType,
|
|
1107
1100
|
getElements,
|
|
1108
1101
|
getLinkInLinkRestriction,
|
|
1109
|
-
getModel,
|
|
1110
1102
|
getSelectedElements,
|
|
1111
1103
|
getWidgetsCache,
|
|
1112
1104
|
isElementAnchored,
|