@blocknote/core 0.8.2 → 0.8.4-alpha.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/README.md +4 -0
- package/dist/blocknote.js +1777 -1849
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +4 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/src/BlockNoteEditor.ts +89 -39
- package/src/BlockNoteExtensions.ts +1 -58
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +10 -10
- package/src/api/formatConversions/formatConversions.test.ts +587 -605
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +15 -15
- package/src/api/nodeConversions/nodeConversions.test.ts +90 -94
- package/src/extensions/Blocks/api/blockTypes.ts +3 -2
- package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +6 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +101 -114
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +184 -149
- package/src/extensions/Placeholder/PlaceholderExtension.ts +2 -2
- package/src/extensions/{DraggableBlocks/DraggableBlocksPlugin.ts → SideMenu/SideMenuPlugin.ts} +181 -164
- package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +7 -30
- package/src/extensions/SlashMenu/SlashMenuPlugin.ts +51 -0
- package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +109 -0
- package/src/extensions/UniqueID/UniqueID.ts +29 -30
- package/src/index.ts +9 -8
- package/src/shared/BaseUiElementTypes.ts +8 -0
- package/src/shared/EditorElement.ts +0 -16
- package/src/shared/EventEmitter.ts +58 -0
- package/src/shared/plugins/suggestion/SuggestionItem.ts +3 -6
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +341 -403
- package/types/src/BlockNoteEditor.d.ts +18 -11
- package/types/src/BlockNoteExtensions.d.ts +0 -19
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +3 -2
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +18 -24
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +37 -10
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +79 -0
- package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +5 -18
- package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +13 -0
- package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +1 -69
- package/types/src/index.d.ts +9 -8
- package/types/src/shared/BaseUiElementTypes.d.ts +7 -0
- package/types/src/shared/EditorElement.d.ts +0 -10
- package/types/src/shared/EventEmitter.d.ts +11 -0
- package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +2 -7
- package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +12 -43
- package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +0 -29
- package/src/extensions/DraggableBlocks/DraggableBlocksExtension.ts +0 -37
- package/src/extensions/FormattingToolbar/FormattingToolbarExtension.ts +0 -37
- package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +0 -18
- package/src/extensions/HyperlinkToolbar/HyperlinkMark.ts +0 -28
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +0 -19
- package/src/extensions/SlashMenu/SlashMenuExtension.ts +0 -53
- package/src/extensions/SlashMenu/defaultSlashMenuItems.tsx +0 -195
- package/src/extensions/SlashMenu/index.ts +0 -5
- package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +0 -21
- package/types/src/CustomBlock.d.ts +0 -15
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableCol.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableContent.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableRow.d.ts +0 -2
- package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -17
- package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +0 -16
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +0 -49
- package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +0 -11
- package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +0 -10
- package/types/src/extensions/HyperlinkToolbar/HyperlinkMark.d.ts +0 -8
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -12
- package/types/src/extensions/Placeholder/localisation/index.d.ts +0 -2
- package/types/src/extensions/Placeholder/localisation/translation.d.ts +0 -51
- package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +0 -13
- package/types/src/extensions/SlashMenu/index.d.ts +0 -4
- package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +0 -12
- /package/src/extensions/{DraggableBlocks → SideMenu}/MultipleNodeSelection.ts +0 -0
- /package/types/src/extensions/{DraggableBlocks → SideMenu}/MultipleNodeSelection.d.ts +0 -0
|
@@ -1,662 +1,587 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
2
|
import { Block, BlockNoteEditor } from "../..";
|
|
3
3
|
import UniqueID from "../../extensions/UniqueID/UniqueID";
|
|
4
|
-
import { DefaultBlockSchema } from "../../extensions/Blocks/api/defaultBlocks";
|
|
5
4
|
|
|
6
5
|
let editor: BlockNoteEditor;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function removeInlineContentClass(html: string) {
|
|
25
|
-
return html.replace(/ class="_inlineContent_1c48ad"/g, "");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
|
|
30
|
-
|
|
31
|
-
editor = new BlockNoteEditor();
|
|
32
|
-
|
|
33
|
-
nonNestedBlocks = [
|
|
34
|
-
{
|
|
35
|
-
id: UniqueID.options.generateID(),
|
|
36
|
-
type: "heading",
|
|
37
|
-
props: {
|
|
38
|
-
backgroundColor: "default",
|
|
39
|
-
textColor: "default",
|
|
40
|
-
textAlignment: "left",
|
|
41
|
-
level: "1",
|
|
7
|
+
const getNonNestedBlocks = (): Block[] => [
|
|
8
|
+
{
|
|
9
|
+
id: UniqueID.options.generateID(),
|
|
10
|
+
type: "heading",
|
|
11
|
+
props: {
|
|
12
|
+
backgroundColor: "default",
|
|
13
|
+
textColor: "default",
|
|
14
|
+
textAlignment: "left",
|
|
15
|
+
level: "1",
|
|
16
|
+
},
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: "Heading",
|
|
21
|
+
styles: {},
|
|
42
22
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
],
|
|
24
|
+
children: [],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: UniqueID.options.generateID(),
|
|
28
|
+
type: "paragraph",
|
|
29
|
+
props: {
|
|
30
|
+
backgroundColor: "default",
|
|
31
|
+
textColor: "default",
|
|
32
|
+
textAlignment: "left",
|
|
51
33
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
textColor: "default",
|
|
58
|
-
textAlignment: "left",
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: "Paragraph",
|
|
38
|
+
styles: {},
|
|
59
39
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
],
|
|
41
|
+
children: [],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: UniqueID.options.generateID(),
|
|
45
|
+
type: "bulletListItem",
|
|
46
|
+
props: {
|
|
47
|
+
backgroundColor: "default",
|
|
48
|
+
textColor: "default",
|
|
49
|
+
textAlignment: "left",
|
|
68
50
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
textColor: "default",
|
|
75
|
-
textAlignment: "left",
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: "text",
|
|
54
|
+
text: "Bullet List Item",
|
|
55
|
+
styles: {},
|
|
76
56
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
57
|
+
],
|
|
58
|
+
children: [],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: UniqueID.options.generateID(),
|
|
62
|
+
type: "numberedListItem",
|
|
63
|
+
props: {
|
|
64
|
+
backgroundColor: "default",
|
|
65
|
+
textColor: "default",
|
|
66
|
+
textAlignment: "left",
|
|
85
67
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
textColor: "default",
|
|
92
|
-
textAlignment: "left",
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: "Numbered List Item",
|
|
72
|
+
styles: {},
|
|
93
73
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
74
|
+
],
|
|
75
|
+
children: [],
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const getNestedBlocks = (): Block[] => [
|
|
80
|
+
{
|
|
81
|
+
id: UniqueID.options.generateID(),
|
|
82
|
+
type: "heading",
|
|
83
|
+
props: {
|
|
84
|
+
backgroundColor: "default",
|
|
85
|
+
textColor: "default",
|
|
86
|
+
textAlignment: "left",
|
|
87
|
+
level: "1",
|
|
102
88
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
* Bullet List Item
|
|
110
|
-
|
|
111
|
-
1. Numbered List Item
|
|
112
|
-
`;
|
|
113
|
-
|
|
114
|
-
nestedBlocks = [
|
|
115
|
-
{
|
|
116
|
-
id: UniqueID.options.generateID(),
|
|
117
|
-
type: "heading",
|
|
118
|
-
props: {
|
|
119
|
-
backgroundColor: "default",
|
|
120
|
-
textColor: "default",
|
|
121
|
-
textAlignment: "left",
|
|
122
|
-
level: "1",
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: "Heading",
|
|
93
|
+
styles: {},
|
|
123
94
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
95
|
+
],
|
|
96
|
+
children: [
|
|
97
|
+
{
|
|
98
|
+
id: UniqueID.options.generateID(),
|
|
99
|
+
type: "paragraph",
|
|
100
|
+
props: {
|
|
101
|
+
backgroundColor: "default",
|
|
102
|
+
textColor: "default",
|
|
103
|
+
textAlignment: "left",
|
|
129
104
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
props: {
|
|
136
|
-
backgroundColor: "default",
|
|
137
|
-
textColor: "default",
|
|
138
|
-
textAlignment: "left",
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: "text",
|
|
108
|
+
text: "Paragraph",
|
|
109
|
+
styles: {},
|
|
139
110
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
111
|
+
],
|
|
112
|
+
children: [
|
|
113
|
+
{
|
|
114
|
+
id: UniqueID.options.generateID(),
|
|
115
|
+
type: "bulletListItem",
|
|
116
|
+
props: {
|
|
117
|
+
backgroundColor: "default",
|
|
118
|
+
textColor: "default",
|
|
119
|
+
textAlignment: "left",
|
|
145
120
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
props: {
|
|
152
|
-
backgroundColor: "default",
|
|
153
|
-
textColor: "default",
|
|
154
|
-
textAlignment: "left",
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: "Bullet List Item",
|
|
125
|
+
styles: {},
|
|
155
126
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
127
|
+
],
|
|
128
|
+
children: [
|
|
129
|
+
{
|
|
130
|
+
id: UniqueID.options.generateID(),
|
|
131
|
+
type: "numberedListItem",
|
|
132
|
+
props: {
|
|
133
|
+
backgroundColor: "default",
|
|
134
|
+
textColor: "default",
|
|
135
|
+
textAlignment: "left",
|
|
161
136
|
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
props: {
|
|
168
|
-
backgroundColor: "default",
|
|
169
|
-
textColor: "default",
|
|
170
|
-
textAlignment: "left",
|
|
137
|
+
content: [
|
|
138
|
+
{
|
|
139
|
+
type: "text",
|
|
140
|
+
text: "Numbered List Item",
|
|
141
|
+
styles: {},
|
|
171
142
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
styles: {},
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
children: [],
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
},
|
|
187
|
-
];
|
|
188
|
-
// nestedHTML = `<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ul>`;
|
|
189
|
-
// nestedMarkdown = `# Heading
|
|
190
|
-
//
|
|
191
|
-
// Paragraph
|
|
192
|
-
//
|
|
193
|
-
// * Bullet List Item
|
|
194
|
-
//
|
|
195
|
-
// 1. Numbered List Item
|
|
196
|
-
// `;
|
|
197
|
-
|
|
198
|
-
styledBlocks = [
|
|
199
|
-
{
|
|
200
|
-
id: UniqueID.options.generateID(),
|
|
201
|
-
type: "paragraph",
|
|
202
|
-
props: {
|
|
203
|
-
backgroundColor: "default",
|
|
204
|
-
textColor: "default",
|
|
205
|
-
textAlignment: "left",
|
|
206
|
-
},
|
|
207
|
-
content: [
|
|
208
|
-
{
|
|
209
|
-
type: "text",
|
|
210
|
-
text: "Bold",
|
|
211
|
-
styles: {
|
|
212
|
-
bold: true,
|
|
143
|
+
],
|
|
144
|
+
children: [],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
213
147
|
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
const getStyledBlocks = (): Block[] => [
|
|
155
|
+
{
|
|
156
|
+
id: UniqueID.options.generateID(),
|
|
157
|
+
type: "paragraph",
|
|
158
|
+
props: {
|
|
159
|
+
backgroundColor: "default",
|
|
160
|
+
textColor: "default",
|
|
161
|
+
textAlignment: "left",
|
|
162
|
+
},
|
|
163
|
+
content: [
|
|
164
|
+
{
|
|
165
|
+
type: "text",
|
|
166
|
+
text: "Bold",
|
|
167
|
+
styles: {
|
|
168
|
+
bold: true,
|
|
214
169
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: "text",
|
|
173
|
+
text: "Italic",
|
|
174
|
+
styles: {
|
|
175
|
+
italic: true,
|
|
221
176
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
type: "text",
|
|
180
|
+
text: "Underline",
|
|
181
|
+
styles: {
|
|
182
|
+
underline: true,
|
|
228
183
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: "text",
|
|
187
|
+
text: "Strikethrough",
|
|
188
|
+
styles: {
|
|
189
|
+
strike: true,
|
|
235
190
|
},
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: "text",
|
|
194
|
+
text: "TextColor",
|
|
195
|
+
styles: {
|
|
196
|
+
textColor: "red",
|
|
242
197
|
},
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: "text",
|
|
201
|
+
text: "BackgroundColor",
|
|
202
|
+
styles: {
|
|
203
|
+
backgroundColor: "red",
|
|
249
204
|
},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
type: "text",
|
|
208
|
+
text: "Multiple",
|
|
209
|
+
styles: {
|
|
210
|
+
bold: true,
|
|
211
|
+
italic: true,
|
|
257
212
|
},
|
|
258
|
-
|
|
259
|
-
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
children: [],
|
|
216
|
+
},
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
const getComplexBlocks = (): Block[] => [
|
|
220
|
+
{
|
|
221
|
+
id: UniqueID.options.generateID(),
|
|
222
|
+
type: "heading",
|
|
223
|
+
props: {
|
|
224
|
+
backgroundColor: "red",
|
|
225
|
+
textColor: "yellow",
|
|
226
|
+
textAlignment: "right",
|
|
227
|
+
level: "1",
|
|
260
228
|
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
{
|
|
267
|
-
id: UniqueID.options.generateID(),
|
|
268
|
-
type: "heading",
|
|
269
|
-
props: {
|
|
270
|
-
backgroundColor: "red",
|
|
271
|
-
textColor: "yellow",
|
|
272
|
-
textAlignment: "right",
|
|
273
|
-
level: "1",
|
|
229
|
+
content: [
|
|
230
|
+
{
|
|
231
|
+
type: "text",
|
|
232
|
+
text: "Heading 1",
|
|
233
|
+
styles: {},
|
|
274
234
|
},
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
235
|
+
],
|
|
236
|
+
children: [
|
|
237
|
+
{
|
|
238
|
+
id: UniqueID.options.generateID(),
|
|
239
|
+
type: "heading",
|
|
240
|
+
props: {
|
|
241
|
+
backgroundColor: "orange",
|
|
242
|
+
textColor: "orange",
|
|
243
|
+
textAlignment: "center",
|
|
244
|
+
level: "2",
|
|
280
245
|
},
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
props: {
|
|
287
|
-
backgroundColor: "orange",
|
|
288
|
-
textColor: "orange",
|
|
289
|
-
textAlignment: "center",
|
|
290
|
-
level: "2",
|
|
246
|
+
content: [
|
|
247
|
+
{
|
|
248
|
+
type: "text",
|
|
249
|
+
text: "Heading 2",
|
|
250
|
+
styles: {},
|
|
291
251
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
252
|
+
],
|
|
253
|
+
children: [
|
|
254
|
+
{
|
|
255
|
+
id: UniqueID.options.generateID(),
|
|
256
|
+
type: "heading",
|
|
257
|
+
props: {
|
|
258
|
+
backgroundColor: "yellow",
|
|
259
|
+
textColor: "red",
|
|
260
|
+
textAlignment: "left",
|
|
261
|
+
level: "3",
|
|
297
262
|
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
props: {
|
|
304
|
-
backgroundColor: "yellow",
|
|
305
|
-
textColor: "red",
|
|
306
|
-
textAlignment: "left",
|
|
307
|
-
level: "3",
|
|
263
|
+
content: [
|
|
264
|
+
{
|
|
265
|
+
type: "text",
|
|
266
|
+
text: "Heading 3",
|
|
267
|
+
styles: {},
|
|
308
268
|
},
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
type: "text",
|
|
312
|
-
text: "Heading 3",
|
|
313
|
-
styles: {},
|
|
314
|
-
},
|
|
315
|
-
],
|
|
316
|
-
children: [],
|
|
317
|
-
},
|
|
318
|
-
],
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
id: UniqueID.options.generateID(),
|
|
324
|
-
type: "paragraph",
|
|
325
|
-
props: {
|
|
326
|
-
backgroundColor: "default",
|
|
327
|
-
textColor: "default",
|
|
328
|
-
textAlignment: "left",
|
|
329
|
-
},
|
|
330
|
-
content: [
|
|
331
|
-
{
|
|
332
|
-
type: "text",
|
|
333
|
-
text: "Paragraph",
|
|
334
|
-
styles: {
|
|
335
|
-
textColor: "purple",
|
|
336
|
-
backgroundColor: "green",
|
|
269
|
+
],
|
|
270
|
+
children: [],
|
|
337
271
|
},
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: UniqueID.options.generateID(),
|
|
278
|
+
type: "paragraph",
|
|
279
|
+
props: {
|
|
280
|
+
backgroundColor: "default",
|
|
281
|
+
textColor: "default",
|
|
282
|
+
textAlignment: "left",
|
|
283
|
+
},
|
|
284
|
+
content: [
|
|
285
|
+
{
|
|
286
|
+
type: "text",
|
|
287
|
+
text: "Paragraph",
|
|
288
|
+
styles: {
|
|
289
|
+
textColor: "purple",
|
|
290
|
+
backgroundColor: "green",
|
|
338
291
|
},
|
|
339
|
-
|
|
340
|
-
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
children: [],
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: UniqueID.options.generateID(),
|
|
298
|
+
type: "paragraph",
|
|
299
|
+
props: {
|
|
300
|
+
backgroundColor: "default",
|
|
301
|
+
textColor: "default",
|
|
302
|
+
textAlignment: "left",
|
|
341
303
|
},
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
textColor: "default",
|
|
348
|
-
textAlignment: "left",
|
|
304
|
+
content: [
|
|
305
|
+
{
|
|
306
|
+
type: "text",
|
|
307
|
+
text: "P",
|
|
308
|
+
styles: {},
|
|
349
309
|
},
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
type: "text",
|
|
358
|
-
text: "ara",
|
|
359
|
-
styles: {
|
|
360
|
-
bold: true,
|
|
361
|
-
},
|
|
310
|
+
{
|
|
311
|
+
type: "text",
|
|
312
|
+
text: "ara",
|
|
313
|
+
styles: {
|
|
314
|
+
bold: true,
|
|
362
315
|
},
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
type: "text",
|
|
372
|
-
text: "h",
|
|
373
|
-
styles: {},
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
type: "text",
|
|
319
|
+
text: "grap",
|
|
320
|
+
styles: {
|
|
321
|
+
italic: true,
|
|
374
322
|
},
|
|
375
|
-
|
|
376
|
-
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
type: "text",
|
|
326
|
+
text: "h",
|
|
327
|
+
styles: {},
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
children: [],
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
id: UniqueID.options.generateID(),
|
|
334
|
+
type: "paragraph",
|
|
335
|
+
props: {
|
|
336
|
+
backgroundColor: "default",
|
|
337
|
+
textColor: "default",
|
|
338
|
+
textAlignment: "left",
|
|
377
339
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
textColor: "default",
|
|
384
|
-
textAlignment: "left",
|
|
340
|
+
content: [
|
|
341
|
+
{
|
|
342
|
+
type: "text",
|
|
343
|
+
text: "P",
|
|
344
|
+
styles: {},
|
|
385
345
|
},
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
type: "text",
|
|
394
|
-
text: "ara",
|
|
395
|
-
styles: {
|
|
396
|
-
underline: true,
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
type: "text",
|
|
401
|
-
text: "grap",
|
|
402
|
-
styles: {
|
|
403
|
-
strike: true,
|
|
404
|
-
},
|
|
346
|
+
{
|
|
347
|
+
type: "text",
|
|
348
|
+
text: "ara",
|
|
349
|
+
styles: {
|
|
350
|
+
underline: true,
|
|
405
351
|
},
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
type: "text",
|
|
355
|
+
text: "grap",
|
|
356
|
+
styles: {
|
|
357
|
+
strike: true,
|
|
410
358
|
},
|
|
411
|
-
|
|
412
|
-
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
type: "text",
|
|
362
|
+
text: "h",
|
|
363
|
+
styles: {},
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
children: [],
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: UniqueID.options.generateID(),
|
|
370
|
+
type: "bulletListItem",
|
|
371
|
+
props: {
|
|
372
|
+
backgroundColor: "default",
|
|
373
|
+
textColor: "default",
|
|
374
|
+
textAlignment: "left",
|
|
413
375
|
},
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
textColor: "default",
|
|
420
|
-
textAlignment: "left",
|
|
376
|
+
content: [
|
|
377
|
+
{
|
|
378
|
+
type: "text",
|
|
379
|
+
text: "Bullet List Item",
|
|
380
|
+
styles: {},
|
|
421
381
|
},
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
382
|
+
],
|
|
383
|
+
children: [],
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
id: UniqueID.options.generateID(),
|
|
387
|
+
type: "bulletListItem",
|
|
388
|
+
props: {
|
|
389
|
+
backgroundColor: "default",
|
|
390
|
+
textColor: "default",
|
|
391
|
+
textAlignment: "left",
|
|
430
392
|
},
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
textColor: "default",
|
|
437
|
-
textAlignment: "left",
|
|
393
|
+
content: [
|
|
394
|
+
{
|
|
395
|
+
type: "text",
|
|
396
|
+
text: "Bullet List Item",
|
|
397
|
+
styles: {},
|
|
438
398
|
},
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
399
|
+
],
|
|
400
|
+
children: [
|
|
401
|
+
{
|
|
402
|
+
id: UniqueID.options.generateID(),
|
|
403
|
+
type: "bulletListItem",
|
|
404
|
+
props: {
|
|
405
|
+
backgroundColor: "default",
|
|
406
|
+
textColor: "default",
|
|
407
|
+
textAlignment: "left",
|
|
444
408
|
},
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
props: {
|
|
451
|
-
backgroundColor: "default",
|
|
452
|
-
textColor: "default",
|
|
453
|
-
textAlignment: "left",
|
|
409
|
+
content: [
|
|
410
|
+
{
|
|
411
|
+
type: "text",
|
|
412
|
+
text: "Bullet List Item",
|
|
413
|
+
styles: {},
|
|
454
414
|
},
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
415
|
+
],
|
|
416
|
+
children: [
|
|
417
|
+
{
|
|
418
|
+
id: UniqueID.options.generateID(),
|
|
419
|
+
type: "bulletListItem",
|
|
420
|
+
props: {
|
|
421
|
+
backgroundColor: "default",
|
|
422
|
+
textColor: "default",
|
|
423
|
+
textAlignment: "left",
|
|
460
424
|
},
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
props: {
|
|
467
|
-
backgroundColor: "default",
|
|
468
|
-
textColor: "default",
|
|
469
|
-
textAlignment: "left",
|
|
425
|
+
content: [
|
|
426
|
+
{
|
|
427
|
+
type: "text",
|
|
428
|
+
text: "Bullet List Item",
|
|
429
|
+
styles: {},
|
|
470
430
|
},
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
431
|
+
],
|
|
432
|
+
children: [],
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
id: UniqueID.options.generateID(),
|
|
436
|
+
type: "paragraph",
|
|
437
|
+
props: {
|
|
438
|
+
backgroundColor: "default",
|
|
439
|
+
textColor: "default",
|
|
440
|
+
textAlignment: "left",
|
|
479
441
|
},
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
textColor: "default",
|
|
486
|
-
textAlignment: "left",
|
|
442
|
+
content: [
|
|
443
|
+
{
|
|
444
|
+
type: "text",
|
|
445
|
+
text: "Paragraph",
|
|
446
|
+
styles: {},
|
|
487
447
|
},
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
448
|
+
],
|
|
449
|
+
children: [],
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
id: UniqueID.options.generateID(),
|
|
453
|
+
type: "numberedListItem",
|
|
454
|
+
props: {
|
|
455
|
+
backgroundColor: "default",
|
|
456
|
+
textColor: "default",
|
|
457
|
+
textAlignment: "left",
|
|
496
458
|
},
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
textColor: "default",
|
|
503
|
-
textAlignment: "left",
|
|
459
|
+
content: [
|
|
460
|
+
{
|
|
461
|
+
type: "text",
|
|
462
|
+
text: "Numbered List Item",
|
|
463
|
+
styles: {},
|
|
504
464
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
465
|
+
],
|
|
466
|
+
children: [],
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
id: UniqueID.options.generateID(),
|
|
470
|
+
type: "numberedListItem",
|
|
471
|
+
props: {
|
|
472
|
+
backgroundColor: "default",
|
|
473
|
+
textColor: "default",
|
|
474
|
+
textAlignment: "left",
|
|
513
475
|
},
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
textColor: "default",
|
|
520
|
-
textAlignment: "left",
|
|
476
|
+
content: [
|
|
477
|
+
{
|
|
478
|
+
type: "text",
|
|
479
|
+
text: "Numbered List Item",
|
|
480
|
+
styles: {},
|
|
521
481
|
},
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
482
|
+
],
|
|
483
|
+
children: [],
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: UniqueID.options.generateID(),
|
|
487
|
+
type: "numberedListItem",
|
|
488
|
+
props: {
|
|
489
|
+
backgroundColor: "default",
|
|
490
|
+
textColor: "default",
|
|
491
|
+
textAlignment: "left",
|
|
530
492
|
},
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
textColor: "default",
|
|
537
|
-
textAlignment: "left",
|
|
493
|
+
content: [
|
|
494
|
+
{
|
|
495
|
+
type: "text",
|
|
496
|
+
text: "Numbered List Item",
|
|
497
|
+
styles: {},
|
|
538
498
|
},
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
499
|
+
],
|
|
500
|
+
children: [
|
|
501
|
+
{
|
|
502
|
+
id: UniqueID.options.generateID(),
|
|
503
|
+
type: "numberedListItem",
|
|
504
|
+
props: {
|
|
505
|
+
backgroundColor: "default",
|
|
506
|
+
textColor: "default",
|
|
507
|
+
textAlignment: "left",
|
|
544
508
|
},
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
props: {
|
|
551
|
-
backgroundColor: "default",
|
|
552
|
-
textColor: "default",
|
|
553
|
-
textAlignment: "left",
|
|
509
|
+
content: [
|
|
510
|
+
{
|
|
511
|
+
type: "text",
|
|
512
|
+
text: "Numbered List Item",
|
|
513
|
+
styles: {},
|
|
554
514
|
},
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
type: "text",
|
|
558
|
-
text: "Numbered List Item",
|
|
559
|
-
styles: {},
|
|
560
|
-
},
|
|
561
|
-
],
|
|
562
|
-
children: [],
|
|
563
|
-
},
|
|
564
|
-
],
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
id: UniqueID.options.generateID(),
|
|
568
|
-
type: "bulletListItem",
|
|
569
|
-
props: {
|
|
570
|
-
backgroundColor: "default",
|
|
571
|
-
textColor: "default",
|
|
572
|
-
textAlignment: "left",
|
|
515
|
+
],
|
|
516
|
+
children: [],
|
|
573
517
|
},
|
|
574
|
-
|
|
575
|
-
{
|
|
576
|
-
type: "text",
|
|
577
|
-
text: "Bullet List Item",
|
|
578
|
-
styles: {},
|
|
579
|
-
},
|
|
580
|
-
],
|
|
581
|
-
children: [],
|
|
582
|
-
},
|
|
583
|
-
],
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
id: UniqueID.options.generateID(),
|
|
587
|
-
type: "bulletListItem",
|
|
588
|
-
props: {
|
|
589
|
-
backgroundColor: "default",
|
|
590
|
-
textColor: "default",
|
|
591
|
-
textAlignment: "left",
|
|
518
|
+
],
|
|
592
519
|
},
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
520
|
+
{
|
|
521
|
+
id: UniqueID.options.generateID(),
|
|
522
|
+
type: "bulletListItem",
|
|
523
|
+
props: {
|
|
524
|
+
backgroundColor: "default",
|
|
525
|
+
textColor: "default",
|
|
526
|
+
textAlignment: "left",
|
|
598
527
|
},
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
textColor: "default",
|
|
610
|
-
textAlignment: "left",
|
|
528
|
+
content: [
|
|
529
|
+
{
|
|
530
|
+
type: "text",
|
|
531
|
+
text: "Bullet List Item",
|
|
532
|
+
styles: {},
|
|
533
|
+
},
|
|
534
|
+
],
|
|
535
|
+
children: [],
|
|
536
|
+
},
|
|
537
|
+
],
|
|
611
538
|
},
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
539
|
+
{
|
|
540
|
+
id: UniqueID.options.generateID(),
|
|
541
|
+
type: "bulletListItem",
|
|
542
|
+
props: {
|
|
543
|
+
backgroundColor: "default",
|
|
544
|
+
textColor: "default",
|
|
545
|
+
textAlignment: "left",
|
|
617
546
|
},
|
|
618
|
-
|
|
619
|
-
|
|
547
|
+
content: [
|
|
548
|
+
{
|
|
549
|
+
type: "text",
|
|
550
|
+
text: "Bullet List Item",
|
|
551
|
+
styles: {},
|
|
552
|
+
},
|
|
553
|
+
],
|
|
554
|
+
children: [],
|
|
555
|
+
},
|
|
556
|
+
],
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
id: UniqueID.options.generateID(),
|
|
560
|
+
type: "bulletListItem",
|
|
561
|
+
props: {
|
|
562
|
+
backgroundColor: "default",
|
|
563
|
+
textColor: "default",
|
|
564
|
+
textAlignment: "left",
|
|
620
565
|
},
|
|
621
|
-
|
|
566
|
+
content: [
|
|
567
|
+
{
|
|
568
|
+
type: "text",
|
|
569
|
+
text: "Bullet List Item",
|
|
570
|
+
styles: {},
|
|
571
|
+
},
|
|
572
|
+
],
|
|
573
|
+
children: [],
|
|
574
|
+
},
|
|
575
|
+
];
|
|
622
576
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
//
|
|
632
|
-
// P**ara***grap*h
|
|
633
|
-
//
|
|
634
|
-
// P*ara*~~grap~~h
|
|
635
|
-
//
|
|
636
|
-
// * Bullet List Item
|
|
637
|
-
//
|
|
638
|
-
// * Bullet List Item
|
|
639
|
-
//
|
|
640
|
-
// * Bullet List Item
|
|
641
|
-
//
|
|
642
|
-
// * Bullet List Item
|
|
643
|
-
//
|
|
644
|
-
// Paragraph
|
|
645
|
-
//
|
|
646
|
-
// 1. Numbered List Item
|
|
647
|
-
//
|
|
648
|
-
// 2. Numbered List Item
|
|
649
|
-
//
|
|
650
|
-
// 3. Numbered List Item
|
|
651
|
-
//
|
|
652
|
-
// 1. Numbered List Item
|
|
653
|
-
//
|
|
654
|
-
// * Bullet List Item
|
|
655
|
-
//
|
|
656
|
-
// * Bullet List Item
|
|
657
|
-
//
|
|
658
|
-
// * Bullet List Item
|
|
659
|
-
// `;
|
|
577
|
+
function removeInlineContentClass(html: string) {
|
|
578
|
+
return html.replace(/ class="_inlineContent_([a-zA-Z0-9_-])+"/g, "");
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
beforeEach(() => {
|
|
582
|
+
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
|
|
583
|
+
|
|
584
|
+
editor = new BlockNoteEditor();
|
|
660
585
|
});
|
|
661
586
|
|
|
662
587
|
afterEach(() => {
|
|
@@ -668,25 +593,34 @@ afterEach(() => {
|
|
|
668
593
|
|
|
669
594
|
describe("Non-Nested Block/HTML/Markdown Conversions", () => {
|
|
670
595
|
it("Convert non-nested blocks to HTML", async () => {
|
|
671
|
-
const output = await editor.blocksToHTML(
|
|
596
|
+
const output = await editor.blocksToHTML(getNonNestedBlocks());
|
|
672
597
|
|
|
673
598
|
expect(removeInlineContentClass(output)).toMatchSnapshot();
|
|
674
599
|
});
|
|
675
600
|
|
|
676
601
|
it("Convert non-nested blocks to Markdown", async () => {
|
|
677
|
-
const output = await editor.blocksToMarkdown(
|
|
602
|
+
const output = await editor.blocksToMarkdown(getNonNestedBlocks());
|
|
678
603
|
|
|
679
604
|
expect(output).toMatchSnapshot();
|
|
680
605
|
});
|
|
681
606
|
|
|
682
607
|
it("Convert non-nested HTML to blocks", async () => {
|
|
683
|
-
const
|
|
608
|
+
const html = `<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p></li></ul><ol><li><p>Numbered List Item</p></li></ol>`;
|
|
609
|
+
const output = await editor.HTMLToBlocks(html);
|
|
684
610
|
|
|
685
611
|
expect(output).toMatchSnapshot();
|
|
686
612
|
});
|
|
687
613
|
|
|
688
614
|
it("Convert non-nested Markdown to blocks", async () => {
|
|
689
|
-
const
|
|
615
|
+
const markdown = `# Heading
|
|
616
|
+
|
|
617
|
+
Paragraph
|
|
618
|
+
|
|
619
|
+
* Bullet List Item
|
|
620
|
+
|
|
621
|
+
1. Numbered List Item
|
|
622
|
+
`;
|
|
623
|
+
const output = await editor.markdownToBlocks(markdown);
|
|
690
624
|
|
|
691
625
|
expect(output).toMatchSnapshot();
|
|
692
626
|
});
|
|
@@ -694,25 +628,34 @@ describe("Non-Nested Block/HTML/Markdown Conversions", () => {
|
|
|
694
628
|
|
|
695
629
|
describe("Nested Block/HTML/Markdown Conversions", () => {
|
|
696
630
|
it("Convert nested blocks to HTML", async () => {
|
|
697
|
-
const output = await editor.blocksToHTML(
|
|
631
|
+
const output = await editor.blocksToHTML(getNestedBlocks());
|
|
698
632
|
|
|
699
633
|
expect(removeInlineContentClass(output)).toMatchSnapshot();
|
|
700
634
|
});
|
|
701
635
|
|
|
702
636
|
it("Convert nested blocks to Markdown", async () => {
|
|
703
|
-
const output = await editor.blocksToMarkdown(
|
|
637
|
+
const output = await editor.blocksToMarkdown(getNestedBlocks());
|
|
704
638
|
|
|
705
639
|
expect(output).toMatchSnapshot();
|
|
706
640
|
});
|
|
707
641
|
// // Failing due to nested block parsing bug.
|
|
708
642
|
// it("Convert nested HTML to blocks", async () => {
|
|
709
|
-
// const
|
|
643
|
+
// const html = `<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ul>`;
|
|
644
|
+
// const output = await editor.HTMLToBlocks(html);
|
|
710
645
|
//
|
|
711
646
|
// expect(output).toMatchSnapshot();
|
|
712
647
|
// });
|
|
713
648
|
// // Failing due to nested block parsing bug.
|
|
714
649
|
// it("Convert nested Markdown to blocks", async () => {
|
|
715
|
-
// const
|
|
650
|
+
// const markdown = `# Heading
|
|
651
|
+
//
|
|
652
|
+
// Paragraph
|
|
653
|
+
//
|
|
654
|
+
// * Bullet List Item
|
|
655
|
+
//
|
|
656
|
+
// 1. Numbered List Item
|
|
657
|
+
// `;
|
|
658
|
+
// const output = await editor.markdownToBlocks(markdown);
|
|
716
659
|
//
|
|
717
660
|
// expect(output).toMatchSnapshot();
|
|
718
661
|
// });
|
|
@@ -720,25 +663,27 @@ describe("Nested Block/HTML/Markdown Conversions", () => {
|
|
|
720
663
|
|
|
721
664
|
describe("Styled Block/HTML/Markdown Conversions", () => {
|
|
722
665
|
it("Convert styled blocks to HTML", async () => {
|
|
723
|
-
const output = await editor.blocksToHTML(
|
|
666
|
+
const output = await editor.blocksToHTML(getStyledBlocks());
|
|
724
667
|
|
|
725
668
|
expect(removeInlineContentClass(output)).toMatchSnapshot();
|
|
726
669
|
});
|
|
727
670
|
|
|
728
671
|
it("Convert styled blocks to Markdown", async () => {
|
|
729
|
-
const output = await editor.blocksToMarkdown(
|
|
672
|
+
const output = await editor.blocksToMarkdown(getStyledBlocks());
|
|
730
673
|
|
|
731
674
|
expect(output).toMatchSnapshot();
|
|
732
675
|
});
|
|
733
676
|
|
|
734
677
|
it("Convert styled HTML to blocks", async () => {
|
|
735
|
-
const
|
|
678
|
+
const html = `<p><strong>Bold</strong><em>Italic</em><u>Underline</u><s>Strikethrough</s><span data-text-color="red">TextColor</span><span data-background-color="red">BackgroundColor</span><strong><em>Multiple</em></strong></p>`;
|
|
679
|
+
const output = await editor.HTMLToBlocks(html);
|
|
736
680
|
|
|
737
681
|
expect(output).toMatchSnapshot();
|
|
738
682
|
});
|
|
739
683
|
|
|
740
684
|
it("Convert styled Markdown to blocks", async () => {
|
|
741
|
-
const
|
|
685
|
+
const markdown = `**Bold***Italic*Underline~~Strikethrough~~TextColorBackgroundColor***Multiple***`;
|
|
686
|
+
const output = await editor.markdownToBlocks(markdown);
|
|
742
687
|
|
|
743
688
|
expect(output).toMatchSnapshot();
|
|
744
689
|
});
|
|
@@ -746,25 +691,62 @@ describe("Styled Block/HTML/Markdown Conversions", () => {
|
|
|
746
691
|
|
|
747
692
|
describe("Complex Block/HTML/Markdown Conversions", () => {
|
|
748
693
|
it("Convert complex blocks to HTML", async () => {
|
|
749
|
-
const output = await editor.blocksToHTML(
|
|
694
|
+
const output = await editor.blocksToHTML(getComplexBlocks());
|
|
750
695
|
|
|
751
696
|
expect(removeInlineContentClass(output)).toMatchSnapshot();
|
|
752
697
|
});
|
|
753
698
|
|
|
754
699
|
it("Convert complex blocks to Markdown", async () => {
|
|
755
|
-
const output = await editor.blocksToMarkdown(
|
|
700
|
+
const output = await editor.blocksToMarkdown(getComplexBlocks());
|
|
756
701
|
|
|
757
702
|
expect(output).toMatchSnapshot();
|
|
758
703
|
});
|
|
759
704
|
// // Failing due to nested block parsing bug.
|
|
760
705
|
// it("Convert complex HTML to blocks", async () => {
|
|
761
|
-
// const
|
|
706
|
+
// const html = `<h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><p><span data-text-color="purple"><span data-background-color="green">Paragraph</span></span></p><p>P<strong>ara</strong><em>grap</em>h</p><p>P<u>ara</u><s>grap</s>h</p><ul><li><p>Bullet List Item</p></li><li><p>Bullet List Item</p><ul><li><p>Bullet List Item</p><ul><li><p>Bullet List Item</p></li></ul><p>Paragraph</p><ol><li><p>Numbered List Item</p></li><li><p>Numbered List Item</p></li><li><p>Numbered List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ol><ul><li><p>Bullet List Item</p></li></ul></li><li><p>Bullet List Item</p></li></ul></li><li><p>Bullet List Item</p></li></ul>`;
|
|
707
|
+
// const output = await editor.HTMLToBlocks(html);
|
|
762
708
|
//
|
|
763
709
|
// expect(output).toMatchSnapshot();
|
|
764
710
|
// });
|
|
765
711
|
// // Failing due to nested block parsing bug.
|
|
766
712
|
// it("Convert complex Markdown to blocks", async () => {
|
|
767
|
-
// const
|
|
713
|
+
// const markdown = `# Heading 1
|
|
714
|
+
//
|
|
715
|
+
// ## Heading 2
|
|
716
|
+
//
|
|
717
|
+
// ### Heading 3
|
|
718
|
+
//
|
|
719
|
+
// Paragraph
|
|
720
|
+
//
|
|
721
|
+
// P**ara***grap*h
|
|
722
|
+
//
|
|
723
|
+
// P*ara*~~grap~~h
|
|
724
|
+
//
|
|
725
|
+
// * Bullet List Item
|
|
726
|
+
//
|
|
727
|
+
// * Bullet List Item
|
|
728
|
+
//
|
|
729
|
+
// * Bullet List Item
|
|
730
|
+
//
|
|
731
|
+
// * Bullet List Item
|
|
732
|
+
//
|
|
733
|
+
// Paragraph
|
|
734
|
+
//
|
|
735
|
+
// 1. Numbered List Item
|
|
736
|
+
//
|
|
737
|
+
// 2. Numbered List Item
|
|
738
|
+
//
|
|
739
|
+
// 3. Numbered List Item
|
|
740
|
+
//
|
|
741
|
+
// 1. Numbered List Item
|
|
742
|
+
//
|
|
743
|
+
// * Bullet List Item
|
|
744
|
+
//
|
|
745
|
+
// * Bullet List Item
|
|
746
|
+
//
|
|
747
|
+
// * Bullet List Item
|
|
748
|
+
// `;
|
|
749
|
+
// const output = await editor.markdownToBlocks(markdown);
|
|
768
750
|
//
|
|
769
751
|
// expect(output).toMatchSnapshot();
|
|
770
752
|
// });
|