@orion-studios/payload-studio 0.6.0-beta.52 → 0.6.0-beta.54
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/admin/index.mjs +2 -2
- package/dist/builder-v2/client.js +139 -0
- package/dist/builder-v2/client.mjs +139 -0
- package/dist/index.mjs +10 -10
- package/dist/studio-pages/index.mjs +2 -2
- package/package.json +1 -1
- package/dist/{chunk-NGLIA2OE.mjs → chunk-7HME6R2V.mjs} +3 -3
- package/dist/{chunk-JC3UV74N.mjs → chunk-KHK6RTGC.mjs} +3 -3
package/dist/admin/index.mjs
CHANGED
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
socialMediaConnectionsField,
|
|
8
8
|
themePreferenceField,
|
|
9
9
|
withTooltips
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-W2UOCJDX.mjs";
|
|
10
|
+
} from "../chunk-KHK6RTGC.mjs";
|
|
12
11
|
import {
|
|
13
12
|
SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
|
|
14
13
|
SOCIAL_MEDIA_ICON_OPTIONS,
|
|
15
14
|
SOCIAL_MEDIA_PLATFORMS,
|
|
16
15
|
SOCIAL_MEDIA_PLATFORM_LABELS
|
|
17
16
|
} from "../chunk-ZTXJG4K5.mjs";
|
|
17
|
+
import "../chunk-W2UOCJDX.mjs";
|
|
18
18
|
import "../chunk-6BWS3CLP.mjs";
|
|
19
19
|
export {
|
|
20
20
|
SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
|
|
@@ -604,6 +604,7 @@ var decodeHtmlAttribute2 = (value) => {
|
|
|
604
604
|
return decoded;
|
|
605
605
|
};
|
|
606
606
|
var attrToPropName = (name) => name.replace(/^data-orion-/, "").replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
607
|
+
var propToAttrName = (name) => `data-orion-${name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
|
|
607
608
|
var propsFromAttributes = (attributes = {}) => {
|
|
608
609
|
const props = {};
|
|
609
610
|
Object.keys(attributes).forEach((name) => {
|
|
@@ -627,6 +628,142 @@ var propsFromAttributes = (attributes = {}) => {
|
|
|
627
628
|
return props;
|
|
628
629
|
};
|
|
629
630
|
var previewForDefinition = (definition, props) => definition.editorPreview?.(props) || `<div class="orion-builder-v2-dynamic-placeholder"><strong>${definition.label}</strong></div>`;
|
|
631
|
+
var lockPreviewChildren = (component) => {
|
|
632
|
+
const children = typeof component.components === "function" ? component.components() : null;
|
|
633
|
+
const childList = children && typeof children === "object" && "forEach" in children ? children : null;
|
|
634
|
+
childList?.forEach((child) => {
|
|
635
|
+
if (typeof child.set === "function") {
|
|
636
|
+
child.set({
|
|
637
|
+
copyable: false,
|
|
638
|
+
draggable: false,
|
|
639
|
+
droppable: false,
|
|
640
|
+
editable: false,
|
|
641
|
+
highlightable: false,
|
|
642
|
+
hoverable: false,
|
|
643
|
+
removable: false,
|
|
644
|
+
selectable: false
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
lockPreviewChildren(child);
|
|
648
|
+
});
|
|
649
|
+
};
|
|
650
|
+
var parseJsonArray = (value) => {
|
|
651
|
+
const decoded = decodeHtmlAttribute2(value);
|
|
652
|
+
if (!decoded) {
|
|
653
|
+
return [];
|
|
654
|
+
}
|
|
655
|
+
try {
|
|
656
|
+
const parsed = JSON.parse(decoded);
|
|
657
|
+
return Array.isArray(parsed) ? parsed.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))) : [];
|
|
658
|
+
} catch {
|
|
659
|
+
return [];
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
var updateJsonListAttribute = ({
|
|
663
|
+
field,
|
|
664
|
+
index,
|
|
665
|
+
listAttr,
|
|
666
|
+
model,
|
|
667
|
+
value
|
|
668
|
+
}) => {
|
|
669
|
+
const attrs = model.getAttributes?.() || {};
|
|
670
|
+
const list = parseJsonArray(attrs[listAttr]);
|
|
671
|
+
if (!list[index]) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
list[index] = {
|
|
675
|
+
...list[index],
|
|
676
|
+
[field]: value
|
|
677
|
+
};
|
|
678
|
+
model.addAttributes?.({
|
|
679
|
+
[listAttr]: JSON.stringify(list)
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
var chooseAsset = (editor, callback) => {
|
|
683
|
+
const assetManager = editor?.AssetManager;
|
|
684
|
+
if (!assetManager?.open) {
|
|
685
|
+
const src = window.prompt("Image URL");
|
|
686
|
+
if (src) {
|
|
687
|
+
callback(src);
|
|
688
|
+
}
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
assetManager.open({
|
|
692
|
+
select(asset) {
|
|
693
|
+
const src = typeof asset === "string" ? asset : asset && typeof asset === "object" && "get" in asset && typeof asset.get === "function" ? String(asset.get("src") || "") : asset && typeof asset === "object" && "src" in asset ? String(asset.src || "") : "";
|
|
694
|
+
if (src) {
|
|
695
|
+
callback(src);
|
|
696
|
+
}
|
|
697
|
+
assetManager.close?.();
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
};
|
|
701
|
+
var bindEditablePreview = (view, editor) => {
|
|
702
|
+
const root = view.el;
|
|
703
|
+
if (!root) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
root.querySelectorAll("[data-orion-edit-field]").forEach((element) => {
|
|
707
|
+
const field = element.dataset.orionEditField || "";
|
|
708
|
+
const listName = element.dataset.orionEditList || "";
|
|
709
|
+
const listIndex = Number(element.dataset.orionEditIndex);
|
|
710
|
+
const attrName = listName ? propToAttrName(listName) : propToAttrName(field);
|
|
711
|
+
const isImage = element.dataset.orionEditKind === "image" || element instanceof HTMLImageElement;
|
|
712
|
+
element.setAttribute("title", isImage ? "Click to replace image" : "Click and type to edit");
|
|
713
|
+
element.style.cursor = "text";
|
|
714
|
+
element.addEventListener("click", (event) => {
|
|
715
|
+
event.stopPropagation();
|
|
716
|
+
editor.select?.(view.model);
|
|
717
|
+
if (!isImage) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
element.style.cursor = "pointer";
|
|
721
|
+
chooseAsset(editor, (src) => {
|
|
722
|
+
if (listName && Number.isInteger(listIndex)) {
|
|
723
|
+
updateJsonListAttribute({
|
|
724
|
+
field,
|
|
725
|
+
index: listIndex,
|
|
726
|
+
listAttr: attrName,
|
|
727
|
+
model: view.model,
|
|
728
|
+
value: src
|
|
729
|
+
});
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
view.model.addAttributes?.({
|
|
733
|
+
[attrName]: src
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
if (isImage) {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
element.setAttribute("contenteditable", "true");
|
|
741
|
+
element.setAttribute("spellcheck", "true");
|
|
742
|
+
const commit = () => {
|
|
743
|
+
const value = element.innerText.trim();
|
|
744
|
+
if (listName && Number.isInteger(listIndex)) {
|
|
745
|
+
updateJsonListAttribute({
|
|
746
|
+
field,
|
|
747
|
+
index: listIndex,
|
|
748
|
+
listAttr: attrName,
|
|
749
|
+
model: view.model,
|
|
750
|
+
value
|
|
751
|
+
});
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
view.model.addAttributes?.({
|
|
755
|
+
[attrName]: value
|
|
756
|
+
});
|
|
757
|
+
};
|
|
758
|
+
element.addEventListener("blur", commit);
|
|
759
|
+
element.addEventListener("keydown", (event) => {
|
|
760
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
761
|
+
event.preventDefault();
|
|
762
|
+
element.blur();
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
};
|
|
630
767
|
var registerProjectDynamicComponents = (editor, adapter) => {
|
|
631
768
|
const components = adapter?.components || {};
|
|
632
769
|
Object.keys(components).forEach((type) => {
|
|
@@ -669,6 +806,8 @@ var registerProjectDynamicComponents = (editor, adapter) => {
|
|
|
669
806
|
const attributes = this.model.getAttributes?.() || {};
|
|
670
807
|
const props = propsFromAttributes(attributes);
|
|
671
808
|
this.model.components(previewForDefinition(definition, props));
|
|
809
|
+
lockPreviewChildren(this.model);
|
|
810
|
+
queueMicrotask(() => bindEditablePreview(this, editor));
|
|
672
811
|
}
|
|
673
812
|
}
|
|
674
813
|
});
|
|
@@ -480,6 +480,7 @@ var decodeHtmlAttribute2 = (value) => {
|
|
|
480
480
|
return decoded;
|
|
481
481
|
};
|
|
482
482
|
var attrToPropName = (name) => name.replace(/^data-orion-/, "").replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
483
|
+
var propToAttrName = (name) => `data-orion-${name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
|
|
483
484
|
var propsFromAttributes = (attributes = {}) => {
|
|
484
485
|
const props = {};
|
|
485
486
|
Object.keys(attributes).forEach((name) => {
|
|
@@ -503,6 +504,142 @@ var propsFromAttributes = (attributes = {}) => {
|
|
|
503
504
|
return props;
|
|
504
505
|
};
|
|
505
506
|
var previewForDefinition = (definition, props) => definition.editorPreview?.(props) || `<div class="orion-builder-v2-dynamic-placeholder"><strong>${definition.label}</strong></div>`;
|
|
507
|
+
var lockPreviewChildren = (component) => {
|
|
508
|
+
const children = typeof component.components === "function" ? component.components() : null;
|
|
509
|
+
const childList = children && typeof children === "object" && "forEach" in children ? children : null;
|
|
510
|
+
childList?.forEach((child) => {
|
|
511
|
+
if (typeof child.set === "function") {
|
|
512
|
+
child.set({
|
|
513
|
+
copyable: false,
|
|
514
|
+
draggable: false,
|
|
515
|
+
droppable: false,
|
|
516
|
+
editable: false,
|
|
517
|
+
highlightable: false,
|
|
518
|
+
hoverable: false,
|
|
519
|
+
removable: false,
|
|
520
|
+
selectable: false
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
lockPreviewChildren(child);
|
|
524
|
+
});
|
|
525
|
+
};
|
|
526
|
+
var parseJsonArray = (value) => {
|
|
527
|
+
const decoded = decodeHtmlAttribute2(value);
|
|
528
|
+
if (!decoded) {
|
|
529
|
+
return [];
|
|
530
|
+
}
|
|
531
|
+
try {
|
|
532
|
+
const parsed = JSON.parse(decoded);
|
|
533
|
+
return Array.isArray(parsed) ? parsed.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))) : [];
|
|
534
|
+
} catch {
|
|
535
|
+
return [];
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
var updateJsonListAttribute = ({
|
|
539
|
+
field,
|
|
540
|
+
index,
|
|
541
|
+
listAttr,
|
|
542
|
+
model,
|
|
543
|
+
value
|
|
544
|
+
}) => {
|
|
545
|
+
const attrs = model.getAttributes?.() || {};
|
|
546
|
+
const list = parseJsonArray(attrs[listAttr]);
|
|
547
|
+
if (!list[index]) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
list[index] = {
|
|
551
|
+
...list[index],
|
|
552
|
+
[field]: value
|
|
553
|
+
};
|
|
554
|
+
model.addAttributes?.({
|
|
555
|
+
[listAttr]: JSON.stringify(list)
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
var chooseAsset = (editor, callback) => {
|
|
559
|
+
const assetManager = editor?.AssetManager;
|
|
560
|
+
if (!assetManager?.open) {
|
|
561
|
+
const src = window.prompt("Image URL");
|
|
562
|
+
if (src) {
|
|
563
|
+
callback(src);
|
|
564
|
+
}
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
assetManager.open({
|
|
568
|
+
select(asset) {
|
|
569
|
+
const src = typeof asset === "string" ? asset : asset && typeof asset === "object" && "get" in asset && typeof asset.get === "function" ? String(asset.get("src") || "") : asset && typeof asset === "object" && "src" in asset ? String(asset.src || "") : "";
|
|
570
|
+
if (src) {
|
|
571
|
+
callback(src);
|
|
572
|
+
}
|
|
573
|
+
assetManager.close?.();
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
var bindEditablePreview = (view, editor) => {
|
|
578
|
+
const root = view.el;
|
|
579
|
+
if (!root) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
root.querySelectorAll("[data-orion-edit-field]").forEach((element) => {
|
|
583
|
+
const field = element.dataset.orionEditField || "";
|
|
584
|
+
const listName = element.dataset.orionEditList || "";
|
|
585
|
+
const listIndex = Number(element.dataset.orionEditIndex);
|
|
586
|
+
const attrName = listName ? propToAttrName(listName) : propToAttrName(field);
|
|
587
|
+
const isImage = element.dataset.orionEditKind === "image" || element instanceof HTMLImageElement;
|
|
588
|
+
element.setAttribute("title", isImage ? "Click to replace image" : "Click and type to edit");
|
|
589
|
+
element.style.cursor = "text";
|
|
590
|
+
element.addEventListener("click", (event) => {
|
|
591
|
+
event.stopPropagation();
|
|
592
|
+
editor.select?.(view.model);
|
|
593
|
+
if (!isImage) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
element.style.cursor = "pointer";
|
|
597
|
+
chooseAsset(editor, (src) => {
|
|
598
|
+
if (listName && Number.isInteger(listIndex)) {
|
|
599
|
+
updateJsonListAttribute({
|
|
600
|
+
field,
|
|
601
|
+
index: listIndex,
|
|
602
|
+
listAttr: attrName,
|
|
603
|
+
model: view.model,
|
|
604
|
+
value: src
|
|
605
|
+
});
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
view.model.addAttributes?.({
|
|
609
|
+
[attrName]: src
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
if (isImage) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
element.setAttribute("contenteditable", "true");
|
|
617
|
+
element.setAttribute("spellcheck", "true");
|
|
618
|
+
const commit = () => {
|
|
619
|
+
const value = element.innerText.trim();
|
|
620
|
+
if (listName && Number.isInteger(listIndex)) {
|
|
621
|
+
updateJsonListAttribute({
|
|
622
|
+
field,
|
|
623
|
+
index: listIndex,
|
|
624
|
+
listAttr: attrName,
|
|
625
|
+
model: view.model,
|
|
626
|
+
value
|
|
627
|
+
});
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
view.model.addAttributes?.({
|
|
631
|
+
[attrName]: value
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
element.addEventListener("blur", commit);
|
|
635
|
+
element.addEventListener("keydown", (event) => {
|
|
636
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
637
|
+
event.preventDefault();
|
|
638
|
+
element.blur();
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
};
|
|
506
643
|
var registerProjectDynamicComponents = (editor, adapter) => {
|
|
507
644
|
const components = adapter?.components || {};
|
|
508
645
|
Object.keys(components).forEach((type) => {
|
|
@@ -545,6 +682,8 @@ var registerProjectDynamicComponents = (editor, adapter) => {
|
|
|
545
682
|
const attributes = this.model.getAttributes?.() || {};
|
|
546
683
|
const props = propsFromAttributes(attributes);
|
|
547
684
|
this.model.components(previewForDefinition(definition, props));
|
|
685
|
+
lockPreviewChildren(this.model);
|
|
686
|
+
queueMicrotask(() => bindEditablePreview(this, editor));
|
|
548
687
|
}
|
|
549
688
|
}
|
|
550
689
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
admin_exports
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
admin_app_exports
|
|
6
|
-
} from "./chunk-RKTIFEUY.mjs";
|
|
7
|
-
import "./chunk-W2UOCJDX.mjs";
|
|
8
|
-
import {
|
|
9
|
-
blocks_exports
|
|
10
|
-
} from "./chunk-JQAHXYAM.mjs";
|
|
3
|
+
} from "./chunk-KHK6RTGC.mjs";
|
|
11
4
|
import {
|
|
12
5
|
nextjs_exports
|
|
13
6
|
} from "./chunk-ZADL33R6.mjs";
|
|
14
7
|
import "./chunk-ZTXJG4K5.mjs";
|
|
15
8
|
import {
|
|
16
9
|
studio_pages_exports
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-OQSEJXC4.mjs";
|
|
10
|
+
} from "./chunk-7HME6R2V.mjs";
|
|
19
11
|
import "./chunk-7ZMXZRBP.mjs";
|
|
20
12
|
import {
|
|
21
13
|
studio_exports
|
|
22
14
|
} from "./chunk-ADIIWIYL.mjs";
|
|
15
|
+
import {
|
|
16
|
+
blocks_exports
|
|
17
|
+
} from "./chunk-JQAHXYAM.mjs";
|
|
18
|
+
import "./chunk-OQSEJXC4.mjs";
|
|
19
|
+
import {
|
|
20
|
+
admin_app_exports
|
|
21
|
+
} from "./chunk-RKTIFEUY.mjs";
|
|
22
|
+
import "./chunk-W2UOCJDX.mjs";
|
|
23
23
|
import "./chunk-6BWS3CLP.mjs";
|
|
24
24
|
export {
|
|
25
25
|
admin_exports as admin,
|
|
@@ -7,8 +7,7 @@ import {
|
|
|
7
7
|
pageStudioModuleManifest,
|
|
8
8
|
resolveBuilderThemeTokens,
|
|
9
9
|
toEditorInitialDoc
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-OQSEJXC4.mjs";
|
|
10
|
+
} from "../chunk-7HME6R2V.mjs";
|
|
12
11
|
import {
|
|
13
12
|
createDefaultStudioDocument,
|
|
14
13
|
defaultBuilderThemeTokens,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
studioDocumentToLayout
|
|
17
16
|
} from "../chunk-7ZMXZRBP.mjs";
|
|
18
17
|
import "../chunk-ADIIWIYL.mjs";
|
|
18
|
+
import "../chunk-OQSEJXC4.mjs";
|
|
19
19
|
import "../chunk-6BWS3CLP.mjs";
|
|
20
20
|
export {
|
|
21
21
|
createDefaultStudioDocument,
|
package/package.json
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sectionStyleDefaults
|
|
3
|
-
} from "./chunk-OQSEJXC4.mjs";
|
|
4
1
|
import {
|
|
5
2
|
createDefaultStudioDocument,
|
|
6
3
|
defaultBuilderThemeTokens,
|
|
@@ -14,6 +11,9 @@ import {
|
|
|
14
11
|
createEmptyStudioDocument,
|
|
15
12
|
validateStudioDocument
|
|
16
13
|
} from "./chunk-ADIIWIYL.mjs";
|
|
14
|
+
import {
|
|
15
|
+
sectionStyleDefaults
|
|
16
|
+
} from "./chunk-OQSEJXC4.mjs";
|
|
17
17
|
import {
|
|
18
18
|
__export
|
|
19
19
|
} from "./chunk-6BWS3CLP.mjs";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
adminNavIcons
|
|
3
|
-
} from "./chunk-W2UOCJDX.mjs";
|
|
4
1
|
import {
|
|
5
2
|
SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
|
|
6
3
|
SOCIAL_MEDIA_ICON_OPTIONS,
|
|
7
4
|
SOCIAL_MEDIA_PLATFORMS,
|
|
8
5
|
SOCIAL_MEDIA_PLATFORM_LABELS
|
|
9
6
|
} from "./chunk-ZTXJG4K5.mjs";
|
|
7
|
+
import {
|
|
8
|
+
adminNavIcons
|
|
9
|
+
} from "./chunk-W2UOCJDX.mjs";
|
|
10
10
|
import {
|
|
11
11
|
__export,
|
|
12
12
|
__require
|