@coorax/schema 0.0.0-canary.3 → 0.0.0-canary.5
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 +99 -71
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -319,7 +319,7 @@ var ContainersUtils = {
|
|
|
319
319
|
var Text = {
|
|
320
320
|
style: {
|
|
321
321
|
width: "100%",
|
|
322
|
-
color: "var(--foreground)",
|
|
322
|
+
color: "var(--corax-foreground)",
|
|
323
323
|
fontSize: "18px",
|
|
324
324
|
minHeight: "32px",
|
|
325
325
|
whiteSpace: "pre-wrap",
|
|
@@ -331,16 +331,15 @@ var Text = {
|
|
|
331
331
|
border: "none",
|
|
332
332
|
fieldSizing: "content",
|
|
333
333
|
cursor: "default",
|
|
334
|
-
paddingInline: 4
|
|
335
|
-
userSelect: "none"
|
|
334
|
+
paddingInline: 4
|
|
336
335
|
},
|
|
337
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
336
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none"
|
|
338
337
|
};
|
|
339
338
|
var Heading = {
|
|
340
339
|
style: {
|
|
341
340
|
width: "100%",
|
|
342
341
|
maxWidth: "100%",
|
|
343
|
-
color: "var(--foreground)",
|
|
342
|
+
color: "var(--corax-foreground)",
|
|
344
343
|
fontSize: "40px",
|
|
345
344
|
minHeight: "48px",
|
|
346
345
|
fontWeight: 400,
|
|
@@ -351,16 +350,15 @@ var Heading = {
|
|
|
351
350
|
border: "none",
|
|
352
351
|
fieldSizing: "content",
|
|
353
352
|
cursor: "default",
|
|
354
|
-
paddingInline: 4
|
|
355
|
-
userSelect: "none"
|
|
353
|
+
paddingInline: 4
|
|
356
354
|
},
|
|
357
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
355
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none"
|
|
358
356
|
};
|
|
359
357
|
var SubHeading = {
|
|
360
358
|
style: {
|
|
361
359
|
width: "100%",
|
|
362
360
|
maxWidth: "100%",
|
|
363
|
-
color: "var(--foreground)",
|
|
361
|
+
color: "var(--corax-foreground)",
|
|
364
362
|
fontSize: "28px",
|
|
365
363
|
minHeight: "40px",
|
|
366
364
|
fontWeight: 400,
|
|
@@ -371,10 +369,9 @@ var SubHeading = {
|
|
|
371
369
|
border: "none",
|
|
372
370
|
fieldSizing: "content",
|
|
373
371
|
cursor: "default",
|
|
374
|
-
paddingInline: 4
|
|
375
|
-
userSelect: "none"
|
|
372
|
+
paddingInline: 4
|
|
376
373
|
},
|
|
377
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
374
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none"
|
|
378
375
|
};
|
|
379
376
|
var Image = {
|
|
380
377
|
style: {
|
|
@@ -386,8 +383,7 @@ var Image = {
|
|
|
386
383
|
outline: "none",
|
|
387
384
|
border: "none",
|
|
388
385
|
fieldSizing: "content",
|
|
389
|
-
cursor: "default"
|
|
390
|
-
userSelect: "none"
|
|
386
|
+
cursor: "default"
|
|
391
387
|
}
|
|
392
388
|
};
|
|
393
389
|
var Video = {
|
|
@@ -399,8 +395,7 @@ var Video = {
|
|
|
399
395
|
outline: "none",
|
|
400
396
|
border: "none",
|
|
401
397
|
fieldSizing: "content",
|
|
402
|
-
cursor: "default"
|
|
403
|
-
userSelect: "none"
|
|
398
|
+
cursor: "default"
|
|
404
399
|
}
|
|
405
400
|
};
|
|
406
401
|
var IFrame = {
|
|
@@ -413,14 +408,13 @@ var IFrame = {
|
|
|
413
408
|
outline: "none",
|
|
414
409
|
border: "none",
|
|
415
410
|
fieldSizing: "content",
|
|
416
|
-
cursor: "default"
|
|
417
|
-
userSelect: "none"
|
|
411
|
+
cursor: "default"
|
|
418
412
|
}
|
|
419
413
|
};
|
|
420
414
|
var Link = {
|
|
421
415
|
style: {
|
|
422
416
|
width: "100%",
|
|
423
|
-
color: "var(--primary)",
|
|
417
|
+
color: "var(--corax-primary)",
|
|
424
418
|
fontSize: "18px",
|
|
425
419
|
minHeight: "32px",
|
|
426
420
|
whiteSpace: "pre-wrap",
|
|
@@ -431,17 +425,16 @@ var Link = {
|
|
|
431
425
|
outline: "none",
|
|
432
426
|
border: "none",
|
|
433
427
|
fieldSizing: "content",
|
|
434
|
-
cursor: "
|
|
435
|
-
paddingInline: 4
|
|
436
|
-
userSelect: "none"
|
|
428
|
+
cursor: "pointer",
|
|
429
|
+
paddingInline: 4
|
|
437
430
|
},
|
|
438
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
431
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none"
|
|
439
432
|
};
|
|
440
433
|
var Blockquote = {
|
|
441
434
|
style: {
|
|
442
435
|
width: "100%",
|
|
443
436
|
maxWidth: "100%",
|
|
444
|
-
color: "var(--muted-foreground)",
|
|
437
|
+
color: "var(--corax-muted-foreground)",
|
|
445
438
|
fontSize: "18px",
|
|
446
439
|
minHeight: "32px",
|
|
447
440
|
fontWeight: 400,
|
|
@@ -453,17 +446,16 @@ var Blockquote = {
|
|
|
453
446
|
border: "none",
|
|
454
447
|
fieldSizing: "content",
|
|
455
448
|
cursor: "default",
|
|
456
|
-
paddingInline: 4
|
|
457
|
-
userSelect: "none"
|
|
449
|
+
paddingInline: 4
|
|
458
450
|
},
|
|
459
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
451
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none"
|
|
460
452
|
};
|
|
461
453
|
var Divider = {
|
|
462
454
|
style: {
|
|
463
455
|
width: "100%",
|
|
464
456
|
borderTopWidth: 1,
|
|
465
457
|
borderTopStyle: "solid",
|
|
466
|
-
borderTopColor: "var(--color-muted-foreground)",
|
|
458
|
+
borderTopColor: "var(--color-corax-muted-foreground)",
|
|
467
459
|
marginBlock: 8,
|
|
468
460
|
outline: "none",
|
|
469
461
|
height: 1,
|
|
@@ -488,7 +480,7 @@ var Code = {
|
|
|
488
480
|
style: {
|
|
489
481
|
width: "100%",
|
|
490
482
|
maxWidth: "100%",
|
|
491
|
-
color: "var(--foreground)",
|
|
483
|
+
color: "var(--corax-foreground)",
|
|
492
484
|
fontSize: "14px",
|
|
493
485
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace",
|
|
494
486
|
minHeight: "40px",
|
|
@@ -497,19 +489,18 @@ var Code = {
|
|
|
497
489
|
whiteSpace: "pre-wrap",
|
|
498
490
|
display: "block",
|
|
499
491
|
outline: "none",
|
|
500
|
-
border: "1px solid var(--border)",
|
|
492
|
+
border: "1px solid var(--corax-border)",
|
|
501
493
|
fieldSizing: "content",
|
|
502
494
|
cursor: "default",
|
|
503
|
-
padding: 12
|
|
504
|
-
userSelect: "none"
|
|
495
|
+
padding: 12
|
|
505
496
|
},
|
|
506
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none bg-foreground dark:bg-transparent"
|
|
497
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none bg-corax-foreground dark:bg-transparent"
|
|
507
498
|
};
|
|
508
499
|
var Caption = {
|
|
509
500
|
style: {
|
|
510
501
|
width: "100%",
|
|
511
502
|
maxWidth: "100%",
|
|
512
|
-
color: "var(--muted-foreground)",
|
|
503
|
+
color: "var(--corax-muted-foreground)",
|
|
513
504
|
fontSize: "14px",
|
|
514
505
|
minHeight: "24px",
|
|
515
506
|
fontWeight: 400,
|
|
@@ -522,10 +513,9 @@ var Caption = {
|
|
|
522
513
|
fieldSizing: "content",
|
|
523
514
|
cursor: "default",
|
|
524
515
|
paddingInline: 4,
|
|
525
|
-
paddingBottom: 4
|
|
526
|
-
userSelect: "none"
|
|
516
|
+
paddingBottom: 4
|
|
527
517
|
},
|
|
528
|
-
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-muted-foreground [&:empty:before]:pointer-events-none"
|
|
518
|
+
className: "[&:empty:before]:content-[attr(data-placeholder)] [&:empty:before]:text-corax-muted-foreground [&:empty:before]:pointer-events-none"
|
|
529
519
|
};
|
|
530
520
|
var DEFAULT_STYLES = {
|
|
531
521
|
text: Text,
|
|
@@ -573,182 +563,211 @@ function getIframeSrc(value) {
|
|
|
573
563
|
return null;
|
|
574
564
|
return `https://www.youtube.com/embed/${videoId}?enablejsapi=1`;
|
|
575
565
|
}
|
|
566
|
+
function mergeFieldProps(defaults, overrides) {
|
|
567
|
+
if (!overrides)
|
|
568
|
+
return defaults;
|
|
569
|
+
const merged = { ...defaults, ...overrides };
|
|
570
|
+
if (defaults.style || overrides.style) {
|
|
571
|
+
merged.style = {
|
|
572
|
+
...defaults.style,
|
|
573
|
+
...overrides.style
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
if (defaults.pseudoStyle || overrides.pseudoStyle) {
|
|
577
|
+
merged.pseudoStyle = {
|
|
578
|
+
...defaults.pseudoStyle,
|
|
579
|
+
...overrides.pseudoStyle
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
return merged;
|
|
583
|
+
}
|
|
576
584
|
function NewTextField(defaultValue) {
|
|
585
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
577
586
|
return new FieldClass({
|
|
578
587
|
id: UTILS.generateFieldId(),
|
|
579
588
|
name: "Text field",
|
|
580
589
|
type: "text",
|
|
581
590
|
tag: "p",
|
|
582
591
|
variant: "field",
|
|
583
|
-
props: {
|
|
592
|
+
props: mergeFieldProps({
|
|
584
593
|
children: { text: "", marks: [] },
|
|
585
594
|
"data-text-path": "props.children",
|
|
586
595
|
contentEditable: false,
|
|
587
596
|
...DEFAULT_STYLES["text"]
|
|
588
|
-
},
|
|
589
|
-
...
|
|
597
|
+
}, defaultProps),
|
|
598
|
+
...restDefault
|
|
590
599
|
});
|
|
591
600
|
}
|
|
592
601
|
function NewHeadingField(defaultValue) {
|
|
602
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
593
603
|
return new FieldClass({
|
|
594
604
|
id: UTILS.generateFieldId(),
|
|
595
605
|
name: "Heading field",
|
|
596
606
|
type: "heading",
|
|
597
607
|
tag: "h1",
|
|
598
608
|
variant: "field",
|
|
599
|
-
props: {
|
|
609
|
+
props: mergeFieldProps({
|
|
600
610
|
children: { text: "", marks: [] },
|
|
601
611
|
"data-text-path": "props.children",
|
|
602
612
|
contentEditable: false,
|
|
603
613
|
...DEFAULT_STYLES["heading"]
|
|
604
|
-
},
|
|
605
|
-
...
|
|
614
|
+
}, defaultProps),
|
|
615
|
+
...restDefault
|
|
606
616
|
});
|
|
607
617
|
}
|
|
608
618
|
function NewSubHeadingField(defaultValue) {
|
|
619
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
609
620
|
return new FieldClass({
|
|
610
621
|
id: UTILS.generateFieldId(),
|
|
611
622
|
name: "Sub-heading field",
|
|
612
623
|
type: "sub-heading",
|
|
613
624
|
tag: "h2",
|
|
614
625
|
variant: "field",
|
|
615
|
-
props: {
|
|
626
|
+
props: mergeFieldProps({
|
|
616
627
|
children: { text: "", marks: [] },
|
|
617
628
|
"data-text-path": "props.children",
|
|
618
629
|
contentEditable: false,
|
|
619
630
|
...DEFAULT_STYLES["sub-heading"]
|
|
620
|
-
},
|
|
621
|
-
...
|
|
631
|
+
}, defaultProps),
|
|
632
|
+
...restDefault
|
|
622
633
|
});
|
|
623
634
|
}
|
|
624
635
|
function NewImageField(defaultValue) {
|
|
636
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
625
637
|
return new FieldClass({
|
|
626
638
|
id: UTILS.generateFieldId(),
|
|
627
639
|
name: "Image field",
|
|
628
640
|
type: "image",
|
|
629
641
|
tag: "img",
|
|
630
642
|
variant: "field",
|
|
631
|
-
props: {
|
|
643
|
+
props: mergeFieldProps({
|
|
632
644
|
src: "",
|
|
633
645
|
alt: "image",
|
|
634
646
|
...DEFAULT_STYLES["image"]
|
|
635
|
-
},
|
|
636
|
-
...
|
|
647
|
+
}, defaultProps),
|
|
648
|
+
...restDefault
|
|
637
649
|
});
|
|
638
650
|
}
|
|
639
651
|
function NewVideoField(defaultValue) {
|
|
652
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
640
653
|
return new FieldClass({
|
|
641
654
|
id: UTILS.generateFieldId(),
|
|
642
655
|
name: "Video field",
|
|
643
656
|
type: "video",
|
|
644
657
|
tag: "video",
|
|
645
658
|
variant: "field",
|
|
646
|
-
props: {
|
|
659
|
+
props: mergeFieldProps({
|
|
647
660
|
src: "",
|
|
648
661
|
alt: "video",
|
|
649
662
|
controlsList: "nodownload nofullscreen noremoteplayback noplaybackrate",
|
|
650
663
|
preload: "metadata",
|
|
651
664
|
controls: true,
|
|
652
665
|
...DEFAULT_STYLES["video"]
|
|
653
|
-
},
|
|
654
|
-
...
|
|
666
|
+
}, defaultProps),
|
|
667
|
+
...restDefault
|
|
655
668
|
});
|
|
656
669
|
}
|
|
657
670
|
function NewIFrameField(defaultValue) {
|
|
671
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
658
672
|
return new FieldClass({
|
|
659
673
|
id: UTILS.generateFieldId(),
|
|
660
674
|
name: "IFrame field",
|
|
661
675
|
type: "iframe",
|
|
662
676
|
tag: "iframe",
|
|
663
677
|
variant: "field",
|
|
664
|
-
props: {
|
|
678
|
+
props: mergeFieldProps({
|
|
665
679
|
src: "",
|
|
666
680
|
alt: "image",
|
|
667
681
|
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
|
|
668
682
|
referrerPolicy: "strict-origin-when-cross-origin",
|
|
669
|
-
allowFullScreen:
|
|
683
|
+
allowFullScreen: true,
|
|
670
684
|
frameBorder: 0,
|
|
671
685
|
...DEFAULT_STYLES["iframe"]
|
|
672
|
-
},
|
|
673
|
-
...
|
|
686
|
+
}, defaultProps),
|
|
687
|
+
...restDefault
|
|
674
688
|
});
|
|
675
689
|
}
|
|
676
690
|
function NewLinkField(defaultValue) {
|
|
691
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
677
692
|
return new FieldClass({
|
|
678
693
|
id: UTILS.generateFieldId(),
|
|
679
694
|
name: "Link field",
|
|
680
695
|
type: "link",
|
|
681
696
|
tag: "a",
|
|
682
697
|
variant: "field",
|
|
683
|
-
props: {
|
|
698
|
+
props: mergeFieldProps({
|
|
684
699
|
href: "#",
|
|
685
700
|
alt: "Preview new link",
|
|
686
701
|
"data-text-path": "props.children",
|
|
687
702
|
children: { text: "Preview new link", marks: [] },
|
|
688
703
|
...DEFAULT_STYLES["link"]
|
|
689
|
-
},
|
|
690
|
-
...
|
|
704
|
+
}, defaultProps),
|
|
705
|
+
...restDefault
|
|
691
706
|
});
|
|
692
707
|
}
|
|
693
708
|
function NewBlockquoteField(defaultValue) {
|
|
709
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
694
710
|
return new FieldClass({
|
|
695
711
|
id: UTILS.generateFieldId(),
|
|
696
712
|
name: "Blockquote field",
|
|
697
713
|
type: "blockquote",
|
|
698
714
|
tag: "blockquote",
|
|
699
715
|
variant: "field",
|
|
700
|
-
props: {
|
|
716
|
+
props: mergeFieldProps({
|
|
701
717
|
"data-text-path": "props.children",
|
|
702
718
|
children: { text: "", marks: [] },
|
|
703
719
|
...DEFAULT_STYLES["blockquote"]
|
|
704
|
-
},
|
|
705
|
-
...
|
|
720
|
+
}, defaultProps),
|
|
721
|
+
...restDefault
|
|
706
722
|
});
|
|
707
723
|
}
|
|
708
724
|
function NewDividerField(defaultValue) {
|
|
725
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
709
726
|
return new FieldClass({
|
|
710
727
|
id: UTILS.generateFieldId(),
|
|
711
728
|
name: "Divider field",
|
|
712
729
|
type: "divider",
|
|
713
730
|
tag: "hr",
|
|
714
731
|
variant: "field",
|
|
715
|
-
props: {
|
|
732
|
+
props: mergeFieldProps({
|
|
716
733
|
...DEFAULT_STYLES["divider"]
|
|
717
|
-
},
|
|
718
|
-
...
|
|
734
|
+
}, defaultProps),
|
|
735
|
+
...restDefault
|
|
719
736
|
});
|
|
720
737
|
}
|
|
721
738
|
function NewCodeField(defaultValue) {
|
|
739
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
722
740
|
return new FieldClass({
|
|
723
741
|
id: UTILS.generateFieldId(),
|
|
724
742
|
name: "Code field",
|
|
725
743
|
type: "code",
|
|
726
744
|
tag: "pre",
|
|
727
745
|
variant: "field",
|
|
728
|
-
props: {
|
|
746
|
+
props: mergeFieldProps({
|
|
729
747
|
"data-text-path": "props.children",
|
|
730
748
|
children: { text: "", marks: [] },
|
|
731
749
|
theme: "dark",
|
|
732
750
|
contentEditable: false,
|
|
733
751
|
...DEFAULT_STYLES["code"]
|
|
734
|
-
},
|
|
735
|
-
...
|
|
752
|
+
}, defaultProps),
|
|
753
|
+
...restDefault
|
|
736
754
|
});
|
|
737
755
|
}
|
|
738
756
|
function NewCaptionField(defaultValue) {
|
|
757
|
+
const { props: defaultProps, ...restDefault } = defaultValue ?? {};
|
|
739
758
|
return new FieldClass({
|
|
740
759
|
id: UTILS.generateFieldId(),
|
|
741
760
|
name: "Caption field",
|
|
742
761
|
type: "caption",
|
|
743
762
|
tag: "figcaption",
|
|
744
763
|
variant: "field",
|
|
745
|
-
props: {
|
|
764
|
+
props: mergeFieldProps({
|
|
746
765
|
"data-text-path": "props.children",
|
|
747
766
|
children: { text: "", marks: [] },
|
|
748
767
|
contentEditable: false,
|
|
749
768
|
...DEFAULT_STYLES["caption"]
|
|
750
|
-
},
|
|
751
|
-
...
|
|
769
|
+
}, defaultProps),
|
|
770
|
+
...restDefault
|
|
752
771
|
});
|
|
753
772
|
}
|
|
754
773
|
function NewField(type, defaultValue) {
|
|
@@ -780,6 +799,15 @@ function NewField(type, defaultValue) {
|
|
|
780
799
|
}
|
|
781
800
|
}
|
|
782
801
|
function DeserializeField(field4) {
|
|
802
|
+
const defaultStyle = DEFAULT_STYLES[field4.type];
|
|
803
|
+
if (defaultStyle) {
|
|
804
|
+
return new FieldClass({
|
|
805
|
+
...field4,
|
|
806
|
+
props: mergeFieldProps({
|
|
807
|
+
...defaultStyle
|
|
808
|
+
}, field4.props)
|
|
809
|
+
});
|
|
810
|
+
}
|
|
783
811
|
return new FieldClass(field4);
|
|
784
812
|
}
|
|
785
813
|
var FieldsUtils = {
|