@blocknote/core 0.13.4 → 0.14.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/dist/blocknote.js +526 -477
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -5
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +29 -29
- package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +98 -0
- package/src/api/blockManipulation/blockManipulation.test.ts +86 -7
- package/src/api/exporters/html/__snapshots__/customBlock/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/customBlock/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/internal.html +1 -0
- package/src/api/exporters/markdown/__snapshots__/customBlock/basic/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/customParagraph/lineBreaks/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/lineBreaks/markdown.md +2 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +566 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +2 -0
- package/src/api/nodeConversions/nodeConversions.ts +2 -4
- package/src/api/parsers/html/__snapshots__/paste/parse-image-in-paragraph.json +16 -0
- package/src/api/parsers/html/parseHTML.test.ts +8 -0
- package/src/api/parsers/pasteExtension.ts +5 -0
- package/src/api/testUtil/cases/customBlocks.ts +9 -0
- package/src/api/testUtil/cases/defaultSchema.ts +9 -0
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +6 -6
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +7 -2
- package/src/blocks/TableBlockContent/TableBlockContent.ts +23 -1
- package/src/editor/Block.css +2 -3
- package/src/editor/BlockNoteEditor.ts +7 -6
- package/src/editor/BlockNoteExtensions.ts +10 -1
- package/src/editor/BlockNoteTipTapEditor.ts +1 -0
- package/src/extensions/FilePanel/FilePanelPlugin.ts +16 -12
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +12 -15
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +6 -2
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +5 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +157 -118
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +5 -2
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +7 -4
- package/src/i18n/locales/pt.ts +1 -1
- package/src/i18n/locales/zh.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +11 -7
- package/src/schema/blocks/createSpec.ts +2 -2
- package/src/schema/inlineContent/createSpec.ts +2 -2
- package/types/src/editor/BlockNoteEditor.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +5 -5
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +0 -1
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +9 -8
- package/types/src/schema/blocks/createSpec.d.ts +2 -2
- package/types/src/schema/inlineContent/createSpec.d.ts +2 -2
|
@@ -1,5 +1,539 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/basic to/from prosemirror 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"attrs": {
|
|
6
|
+
"backgroundColor": "default",
|
|
7
|
+
"id": "1",
|
|
8
|
+
"textColor": "default",
|
|
9
|
+
},
|
|
10
|
+
"content": [
|
|
11
|
+
{
|
|
12
|
+
"attrs": {
|
|
13
|
+
"textAlignment": "left",
|
|
14
|
+
},
|
|
15
|
+
"content": [
|
|
16
|
+
{
|
|
17
|
+
"text": "Custom Paragraph",
|
|
18
|
+
"type": "text",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
"type": "customParagraph",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
"type": "blockContainer",
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/lineBreaks to/from prosemirror 1`] = `
|
|
29
|
+
{
|
|
30
|
+
"attrs": {
|
|
31
|
+
"backgroundColor": "default",
|
|
32
|
+
"id": "1",
|
|
33
|
+
"textColor": "default",
|
|
34
|
+
},
|
|
35
|
+
"content": [
|
|
36
|
+
{
|
|
37
|
+
"attrs": {
|
|
38
|
+
"textAlignment": "left",
|
|
39
|
+
},
|
|
40
|
+
"content": [
|
|
41
|
+
{
|
|
42
|
+
"text": "Line 1",
|
|
43
|
+
"type": "text",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "hardBreak",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"text": "Line 2",
|
|
50
|
+
"type": "text",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
"type": "customParagraph",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
"type": "blockContainer",
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/nested to/from prosemirror 1`] = `
|
|
61
|
+
{
|
|
62
|
+
"attrs": {
|
|
63
|
+
"backgroundColor": "default",
|
|
64
|
+
"id": "1",
|
|
65
|
+
"textColor": "default",
|
|
66
|
+
},
|
|
67
|
+
"content": [
|
|
68
|
+
{
|
|
69
|
+
"attrs": {
|
|
70
|
+
"textAlignment": "left",
|
|
71
|
+
},
|
|
72
|
+
"content": [
|
|
73
|
+
{
|
|
74
|
+
"text": "Custom Paragraph",
|
|
75
|
+
"type": "text",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
"type": "customParagraph",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"content": [
|
|
82
|
+
{
|
|
83
|
+
"attrs": {
|
|
84
|
+
"backgroundColor": "default",
|
|
85
|
+
"id": "2",
|
|
86
|
+
"textColor": "default",
|
|
87
|
+
},
|
|
88
|
+
"content": [
|
|
89
|
+
{
|
|
90
|
+
"attrs": {
|
|
91
|
+
"textAlignment": "left",
|
|
92
|
+
},
|
|
93
|
+
"content": [
|
|
94
|
+
{
|
|
95
|
+
"text": "Nested Custom Paragraph 1",
|
|
96
|
+
"type": "text",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
"type": "customParagraph",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
"type": "blockContainer",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"attrs": {
|
|
106
|
+
"backgroundColor": "default",
|
|
107
|
+
"id": "3",
|
|
108
|
+
"textColor": "default",
|
|
109
|
+
},
|
|
110
|
+
"content": [
|
|
111
|
+
{
|
|
112
|
+
"attrs": {
|
|
113
|
+
"textAlignment": "left",
|
|
114
|
+
},
|
|
115
|
+
"content": [
|
|
116
|
+
{
|
|
117
|
+
"text": "Nested Custom Paragraph 2",
|
|
118
|
+
"type": "text",
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
"type": "customParagraph",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
"type": "blockContainer",
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
"type": "blockGroup",
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
"type": "blockContainer",
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/styled to/from prosemirror 1`] = `
|
|
135
|
+
{
|
|
136
|
+
"attrs": {
|
|
137
|
+
"backgroundColor": "pink",
|
|
138
|
+
"id": "1",
|
|
139
|
+
"textColor": "orange",
|
|
140
|
+
},
|
|
141
|
+
"content": [
|
|
142
|
+
{
|
|
143
|
+
"attrs": {
|
|
144
|
+
"textAlignment": "center",
|
|
145
|
+
},
|
|
146
|
+
"content": [
|
|
147
|
+
{
|
|
148
|
+
"text": "Plain ",
|
|
149
|
+
"type": "text",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"marks": [
|
|
153
|
+
{
|
|
154
|
+
"attrs": {
|
|
155
|
+
"stringValue": "red",
|
|
156
|
+
},
|
|
157
|
+
"type": "textColor",
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
"text": "Red Text ",
|
|
161
|
+
"type": "text",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"marks": [
|
|
165
|
+
{
|
|
166
|
+
"attrs": {
|
|
167
|
+
"stringValue": "blue",
|
|
168
|
+
},
|
|
169
|
+
"type": "backgroundColor",
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
"text": "Blue Background ",
|
|
173
|
+
"type": "text",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"marks": [
|
|
177
|
+
{
|
|
178
|
+
"attrs": {
|
|
179
|
+
"stringValue": "red",
|
|
180
|
+
},
|
|
181
|
+
"type": "textColor",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"attrs": {
|
|
185
|
+
"stringValue": "blue",
|
|
186
|
+
},
|
|
187
|
+
"type": "backgroundColor",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
"text": "Mixed Colors",
|
|
191
|
+
"type": "text",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
"type": "customParagraph",
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
"type": "blockContainer",
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleCustomParagraph/basic to/from prosemirror 1`] = `
|
|
202
|
+
{
|
|
203
|
+
"attrs": {
|
|
204
|
+
"backgroundColor": "default",
|
|
205
|
+
"id": "1",
|
|
206
|
+
"textColor": "default",
|
|
207
|
+
},
|
|
208
|
+
"content": [
|
|
209
|
+
{
|
|
210
|
+
"attrs": {
|
|
211
|
+
"textAlignment": "left",
|
|
212
|
+
},
|
|
213
|
+
"content": [
|
|
214
|
+
{
|
|
215
|
+
"text": "Custom Paragraph",
|
|
216
|
+
"type": "text",
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
"type": "simpleCustomParagraph",
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
"type": "blockContainer",
|
|
223
|
+
}
|
|
224
|
+
`;
|
|
225
|
+
|
|
226
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleCustomParagraph/nested to/from prosemirror 1`] = `
|
|
227
|
+
{
|
|
228
|
+
"attrs": {
|
|
229
|
+
"backgroundColor": "default",
|
|
230
|
+
"id": "1",
|
|
231
|
+
"textColor": "default",
|
|
232
|
+
},
|
|
233
|
+
"content": [
|
|
234
|
+
{
|
|
235
|
+
"attrs": {
|
|
236
|
+
"textAlignment": "left",
|
|
237
|
+
},
|
|
238
|
+
"content": [
|
|
239
|
+
{
|
|
240
|
+
"text": "Custom Paragraph",
|
|
241
|
+
"type": "text",
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
"type": "simpleCustomParagraph",
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"content": [
|
|
248
|
+
{
|
|
249
|
+
"attrs": {
|
|
250
|
+
"backgroundColor": "default",
|
|
251
|
+
"id": "2",
|
|
252
|
+
"textColor": "default",
|
|
253
|
+
},
|
|
254
|
+
"content": [
|
|
255
|
+
{
|
|
256
|
+
"attrs": {
|
|
257
|
+
"textAlignment": "left",
|
|
258
|
+
},
|
|
259
|
+
"content": [
|
|
260
|
+
{
|
|
261
|
+
"text": "Nested Custom Paragraph 1",
|
|
262
|
+
"type": "text",
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
"type": "simpleCustomParagraph",
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
"type": "blockContainer",
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"attrs": {
|
|
272
|
+
"backgroundColor": "default",
|
|
273
|
+
"id": "3",
|
|
274
|
+
"textColor": "default",
|
|
275
|
+
},
|
|
276
|
+
"content": [
|
|
277
|
+
{
|
|
278
|
+
"attrs": {
|
|
279
|
+
"textAlignment": "left",
|
|
280
|
+
},
|
|
281
|
+
"content": [
|
|
282
|
+
{
|
|
283
|
+
"text": "Nested Custom Paragraph 2",
|
|
284
|
+
"type": "text",
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
"type": "simpleCustomParagraph",
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
"type": "blockContainer",
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
"type": "blockGroup",
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
"type": "blockContainer",
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
|
|
300
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleCustomParagraph/styled to/from prosemirror 1`] = `
|
|
301
|
+
{
|
|
302
|
+
"attrs": {
|
|
303
|
+
"backgroundColor": "pink",
|
|
304
|
+
"id": "1",
|
|
305
|
+
"textColor": "orange",
|
|
306
|
+
},
|
|
307
|
+
"content": [
|
|
308
|
+
{
|
|
309
|
+
"attrs": {
|
|
310
|
+
"textAlignment": "center",
|
|
311
|
+
},
|
|
312
|
+
"content": [
|
|
313
|
+
{
|
|
314
|
+
"text": "Plain ",
|
|
315
|
+
"type": "text",
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"marks": [
|
|
319
|
+
{
|
|
320
|
+
"attrs": {
|
|
321
|
+
"stringValue": "red",
|
|
322
|
+
},
|
|
323
|
+
"type": "textColor",
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
"text": "Red Text ",
|
|
327
|
+
"type": "text",
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"marks": [
|
|
331
|
+
{
|
|
332
|
+
"attrs": {
|
|
333
|
+
"stringValue": "blue",
|
|
334
|
+
},
|
|
335
|
+
"type": "backgroundColor",
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
"text": "Blue Background ",
|
|
339
|
+
"type": "text",
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"marks": [
|
|
343
|
+
{
|
|
344
|
+
"attrs": {
|
|
345
|
+
"stringValue": "red",
|
|
346
|
+
},
|
|
347
|
+
"type": "textColor",
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"attrs": {
|
|
351
|
+
"stringValue": "blue",
|
|
352
|
+
},
|
|
353
|
+
"type": "backgroundColor",
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
"text": "Mixed Colors",
|
|
357
|
+
"type": "text",
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
"type": "simpleCustomParagraph",
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
"type": "blockContainer",
|
|
364
|
+
}
|
|
365
|
+
`;
|
|
366
|
+
|
|
367
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/basic to/from prosemirror 1`] = `
|
|
368
|
+
{
|
|
369
|
+
"attrs": {
|
|
370
|
+
"backgroundColor": "default",
|
|
371
|
+
"id": "1",
|
|
372
|
+
"textColor": "default",
|
|
373
|
+
},
|
|
374
|
+
"content": [
|
|
375
|
+
{
|
|
376
|
+
"attrs": {
|
|
377
|
+
"caption": "Caption",
|
|
378
|
+
"name": "example",
|
|
379
|
+
"previewWidth": 256,
|
|
380
|
+
"showPreview": true,
|
|
381
|
+
"textAlignment": "left",
|
|
382
|
+
"url": "exampleURL",
|
|
383
|
+
},
|
|
384
|
+
"type": "simpleImage",
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
"type": "blockContainer",
|
|
388
|
+
}
|
|
389
|
+
`;
|
|
390
|
+
|
|
391
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/button to/from prosemirror 1`] = `
|
|
392
|
+
{
|
|
393
|
+
"attrs": {
|
|
394
|
+
"backgroundColor": "default",
|
|
395
|
+
"id": "1",
|
|
396
|
+
"textColor": "default",
|
|
397
|
+
},
|
|
398
|
+
"content": [
|
|
399
|
+
{
|
|
400
|
+
"attrs": {
|
|
401
|
+
"caption": "",
|
|
402
|
+
"name": "",
|
|
403
|
+
"previewWidth": 512,
|
|
404
|
+
"showPreview": true,
|
|
405
|
+
"textAlignment": "left",
|
|
406
|
+
"url": "",
|
|
407
|
+
},
|
|
408
|
+
"type": "simpleImage",
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
"type": "blockContainer",
|
|
412
|
+
}
|
|
413
|
+
`;
|
|
414
|
+
|
|
415
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/nested to/from prosemirror 1`] = `
|
|
416
|
+
{
|
|
417
|
+
"attrs": {
|
|
418
|
+
"backgroundColor": "default",
|
|
419
|
+
"id": "1",
|
|
420
|
+
"textColor": "default",
|
|
421
|
+
},
|
|
422
|
+
"content": [
|
|
423
|
+
{
|
|
424
|
+
"attrs": {
|
|
425
|
+
"caption": "Caption",
|
|
426
|
+
"name": "example",
|
|
427
|
+
"previewWidth": 256,
|
|
428
|
+
"showPreview": true,
|
|
429
|
+
"textAlignment": "left",
|
|
430
|
+
"url": "exampleURL",
|
|
431
|
+
},
|
|
432
|
+
"type": "simpleImage",
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"content": [
|
|
436
|
+
{
|
|
437
|
+
"attrs": {
|
|
438
|
+
"backgroundColor": "default",
|
|
439
|
+
"id": "2",
|
|
440
|
+
"textColor": "default",
|
|
441
|
+
},
|
|
442
|
+
"content": [
|
|
443
|
+
{
|
|
444
|
+
"attrs": {
|
|
445
|
+
"caption": "Caption",
|
|
446
|
+
"name": "example",
|
|
447
|
+
"previewWidth": 256,
|
|
448
|
+
"showPreview": true,
|
|
449
|
+
"textAlignment": "left",
|
|
450
|
+
"url": "exampleURL",
|
|
451
|
+
},
|
|
452
|
+
"type": "simpleImage",
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
"type": "blockContainer",
|
|
456
|
+
},
|
|
457
|
+
],
|
|
458
|
+
"type": "blockGroup",
|
|
459
|
+
},
|
|
460
|
+
],
|
|
461
|
+
"type": "blockContainer",
|
|
462
|
+
}
|
|
463
|
+
`;
|
|
464
|
+
|
|
465
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/noCaption to/from prosemirror 1`] = `
|
|
466
|
+
{
|
|
467
|
+
"attrs": {
|
|
468
|
+
"backgroundColor": "default",
|
|
469
|
+
"id": "1",
|
|
470
|
+
"textColor": "default",
|
|
471
|
+
},
|
|
472
|
+
"content": [
|
|
473
|
+
{
|
|
474
|
+
"attrs": {
|
|
475
|
+
"caption": "",
|
|
476
|
+
"name": "example",
|
|
477
|
+
"previewWidth": 256,
|
|
478
|
+
"showPreview": true,
|
|
479
|
+
"textAlignment": "left",
|
|
480
|
+
"url": "exampleURL",
|
|
481
|
+
},
|
|
482
|
+
"type": "simpleImage",
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
"type": "blockContainer",
|
|
486
|
+
}
|
|
487
|
+
`;
|
|
488
|
+
|
|
489
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/noName to/from prosemirror 1`] = `
|
|
490
|
+
{
|
|
491
|
+
"attrs": {
|
|
492
|
+
"backgroundColor": "default",
|
|
493
|
+
"id": "1",
|
|
494
|
+
"textColor": "default",
|
|
495
|
+
},
|
|
496
|
+
"content": [
|
|
497
|
+
{
|
|
498
|
+
"attrs": {
|
|
499
|
+
"caption": "Caption",
|
|
500
|
+
"name": "",
|
|
501
|
+
"previewWidth": 256,
|
|
502
|
+
"showPreview": true,
|
|
503
|
+
"textAlignment": "left",
|
|
504
|
+
"url": "exampleURL",
|
|
505
|
+
},
|
|
506
|
+
"type": "simpleImage",
|
|
507
|
+
},
|
|
508
|
+
],
|
|
509
|
+
"type": "blockContainer",
|
|
510
|
+
}
|
|
511
|
+
`;
|
|
512
|
+
|
|
513
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/noPreview to/from prosemirror 1`] = `
|
|
514
|
+
{
|
|
515
|
+
"attrs": {
|
|
516
|
+
"backgroundColor": "default",
|
|
517
|
+
"id": "1",
|
|
518
|
+
"textColor": "default",
|
|
519
|
+
},
|
|
520
|
+
"content": [
|
|
521
|
+
{
|
|
522
|
+
"attrs": {
|
|
523
|
+
"caption": "Caption",
|
|
524
|
+
"name": "example",
|
|
525
|
+
"previewWidth": 256,
|
|
526
|
+
"showPreview": false,
|
|
527
|
+
"textAlignment": "left",
|
|
528
|
+
"url": "exampleURL",
|
|
529
|
+
},
|
|
530
|
+
"type": "simpleImage",
|
|
531
|
+
},
|
|
532
|
+
],
|
|
533
|
+
"type": "blockContainer",
|
|
534
|
+
}
|
|
535
|
+
`;
|
|
536
|
+
|
|
3
537
|
exports[`Test BlockNote-Prosemirror conversion > Case: custom inline content schema > Convert mention/basic to/from prosemirror 1`] = `
|
|
4
538
|
{
|
|
5
539
|
"attrs": {
|
|
@@ -1046,6 +1580,38 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
1046
1580
|
}
|
|
1047
1581
|
`;
|
|
1048
1582
|
|
|
1583
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/lineBreaks to/from prosemirror 1`] = `
|
|
1584
|
+
{
|
|
1585
|
+
"attrs": {
|
|
1586
|
+
"backgroundColor": "default",
|
|
1587
|
+
"id": "1",
|
|
1588
|
+
"textColor": "default",
|
|
1589
|
+
},
|
|
1590
|
+
"content": [
|
|
1591
|
+
{
|
|
1592
|
+
"attrs": {
|
|
1593
|
+
"textAlignment": "left",
|
|
1594
|
+
},
|
|
1595
|
+
"content": [
|
|
1596
|
+
{
|
|
1597
|
+
"text": "Line 1",
|
|
1598
|
+
"type": "text",
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
"type": "hardBreak",
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
"text": "Line 2",
|
|
1605
|
+
"type": "text",
|
|
1606
|
+
},
|
|
1607
|
+
],
|
|
1608
|
+
"type": "paragraph",
|
|
1609
|
+
},
|
|
1610
|
+
],
|
|
1611
|
+
"type": "blockContainer",
|
|
1612
|
+
}
|
|
1613
|
+
`;
|
|
1614
|
+
|
|
1049
1615
|
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/nested to/from prosemirror 1`] = `
|
|
1050
1616
|
{
|
|
1051
1617
|
"attrs": {
|
|
@@ -6,6 +6,7 @@ import { PartialBlock } from "../../blocks/defaultBlocks";
|
|
|
6
6
|
import { customInlineContentTestCases } from "../testUtil/cases/customInlineContent";
|
|
7
7
|
import { customStylesTestCases } from "../testUtil/cases/customStyles";
|
|
8
8
|
import { defaultSchemaTestCases } from "../testUtil/cases/defaultSchema";
|
|
9
|
+
import { customBlocksTestCases } from "../testUtil/cases/customBlocks";
|
|
9
10
|
import {
|
|
10
11
|
addIdsToBlock,
|
|
11
12
|
partialBlockToBlockForTesting,
|
|
@@ -44,6 +45,7 @@ const testCases = [
|
|
|
44
45
|
defaultSchemaTestCases,
|
|
45
46
|
customStylesTestCases,
|
|
46
47
|
customInlineContentTestCases,
|
|
48
|
+
customBlocksTestCases,
|
|
47
49
|
];
|
|
48
50
|
|
|
49
51
|
describe("Test BlockNote-Prosemirror conversion", () => {
|
|
@@ -212,10 +212,8 @@ function blockOrInlineContentToContentNode(
|
|
|
212
212
|
if (!block.content) {
|
|
213
213
|
contentNode = schema.nodes[type].create(block.props);
|
|
214
214
|
} else if (typeof block.content === "string") {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
schema.text(block.content)
|
|
218
|
-
);
|
|
215
|
+
const nodes = inlineContentToNodes([block.content], schema, styleSchema);
|
|
216
|
+
contentNode = schema.nodes[type].create(block.props, nodes);
|
|
219
217
|
} else if (Array.isArray(block.content)) {
|
|
220
218
|
const nodes = inlineContentToNodes(block.content, schema, styleSchema);
|
|
221
219
|
contentNode = schema.nodes[type].create(block.props, nodes);
|
|
@@ -295,6 +295,14 @@ describe("Parse HTML", () => {
|
|
|
295
295
|
await parseHTMLAndCompareSnapshots(html, "parse-two-divs");
|
|
296
296
|
});
|
|
297
297
|
|
|
298
|
+
it("Parse image in paragraph", async () => {
|
|
299
|
+
const html = `<p>
|
|
300
|
+
<img src="exampleURL">
|
|
301
|
+
</p>`;
|
|
302
|
+
|
|
303
|
+
await parseHTMLAndCompareSnapshots(html, "parse-image-in-paragraph");
|
|
304
|
+
});
|
|
305
|
+
|
|
298
306
|
it("Parse fake image caption", async () => {
|
|
299
307
|
const html = `<div>
|
|
300
308
|
<img src="exampleURL">
|
|
@@ -27,6 +27,11 @@ export const createPasteFromClipboardExtension = <
|
|
|
27
27
|
handleDOMEvents: {
|
|
28
28
|
paste(_view, event) {
|
|
29
29
|
event.preventDefault();
|
|
30
|
+
|
|
31
|
+
if (!editor.isEditable) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
let format: (typeof acceptedMIMETypes)[number] | null = null;
|
|
31
36
|
|
|
32
37
|
for (const mimeType of acceptedMIMETypes) {
|
|
@@ -259,6 +259,15 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
259
259
|
},
|
|
260
260
|
],
|
|
261
261
|
},
|
|
262
|
+
{
|
|
263
|
+
name: "customParagraph/lineBreaks",
|
|
264
|
+
blocks: [
|
|
265
|
+
{
|
|
266
|
+
type: "customParagraph",
|
|
267
|
+
content: "Line 1\nLine 2",
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
},
|
|
262
271
|
{
|
|
263
272
|
name: "simpleCustomParagraph/basic",
|
|
264
273
|
blocks: [
|
|
@@ -98,6 +98,15 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
98
98
|
},
|
|
99
99
|
],
|
|
100
100
|
},
|
|
101
|
+
{
|
|
102
|
+
name: "paragraph/lineBreaks",
|
|
103
|
+
blocks: [
|
|
104
|
+
{
|
|
105
|
+
type: "paragraph",
|
|
106
|
+
content: "Line 1\nLine 2",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
101
110
|
{
|
|
102
111
|
name: "lists/basic",
|
|
103
112
|
blocks: [
|