@blocknote/core 0.15.10 → 0.16.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.
Files changed (76) hide show
  1. package/dist/blocknote.js +1019 -957
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +6 -6
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/webpack-stats.json +1 -1
  6. package/package.json +2 -2
  7. package/src/api/blockManipulation/blockManipulation.test.ts +7 -32
  8. package/src/api/clipboard/__snapshots__/childToParent.html +1 -0
  9. package/src/api/clipboard/__snapshots__/childrenToNextParent.html +1 -0
  10. package/src/api/clipboard/__snapshots__/childrenToNextParentsChildren.html +1 -0
  11. package/src/api/clipboard/__snapshots__/image.html +1 -0
  12. package/src/api/clipboard/__snapshots__/multipleStyledText.html +1 -0
  13. package/src/api/clipboard/__snapshots__/nestedImage.html +1 -0
  14. package/src/api/clipboard/__snapshots__/partialChildToParent.html +1 -0
  15. package/src/api/clipboard/__snapshots__/styledText.html +1 -0
  16. package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -0
  17. package/src/api/clipboard/__snapshots__/tableCell.html +1 -0
  18. package/src/api/clipboard/__snapshots__/tableCellText.html +1 -0
  19. package/src/api/clipboard/__snapshots__/tableRow.html +1 -0
  20. package/src/api/clipboard/__snapshots__/unstyledText.html +1 -0
  21. package/src/api/clipboard/clipboard.test.ts +284 -0
  22. package/src/api/{parsers → clipboard/fromClipboard}/fileDropExtension.ts +2 -2
  23. package/src/api/{parsers → clipboard/fromClipboard}/handleFileInsertion.ts +4 -4
  24. package/src/api/{parsers → clipboard/fromClipboard}/pasteExtension.ts +14 -7
  25. package/src/api/{exporters → clipboard/toClipboard}/copyExtension.ts +70 -43
  26. package/src/api/exporters/html/externalHTMLExporter.ts +14 -7
  27. package/src/api/exporters/html/htmlConversion.test.ts +4 -147
  28. package/src/api/exporters/html/internalHTMLSerializer.ts +5 -2
  29. package/src/api/parsers/html/parseHTML.test.ts +3 -6
  30. package/src/api/parsers/markdown/__snapshots__/pasted/complex.json +319 -0
  31. package/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json +81 -0
  32. package/src/api/parsers/{html/__snapshots__/paste/parse-deep-nested-content.json → markdown/__snapshots__/pasted/issue-226-2.json} +35 -110
  33. package/src/api/parsers/markdown/__snapshots__/pasted/nested.json +81 -0
  34. package/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json +81 -0
  35. package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +61 -0
  36. package/src/api/parsers/markdown/parseMarkdown.test.ts +15 -0
  37. package/src/api/testUtil/paste.ts +46 -0
  38. package/src/blocks/TableBlockContent/TableBlockContent.ts +0 -1
  39. package/src/editor/BlockNoteEditor.ts +2 -2
  40. package/src/editor/BlockNoteExtensions.ts +3 -3
  41. package/src/editor/BlockNoteTipTapEditor.ts +34 -7
  42. package/src/editor/transformPasted.ts +34 -2
  43. package/src/extensions/SideMenu/SideMenuPlugin.ts +6 -7
  44. package/src/extensions/TableHandles/TableHandlesPlugin.ts +26 -0
  45. package/src/schema/blocks/createSpec.ts +20 -15
  46. package/types/src/api/clipboard/clipboard.test.d.ts +1 -0
  47. package/types/src/api/clipboard/fromClipboard/fileDropExtension.d.ts +6 -0
  48. package/types/src/api/{parsers → clipboard/fromClipboard}/handleFileInsertion.d.ts +2 -2
  49. package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +6 -0
  50. package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +12 -0
  51. package/types/src/api/exporters/html/externalHTMLExporter.d.ts +1 -0
  52. package/types/src/api/testUtil/paste.d.ts +2 -0
  53. package/types/src/editor/BlockNoteEditor.d.ts +1 -1
  54. package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -1
  55. package/types/src/editor/transformPasted.d.ts +8 -1
  56. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +3 -0
  57. package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionLeavesBlockChildren.html +0 -1
  58. package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionSpansBlocksChildren.html +0 -1
  59. package/src/api/parsers/html/__snapshots__/paste/parse-google-docs-html.json +0 -476
  60. package/types/src/api/exporters/copyExtension.d.ts +0 -6
  61. package/types/src/api/parsers/fileDropExtension.d.ts +0 -6
  62. package/types/src/api/parsers/pasteExtension.d.ts +0 -6
  63. /package/src/api/{exporters/html/__snapshots_fragment_edge_cases__/selectionWithinBlockChildren.html → clipboard/__snapshots__/multipleChildren.html} +0 -0
  64. /package/src/api/{parsers → clipboard/fromClipboard}/acceptedMIMETypes.ts +0 -0
  65. /package/src/api/parsers/html/__snapshots__/{paste/list-test.json → list-test.json} +0 -0
  66. /package/src/api/parsers/html/__snapshots__/{paste/parse-basic-block-types.json → parse-basic-block-types.json} +0 -0
  67. /package/src/api/parsers/html/__snapshots__/{paste/parse-div-with-inline-content.json → parse-div-with-inline-content.json} +0 -0
  68. /package/src/api/parsers/html/__snapshots__/{paste/parse-divs.json → parse-divs.json} +0 -0
  69. /package/src/api/parsers/html/__snapshots__/{paste/parse-fake-image-caption.json → parse-fake-image-caption.json} +0 -0
  70. /package/src/api/parsers/html/__snapshots__/{paste/parse-image-in-paragraph.json → parse-image-in-paragraph.json} +0 -0
  71. /package/src/api/parsers/html/__snapshots__/{paste/parse-mixed-nested-lists.json → parse-mixed-nested-lists.json} +0 -0
  72. /package/src/api/parsers/html/__snapshots__/{paste/parse-nested-lists-with-paragraphs.json → parse-nested-lists-with-paragraphs.json} +0 -0
  73. /package/src/api/parsers/html/__snapshots__/{paste/parse-nested-lists.json → parse-nested-lists.json} +0 -0
  74. /package/src/api/parsers/html/__snapshots__/{paste/parse-notion-html.json → parse-notion-html.json} +0 -0
  75. /package/src/api/parsers/html/__snapshots__/{paste/parse-two-divs.json → parse-two-divs.json} +0 -0
  76. /package/types/src/api/{parsers → clipboard/fromClipboard}/acceptedMIMETypes.d.ts +0 -0
@@ -8,7 +8,7 @@ import { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkTool
8
8
  import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin";
9
9
  import { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin";
10
10
  import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin";
11
- import { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema";
11
+ import { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, PartialInlineContent, StyleSchema, StyleSpecs, Styles } from "../schema";
12
12
  import { NoInfer } from "../util/typescript";
13
13
  import { TextCursorPosition } from "./cursorPositionTypes";
14
14
  import { Selection } from "./selectionTypes";
@@ -12,7 +12,8 @@ export type BlockNoteTipTapEditorOptions = Partial<Omit<EditorOptions, "content"
12
12
  */
13
13
  export declare class BlockNoteTipTapEditor extends TiptapEditor {
14
14
  private _state;
15
- constructor(options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema);
15
+ static create: (options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema) => BlockNoteTipTapEditor;
16
+ protected constructor(options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema);
16
17
  get state(): EditorState;
17
18
  dispatch(tr: Transaction): void;
18
19
  /**
@@ -1,5 +1,12 @@
1
- import { Slice } from "@tiptap/pm/model";
1
+ import { Fragment, Schema, Slice } from "@tiptap/pm/model";
2
2
  import { EditorView } from "@tiptap/pm/view";
3
+ /**
4
+ * Wrap adjacent tableRow items in a table.
5
+ *
6
+ * This makes sure the content that we paste is always a table (and not a tableRow)
7
+ * A table works better for the remaing paste handling logic, as it's actually a blockContent node
8
+ */
9
+ export declare function wrapTableRows(f: Fragment, schema: Schema): Fragment;
3
10
  /**
4
11
  * fix for https://github.com/ProseMirror/prosemirror/issues/1430#issuecomment-1822570821
5
12
  *
@@ -25,8 +25,11 @@ export declare class TableHandlesView<I extends InlineContentSchema, S extends S
25
25
  tableId: string | undefined;
26
26
  tablePos: number | undefined;
27
27
  menuFrozen: boolean;
28
+ mouseState: "up" | "down" | "selecting";
28
29
  prevWasEditable: boolean | null;
29
30
  constructor(editor: BlockNoteEditor<BlockSchemaWithBlock<"table", DefaultBlockSchema["table"]>, I, S>, pmView: EditorView, emitUpdate: (state: TableHandlesState<I, S>) => void);
31
+ viewMousedownHandler: () => void;
32
+ viewMouseupHandler: (event: MouseEvent) => void;
30
33
  mouseMoveHandler: (event: MouseEvent) => false | undefined;
31
34
  dragOverHandler: (event: DragEvent) => void;
32
35
  dropHandler: (event: DragEvent) => void;
@@ -1 +0,0 @@
1
- <p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p><p>Paragraph 2</p>
@@ -1 +0,0 @@
1
- <p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p><p>Paragraph 2</p><p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p>
@@ -1,476 +0,0 @@
1
- [
2
- {
3
- "id": "1",
4
- "type": "heading",
5
- "props": {
6
- "textColor": "default",
7
- "backgroundColor": "default",
8
- "textAlignment": "left",
9
- "level": 1
10
- },
11
- "content": [
12
- {
13
- "type": "text",
14
- "text": "Heading 1",
15
- "styles": {
16
- "bold": true
17
- }
18
- }
19
- ],
20
- "children": []
21
- },
22
- {
23
- "id": "2",
24
- "type": "heading",
25
- "props": {
26
- "textColor": "default",
27
- "backgroundColor": "default",
28
- "textAlignment": "left",
29
- "level": 2
30
- },
31
- "content": [
32
- {
33
- "type": "text",
34
- "text": "Heading 2",
35
- "styles": {
36
- "bold": true
37
- }
38
- }
39
- ],
40
- "children": []
41
- },
42
- {
43
- "id": "3",
44
- "type": "heading",
45
- "props": {
46
- "textColor": "default",
47
- "backgroundColor": "default",
48
- "textAlignment": "left",
49
- "level": 3
50
- },
51
- "content": [
52
- {
53
- "type": "text",
54
- "text": "Heading 3",
55
- "styles": {
56
- "bold": true
57
- }
58
- }
59
- ],
60
- "children": []
61
- },
62
- {
63
- "id": "4",
64
- "type": "paragraph",
65
- "props": {
66
- "textColor": "default",
67
- "backgroundColor": "default",
68
- "textAlignment": "left"
69
- },
70
- "content": [
71
- {
72
- "type": "text",
73
- "text": "Paragraph 1",
74
- "styles": {}
75
- }
76
- ],
77
- "children": []
78
- },
79
- {
80
- "id": "5",
81
- "type": "paragraph",
82
- "props": {
83
- "textColor": "default",
84
- "backgroundColor": "default",
85
- "textAlignment": "left"
86
- },
87
- "content": [
88
- {
89
- "type": "text",
90
- "text": "Paragraph 2",
91
- "styles": {}
92
- }
93
- ],
94
- "children": []
95
- },
96
- {
97
- "id": "6",
98
- "type": "paragraph",
99
- "props": {
100
- "textColor": "default",
101
- "backgroundColor": "default",
102
- "textAlignment": "left"
103
- },
104
- "content": [
105
- {
106
- "type": "text",
107
- "text": "Paragraph 3",
108
- "styles": {}
109
- }
110
- ],
111
- "children": []
112
- },
113
- {
114
- "id": "7",
115
- "type": "paragraph",
116
- "props": {
117
- "textColor": "default",
118
- "backgroundColor": "default",
119
- "textAlignment": "left"
120
- },
121
- "content": [
122
- {
123
- "type": "text",
124
- "text": "Paragraph With \nHard Break",
125
- "styles": {}
126
- }
127
- ],
128
- "children": []
129
- },
130
- {
131
- "id": "8",
132
- "type": "paragraph",
133
- "props": {
134
- "textColor": "default",
135
- "backgroundColor": "default",
136
- "textAlignment": "left"
137
- },
138
- "content": [
139
- {
140
- "type": "text",
141
- "text": "Bold",
142
- "styles": {
143
- "bold": true
144
- }
145
- },
146
- {
147
- "type": "text",
148
- "text": " ",
149
- "styles": {}
150
- },
151
- {
152
- "type": "text",
153
- "text": "Italic",
154
- "styles": {
155
- "italic": true
156
- }
157
- },
158
- {
159
- "type": "text",
160
- "text": " Underline ",
161
- "styles": {}
162
- },
163
- {
164
- "type": "text",
165
- "text": "Strikethrough",
166
- "styles": {
167
- "strike": true
168
- }
169
- },
170
- {
171
- "type": "text",
172
- "text": " ",
173
- "styles": {}
174
- },
175
- {
176
- "type": "text",
177
- "text": "All",
178
- "styles": {
179
- "bold": true,
180
- "italic": true,
181
- "strike": true
182
- }
183
- }
184
- ],
185
- "children": []
186
- },
187
- {
188
- "id": "9",
189
- "type": "bulletListItem",
190
- "props": {
191
- "textColor": "default",
192
- "backgroundColor": "default",
193
- "textAlignment": "left"
194
- },
195
- "content": [
196
- {
197
- "type": "text",
198
- "text": "Bullet List Item 1",
199
- "styles": {}
200
- }
201
- ],
202
- "children": [
203
- {
204
- "id": "10",
205
- "type": "bulletListItem",
206
- "props": {
207
- "textColor": "default",
208
- "backgroundColor": "default",
209
- "textAlignment": "left"
210
- },
211
- "content": [
212
- {
213
- "type": "text",
214
- "text": "Nested Bullet List Item 1",
215
- "styles": {}
216
- }
217
- ],
218
- "children": [
219
- {
220
- "id": "11",
221
- "type": "numberedListItem",
222
- "props": {
223
- "textColor": "default",
224
- "backgroundColor": "default",
225
- "textAlignment": "left"
226
- },
227
- "content": [
228
- {
229
- "type": "text",
230
- "text": "Nested Numbered List Item 1",
231
- "styles": {}
232
- }
233
- ],
234
- "children": []
235
- },
236
- {
237
- "id": "12",
238
- "type": "numberedListItem",
239
- "props": {
240
- "textColor": "default",
241
- "backgroundColor": "default",
242
- "textAlignment": "left"
243
- },
244
- "content": [
245
- {
246
- "type": "text",
247
- "text": "Nested Numbered List Item 2",
248
- "styles": {}
249
- }
250
- ],
251
- "children": []
252
- }
253
- ]
254
- },
255
- {
256
- "id": "13",
257
- "type": "bulletListItem",
258
- "props": {
259
- "textColor": "default",
260
- "backgroundColor": "default",
261
- "textAlignment": "left"
262
- },
263
- "content": [
264
- {
265
- "type": "text",
266
- "text": "Nested Bullet List Item 2",
267
- "styles": {}
268
- }
269
- ],
270
- "children": []
271
- }
272
- ]
273
- },
274
- {
275
- "id": "14",
276
- "type": "bulletListItem",
277
- "props": {
278
- "textColor": "default",
279
- "backgroundColor": "default",
280
- "textAlignment": "left"
281
- },
282
- "content": [
283
- {
284
- "type": "text",
285
- "text": "Bullet List Item 2",
286
- "styles": {}
287
- }
288
- ],
289
- "children": []
290
- },
291
- {
292
- "id": "15",
293
- "type": "numberedListItem",
294
- "props": {
295
- "textColor": "default",
296
- "backgroundColor": "default",
297
- "textAlignment": "left"
298
- },
299
- "content": [
300
- {
301
- "type": "text",
302
- "text": "Numbered List Item 1",
303
- "styles": {}
304
- }
305
- ],
306
- "children": []
307
- },
308
- {
309
- "id": "16",
310
- "type": "numberedListItem",
311
- "props": {
312
- "textColor": "default",
313
- "backgroundColor": "default",
314
- "textAlignment": "left"
315
- },
316
- "content": [
317
- {
318
- "type": "text",
319
- "text": "Numbered List Item 2",
320
- "styles": {}
321
- }
322
- ],
323
- "children": []
324
- },
325
- {
326
- "id": "17",
327
- "type": "paragraph",
328
- "props": {
329
- "textColor": "default",
330
- "backgroundColor": "default",
331
- "textAlignment": "left"
332
- },
333
- "content": [],
334
- "children": []
335
- },
336
- {
337
- "id": "18",
338
- "type": "paragraph",
339
- "props": {
340
- "textColor": "default",
341
- "backgroundColor": "default",
342
- "textAlignment": "left"
343
- },
344
- "content": [
345
- {
346
- "type": "text",
347
- "text": "\n",
348
- "styles": {}
349
- }
350
- ],
351
- "children": []
352
- },
353
- {
354
- "id": "19",
355
- "type": "table",
356
- "props": {
357
- "textColor": "default",
358
- "backgroundColor": "default"
359
- },
360
- "content": {
361
- "type": "tableContent",
362
- "rows": [
363
- {
364
- "cells": [
365
- [
366
- {
367
- "type": "text",
368
- "text": "Cell 1",
369
- "styles": {}
370
- }
371
- ],
372
- [
373
- {
374
- "type": "text",
375
- "text": "Cell 2",
376
- "styles": {}
377
- }
378
- ],
379
- [
380
- {
381
- "type": "text",
382
- "text": "Cell 3",
383
- "styles": {}
384
- }
385
- ]
386
- ]
387
- },
388
- {
389
- "cells": [
390
- [
391
- {
392
- "type": "text",
393
- "text": "Cell 4",
394
- "styles": {}
395
- }
396
- ],
397
- [
398
- {
399
- "type": "text",
400
- "text": "Cell 5",
401
- "styles": {}
402
- }
403
- ],
404
- [
405
- {
406
- "type": "text",
407
- "text": "Cell 6",
408
- "styles": {}
409
- }
410
- ]
411
- ]
412
- },
413
- {
414
- "cells": [
415
- [
416
- {
417
- "type": "text",
418
- "text": "Cell 7",
419
- "styles": {}
420
- }
421
- ],
422
- [
423
- {
424
- "type": "text",
425
- "text": "Cell 8",
426
- "styles": {}
427
- }
428
- ],
429
- [
430
- {
431
- "type": "text",
432
- "text": "Cell 9",
433
- "styles": {}
434
- }
435
- ]
436
- ]
437
- }
438
- ]
439
- },
440
- "children": []
441
- },
442
- {
443
- "id": "20",
444
- "type": "paragraph",
445
- "props": {
446
- "textColor": "default",
447
- "backgroundColor": "default",
448
- "textAlignment": "left"
449
- },
450
- "content": [
451
- {
452
- "type": "text",
453
- "text": "Paragraph",
454
- "styles": {}
455
- }
456
- ],
457
- "children": []
458
- },
459
- {
460
- "id": "21",
461
- "type": "paragraph",
462
- "props": {
463
- "textColor": "default",
464
- "backgroundColor": "default",
465
- "textAlignment": "left"
466
- },
467
- "content": [
468
- {
469
- "type": "text",
470
- "text": "\n",
471
- "styles": {}
472
- }
473
- ],
474
- "children": []
475
- }
476
- ]
@@ -1,6 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
3
- import { InlineContentSchema, StyleSchema } from "../../schema";
4
- export declare const createCopyToClipboardExtension: <BSchema extends Record<string, import("../../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>) => Extension<{
5
- editor: BlockNoteEditor<BSchema, I, S>;
6
- }, undefined>;
@@ -1,6 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
3
- import { InlineContentSchema, StyleSchema } from "../../schema";
4
- export declare const createDropFileExtension: <BSchema extends Record<string, import("../../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>) => Extension<{
5
- editor: BlockNoteEditor<BSchema, I, S>;
6
- }, undefined>;
@@ -1,6 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
3
- import { InlineContentSchema, StyleSchema } from "../../schema";
4
- export declare const createPasteFromClipboardExtension: <BSchema extends Record<string, import("../../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>) => Extension<{
5
- editor: BlockNoteEditor<BSchema, I, S>;
6
- }, undefined>;