@blocknote/core 0.29.1 → 0.30.1
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 +125 -0
- package/dist/blocknote.cjs +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1501 -1359
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +751 -9
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +7 -8
- package/src/api/README.md +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -7
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -5
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -20
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +7 -7
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -17
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -42
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +18 -18
- package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
- package/src/api/blockManipulation/insertContentAt.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +11 -11
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +7 -7
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +6 -6
- package/src/api/blockManipulation/tables/tables.test.ts +106 -106
- package/src/api/blockManipulation/tables/tables.ts +35 -35
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +21 -3
- package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
- package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
- package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
- package/src/api/exporters/markdown/markdownExporter.ts +3 -3
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
- package/src/api/getBlockInfoFromPos.ts +6 -6
- package/src/api/nodeConversions/blockToNode.ts +26 -26
- package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +37 -33
- package/src/api/nodeUtil.test.ts +16 -16
- package/src/api/nodeUtil.ts +10 -10
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/pmUtil.ts +4 -4
- package/src/api/positionMapping.test.ts +3 -3
- package/src/api/positionMapping.ts +5 -5
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +9 -4
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +40 -26
- package/src/blocks/FileBlockContent/FileBlockContent.ts +7 -2
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +5 -5
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +15 -8
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +9 -6
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +14 -6
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +13 -29
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +24 -13
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -30
- package/src/blocks/ListItemBlockContent/getListItemContent.ts +115 -0
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
- package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +9 -5
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +10 -5
- package/src/blocks/README.md +1 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +76 -19
- package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +14 -6
- package/src/blocks/defaultBlockHelpers.ts +24 -8
- package/src/blocks/defaultBlockTypeGuards.ts +16 -16
- package/src/blocks/defaultBlocks.ts +3 -3
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
- package/src/comments/threadstore/ThreadStore.ts +1 -1
- package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
- package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
- package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
- package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
- package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
- package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
- package/src/editor/Block.css +10 -1
- package/src/editor/BlockNoteEditor.test.ts +3 -3
- package/src/editor/BlockNoteEditor.ts +110 -61
- package/src/editor/BlockNoteExtensions.ts +24 -15
- package/src/editor/BlockNoteSchema.ts +4 -4
- package/src/editor/BlockNoteTipTapEditor.ts +10 -10
- package/src/editor/README.md +1 -1
- package/src/editor/cursorPositionTypes.ts +1 -1
- package/src/editor/editor.css +15 -3
- package/src/editor/selectionTypes.ts +1 -1
- package/src/editor/transformPasted.ts +2 -2
- package/src/exporter/Exporter.ts +5 -5
- package/src/exporter/mapping.ts +7 -7
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
- package/src/extensions/Collaboration/CursorPlugin.ts +152 -0
- package/src/extensions/Collaboration/SyncPlugin.ts +15 -0
- package/src/extensions/Collaboration/UndoPlugin.ts +14 -0
- package/src/extensions/Comments/CommentsPlugin.ts +9 -9
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +37 -28
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +6 -8
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +29 -26
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -11
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +4 -4
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +10 -10
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +2 -2
- package/src/extensions/README.md +1 -1
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +31 -31
- package/src/extensions/SideMenu/dragging.ts +8 -8
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +17 -17
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -12
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +54 -53
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/UniqueID/UniqueID.ts +6 -6
- package/src/extensions/getDraggableBlockFromElement.ts +1 -1
- package/src/fonts/inter.css +18 -9
- package/src/i18n/locales/index.ts +2 -0
- package/src/i18n/locales/ru.ts +2 -2
- package/src/i18n/locales/sk.ts +355 -0
- package/src/i18n/locales/zh-tw.ts +390 -0
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +7 -6
- package/src/pm-nodes/BlockGroup.ts +1 -1
- package/src/pm-nodes/Doc.ts +4 -4
- package/src/schema/README.md +1 -1
- package/src/schema/blocks/createSpec.ts +15 -15
- package/src/schema/blocks/internal.ts +17 -18
- package/src/schema/blocks/types.ts +27 -26
- package/src/schema/inlineContent/createSpec.ts +16 -20
- package/src/schema/inlineContent/internal.ts +9 -9
- package/src/schema/inlineContent/types.ts +26 -26
- package/src/schema/propTypes.ts +8 -8
- package/src/schema/styles/createSpec.ts +2 -2
- package/src/schema/styles/internal.ts +7 -7
- package/src/schema/styles/types.ts +2 -2
- package/src/util/EventEmitter.ts +4 -4
- package/src/util/README.md +1 -1
- package/src/util/combineByGroup.ts +1 -1
- package/src/util/table.ts +33 -30
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -4
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +8 -4
- package/types/src/blocks/ListItemBlockContent/getListItemContent.d.ts +28 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +8 -4
- package/types/src/blocks/defaultBlockHelpers.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -8
- package/types/src/editor/BlockNoteEditor.d.ts +21 -2
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +31 -0
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +7 -0
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +6 -0
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +1 -1
- package/types/src/i18n/locales/index.d.ts +2 -0
- package/types/src/i18n/locales/sk.d.ts +313 -0
- package/types/src/i18n/locales/zh-tw.d.ts +2 -0
- package/types/src/schema/blocks/types.d.ts +2 -1
- package/src/extensions/Collaboration/createCollaborationExtensions.ts +0 -147
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +0 -17
|
@@ -185,7 +185,7 @@ type OccupancyGrid = (RelativeCellIndices & {
|
|
|
185
185
|
* @returns an {@link OccupancyGrid}
|
|
186
186
|
*/
|
|
187
187
|
export function getTableCellOccupancyGrid(
|
|
188
|
-
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any
|
|
188
|
+
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
189
189
|
): OccupancyGrid {
|
|
190
190
|
const { height, width } = getDimensionsOfTable(block);
|
|
191
191
|
|
|
@@ -209,7 +209,7 @@ export function getTableCellOccupancyGrid(
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
throw new Error(
|
|
212
|
-
"Unable to create occupancy grid for table, no more available cells"
|
|
212
|
+
"Unable to create occupancy grid for table, no more available cells",
|
|
213
213
|
);
|
|
214
214
|
};
|
|
215
215
|
|
|
@@ -231,7 +231,7 @@ export function getTableCellOccupancyGrid(
|
|
|
231
231
|
if (grid[i][j]) {
|
|
232
232
|
// The cell is already occupied, the table is malformed
|
|
233
233
|
throw new Error(
|
|
234
|
-
`Unable to create occupancy grid for table, cell at ${i},${j} is already occupied
|
|
234
|
+
`Unable to create occupancy grid for table, cell at ${i},${j} is already occupied`,
|
|
235
235
|
);
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -258,7 +258,7 @@ export function getTableCellOccupancyGrid(
|
|
|
258
258
|
* @note This will remove duplicates from the occupancy grid. And does no bounds checking for validity of the occupancy grid.
|
|
259
259
|
*/
|
|
260
260
|
export function getTableRowsFromOccupancyGrid(
|
|
261
|
-
occupancyGrid: OccupancyGrid
|
|
261
|
+
occupancyGrid: OccupancyGrid,
|
|
262
262
|
): TableContent<any, any>["rows"] {
|
|
263
263
|
// Because a cell can have a rowspan or colspan, it can occupy multiple cells in the occupancy grid
|
|
264
264
|
// So, we need to remove duplicates from the occupancy grid before we can return the table rows
|
|
@@ -299,7 +299,7 @@ export function getAbsoluteTableCells(
|
|
|
299
299
|
/**
|
|
300
300
|
* The occupancy grid of the table.
|
|
301
301
|
*/
|
|
302
|
-
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
|
|
302
|
+
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block),
|
|
303
303
|
): AbsoluteCellIndices & {
|
|
304
304
|
cell: TableCell<any, any>;
|
|
305
305
|
} {
|
|
@@ -317,7 +317,7 @@ export function getAbsoluteTableCells(
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
throw new Error(
|
|
320
|
-
`Unable to resolve relative table cell indices for table, cell at ${relativeCellIndices.row},${relativeCellIndices.col} is not occupied
|
|
320
|
+
`Unable to resolve relative table cell indices for table, cell at ${relativeCellIndices.row},${relativeCellIndices.col} is not occupied`,
|
|
321
321
|
);
|
|
322
322
|
}
|
|
323
323
|
|
|
@@ -327,7 +327,7 @@ export function getAbsoluteTableCells(
|
|
|
327
327
|
* @returns The height and width of the table.
|
|
328
328
|
*/
|
|
329
329
|
export function getDimensionsOfTable(
|
|
330
|
-
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any
|
|
330
|
+
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
331
331
|
): {
|
|
332
332
|
/**
|
|
333
333
|
* The number of rows in the table.
|
|
@@ -374,7 +374,7 @@ export function getRelativeTableCells(
|
|
|
374
374
|
/**
|
|
375
375
|
* The occupancy grid of the table.
|
|
376
376
|
*/
|
|
377
|
-
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
|
|
377
|
+
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block),
|
|
378
378
|
):
|
|
379
379
|
| (RelativeCellIndices & {
|
|
380
380
|
cell: TableContent<any, any>["rows"][number]["cells"][number];
|
|
@@ -429,7 +429,7 @@ export function getRelativeTableCells(
|
|
|
429
429
|
*/
|
|
430
430
|
export function getCellsAtRowHandle(
|
|
431
431
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
432
|
-
relativeRowIndex: RelativeCellIndices["row"]
|
|
432
|
+
relativeRowIndex: RelativeCellIndices["row"],
|
|
433
433
|
) {
|
|
434
434
|
const occupancyGrid = getTableCellOccupancyGrid(block);
|
|
435
435
|
|
|
@@ -459,12 +459,12 @@ export function getCellsAtRowHandle(
|
|
|
459
459
|
return getRelativeTableCells(
|
|
460
460
|
{ row: absoluteRow, col },
|
|
461
461
|
block,
|
|
462
|
-
occupancyGrid
|
|
462
|
+
occupancyGrid,
|
|
463
463
|
);
|
|
464
464
|
})
|
|
465
465
|
.filter(
|
|
466
466
|
(a): a is RelativeCellIndices & { cell: TableCell<any, any> } =>
|
|
467
|
-
a !== undefined
|
|
467
|
+
a !== undefined,
|
|
468
468
|
);
|
|
469
469
|
|
|
470
470
|
// Filter out duplicates based on row and col properties
|
|
@@ -508,7 +508,7 @@ export function getCellsAtRowHandle(
|
|
|
508
508
|
*/
|
|
509
509
|
export function getCellsAtColumnHandle(
|
|
510
510
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
511
|
-
relativeColumnIndex: RelativeCellIndices["col"]
|
|
511
|
+
relativeColumnIndex: RelativeCellIndices["col"],
|
|
512
512
|
) {
|
|
513
513
|
const occupancyGrid = getTableCellOccupancyGrid(block);
|
|
514
514
|
|
|
@@ -541,12 +541,12 @@ export function getCellsAtColumnHandle(
|
|
|
541
541
|
return getRelativeTableCells(
|
|
542
542
|
{ row, col: absoluteCol },
|
|
543
543
|
block,
|
|
544
|
-
occupancyGrid
|
|
544
|
+
occupancyGrid,
|
|
545
545
|
);
|
|
546
546
|
})
|
|
547
547
|
.filter(
|
|
548
548
|
(a): a is RelativeCellIndices & { cell: TableCell<any, any> } =>
|
|
549
|
-
a !== undefined
|
|
549
|
+
a !== undefined,
|
|
550
550
|
);
|
|
551
551
|
|
|
552
552
|
// Filter out duplicates based on row and col properties
|
|
@@ -566,7 +566,7 @@ export function moveColumn(
|
|
|
566
566
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
567
567
|
fromColIndex: RelativeCellIndices["col"],
|
|
568
568
|
toColIndex: RelativeCellIndices["col"],
|
|
569
|
-
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
|
|
569
|
+
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block),
|
|
570
570
|
): TableContent<any, any>["rows"] {
|
|
571
571
|
// To move cells in a column, we need to layout the whole table
|
|
572
572
|
// and then move the cells accordingly.
|
|
@@ -576,7 +576,7 @@ export function moveColumn(
|
|
|
576
576
|
col: fromColIndex,
|
|
577
577
|
},
|
|
578
578
|
block,
|
|
579
|
-
occupancyGrid
|
|
579
|
+
occupancyGrid,
|
|
580
580
|
);
|
|
581
581
|
const { col: absoluteTargetCol } = getAbsoluteTableCells(
|
|
582
582
|
{
|
|
@@ -584,7 +584,7 @@ export function moveColumn(
|
|
|
584
584
|
col: toColIndex,
|
|
585
585
|
},
|
|
586
586
|
block,
|
|
587
|
-
occupancyGrid
|
|
587
|
+
occupancyGrid,
|
|
588
588
|
);
|
|
589
589
|
|
|
590
590
|
/**
|
|
@@ -610,7 +610,7 @@ export function moveRow(
|
|
|
610
610
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
611
611
|
fromRowIndex: RelativeCellIndices["row"],
|
|
612
612
|
toRowIndex: RelativeCellIndices["row"],
|
|
613
|
-
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
|
|
613
|
+
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block),
|
|
614
614
|
): TableContent<any, any>["rows"] {
|
|
615
615
|
// To move cells in a column, we need to layout the whole table
|
|
616
616
|
// and then move the cells accordingly.
|
|
@@ -620,7 +620,7 @@ export function moveRow(
|
|
|
620
620
|
col: 0,
|
|
621
621
|
},
|
|
622
622
|
block,
|
|
623
|
-
occupancyGrid
|
|
623
|
+
occupancyGrid,
|
|
624
624
|
);
|
|
625
625
|
const { row: absoluteTargetRow } = getAbsoluteTableCells(
|
|
626
626
|
{
|
|
@@ -628,7 +628,7 @@ export function moveRow(
|
|
|
628
628
|
col: 0,
|
|
629
629
|
},
|
|
630
630
|
block,
|
|
631
|
-
occupancyGrid
|
|
631
|
+
occupancyGrid,
|
|
632
632
|
);
|
|
633
633
|
|
|
634
634
|
/**
|
|
@@ -650,7 +650,7 @@ export function moveRow(
|
|
|
650
650
|
function isCellEmpty(
|
|
651
651
|
cell:
|
|
652
652
|
| PartialTableContent<any, any>["rows"][number]["cells"][number]
|
|
653
|
-
| undefined
|
|
653
|
+
| undefined,
|
|
654
654
|
): boolean {
|
|
655
655
|
if (!cell) {
|
|
656
656
|
return true;
|
|
@@ -664,12 +664,12 @@ function isCellEmpty(
|
|
|
664
664
|
typeof c === "string"
|
|
665
665
|
? c.length === 0
|
|
666
666
|
: isStyledTextInlineContent(c)
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
667
|
+
? c.text.length === 0
|
|
668
|
+
: isPartialLinkInlineContent(c)
|
|
669
|
+
? typeof c.content === "string"
|
|
670
|
+
? c.content.length === 0
|
|
671
|
+
: c.content.every((s) => s.text.length === 0)
|
|
672
|
+
: false,
|
|
673
673
|
);
|
|
674
674
|
} else {
|
|
675
675
|
return false;
|
|
@@ -684,7 +684,7 @@ function isCellEmpty(
|
|
|
684
684
|
export function cropEmptyRowsOrColumns(
|
|
685
685
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
686
686
|
removeEmpty: "columns" | "rows",
|
|
687
|
-
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
|
|
687
|
+
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block),
|
|
688
688
|
): TableContent<any, any>["rows"] {
|
|
689
689
|
if (removeEmpty === "columns") {
|
|
690
690
|
// strips empty columns on the right
|
|
@@ -696,7 +696,7 @@ export function cropEmptyRowsOrColumns(
|
|
|
696
696
|
) {
|
|
697
697
|
const isEmpty = occupancyGrid.every(
|
|
698
698
|
(row) =>
|
|
699
|
-
isCellEmpty(row[cellIndex].cell) && row[cellIndex].colspan === 1
|
|
699
|
+
isCellEmpty(row[cellIndex].cell) && row[cellIndex].colspan === 1,
|
|
700
700
|
);
|
|
701
701
|
if (!isEmpty) {
|
|
702
702
|
break;
|
|
@@ -709,7 +709,7 @@ export function cropEmptyRowsOrColumns(
|
|
|
709
709
|
// We maintain at least one cell, even if all the cells are empty
|
|
710
710
|
const cellsToRemove = Math.max(
|
|
711
711
|
occupancyGrid[i].length - emptyColsOnRight,
|
|
712
|
-
1
|
|
712
|
+
1,
|
|
713
713
|
);
|
|
714
714
|
occupancyGrid[i] = occupancyGrid[i].slice(0, cellsToRemove);
|
|
715
715
|
}
|
|
@@ -721,7 +721,7 @@ export function cropEmptyRowsOrColumns(
|
|
|
721
721
|
let emptyRowsOnBottom = 0;
|
|
722
722
|
for (let rowIndex = occupancyGrid.length - 1; rowIndex >= 0; rowIndex--) {
|
|
723
723
|
const isEmpty = occupancyGrid[rowIndex].every(
|
|
724
|
-
(cell) => isCellEmpty(cell.cell) && cell.rowspan === 1
|
|
724
|
+
(cell) => isCellEmpty(cell.cell) && cell.rowspan === 1,
|
|
725
725
|
);
|
|
726
726
|
if (!isEmpty) {
|
|
727
727
|
break;
|
|
@@ -752,7 +752,7 @@ export function addRowsOrColumns(
|
|
|
752
752
|
* @note if negative, it will remove rows or columns.
|
|
753
753
|
*/
|
|
754
754
|
numToAdd: number,
|
|
755
|
-
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block)
|
|
755
|
+
occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block),
|
|
756
756
|
): TableContent<any, any>["rows"] {
|
|
757
757
|
const { width, height } = getDimensionsOfTable(block);
|
|
758
758
|
|
|
@@ -802,7 +802,7 @@ export function addRowsOrColumns(
|
|
|
802
802
|
export function canRowBeDraggedInto(
|
|
803
803
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
804
804
|
draggingIndex: RelativeCellIndices["row"],
|
|
805
|
-
targetRowIndex: RelativeCellIndices["row"]
|
|
805
|
+
targetRowIndex: RelativeCellIndices["row"],
|
|
806
806
|
) {
|
|
807
807
|
// Check cells at the target row
|
|
808
808
|
const targetCells = getCellsAtRowHandle(block, targetRowIndex);
|
|
@@ -837,7 +837,7 @@ export function canRowBeDraggedInto(
|
|
|
837
837
|
export function canColumnBeDraggedInto(
|
|
838
838
|
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
839
839
|
draggingIndex: RelativeCellIndices["col"],
|
|
840
|
-
targetColumnIndex: RelativeCellIndices["col"]
|
|
840
|
+
targetColumnIndex: RelativeCellIndices["col"],
|
|
841
841
|
) {
|
|
842
842
|
// Check cells at the target column
|
|
843
843
|
const targetCells = getCellsAtColumnHandle(block, targetColumnIndex);
|
|
@@ -874,7 +874,7 @@ export function canColumnBeDraggedInto(
|
|
|
874
874
|
export function areInSameColumn(
|
|
875
875
|
from: RelativeCellIndices,
|
|
876
876
|
to: RelativeCellIndices,
|
|
877
|
-
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any
|
|
877
|
+
block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>,
|
|
878
878
|
) {
|
|
879
879
|
// Table indices are relative to the table, so we need to resolve the absolute cell indices
|
|
880
880
|
const anchorAbsoluteCellIndices = getAbsoluteTableCells(from, block);
|
|
@@ -13,9 +13,9 @@ import { handleFileInsertion } from "./handleFileInsertion.js";
|
|
|
13
13
|
export const createDropFileExtension = <
|
|
14
14
|
BSchema extends BlockSchema,
|
|
15
15
|
I extends InlineContentSchema,
|
|
16
|
-
S extends StyleSchema
|
|
16
|
+
S extends StyleSchema,
|
|
17
17
|
>(
|
|
18
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
18
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
19
19
|
) =>
|
|
20
20
|
Extension.create<{ editor: BlockNoteEditor<BSchema, I, S> }, undefined>({
|
|
21
21
|
name: "dropFile",
|
|
@@ -11,7 +11,7 @@ import { acceptedMIMETypes } from "./acceptedMIMETypes.js";
|
|
|
11
11
|
|
|
12
12
|
function checkFileExtensionsMatch(
|
|
13
13
|
fileExtension1: string,
|
|
14
|
-
fileExtension2: string
|
|
14
|
+
fileExtension2: string,
|
|
15
15
|
) {
|
|
16
16
|
if (!fileExtension1.startsWith(".") || !fileExtension2.startsWith(".")) {
|
|
17
17
|
throw new Error(`The strings provided are not valid file extensions.`);
|
|
@@ -44,11 +44,11 @@ function checkMIMETypesMatch(mimeType1: string, mimeType2: string) {
|
|
|
44
44
|
function insertOrUpdateBlock<
|
|
45
45
|
BSchema extends BlockSchema,
|
|
46
46
|
I extends InlineContentSchema,
|
|
47
|
-
S extends StyleSchema
|
|
47
|
+
S extends StyleSchema,
|
|
48
48
|
>(
|
|
49
49
|
editor: BlockNoteEditor<BSchema, I, S>,
|
|
50
50
|
referenceBlock: Block<BSchema, I, S>,
|
|
51
|
-
newBlock: PartialBlock<BSchema, I, S
|
|
51
|
+
newBlock: PartialBlock<BSchema, I, S>,
|
|
52
52
|
) {
|
|
53
53
|
let insertedBlockId: string | undefined;
|
|
54
54
|
|
|
@@ -61,7 +61,7 @@ function insertOrUpdateBlock<
|
|
|
61
61
|
insertedBlockId = editor.insertBlocks(
|
|
62
62
|
[newBlock],
|
|
63
63
|
referenceBlock,
|
|
64
|
-
"after"
|
|
64
|
+
"after",
|
|
65
65
|
)[0].id;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -71,12 +71,12 @@ function insertOrUpdateBlock<
|
|
|
71
71
|
export async function handleFileInsertion<
|
|
72
72
|
BSchema extends BlockSchema,
|
|
73
73
|
I extends InlineContentSchema,
|
|
74
|
-
S extends StyleSchema
|
|
74
|
+
S extends StyleSchema,
|
|
75
75
|
>(event: DragEvent | ClipboardEvent, editor: BlockNoteEditor<BSchema, I, S>) {
|
|
76
76
|
if (!editor.uploadFile) {
|
|
77
77
|
// eslint-disable-next-line no-console
|
|
78
78
|
console.warn(
|
|
79
|
-
"Attempted ot insert file, but uploadFile is not set in the BlockNote editor options"
|
|
79
|
+
"Attempted ot insert file, but uploadFile is not set in the BlockNote editor options",
|
|
80
80
|
);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
@@ -106,7 +106,7 @@ export async function handleFileInsertion<
|
|
|
106
106
|
event.preventDefault();
|
|
107
107
|
|
|
108
108
|
const fileBlockConfigs = Object.values(editor.schema.blockSchema).filter(
|
|
109
|
-
(blockConfig) => blockConfig.isFileBlock
|
|
109
|
+
(blockConfig) => blockConfig.isFileBlock,
|
|
110
110
|
) as FileBlockConfig[];
|
|
111
111
|
|
|
112
112
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -125,7 +125,7 @@ export async function handleFileInsertion<
|
|
|
125
125
|
(isFileExtension &&
|
|
126
126
|
checkFileExtensionsMatch(
|
|
127
127
|
"." + file.name.split(".").pop(),
|
|
128
|
-
mimeType
|
|
128
|
+
mimeType,
|
|
129
129
|
))
|
|
130
130
|
) {
|
|
131
131
|
fileBlockType = fileBlockConfig.type;
|
|
@@ -165,7 +165,7 @@ export async function handleFileInsertion<
|
|
|
165
165
|
return insertOrUpdateBlock(
|
|
166
166
|
editor,
|
|
167
167
|
editor.getBlock(posInfo.node.attrs.id)!,
|
|
168
|
-
fileBlock
|
|
168
|
+
fileBlock,
|
|
169
169
|
);
|
|
170
170
|
});
|
|
171
171
|
} else {
|
|
@@ -2,7 +2,7 @@ import { EditorView } from "prosemirror-view";
|
|
|
2
2
|
|
|
3
3
|
export async function handleVSCodePaste(
|
|
4
4
|
event: ClipboardEvent,
|
|
5
|
-
view: EditorView
|
|
5
|
+
view: EditorView,
|
|
6
6
|
) {
|
|
7
7
|
const { schema } = view.state;
|
|
8
8
|
|
|
@@ -34,8 +34,8 @@ export async function handleVSCodePaste(
|
|
|
34
34
|
view.pasteHTML(
|
|
35
35
|
`<pre><code class="language-${language}">${text.replace(
|
|
36
36
|
/\r\n?/g,
|
|
37
|
-
"\n"
|
|
38
|
-
)}</code></pre
|
|
37
|
+
"\n",
|
|
38
|
+
)}</code></pre>`,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
return true;
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
BlockNoteEditor,
|
|
6
6
|
BlockNoteEditorOptions,
|
|
7
7
|
} from "../../../editor/BlockNoteEditor";
|
|
8
|
+
import { isMarkdown } from "../../parsers/markdown/detectMarkdown.js";
|
|
8
9
|
import {
|
|
9
10
|
BlockSchema,
|
|
10
11
|
InlineContentSchema,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
import { acceptedMIMETypes } from "./acceptedMIMETypes.js";
|
|
14
15
|
import { handleFileInsertion } from "./handleFileInsertion.js";
|
|
15
16
|
import { handleVSCodePaste } from "./handleVSCodePaste.js";
|
|
16
|
-
import { isMarkdown } from "../../parsers/markdown/detectMarkdown.js";
|
|
17
17
|
|
|
18
18
|
function defaultPasteHandler({
|
|
19
19
|
event,
|
|
@@ -26,6 +26,24 @@ function defaultPasteHandler({
|
|
|
26
26
|
prioritizeMarkdownOverHTML: boolean;
|
|
27
27
|
plainTextAsMarkdown: boolean;
|
|
28
28
|
}) {
|
|
29
|
+
// Special case for code blocks, as they do not support any rich text
|
|
30
|
+
// formatting, so we force pasting plain text.
|
|
31
|
+
const isInCodeBlock = editor.transact(
|
|
32
|
+
(tr) =>
|
|
33
|
+
tr.selection.$from.parent.type.spec.code &&
|
|
34
|
+
tr.selection.$to.parent.type.spec.code,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (isInCodeBlock) {
|
|
38
|
+
const data = event.clipboardData?.getData("text/plain");
|
|
39
|
+
|
|
40
|
+
if (data) {
|
|
41
|
+
editor.pasteText(data);
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
29
47
|
let format: (typeof acceptedMIMETypes)[number] | undefined;
|
|
30
48
|
for (const mimeType of acceptedMIMETypes) {
|
|
31
49
|
if (event.clipboardData!.types.includes(mimeType)) {
|
|
@@ -88,13 +106,13 @@ function defaultPasteHandler({
|
|
|
88
106
|
export const createPasteFromClipboardExtension = <
|
|
89
107
|
BSchema extends BlockSchema,
|
|
90
108
|
I extends InlineContentSchema,
|
|
91
|
-
S extends StyleSchema
|
|
109
|
+
S extends StyleSchema,
|
|
92
110
|
>(
|
|
93
111
|
editor: BlockNoteEditor<BSchema, I, S>,
|
|
94
112
|
pasteHandler: Exclude<
|
|
95
113
|
BlockNoteEditorOptions<any, any, any>["pasteHandler"],
|
|
96
114
|
undefined
|
|
97
|
-
|
|
115
|
+
>,
|
|
98
116
|
) =>
|
|
99
117
|
Extension.create({
|
|
100
118
|
name: "pasteFromClipboard",
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
function fragmentToExternalHTML<
|
|
22
22
|
BSchema extends BlockSchema,
|
|
23
23
|
I extends InlineContentSchema,
|
|
24
|
-
S extends StyleSchema
|
|
24
|
+
S extends StyleSchema,
|
|
25
25
|
>(
|
|
26
26
|
view: EditorView,
|
|
27
27
|
selectedFragment: Fragment,
|
|
28
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
28
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
29
29
|
) {
|
|
30
30
|
let isWithinBlockContent = false;
|
|
31
31
|
const isWithinTable = view.state.selection instanceof CellSelection;
|
|
@@ -37,7 +37,7 @@ function fragmentToExternalHTML<
|
|
|
37
37
|
const fragmentWithoutParents = view.state.doc.slice(
|
|
38
38
|
view.state.selection.from,
|
|
39
39
|
view.state.selection.to,
|
|
40
|
-
false
|
|
40
|
+
false,
|
|
41
41
|
).content;
|
|
42
42
|
|
|
43
43
|
const children = [];
|
|
@@ -50,7 +50,7 @@ function fragmentToExternalHTML<
|
|
|
50
50
|
(child) =>
|
|
51
51
|
child.type.isInGroup("bnBlock") ||
|
|
52
52
|
child.type.name === "blockGroup" ||
|
|
53
|
-
child.type.spec.group === "blockContent"
|
|
53
|
+
child.type.spec.group === "blockContent",
|
|
54
54
|
) === undefined;
|
|
55
55
|
if (isWithinBlockContent) {
|
|
56
56
|
selectedFragment = fragmentWithoutParents;
|
|
@@ -61,7 +61,7 @@ function fragmentToExternalHTML<
|
|
|
61
61
|
|
|
62
62
|
const externalHTMLExporter = createExternalHTMLExporter(
|
|
63
63
|
view.state.schema,
|
|
64
|
-
editor
|
|
64
|
+
editor,
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
if (isWithinTable) {
|
|
@@ -76,13 +76,13 @@ function fragmentToExternalHTML<
|
|
|
76
76
|
const ic = contentNodeToTableContent(
|
|
77
77
|
selectedFragment as any,
|
|
78
78
|
editor.schema.inlineContentSchema,
|
|
79
|
-
editor.schema.styleSchema
|
|
79
|
+
editor.schema.styleSchema,
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
// Wrap in table to ensure correct parsing by spreadsheet applications
|
|
83
83
|
externalHTML = `<table>${externalHTMLExporter.exportInlineContent(
|
|
84
84
|
ic as any,
|
|
85
|
-
{}
|
|
85
|
+
{},
|
|
86
86
|
)}</table>`;
|
|
87
87
|
} else if (isWithinBlockContent) {
|
|
88
88
|
// first convert selection to blocknote-style inline content, and then
|
|
@@ -90,7 +90,7 @@ function fragmentToExternalHTML<
|
|
|
90
90
|
const ic = contentNodeToInlineContent(
|
|
91
91
|
selectedFragment as any,
|
|
92
92
|
editor.schema.inlineContentSchema,
|
|
93
|
-
editor.schema.styleSchema
|
|
93
|
+
editor.schema.styleSchema,
|
|
94
94
|
);
|
|
95
95
|
externalHTML = externalHTMLExporter.exportInlineContent(ic, {});
|
|
96
96
|
} else {
|
|
@@ -103,10 +103,10 @@ function fragmentToExternalHTML<
|
|
|
103
103
|
export function selectedFragmentToHTML<
|
|
104
104
|
BSchema extends BlockSchema,
|
|
105
105
|
I extends InlineContentSchema,
|
|
106
|
-
S extends StyleSchema
|
|
106
|
+
S extends StyleSchema,
|
|
107
107
|
>(
|
|
108
108
|
view: EditorView,
|
|
109
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
109
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
110
110
|
): {
|
|
111
111
|
clipboardHTML: string;
|
|
112
112
|
externalHTML: string;
|
|
@@ -122,14 +122,14 @@ export function selectedFragmentToHTML<
|
|
|
122
122
|
) {
|
|
123
123
|
editor.transact((tr) =>
|
|
124
124
|
tr.setSelection(
|
|
125
|
-
new NodeSelection(tr.doc.resolve(view.state.selection.from - 1))
|
|
126
|
-
)
|
|
125
|
+
new NodeSelection(tr.doc.resolve(view.state.selection.from - 1)),
|
|
126
|
+
),
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// Uses default ProseMirror clipboard serialization.
|
|
131
131
|
const clipboardHTML: string = view.serializeForClipboard(
|
|
132
|
-
view.state.selection.content()
|
|
132
|
+
view.state.selection.content(),
|
|
133
133
|
).dom.innerHTML;
|
|
134
134
|
|
|
135
135
|
const selectedFragment = view.state.selection.content().content;
|
|
@@ -137,7 +137,7 @@ export function selectedFragmentToHTML<
|
|
|
137
137
|
const externalHTML = fragmentToExternalHTML<BSchema, I, S>(
|
|
138
138
|
view,
|
|
139
139
|
selectedFragment,
|
|
140
|
-
editor
|
|
140
|
+
editor,
|
|
141
141
|
);
|
|
142
142
|
|
|
143
143
|
const markdown = cleanHTMLToMarkdown(externalHTML);
|
|
@@ -176,11 +176,11 @@ const checkIfSelectionInNonEditableBlock = () => {
|
|
|
176
176
|
const copyToClipboard = <
|
|
177
177
|
BSchema extends BlockSchema,
|
|
178
178
|
I extends InlineContentSchema,
|
|
179
|
-
S extends StyleSchema
|
|
179
|
+
S extends StyleSchema,
|
|
180
180
|
>(
|
|
181
181
|
editor: BlockNoteEditor<BSchema, I, S>,
|
|
182
182
|
view: EditorView,
|
|
183
|
-
event: ClipboardEvent
|
|
183
|
+
event: ClipboardEvent,
|
|
184
184
|
) => {
|
|
185
185
|
// Stops the default browser copy behaviour.
|
|
186
186
|
event.preventDefault();
|
|
@@ -188,7 +188,7 @@ const copyToClipboard = <
|
|
|
188
188
|
|
|
189
189
|
const { clipboardHTML, externalHTML, markdown } = selectedFragmentToHTML(
|
|
190
190
|
view,
|
|
191
|
-
editor
|
|
191
|
+
editor,
|
|
192
192
|
);
|
|
193
193
|
|
|
194
194
|
// TODO: Writing to other MIME types not working in Safari for
|
|
@@ -201,9 +201,9 @@ const copyToClipboard = <
|
|
|
201
201
|
export const createCopyToClipboardExtension = <
|
|
202
202
|
BSchema extends BlockSchema,
|
|
203
203
|
I extends InlineContentSchema,
|
|
204
|
-
S extends StyleSchema
|
|
204
|
+
S extends StyleSchema,
|
|
205
205
|
>(
|
|
206
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
206
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
207
207
|
) =>
|
|
208
208
|
Extension.create<{ editor: BlockNoteEditor<BSchema, I, S> }, undefined>({
|
|
209
209
|
name: "copyToClipboard",
|
|
@@ -254,9 +254,9 @@ export const createCopyToClipboardExtension = <
|
|
|
254
254
|
editor.transact((tr) =>
|
|
255
255
|
tr.setSelection(
|
|
256
256
|
new NodeSelection(
|
|
257
|
-
tr.doc.resolve(view.state.selection.from - 1)
|
|
258
|
-
)
|
|
259
|
-
)
|
|
257
|
+
tr.doc.resolve(view.state.selection.from - 1),
|
|
258
|
+
),
|
|
259
|
+
),
|
|
260
260
|
);
|
|
261
261
|
|
|
262
262
|
// Stops the default browser drag start behaviour.
|
|
@@ -32,17 +32,17 @@ import {
|
|
|
32
32
|
export const createExternalHTMLExporter = <
|
|
33
33
|
BSchema extends BlockSchema,
|
|
34
34
|
I extends InlineContentSchema,
|
|
35
|
-
S extends StyleSchema
|
|
35
|
+
S extends StyleSchema,
|
|
36
36
|
>(
|
|
37
37
|
schema: Schema,
|
|
38
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
38
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
39
39
|
) => {
|
|
40
40
|
const serializer = DOMSerializer.fromSchema(schema);
|
|
41
41
|
|
|
42
42
|
return {
|
|
43
43
|
exportBlocks: (
|
|
44
44
|
blocks: PartialBlock<BSchema, I, S>[],
|
|
45
|
-
options: { document?: Document }
|
|
45
|
+
options: { document?: Document },
|
|
46
46
|
) => {
|
|
47
47
|
const html = serializeBlocksExternalHTML(
|
|
48
48
|
editor,
|
|
@@ -50,7 +50,7 @@ export const createExternalHTMLExporter = <
|
|
|
50
50
|
serializer,
|
|
51
51
|
new Set<string>(["numberedListItem"]),
|
|
52
52
|
new Set<string>(["bulletListItem", "checkListItem"]),
|
|
53
|
-
options
|
|
53
|
+
options,
|
|
54
54
|
);
|
|
55
55
|
const div = document.createElement("div");
|
|
56
56
|
div.append(html);
|
|
@@ -59,13 +59,13 @@ export const createExternalHTMLExporter = <
|
|
|
59
59
|
|
|
60
60
|
exportInlineContent: (
|
|
61
61
|
inlineContent: InlineContent<I, S>[],
|
|
62
|
-
options: { document?: Document }
|
|
62
|
+
options: { document?: Document },
|
|
63
63
|
) => {
|
|
64
64
|
const domFragment = serializeInlineContentExternalHTML(
|
|
65
65
|
editor,
|
|
66
66
|
inlineContent as any,
|
|
67
67
|
serializer,
|
|
68
|
-
options
|
|
68
|
+
options,
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
const parent = document.createElement("div");
|
|
@@ -19,17 +19,17 @@ import { serializeBlocksInternalHTML } from "./util/serializeBlocksInternalHTML.
|
|
|
19
19
|
export const createInternalHTMLSerializer = <
|
|
20
20
|
BSchema extends BlockSchema,
|
|
21
21
|
I extends InlineContentSchema,
|
|
22
|
-
S extends StyleSchema
|
|
22
|
+
S extends StyleSchema,
|
|
23
23
|
>(
|
|
24
24
|
schema: Schema,
|
|
25
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
25
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
26
26
|
) => {
|
|
27
27
|
const serializer = DOMSerializer.fromSchema(schema);
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
30
|
serializeBlocks: (
|
|
31
31
|
blocks: PartialBlock<BSchema, I, S>[],
|
|
32
|
-
options: { document?: Document }
|
|
32
|
+
options: { document?: Document },
|
|
33
33
|
) => {
|
|
34
34
|
return serializeBlocksInternalHTML(editor, blocks, serializer, options)
|
|
35
35
|
.outerHTML;
|