@crystallize/design-system 1.7.0 → 1.9.0
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/CHANGELOG.md +13 -0
- package/dist/index.css +53 -332
- package/dist/index.d.ts +15 -8
- package/dist/index.js +1717 -4568
- package/dist/index.mjs +1639 -2355
- package/package.json +1 -1
- package/src/action-menu/action-item-separator.tsx +14 -0
- package/src/action-menu/action-item.tsx +2 -2
- package/src/action-menu/action-menu.css +8 -0
- package/src/action-menu/action-menu.tsx +2 -1
- package/src/dropdown-menu/dropdown-menu-root.tsx +3 -1
- package/src/dropdown-menu/index.ts +5 -2
- package/src/iconography/subscription-contracts.tsx +4 -4
- package/src/iconography/subscription-plans.tsx +5 -5
- package/src/rich-text-editor/model/crystallize-to-lexical.ts +12 -1
- package/src/rich-text-editor/model/lexical-to-crystallize.ts +38 -38
- package/src/rich-text-editor/nodes/BaseNodes.ts +0 -7
- package/src/rich-text-editor/nodes/TableCellNodes.ts +0 -7
- package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +1 -1
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +3 -2
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +0 -1
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +17 -17
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +1 -1
- package/src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx +2 -7
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +80 -149
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +23 -36
- package/src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx +55 -0
- package/src/rich-text-editor/rich-text-editor.css +10 -322
- package/src/rich-text-editor/rich-text-editor.stories.tsx +35 -5
- package/src/rich-text-editor/rich-text-editor.tsx +6 -39
- package/src/rich-text-editor/tests/rich-text-editor-code.test.tsx +10 -6
- package/src/rich-text-editor/tests/rich-text-editor-model-conversions.test.tsx +19 -7
- package/src/rich-text-editor/themes/CrystallizeRTEditorTheme.css +3 -11
- package/dist/TableComponent-I2YOOYOU.css +0 -281
- package/dist/TableComponent-QINOO453.mjs +0 -1377
- package/dist/chevron-down-3FRWSIKS.svg +0 -1
- package/dist/chunk-VUXQZRSP.mjs +0 -737
- package/dist/markdown-4BGQNLLT.svg +0 -1
- package/src/rich-text-editor/nodes/KeywordNode.ts +0 -73
- package/src/rich-text-editor/nodes/TableComponent.tsx +0 -1547
- package/src/rich-text-editor/nodes/TableNode.tsx +0 -398
- package/src/rich-text-editor/plugins/ComponentPickerPlugin/index.tsx +0 -320
- package/src/rich-text-editor/plugins/DragDropPastePlugin/index.ts +0 -40
- package/src/rich-text-editor/plugins/MarkdownShortcutPlugin/index.tsx +0 -16
- package/src/rich-text-editor/plugins/MarkdownTransformers/index.ts +0 -195
- package/src/rich-text-editor/plugins/SpeechToTextPlugin/index.ts +0 -113
- package/src/rich-text-editor/plugins/TableCellResizer/index.css +0 -12
- package/src/rich-text-editor/plugins/TableCellResizer/index.tsx +0 -386
- package/src/rich-text-editor/plugins/TablePlugin.tsx +0 -190
- package/src/rich-text-editor/plugins/TreeViewPlugin/index.tsx +0 -25
- package/src/rich-text-editor/plugins/TypingPerfPlugin/index.ts +0 -117
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
max-width: 1100px;
|
|
12
12
|
position: relative;
|
|
13
13
|
line-height: 1.7;
|
|
14
|
+
|
|
14
15
|
> * {
|
|
15
16
|
box-sizing: border-box;
|
|
16
17
|
}
|
|
@@ -90,63 +91,6 @@
|
|
|
90
91
|
background-color: rgba(60, 132, 244, 0.5);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
.editor-image .image-resizer {
|
|
94
|
-
display: block;
|
|
95
|
-
width: 7px;
|
|
96
|
-
height: 7px;
|
|
97
|
-
position: absolute;
|
|
98
|
-
background-color: rgb(60, 132, 244);
|
|
99
|
-
border: 1px solid #fff;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.editor-image .image-resizer.image-resizer-n {
|
|
103
|
-
top: -6px;
|
|
104
|
-
left: 48%;
|
|
105
|
-
cursor: n-resize;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.editor-image .image-resizer.image-resizer-ne {
|
|
109
|
-
top: -6px;
|
|
110
|
-
right: -6px;
|
|
111
|
-
cursor: ne-resize;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.editor-image .image-resizer.image-resizer-e {
|
|
115
|
-
bottom: 48%;
|
|
116
|
-
right: -6px;
|
|
117
|
-
cursor: e-resize;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.editor-image .image-resizer.image-resizer-se {
|
|
121
|
-
bottom: -2px;
|
|
122
|
-
right: -6px;
|
|
123
|
-
cursor: nwse-resize;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.editor-image .image-resizer.image-resizer-s {
|
|
127
|
-
bottom: -2px;
|
|
128
|
-
left: 48%;
|
|
129
|
-
cursor: s-resize;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.editor-image .image-resizer.image-resizer-sw {
|
|
133
|
-
bottom: -2px;
|
|
134
|
-
left: -6px;
|
|
135
|
-
cursor: sw-resize;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.editor-image .image-resizer.image-resizer-w {
|
|
139
|
-
bottom: 48%;
|
|
140
|
-
left: -6px;
|
|
141
|
-
cursor: w-resize;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.editor-image .image-resizer.image-resizer-nw {
|
|
145
|
-
top: -6px;
|
|
146
|
-
left: -6px;
|
|
147
|
-
cursor: nw-resize;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
94
|
.editor-scroller {
|
|
151
95
|
min-height: 150px;
|
|
152
96
|
border: 0;
|
|
@@ -512,10 +456,6 @@
|
|
|
512
456
|
background-image: url(images/icons/indent.svg);
|
|
513
457
|
}
|
|
514
458
|
|
|
515
|
-
i.markdown {
|
|
516
|
-
background-image: url(images/icons/markdown.svg);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
459
|
i.outdent {
|
|
520
460
|
background-image: url(images/icons/outdent.svg);
|
|
521
461
|
}
|
|
@@ -724,98 +664,6 @@
|
|
|
724
664
|
color: red;
|
|
725
665
|
}
|
|
726
666
|
|
|
727
|
-
.dropdown {
|
|
728
|
-
z-index: 10;
|
|
729
|
-
display: block;
|
|
730
|
-
position: fixed;
|
|
731
|
-
box-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1),
|
|
732
|
-
inset 0 0 0 1px rgba(255, 255, 255, 0.5);
|
|
733
|
-
border-radius: 8px;
|
|
734
|
-
min-height: 40px;
|
|
735
|
-
background-color: #fff;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
.dropdown .item {
|
|
739
|
-
margin: 0 8px 0 8px;
|
|
740
|
-
padding: 8px;
|
|
741
|
-
color: #050505;
|
|
742
|
-
cursor: pointer;
|
|
743
|
-
line-height: 16px;
|
|
744
|
-
font-size: 15px;
|
|
745
|
-
display: flex;
|
|
746
|
-
align-content: center;
|
|
747
|
-
flex-direction: row;
|
|
748
|
-
flex-shrink: 0;
|
|
749
|
-
justify-content: space-between;
|
|
750
|
-
background-color: #fff;
|
|
751
|
-
border-radius: 8px;
|
|
752
|
-
border: 0;
|
|
753
|
-
max-width: 250px;
|
|
754
|
-
min-width: 100px;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
.dropdown .item.fontsize-item,
|
|
758
|
-
.dropdown .item.fontsize-item .text {
|
|
759
|
-
min-width: unset;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
.dropdown .item .active {
|
|
763
|
-
display: flex;
|
|
764
|
-
width: 20px;
|
|
765
|
-
height: 20px;
|
|
766
|
-
background-size: contain;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
.dropdown .item:first-child {
|
|
770
|
-
margin-top: 8px;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
.dropdown .item:last-child {
|
|
774
|
-
margin-bottom: 8px;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
.dropdown .item:hover {
|
|
778
|
-
background-color: #eee;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
.dropdown .item .text {
|
|
782
|
-
display: flex;
|
|
783
|
-
line-height: 20px;
|
|
784
|
-
flex-grow: 1;
|
|
785
|
-
min-width: 150px;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
.dropdown .item .icon {
|
|
789
|
-
display: flex;
|
|
790
|
-
width: 20px;
|
|
791
|
-
height: 20px;
|
|
792
|
-
user-select: none;
|
|
793
|
-
margin-right: 12px;
|
|
794
|
-
line-height: 16px;
|
|
795
|
-
background-size: contain;
|
|
796
|
-
background-position: center;
|
|
797
|
-
background-repeat: no-repeat;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
.dropdown .divider {
|
|
801
|
-
width: auto;
|
|
802
|
-
background-color: #eee;
|
|
803
|
-
margin: 4px 8px;
|
|
804
|
-
height: 1px;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
@media screen and (max-width: 1100px) {
|
|
808
|
-
.dropdown-button-text {
|
|
809
|
-
display: none !important;
|
|
810
|
-
}
|
|
811
|
-
.font-size .dropdown-button-text {
|
|
812
|
-
display: flex !important;
|
|
813
|
-
}
|
|
814
|
-
.code-language .dropdown-button-text {
|
|
815
|
-
display: flex !important;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
|
|
819
667
|
.icon.paragraph {
|
|
820
668
|
background-image: url(images/icons/text-paragraph.svg);
|
|
821
669
|
}
|
|
@@ -886,74 +734,8 @@
|
|
|
886
734
|
}
|
|
887
735
|
}
|
|
888
736
|
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
color: #444;
|
|
892
|
-
margin: 5px 0;
|
|
893
|
-
background-color: rgba(238, 238, 238, 0.7);
|
|
894
|
-
padding: 5px 10px;
|
|
895
|
-
border-radius: 10px;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
#rich-text-switch {
|
|
899
|
-
right: 0;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
#character-count-switch {
|
|
903
|
-
right: 130px;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
.switch label {
|
|
907
|
-
margin-right: 5px;
|
|
908
|
-
line-height: 24px;
|
|
909
|
-
width: 100px;
|
|
910
|
-
font-size: 14px;
|
|
911
|
-
display: inline-block;
|
|
912
|
-
vertical-align: middle;
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
.switch button {
|
|
916
|
-
background-color: rgb(206, 208, 212);
|
|
917
|
-
height: 24px;
|
|
918
|
-
box-sizing: border-box;
|
|
919
|
-
border-radius: 12px;
|
|
920
|
-
width: 44px;
|
|
921
|
-
display: inline-block;
|
|
922
|
-
vertical-align: middle;
|
|
923
|
-
position: relative;
|
|
924
|
-
outline: none;
|
|
925
|
-
cursor: pointer;
|
|
926
|
-
transition: background-color 0.1s;
|
|
927
|
-
border: 2px solid transparent;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
.switch button:focus-visible {
|
|
931
|
-
border-color: blue;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
.switch button span {
|
|
935
|
-
top: 0px;
|
|
936
|
-
left: 0px;
|
|
937
|
-
display: block;
|
|
938
|
-
position: absolute;
|
|
939
|
-
width: 20px;
|
|
940
|
-
height: 20px;
|
|
941
|
-
border-radius: 12px;
|
|
942
|
-
background-color: white;
|
|
943
|
-
transition: transform 0.2s;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
.switch button[aria-checked='true'] {
|
|
947
|
-
background-color: rgb(24, 119, 242);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
.switch button[aria-checked='true'] span {
|
|
951
|
-
transform: translateX(20px);
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
.keyword {
|
|
955
|
-
color: rgb(241, 118, 94);
|
|
956
|
-
font-weight: bold;
|
|
737
|
+
[role='separator'] {
|
|
738
|
+
@apply h-px bg-gray-200-700;
|
|
957
739
|
}
|
|
958
740
|
|
|
959
741
|
.actions i.indent {
|
|
@@ -1028,106 +810,6 @@
|
|
|
1028
810
|
will-change: transform;
|
|
1029
811
|
}
|
|
1030
812
|
|
|
1031
|
-
.table-cell-action-button {
|
|
1032
|
-
background-color: none;
|
|
1033
|
-
display: flex;
|
|
1034
|
-
justify-content: center;
|
|
1035
|
-
align-items: center;
|
|
1036
|
-
border: 0;
|
|
1037
|
-
position: relative;
|
|
1038
|
-
border-radius: 15px;
|
|
1039
|
-
color: #222;
|
|
1040
|
-
display: inline-block;
|
|
1041
|
-
cursor: pointer;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
i.chevron-down {
|
|
1045
|
-
background-color: transparent;
|
|
1046
|
-
background-size: contain;
|
|
1047
|
-
display: inline-block;
|
|
1048
|
-
height: 8px;
|
|
1049
|
-
width: 8px;
|
|
1050
|
-
background-image: url(images/icons/chevron-down.svg);
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
.action-button {
|
|
1054
|
-
background-color: #eee;
|
|
1055
|
-
border: 0;
|
|
1056
|
-
padding: 8px 12px;
|
|
1057
|
-
position: relative;
|
|
1058
|
-
margin-left: 5px;
|
|
1059
|
-
border-radius: 15px;
|
|
1060
|
-
color: #222;
|
|
1061
|
-
display: inline-block;
|
|
1062
|
-
cursor: pointer;
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
.action-button:hover {
|
|
1066
|
-
background-color: #ddd;
|
|
1067
|
-
color: #000;
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
.action-button-mic.active {
|
|
1071
|
-
animation: mic-pulsate-color 3s infinite;
|
|
1072
|
-
}
|
|
1073
|
-
button.action-button:disabled {
|
|
1074
|
-
opacity: 0.6;
|
|
1075
|
-
background: #eee;
|
|
1076
|
-
cursor: not-allowed;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
@keyframes mic-pulsate-color {
|
|
1080
|
-
0% {
|
|
1081
|
-
background-color: #ffdcdc;
|
|
1082
|
-
}
|
|
1083
|
-
50% {
|
|
1084
|
-
background-color: #ff8585;
|
|
1085
|
-
}
|
|
1086
|
-
100% {
|
|
1087
|
-
background-color: #ffdcdc;
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
.debug-timetravel-panel {
|
|
1092
|
-
overflow: hidden;
|
|
1093
|
-
padding: 0 0 10px 0;
|
|
1094
|
-
margin: auto;
|
|
1095
|
-
display: flex;
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
.debug-timetravel-panel-slider {
|
|
1099
|
-
padding: 0;
|
|
1100
|
-
flex: 8;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
.debug-timetravel-panel-button {
|
|
1104
|
-
padding: 0;
|
|
1105
|
-
border: 0;
|
|
1106
|
-
background: none;
|
|
1107
|
-
flex: 1;
|
|
1108
|
-
color: #fff;
|
|
1109
|
-
font-size: 12px;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
.debug-timetravel-panel-button:hover {
|
|
1113
|
-
text-decoration: underline;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
.debug-timetravel-button {
|
|
1117
|
-
border: 0;
|
|
1118
|
-
padding: 0;
|
|
1119
|
-
font-size: 12px;
|
|
1120
|
-
top: 10px;
|
|
1121
|
-
right: 15px;
|
|
1122
|
-
position: absolute;
|
|
1123
|
-
background: none;
|
|
1124
|
-
color: #fff;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
.debug-timetravel-button:hover {
|
|
1128
|
-
text-decoration: underline;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
813
|
.connecting {
|
|
1132
814
|
font-size: 15px;
|
|
1133
815
|
color: #999;
|
|
@@ -1334,7 +1016,7 @@
|
|
|
1334
1016
|
}
|
|
1335
1017
|
|
|
1336
1018
|
.TableNode__contentEditable .CrystallizeRTEditorTheme__paragraph {
|
|
1337
|
-
@apply
|
|
1019
|
+
@apply my-2;
|
|
1338
1020
|
}
|
|
1339
1021
|
|
|
1340
1022
|
.CrystallizeRTEditorTheme__blockCursor {
|
|
@@ -1359,3 +1041,9 @@
|
|
|
1359
1041
|
}
|
|
1360
1042
|
}
|
|
1361
1043
|
}
|
|
1044
|
+
|
|
1045
|
+
.c-rte-table-action-dropdown {
|
|
1046
|
+
display: absolute;
|
|
1047
|
+
right: 2px;
|
|
1048
|
+
top: 2px;
|
|
1049
|
+
}
|
|
@@ -25,6 +25,14 @@ export default meta;
|
|
|
25
25
|
|
|
26
26
|
type Story = StoryObj<typeof RichTextEditor>;
|
|
27
27
|
|
|
28
|
+
function paragraphWithText(textContent: string): CrystallizeRichTextNode {
|
|
29
|
+
return {
|
|
30
|
+
kind: 'block',
|
|
31
|
+
type: 'paragraph',
|
|
32
|
+
textContent,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
const fullModel: CrystallizeRichText = [
|
|
29
37
|
{
|
|
30
38
|
kind: 'block',
|
|
@@ -263,7 +271,7 @@ export const CodeBlock: Story = {
|
|
|
263
271
|
args: {
|
|
264
272
|
initialData: [
|
|
265
273
|
{
|
|
266
|
-
type: '
|
|
274
|
+
type: 'code',
|
|
267
275
|
kind: 'block',
|
|
268
276
|
textContent: 'const aVariable = 42;',
|
|
269
277
|
},
|
|
@@ -275,6 +283,28 @@ export const CodeBlock: Story = {
|
|
|
275
283
|
},
|
|
276
284
|
};
|
|
277
285
|
|
|
286
|
+
export const CodeBlockWithinPre: Story = {
|
|
287
|
+
args: {
|
|
288
|
+
initialData: [
|
|
289
|
+
{
|
|
290
|
+
type: 'preformatted',
|
|
291
|
+
kind: 'block',
|
|
292
|
+
children: [
|
|
293
|
+
{
|
|
294
|
+
type: 'code',
|
|
295
|
+
kind: 'block',
|
|
296
|
+
textContent: 'const aVariable = 42;',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
onChange(data) {
|
|
302
|
+
console.log('onChange');
|
|
303
|
+
console.log(JSON.stringify(data, null, 1));
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
|
|
278
308
|
export const LineBreak: Story = {
|
|
279
309
|
args: {
|
|
280
310
|
initialData: [
|
|
@@ -318,12 +348,12 @@ export const Table: Story = {
|
|
|
318
348
|
{
|
|
319
349
|
type: 'table-cell',
|
|
320
350
|
kind: 'inline',
|
|
321
|
-
|
|
351
|
+
children: [paragraphWithText('Hi')],
|
|
322
352
|
},
|
|
323
353
|
{
|
|
324
354
|
type: 'table-cell',
|
|
325
355
|
kind: 'inline',
|
|
326
|
-
|
|
356
|
+
children: [paragraphWithText('from')],
|
|
327
357
|
},
|
|
328
358
|
],
|
|
329
359
|
},
|
|
@@ -334,12 +364,12 @@ export const Table: Story = {
|
|
|
334
364
|
{
|
|
335
365
|
type: 'table-cell',
|
|
336
366
|
kind: 'inline',
|
|
337
|
-
|
|
367
|
+
children: [paragraphWithText('a')],
|
|
338
368
|
},
|
|
339
369
|
{
|
|
340
370
|
type: 'table-cell',
|
|
341
371
|
kind: 'inline',
|
|
342
|
-
|
|
372
|
+
children: [paragraphWithText('table')],
|
|
343
373
|
},
|
|
344
374
|
],
|
|
345
375
|
},
|
|
@@ -19,23 +19,16 @@ import { SharedHistoryContext, useSharedHistoryContext } from './context/SharedH
|
|
|
19
19
|
import { composeInitialState } from './model/crystallize-to-lexical';
|
|
20
20
|
import { lexicalToCrystallizeRichText } from './model/lexical-to-crystallize';
|
|
21
21
|
import { BaseNodes } from './nodes/BaseNodes';
|
|
22
|
-
import { BaseNodes as TableCellNodes } from './nodes/TableCellNodes';
|
|
23
22
|
import AutoLinkPlugin from './plugins/AutoLinkPlugin';
|
|
24
23
|
import CodeActionMenuPlugin from './plugins/CodeActionMenuPlugin';
|
|
25
24
|
import CodeHighlightPlugin from './plugins/CodeHighlightPlugin';
|
|
26
|
-
import ComponentPickerPlugin from './plugins/ComponentPickerPlugin';
|
|
27
|
-
import DragDropPaste from './plugins/DragDropPastePlugin';
|
|
28
25
|
import FloatingLinkEditorPlugin from './plugins/FloatingLinkEditorPlugin';
|
|
29
26
|
import FloatingTextFormatToolbarPlugin from './plugins/FloatingTextFormatToolbarPlugin';
|
|
30
27
|
import LinkPlugin from './plugins/LinkPlugin';
|
|
31
28
|
import ListMaxIndentLevelPlugin from './plugins/ListMaxIndentLevelPlugin';
|
|
32
|
-
import MarkdownShortcutPlugin from './plugins/MarkdownShortcutPlugin';
|
|
33
29
|
import { MaxLengthPlugin } from './plugins/MaxLengthPlugin';
|
|
34
|
-
import SpeechToTextPlugin from './plugins/SpeechToTextPlugin';
|
|
35
30
|
import TabFocusPlugin from './plugins/TabFocusPlugin';
|
|
36
31
|
import TableCellActionMenuPlugin from './plugins/TableActionMenuPlugin';
|
|
37
|
-
import TableCellResizer from './plugins/TableCellResizer';
|
|
38
|
-
import { TableContext, TablePlugin as NewTablePlugin } from './plugins/TablePlugin';
|
|
39
32
|
import ToolbarPlugin from './plugins/ToolbarPlugin';
|
|
40
33
|
import CrystallizeRTEditorTheme from './themes/CrystallizeRTEditorTheme';
|
|
41
34
|
import type { CrystallizeRichText } from './types/crystallize-rich-text-types';
|
|
@@ -90,11 +83,11 @@ export function RichTextEditor({
|
|
|
90
83
|
}}
|
|
91
84
|
>
|
|
92
85
|
<SharedHistoryContext>
|
|
93
|
-
<TableContext>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</TableContext>
|
|
86
|
+
{/* <TableContext> */}
|
|
87
|
+
<div className="c-rich-text-editor">
|
|
88
|
+
<RichTextEditorWithoutContext {...rest} editable={editable} />
|
|
89
|
+
</div>
|
|
90
|
+
{/* </TableContext> */}
|
|
98
91
|
</SharedHistoryContext>
|
|
99
92
|
</LexicalComposer>
|
|
100
93
|
);
|
|
@@ -154,7 +147,7 @@ function RichTextEditorWithoutContext({
|
|
|
154
147
|
function onLocalChange(editorState: EditorState) {
|
|
155
148
|
if (onChange) {
|
|
156
149
|
if (triggerOnChangeOnAutoFocus || firstOnChangeTriggeredRef.current) {
|
|
157
|
-
onChange(lexicalToCrystallizeRichText({ editorState }));
|
|
150
|
+
onChange(lexicalToCrystallizeRichText({ editor, editorState }));
|
|
158
151
|
}
|
|
159
152
|
}
|
|
160
153
|
|
|
@@ -168,11 +161,8 @@ function RichTextEditorWithoutContext({
|
|
|
168
161
|
{slotPreContent}
|
|
169
162
|
<div className="editor-container">
|
|
170
163
|
{maxLength != null ? <MaxLengthPlugin maxLength={maxLength} /> : null}
|
|
171
|
-
<DragDropPaste />
|
|
172
164
|
{!autoFocus ? null : <AutoFocusPlugin />}
|
|
173
165
|
<ClearEditorPlugin />
|
|
174
|
-
<ComponentPickerPlugin />
|
|
175
|
-
<SpeechToTextPlugin />
|
|
176
166
|
<AutoLinkPlugin />
|
|
177
167
|
|
|
178
168
|
<HistoryPlugin externalHistoryState={historyState} />
|
|
@@ -188,34 +178,11 @@ function RichTextEditorWithoutContext({
|
|
|
188
178
|
placeholder={placeholder}
|
|
189
179
|
ErrorBoundary={LexicalErrorBoundary}
|
|
190
180
|
/>
|
|
191
|
-
<MarkdownShortcutPlugin />
|
|
192
181
|
<CodeHighlightPlugin />
|
|
193
182
|
<ListPlugin />
|
|
194
183
|
<ListMaxIndentLevelPlugin maxDepth={7} />
|
|
195
184
|
<TablePlugin />
|
|
196
|
-
<TableCellResizer />
|
|
197
|
-
<NewTablePlugin
|
|
198
|
-
cellEditorConfig={{
|
|
199
|
-
namespace: 'Playground',
|
|
200
|
-
nodes: [...TableCellNodes],
|
|
201
|
-
onError: (error: Error) => {
|
|
202
|
-
throw error;
|
|
203
|
-
},
|
|
204
|
-
theme: CrystallizeRTEditorTheme,
|
|
205
|
-
}}
|
|
206
|
-
>
|
|
207
|
-
{!autoFocus ? <></> : <AutoFocusPlugin />}
|
|
208
|
-
<RichTextPlugin
|
|
209
|
-
contentEditable={<ContentEditable className="TableNode__contentEditable" />}
|
|
210
|
-
placeholder={null}
|
|
211
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
212
|
-
/>
|
|
213
|
-
<HistoryPlugin />
|
|
214
|
-
<LinkPlugin />
|
|
215
|
-
<FloatingTextFormatToolbarPlugin />
|
|
216
|
-
</NewTablePlugin>
|
|
217
185
|
<LinkPlugin />
|
|
218
|
-
|
|
219
186
|
<HorizontalRulePlugin />
|
|
220
187
|
<TabFocusPlugin />
|
|
221
188
|
<TabIndentationPlugin />
|
|
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
|
|
4
4
|
import { RichTextEditor } from '../rich-text-editor';
|
|
5
5
|
|
|
6
6
|
describe('RichTextEditor code node', () => {
|
|
7
|
-
it('can add a code block to an existing paragraph
|
|
7
|
+
it('can add a code block to an existing paragraph texst', async () => {
|
|
8
8
|
const onChange = vi.fn();
|
|
9
9
|
|
|
10
10
|
render(
|
|
@@ -27,12 +27,16 @@ describe('RichTextEditor code node', () => {
|
|
|
27
27
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
28
28
|
expect(onChange).toHaveBeenLastCalledWith([
|
|
29
29
|
{
|
|
30
|
-
type: 'code',
|
|
31
30
|
kind: 'block',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
type: 'preformatted',
|
|
32
|
+
children: [
|
|
33
|
+
{
|
|
34
|
+
type: 'code',
|
|
35
|
+
kind: 'block',
|
|
36
|
+
textContent: 'const aVariable = 42;',
|
|
37
|
+
metadata: { language: 'javascript' },
|
|
38
|
+
},
|
|
39
|
+
],
|
|
36
40
|
},
|
|
37
41
|
]);
|
|
38
42
|
});
|
|
@@ -4,6 +4,14 @@ import { RichTextEditor } from '../rich-text-editor';
|
|
|
4
4
|
import type { CrystallizeRichText, CrystallizeRichTextNode } from '../types/crystallize-rich-text-types';
|
|
5
5
|
import { sleep } from './utils';
|
|
6
6
|
|
|
7
|
+
function paragraphWithText(textContent: string): CrystallizeRichTextNode {
|
|
8
|
+
return {
|
|
9
|
+
kind: 'block',
|
|
10
|
+
type: 'paragraph',
|
|
11
|
+
textContent,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* In these tests, we are ensuring that the conversion from
|
|
9
17
|
* CrystallizeRichText to Lexial back to CrystallizeRichText works
|
|
@@ -94,11 +102,15 @@ const dataTypes: { name: string; model: CrystallizeRichText }[] = [
|
|
|
94
102
|
model: [
|
|
95
103
|
{
|
|
96
104
|
kind: 'block',
|
|
97
|
-
type: '
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
type: 'preformatted',
|
|
106
|
+
children: [
|
|
107
|
+
{
|
|
108
|
+
type: 'code',
|
|
109
|
+
kind: 'block',
|
|
110
|
+
textContent: 'const aVariable = 42;',
|
|
111
|
+
metadata: { language: 'javascript' },
|
|
112
|
+
},
|
|
113
|
+
],
|
|
102
114
|
},
|
|
103
115
|
],
|
|
104
116
|
},
|
|
@@ -137,12 +149,12 @@ const dataTypes: { name: string; model: CrystallizeRichText }[] = [
|
|
|
137
149
|
{
|
|
138
150
|
type: 'table-cell',
|
|
139
151
|
kind: 'inline',
|
|
140
|
-
|
|
152
|
+
children: [paragraphWithText('Hi from ')],
|
|
141
153
|
},
|
|
142
154
|
{
|
|
143
155
|
type: 'table-cell',
|
|
144
156
|
kind: 'inline',
|
|
145
|
-
|
|
157
|
+
children: [paragraphWithText('a table')],
|
|
146
158
|
},
|
|
147
159
|
],
|
|
148
160
|
},
|
|
@@ -242,21 +242,13 @@
|
|
|
242
242
|
opacity: 1;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
display: block;
|
|
247
|
-
position: absolute;
|
|
248
|
-
width: 1px;
|
|
249
|
-
background-color: rgb(60, 132, 244);
|
|
250
|
-
height: 100%;
|
|
251
|
-
top: 0;
|
|
252
|
-
}
|
|
245
|
+
|
|
253
246
|
.CrystallizeRTEditorTheme__tableCellActionButtonContainer {
|
|
254
247
|
display: block;
|
|
255
|
-
right:
|
|
256
|
-
top:
|
|
248
|
+
right: 2px;
|
|
249
|
+
top: 2px;
|
|
257
250
|
position: absolute;
|
|
258
251
|
z-index: 4;
|
|
259
|
-
width: 20px;
|
|
260
252
|
height: 20px;
|
|
261
253
|
}
|
|
262
254
|
.CrystallizeRTEditorTheme__tableCellActionButton {
|