@coorax/schema 0.0.0-canary.3 → 0.0.0-canary.4
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 +71 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -573,95 +573,119 @@ function getIframeSrc(value) {
|
|
|
573
573
|
return null;
|
|
574
574
|
return `https://www.youtube.com/embed/${videoId}?enablejsapi=1`;
|
|
575
575
|
}
|
|
576
|
+
function mergeFieldProps(defaults, overrides) {
|
|
577
|
+
if (!overrides)
|
|
578
|
+
return defaults;
|
|
579
|
+
const merged = { ...defaults, ...overrides };
|
|
580
|
+
if (defaults.style || overrides.style) {
|
|
581
|
+
merged.style = {
|
|
582
|
+
...defaults.style,
|
|
583
|
+
...overrides.style
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (defaults.pseudoStyle || overrides.pseudoStyle) {
|
|
587
|
+
merged.pseudoStyle = {
|
|
588
|
+
...defaults.pseudoStyle,
|
|
589
|
+
...overrides.pseudoStyle
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
return merged;
|
|
593
|
+
}
|
|
576
594
|
function NewTextField(defaultValue) {
|
|
595
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
577
596
|
return new FieldClass({
|
|
578
597
|
id: UTILS.generateFieldId(),
|
|
579
598
|
name: "Text field",
|
|
580
599
|
type: "text",
|
|
581
600
|
tag: "p",
|
|
582
601
|
variant: "field",
|
|
583
|
-
props: {
|
|
602
|
+
props: mergeFieldProps({
|
|
584
603
|
children: { text: "", marks: [] },
|
|
585
604
|
"data-text-path": "props.children",
|
|
586
605
|
contentEditable: false,
|
|
587
606
|
...DEFAULT_STYLES["text"]
|
|
588
|
-
},
|
|
589
|
-
...
|
|
607
|
+
}, defaultProps),
|
|
608
|
+
...restDefault
|
|
590
609
|
});
|
|
591
610
|
}
|
|
592
611
|
function NewHeadingField(defaultValue) {
|
|
612
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
593
613
|
return new FieldClass({
|
|
594
614
|
id: UTILS.generateFieldId(),
|
|
595
615
|
name: "Heading field",
|
|
596
616
|
type: "heading",
|
|
597
617
|
tag: "h1",
|
|
598
618
|
variant: "field",
|
|
599
|
-
props: {
|
|
619
|
+
props: mergeFieldProps({
|
|
600
620
|
children: { text: "", marks: [] },
|
|
601
621
|
"data-text-path": "props.children",
|
|
602
622
|
contentEditable: false,
|
|
603
623
|
...DEFAULT_STYLES["heading"]
|
|
604
|
-
},
|
|
605
|
-
...
|
|
624
|
+
}, defaultProps),
|
|
625
|
+
...restDefault
|
|
606
626
|
});
|
|
607
627
|
}
|
|
608
628
|
function NewSubHeadingField(defaultValue) {
|
|
629
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
609
630
|
return new FieldClass({
|
|
610
631
|
id: UTILS.generateFieldId(),
|
|
611
632
|
name: "Sub-heading field",
|
|
612
633
|
type: "sub-heading",
|
|
613
634
|
tag: "h2",
|
|
614
635
|
variant: "field",
|
|
615
|
-
props: {
|
|
636
|
+
props: mergeFieldProps({
|
|
616
637
|
children: { text: "", marks: [] },
|
|
617
638
|
"data-text-path": "props.children",
|
|
618
639
|
contentEditable: false,
|
|
619
640
|
...DEFAULT_STYLES["sub-heading"]
|
|
620
|
-
},
|
|
621
|
-
...
|
|
641
|
+
}, defaultProps),
|
|
642
|
+
...restDefault
|
|
622
643
|
});
|
|
623
644
|
}
|
|
624
645
|
function NewImageField(defaultValue) {
|
|
646
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
625
647
|
return new FieldClass({
|
|
626
648
|
id: UTILS.generateFieldId(),
|
|
627
649
|
name: "Image field",
|
|
628
650
|
type: "image",
|
|
629
651
|
tag: "img",
|
|
630
652
|
variant: "field",
|
|
631
|
-
props: {
|
|
653
|
+
props: mergeFieldProps({
|
|
632
654
|
src: "",
|
|
633
655
|
alt: "image",
|
|
634
656
|
...DEFAULT_STYLES["image"]
|
|
635
|
-
},
|
|
636
|
-
...
|
|
657
|
+
}, defaultProps),
|
|
658
|
+
...restDefault
|
|
637
659
|
});
|
|
638
660
|
}
|
|
639
661
|
function NewVideoField(defaultValue) {
|
|
662
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
640
663
|
return new FieldClass({
|
|
641
664
|
id: UTILS.generateFieldId(),
|
|
642
665
|
name: "Video field",
|
|
643
666
|
type: "video",
|
|
644
667
|
tag: "video",
|
|
645
668
|
variant: "field",
|
|
646
|
-
props: {
|
|
669
|
+
props: mergeFieldProps({
|
|
647
670
|
src: "",
|
|
648
671
|
alt: "video",
|
|
649
672
|
controlsList: "nodownload nofullscreen noremoteplayback noplaybackrate",
|
|
650
673
|
preload: "metadata",
|
|
651
674
|
controls: true,
|
|
652
675
|
...DEFAULT_STYLES["video"]
|
|
653
|
-
},
|
|
654
|
-
...
|
|
676
|
+
}, defaultProps),
|
|
677
|
+
...restDefault
|
|
655
678
|
});
|
|
656
679
|
}
|
|
657
680
|
function NewIFrameField(defaultValue) {
|
|
681
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
658
682
|
return new FieldClass({
|
|
659
683
|
id: UTILS.generateFieldId(),
|
|
660
684
|
name: "IFrame field",
|
|
661
685
|
type: "iframe",
|
|
662
686
|
tag: "iframe",
|
|
663
687
|
variant: "field",
|
|
664
|
-
props: {
|
|
688
|
+
props: mergeFieldProps({
|
|
665
689
|
src: "",
|
|
666
690
|
alt: "image",
|
|
667
691
|
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
|
|
@@ -669,86 +693,91 @@ function NewIFrameField(defaultValue) {
|
|
|
669
693
|
allowFullScreen: false,
|
|
670
694
|
frameBorder: 0,
|
|
671
695
|
...DEFAULT_STYLES["iframe"]
|
|
672
|
-
},
|
|
673
|
-
...
|
|
696
|
+
}, defaultProps),
|
|
697
|
+
...restDefault
|
|
674
698
|
});
|
|
675
699
|
}
|
|
676
700
|
function NewLinkField(defaultValue) {
|
|
701
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
677
702
|
return new FieldClass({
|
|
678
703
|
id: UTILS.generateFieldId(),
|
|
679
704
|
name: "Link field",
|
|
680
705
|
type: "link",
|
|
681
706
|
tag: "a",
|
|
682
707
|
variant: "field",
|
|
683
|
-
props: {
|
|
708
|
+
props: mergeFieldProps({
|
|
684
709
|
href: "#",
|
|
685
710
|
alt: "Preview new link",
|
|
686
711
|
"data-text-path": "props.children",
|
|
687
712
|
children: { text: "Preview new link", marks: [] },
|
|
688
713
|
...DEFAULT_STYLES["link"]
|
|
689
|
-
},
|
|
690
|
-
...
|
|
714
|
+
}, defaultProps),
|
|
715
|
+
...restDefault
|
|
691
716
|
});
|
|
692
717
|
}
|
|
693
718
|
function NewBlockquoteField(defaultValue) {
|
|
719
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
694
720
|
return new FieldClass({
|
|
695
721
|
id: UTILS.generateFieldId(),
|
|
696
722
|
name: "Blockquote field",
|
|
697
723
|
type: "blockquote",
|
|
698
724
|
tag: "blockquote",
|
|
699
725
|
variant: "field",
|
|
700
|
-
props: {
|
|
726
|
+
props: mergeFieldProps({
|
|
701
727
|
"data-text-path": "props.children",
|
|
702
728
|
children: { text: "", marks: [] },
|
|
703
729
|
...DEFAULT_STYLES["blockquote"]
|
|
704
|
-
},
|
|
705
|
-
...
|
|
730
|
+
}, defaultProps),
|
|
731
|
+
...restDefault
|
|
706
732
|
});
|
|
707
733
|
}
|
|
708
734
|
function NewDividerField(defaultValue) {
|
|
735
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
709
736
|
return new FieldClass({
|
|
710
737
|
id: UTILS.generateFieldId(),
|
|
711
738
|
name: "Divider field",
|
|
712
739
|
type: "divider",
|
|
713
740
|
tag: "hr",
|
|
714
741
|
variant: "field",
|
|
715
|
-
props: {
|
|
742
|
+
props: mergeFieldProps({
|
|
716
743
|
...DEFAULT_STYLES["divider"]
|
|
717
|
-
},
|
|
718
|
-
...
|
|
744
|
+
}, defaultProps),
|
|
745
|
+
...restDefault
|
|
719
746
|
});
|
|
720
747
|
}
|
|
721
748
|
function NewCodeField(defaultValue) {
|
|
749
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
722
750
|
return new FieldClass({
|
|
723
751
|
id: UTILS.generateFieldId(),
|
|
724
752
|
name: "Code field",
|
|
725
753
|
type: "code",
|
|
726
754
|
tag: "pre",
|
|
727
755
|
variant: "field",
|
|
728
|
-
props: {
|
|
756
|
+
props: mergeFieldProps({
|
|
729
757
|
"data-text-path": "props.children",
|
|
730
758
|
children: { text: "", marks: [] },
|
|
731
759
|
theme: "dark",
|
|
732
760
|
contentEditable: false,
|
|
733
761
|
...DEFAULT_STYLES["code"]
|
|
734
|
-
},
|
|
735
|
-
...
|
|
762
|
+
}, defaultProps),
|
|
763
|
+
...restDefault
|
|
736
764
|
});
|
|
737
765
|
}
|
|
738
766
|
function NewCaptionField(defaultValue) {
|
|
767
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
739
768
|
return new FieldClass({
|
|
740
769
|
id: UTILS.generateFieldId(),
|
|
741
770
|
name: "Caption field",
|
|
742
771
|
type: "caption",
|
|
743
772
|
tag: "figcaption",
|
|
744
773
|
variant: "field",
|
|
745
|
-
props: {
|
|
774
|
+
props: mergeFieldProps({
|
|
746
775
|
"data-text-path": "props.children",
|
|
747
776
|
children: { text: "", marks: [] },
|
|
748
777
|
contentEditable: false,
|
|
749
778
|
...DEFAULT_STYLES["caption"]
|
|
750
|
-
},
|
|
751
|
-
...
|
|
779
|
+
}, defaultProps),
|
|
780
|
+
...restDefault
|
|
752
781
|
});
|
|
753
782
|
}
|
|
754
783
|
function NewField(type, defaultValue) {
|
|
@@ -780,6 +809,15 @@ function NewField(type, defaultValue) {
|
|
|
780
809
|
}
|
|
781
810
|
}
|
|
782
811
|
function DeserializeField(field4) {
|
|
812
|
+
const defaultStyle = DEFAULT_STYLES[field4.type];
|
|
813
|
+
if (defaultStyle) {
|
|
814
|
+
return new FieldClass({
|
|
815
|
+
...field4,
|
|
816
|
+
props: mergeFieldProps({
|
|
817
|
+
...defaultStyle
|
|
818
|
+
}, field4.props)
|
|
819
|
+
});
|
|
820
|
+
}
|
|
783
821
|
return new FieldClass(field4);
|
|
784
822
|
}
|
|
785
823
|
var FieldsUtils = {
|