@blocknote/core 0.21.0 → 0.23.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 +2320 -1692
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +7 -7
- package/dist/blocknote.umd.cjs.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 +3 -3
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
- package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
- package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
- package/src/api/clipboard/__snapshots__/internal/basicBlocks.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
- package/src/api/clipboard/clipboardExternal.test.ts +161 -0
- package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +186 -38
- package/src/api/clipboard/testUtil.ts +27 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -0
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html +1 -0
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
- package/src/api/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md +0 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +16 -0
- package/src/api/nodeConversions/nodeToBlock.ts +4 -1
- package/src/api/parsers/html/__snapshots__/parse-codeblocks.json +62 -0
- package/src/api/parsers/html/parseHTML.test.ts +9 -0
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
- package/src/api/testUtil/cases/defaultSchema.ts +15 -1
- package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +32 -11
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -28
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +1 -1
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +4 -16
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +26 -6
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +49 -0
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +45 -0
- package/src/blocks/PageBreakBlockContent/schema.ts +40 -0
- package/src/editor/Block.css +18 -4
- package/src/editor/BlockNoteEditor.test.ts +21 -1
- package/src/editor/BlockNoteEditor.ts +17 -0
- package/src/editor/BlockNoteExtensions.ts +111 -16
- package/src/editor/editor.css +28 -13
- package/src/editor/transformPasted.ts +57 -4
- package/src/extensions/SideMenu/SideMenuPlugin.ts +115 -23
- package/src/extensions/SideMenu/dragging.ts +0 -1
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +6 -0
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +6 -0
- package/src/i18n/locales/fr.ts +47 -17
- package/src/i18n/locales/hr.ts +72 -54
- package/src/i18n/locales/index.ts +1 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/it.ts +315 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +6 -0
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +3 -0
- package/src/schema/blocks/createSpec.ts +1 -1
- package/src/schema/blocks/internal.ts +16 -6
- package/src/schema/inlineContent/internal.ts +4 -1
- package/src/schema/propTypes.ts +41 -18
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
- package/types/src/api/clipboard/testUtil.d.ts +509 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -1
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +2 -0
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
- package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +31 -0
- package/types/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.d.ts +8 -0
- package/types/src/blocks/PageBreakBlockContent/schema.d.ts +86 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -0
- package/types/src/editor/BlockNoteEditor.d.ts +15 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -0
- package/types/src/editor/transformPasted.d.ts +8 -4
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +25 -5
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
- package/types/src/i18n/locales/de.d.ts +6 -0
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/es.d.ts +6 -0
- package/types/src/i18n/locales/hr.d.ts +6 -0
- package/types/src/i18n/locales/index.d.ts +1 -0
- package/types/src/i18n/locales/it.d.ts +245 -0
- package/types/src/index.d.ts +3 -0
- package/types/src/schema/propTypes.d.ts +20 -2
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
- package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
- package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
- package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/selection.js +0 -149
- package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
- package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
- package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
- package/dist/src/api/clipboard/clipboard.test.js +0 -249
- package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -25
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -134
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
- package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
- package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
- package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
- package/dist/src/api/getBlockInfoFromPos.js +0 -165
- package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
- package/dist/src/api/nodeConversions/blockToNode.js +0 -197
- package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
- package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
- package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
- package/dist/src/api/nodeUtil.js +0 -28
- package/dist/src/api/nodeUtil.js.map +0 -1
- package/dist/src/api/parsers/html/parseHTML.js +0 -19
- package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
- package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
- package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
- package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
- package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
- package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -112
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
- package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
- package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
- package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
- package/dist/src/api/testUtil/cases/customStyles.js +0 -83
- package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
- package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
- package/dist/src/api/testUtil/index.js +0 -2
- package/dist/src/api/testUtil/index.js.map +0 -1
- package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
- package/dist/src/api/testUtil/paste.js +0 -29
- package/dist/src/api/testUtil/paste.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -104
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js +0 -5
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +0 -1
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -71
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +0 -5
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +0 -10
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +0 -39
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +0 -51
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +0 -17
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +0 -147
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +0 -9
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +0 -11
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -114
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js +0 -6
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
- package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -114
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js +0 -6
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +0 -1
- package/dist/src/blocks/defaultBlockHelpers.js +0 -50
- package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
- package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
- package/dist/src/blocks/defaultBlocks.js +0 -50
- package/dist/src/blocks/defaultBlocks.js.map +0 -1
- package/dist/src/blocks/defaultProps.js +0 -19
- package/dist/src/blocks/defaultProps.js.map +0 -1
- package/dist/src/editor/BlockNoteEditor.js +0 -751
- package/dist/src/editor/BlockNoteEditor.js.map +0 -1
- package/dist/src/editor/BlockNoteEditor.test.js +0 -65
- package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
- package/dist/src/editor/BlockNoteExtensions.js +0 -192
- package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
- package/dist/src/editor/BlockNoteSchema.js +0 -38
- package/dist/src/editor/BlockNoteSchema.js.map +0 -1
- package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
- package/dist/src/editor/cursorPositionTypes.js +0 -2
- package/dist/src/editor/cursorPositionTypes.js.map +0 -1
- package/dist/src/editor/defaultColors.js +0 -77
- package/dist/src/editor/defaultColors.js.map +0 -1
- package/dist/src/editor/selectionTypes.js +0 -2
- package/dist/src/editor/selectionTypes.js.map +0 -1
- package/dist/src/editor/transformPasted.js +0 -79
- package/dist/src/editor/transformPasted.js.map +0 -1
- package/dist/src/exporter/Exporter.js +0 -36
- package/dist/src/exporter/Exporter.js.map +0 -1
- package/dist/src/exporter/index.js +0 -3
- package/dist/src/exporter/index.js.map +0 -1
- package/dist/src/exporter/mapping.js +0 -12
- package/dist/src/exporter/mapping.js.map +0 -1
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
- package/dist/src/extensions/LinkToolbar/protocols.js +0 -14
- package/dist/src/extensions/LinkToolbar/protocols.js.map +0 -1
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -347
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/dragging.js +0 -135
- package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -579
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
- package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
- package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
- package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
- package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
- package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
- package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
- package/dist/src/extensions-shared/UiElementPosition.js +0 -2
- package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
- package/dist/src/i18n/dictionary.js +0 -4
- package/dist/src/i18n/dictionary.js.map +0 -1
- package/dist/src/i18n/locales/ar.js +0 -298
- package/dist/src/i18n/locales/ar.js.map +0 -1
- package/dist/src/i18n/locales/de.js +0 -313
- package/dist/src/i18n/locales/de.js.map +0 -1
- package/dist/src/i18n/locales/en.js +0 -314
- package/dist/src/i18n/locales/en.js.map +0 -1
- package/dist/src/i18n/locales/es.js +0 -312
- package/dist/src/i18n/locales/es.js.map +0 -1
- package/dist/src/i18n/locales/fr.js +0 -313
- package/dist/src/i18n/locales/fr.js.map +0 -1
- package/dist/src/i18n/locales/hr.js +0 -308
- package/dist/src/i18n/locales/hr.js.map +0 -1
- package/dist/src/i18n/locales/index.js +0 -16
- package/dist/src/i18n/locales/index.js.map +0 -1
- package/dist/src/i18n/locales/is.js +0 -305
- package/dist/src/i18n/locales/is.js.map +0 -1
- package/dist/src/i18n/locales/ja.js +0 -333
- package/dist/src/i18n/locales/ja.js.map +0 -1
- package/dist/src/i18n/locales/ko.js +0 -326
- package/dist/src/i18n/locales/ko.js.map +0 -1
- package/dist/src/i18n/locales/nl.js +0 -313
- package/dist/src/i18n/locales/nl.js.map +0 -1
- package/dist/src/i18n/locales/pl.js +0 -297
- package/dist/src/i18n/locales/pl.js.map +0 -1
- package/dist/src/i18n/locales/pt.js +0 -305
- package/dist/src/i18n/locales/pt.js.map +0 -1
- package/dist/src/i18n/locales/ru.js +0 -340
- package/dist/src/i18n/locales/ru.js.map +0 -1
- package/dist/src/i18n/locales/vi.js +0 -312
- package/dist/src/i18n/locales/vi.js.map +0 -1
- package/dist/src/i18n/locales/zh.js +0 -346
- package/dist/src/i18n/locales/zh.js.map +0 -1
- package/dist/src/index.js +0 -63
- package/dist/src/index.js.map +0 -1
- package/dist/src/pm-nodes/BlockContainer.js +0 -72
- package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
- package/dist/src/pm-nodes/BlockGroup.js +0 -43
- package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
- package/dist/src/pm-nodes/Doc.js +0 -7
- package/dist/src/pm-nodes/Doc.js.map +0 -1
- package/dist/src/pm-nodes/index.js +0 -4
- package/dist/src/pm-nodes/index.js.map +0 -1
- package/dist/src/schema/blocks/createSpec.js +0 -126
- package/dist/src/schema/blocks/createSpec.js.map +0 -1
- package/dist/src/schema/blocks/internal.js +0 -147
- package/dist/src/schema/blocks/internal.js.map +0 -1
- package/dist/src/schema/blocks/types.js +0 -2
- package/dist/src/schema/blocks/types.js.map +0 -1
- package/dist/src/schema/index.js +0 -11
- package/dist/src/schema/index.js.map +0 -1
- package/dist/src/schema/inlineContent/createSpec.js +0 -64
- package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
- package/dist/src/schema/inlineContent/internal.js +0 -52
- package/dist/src/schema/inlineContent/internal.js.map +0 -1
- package/dist/src/schema/inlineContent/types.js +0 -10
- package/dist/src/schema/inlineContent/types.js.map +0 -1
- package/dist/src/schema/propTypes.js +0 -2
- package/dist/src/schema/propTypes.js.map +0 -1
- package/dist/src/schema/styles/createSpec.js +0 -48
- package/dist/src/schema/styles/createSpec.js.map +0 -1
- package/dist/src/schema/styles/internal.js +0 -53
- package/dist/src/schema/styles/internal.js.map +0 -1
- package/dist/src/schema/styles/types.js +0 -2
- package/dist/src/schema/styles/types.js.map +0 -1
- package/dist/src/util/EventEmitter.js +0 -33
- package/dist/src/util/EventEmitter.js.map +0 -1
- package/dist/src/util/browser.js +0 -17
- package/dist/src/util/browser.js.map +0 -1
- package/dist/src/util/combineByGroup.js +0 -20
- package/dist/src/util/combineByGroup.js.map +0 -1
- package/dist/src/util/esmDependencies.js +0 -35
- package/dist/src/util/esmDependencies.js.map +0 -1
- package/dist/src/util/string.js +0 -14
- package/dist/src/util/string.js.map +0 -1
- package/dist/src/util/typescript.js +0 -12
- package/dist/src/util/typescript.js.map +0 -1
- /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableAllCells.html → internal/tableAllCells.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableCell.html → internal/tableCell.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableRow.html → internal/tableRow.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
- /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
package/src/editor/Block.css
CHANGED
|
@@ -114,13 +114,13 @@ NESTED BLOCKS
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/* HEADINGS*/
|
|
117
|
-
[data-
|
|
117
|
+
[data-content-type="heading"] {
|
|
118
118
|
--level: 3em;
|
|
119
119
|
}
|
|
120
|
-
[data-level="2"] {
|
|
120
|
+
[data-content-type="heading"][data-level="2"] {
|
|
121
121
|
--level: 2em;
|
|
122
122
|
}
|
|
123
|
-
[data-level="3"] {
|
|
123
|
+
[data-content-type="heading"][data-level="3"] {
|
|
124
124
|
--level: 1.3em;
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -308,6 +308,20 @@ NESTED BLOCKS
|
|
|
308
308
|
transition-delay: 0.1s;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
/* PAGE BREAK */
|
|
312
|
+
.bn-block-content[data-content-type="pageBreak"] > div {
|
|
313
|
+
width: 100%;
|
|
314
|
+
height: 0;
|
|
315
|
+
border-top: dotted rgb(125, 121, 122) 2px;
|
|
316
|
+
margin-block: 11px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@media print {
|
|
320
|
+
.bn-block-content[data-content-type="pageBreak"] > div {
|
|
321
|
+
page-break-after: always;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
311
325
|
/* FILES */
|
|
312
326
|
|
|
313
327
|
/* Element that wraps content for all file blocks */
|
|
@@ -336,7 +350,7 @@ NESTED BLOCKS
|
|
|
336
350
|
|
|
337
351
|
.bn-editor[contenteditable="true"] [data-file-block] .bn-add-file-button:hover,
|
|
338
352
|
[data-file-block] .bn-file-name-with-icon:hover,
|
|
339
|
-
.ProseMirror-selectednode .bn-file-name-with-icon{
|
|
353
|
+
.ProseMirror-selectednode .bn-file-name-with-icon {
|
|
340
354
|
background-color: rgb(225, 225, 225);
|
|
341
355
|
}
|
|
342
356
|
|
|
@@ -71,6 +71,26 @@ it("adds id attribute when requested", async () => {
|
|
|
71
71
|
);
|
|
72
72
|
editor.replaceBlocks(editor.document, blocks);
|
|
73
73
|
expect(await editor.blocksToFullHTML(editor.document)).toMatchInlineSnapshot(
|
|
74
|
-
`"<div class="bn-block-group" data-node-type="blockGroup"><div class="bn-block-outer" data-node-type="blockOuter" data-id="1" id="1"><div class="bn-block" data-node-type="blockContainer" data-id="1" id="1"><div class="bn-block-content" data-content-type="paragraph"><p class="bn-inline-content">This is a normal text</p></div></div></div><div class="bn-block-outer" data-node-type="blockOuter" data-id="2" id="2"><div class="bn-block" data-node-type="blockContainer" data-id="2" id="2"><div class="bn-block-content" data-content-type="heading"
|
|
74
|
+
`"<div class="bn-block-group" data-node-type="blockGroup"><div class="bn-block-outer" data-node-type="blockOuter" data-id="1" id="1"><div class="bn-block" data-node-type="blockContainer" data-id="1" id="1"><div class="bn-block-content" data-content-type="paragraph"><p class="bn-inline-content">This is a normal text</p></div></div></div><div class="bn-block-outer" data-node-type="blockOuter" data-id="2" id="2"><div class="bn-block" data-node-type="blockContainer" data-id="2" id="2"><div class="bn-block-content" data-content-type="heading"><h1 class="bn-inline-content">And this is a large heading</h1></div></div></div></div>"`
|
|
75
75
|
);
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
it("block prop types", () => {
|
|
79
|
+
// this test checks whether the block props are correctly typed in typescript
|
|
80
|
+
const editor = BlockNoteEditor.create();
|
|
81
|
+
const block = editor.document[0];
|
|
82
|
+
if (block.type === "paragraph") {
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
const level = block.props.level; // doesn't have level prop
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line
|
|
87
|
+
expect(level).toBe(undefined);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (block.type === "heading") {
|
|
91
|
+
const level = block.props.level; // does have level prop
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line
|
|
94
|
+
expect(level).toBe(1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
@@ -196,6 +196,13 @@ export type BlockNoteEditorOptions<
|
|
|
196
196
|
* Optional function to customize how cursors of users are rendered
|
|
197
197
|
*/
|
|
198
198
|
renderCursor?: (user: any) => HTMLElement;
|
|
199
|
+
/**
|
|
200
|
+
* Optional flag to set when the user label should be shown with the default
|
|
201
|
+
* collaboration cursor. Setting to "always" will always show the label,
|
|
202
|
+
* while "activity" will only show the label when the user moves the cursor
|
|
203
|
+
* or types. Defaults to "activity".
|
|
204
|
+
*/
|
|
205
|
+
showCursorLabels?: "always" | "activity";
|
|
199
206
|
};
|
|
200
207
|
|
|
201
208
|
/**
|
|
@@ -245,6 +252,15 @@ export type BlockNoteEditorOptions<
|
|
|
245
252
|
@default "prefer-navigate-ui"
|
|
246
253
|
*/
|
|
247
254
|
tabBehavior: "prefer-navigate-ui" | "prefer-indent";
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The detection mode for showing the side menu - "viewport" always shows the
|
|
258
|
+
* side menu for the block next to the mouse cursor, while "editor" only shows
|
|
259
|
+
* it when hovering the editor or the side menu itself.
|
|
260
|
+
*
|
|
261
|
+
* @default "viewport"
|
|
262
|
+
*/
|
|
263
|
+
sideMenuDetection: "viewport" | "editor";
|
|
248
264
|
};
|
|
249
265
|
|
|
250
266
|
const blockNoteTipTapOptions = {
|
|
@@ -423,6 +439,7 @@ export class BlockNoteEditor<
|
|
|
423
439
|
dropCursor: this.options.dropCursor ?? dropCursor,
|
|
424
440
|
placeholders: newOptions.placeholders,
|
|
425
441
|
tabBehavior: newOptions.tabBehavior,
|
|
442
|
+
sideMenuDetection: newOptions.sideMenuDetection || "viewport",
|
|
426
443
|
});
|
|
427
444
|
|
|
428
445
|
// add extensions from _tiptapOptions
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyExtension, Extension, extensions } from "@tiptap/core";
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
2
3
|
|
|
3
4
|
import type { BlockNoteEditor, BlockNoteExtension } from "./BlockNoteEditor.js";
|
|
4
5
|
|
|
@@ -64,6 +65,7 @@ type ExtensionOptions<
|
|
|
64
65
|
};
|
|
65
66
|
provider: any;
|
|
66
67
|
renderCursor?: (user: any) => HTMLElement;
|
|
68
|
+
showCursorLabels?: "always" | "activity";
|
|
67
69
|
};
|
|
68
70
|
disableExtensions: string[] | undefined;
|
|
69
71
|
setIdAttribute?: boolean;
|
|
@@ -72,6 +74,7 @@ type ExtensionOptions<
|
|
|
72
74
|
dropCursor: (opts: any) => Plugin;
|
|
73
75
|
placeholders: Record<string | "default", string>;
|
|
74
76
|
tabBehavior?: "prefer-navigate-ui" | "prefer-indent";
|
|
77
|
+
sideMenuDetection: "viewport" | "editor";
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
/**
|
|
@@ -97,7 +100,10 @@ export const getBlockNoteExtensions = <
|
|
|
97
100
|
opts.editor
|
|
98
101
|
);
|
|
99
102
|
ret["linkToolbar"] = new LinkToolbarProsemirrorPlugin(opts.editor);
|
|
100
|
-
ret["sideMenu"] = new SideMenuProsemirrorPlugin(
|
|
103
|
+
ret["sideMenu"] = new SideMenuProsemirrorPlugin(
|
|
104
|
+
opts.editor,
|
|
105
|
+
opts.sideMenuDetection
|
|
106
|
+
);
|
|
101
107
|
ret["suggestionMenus"] = new SuggestionMenuProseMirrorPlugin(opts.editor);
|
|
102
108
|
ret["filePanel"] = new FilePanelProsemirrorPlugin(opts.editor as any);
|
|
103
109
|
ret["placeholder"] = new PlaceholderPlugin(opts.editor, opts.placeholders);
|
|
@@ -246,25 +252,114 @@ const getTipTapExtensions = <
|
|
|
246
252
|
fragment: opts.collaboration.fragment,
|
|
247
253
|
})
|
|
248
254
|
);
|
|
249
|
-
if (opts.collaboration.provider?.awareness) {
|
|
250
|
-
const defaultRender = (user: { color: string; name: string }) => {
|
|
251
|
-
const cursor = document.createElement("span");
|
|
252
255
|
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
const awareness = opts.collaboration?.provider.awareness as Awareness;
|
|
257
|
+
|
|
258
|
+
if (awareness) {
|
|
259
|
+
const cursors = new Map<
|
|
260
|
+
number,
|
|
261
|
+
{ element: HTMLElement; hideTimeout: NodeJS.Timeout | undefined }
|
|
262
|
+
>();
|
|
263
|
+
|
|
264
|
+
if (opts.collaboration.showCursorLabels !== "always") {
|
|
265
|
+
awareness.on(
|
|
266
|
+
"change",
|
|
267
|
+
({
|
|
268
|
+
updated,
|
|
269
|
+
}: {
|
|
270
|
+
added: Array<number>;
|
|
271
|
+
updated: Array<number>;
|
|
272
|
+
removed: Array<number>;
|
|
273
|
+
}) => {
|
|
274
|
+
for (const clientID of updated) {
|
|
275
|
+
const cursor = cursors.get(clientID);
|
|
276
|
+
|
|
277
|
+
if (cursor) {
|
|
278
|
+
cursor.element.setAttribute("data-active", "");
|
|
279
|
+
|
|
280
|
+
if (cursor.hideTimeout) {
|
|
281
|
+
clearTimeout(cursor.hideTimeout);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
cursors.set(clientID, {
|
|
285
|
+
element: cursor.element,
|
|
286
|
+
hideTimeout: setTimeout(() => {
|
|
287
|
+
cursor.element.removeAttribute("data-active");
|
|
288
|
+
}, 2000),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const createCursor = (clientID: number, name: string, color: string) => {
|
|
297
|
+
const cursorElement = document.createElement("span");
|
|
298
|
+
|
|
299
|
+
cursorElement.classList.add("collaboration-cursor__caret");
|
|
300
|
+
cursorElement.setAttribute("style", `border-color: ${color}`);
|
|
301
|
+
if (opts.collaboration?.showCursorLabels === "always") {
|
|
302
|
+
cursorElement.setAttribute("data-active", "");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const labelElement = document.createElement("span");
|
|
306
|
+
|
|
307
|
+
labelElement.classList.add("collaboration-cursor__label");
|
|
308
|
+
labelElement.setAttribute("style", `background-color: ${color}`);
|
|
309
|
+
labelElement.insertBefore(document.createTextNode(name), null);
|
|
310
|
+
|
|
311
|
+
cursorElement.insertBefore(document.createTextNode("\u2060"), null); // Non-breaking space
|
|
312
|
+
cursorElement.insertBefore(labelElement, null);
|
|
313
|
+
cursorElement.insertBefore(document.createTextNode("\u2060"), null); // Non-breaking space
|
|
314
|
+
|
|
315
|
+
cursors.set(clientID, {
|
|
316
|
+
element: cursorElement,
|
|
317
|
+
hideTimeout: undefined,
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
if (opts.collaboration?.showCursorLabels !== "always") {
|
|
321
|
+
cursorElement.addEventListener("mouseenter", () => {
|
|
322
|
+
const cursor = cursors.get(clientID)!;
|
|
323
|
+
cursor.element.setAttribute("data-active", "");
|
|
324
|
+
|
|
325
|
+
if (cursor.hideTimeout) {
|
|
326
|
+
clearTimeout(cursor.hideTimeout);
|
|
327
|
+
cursors.set(clientID, {
|
|
328
|
+
element: cursor.element,
|
|
329
|
+
hideTimeout: undefined,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
cursorElement.addEventListener("mouseleave", () => {
|
|
335
|
+
const cursor = cursors.get(clientID)!;
|
|
336
|
+
|
|
337
|
+
cursors.set(clientID, {
|
|
338
|
+
element: cursor.element,
|
|
339
|
+
hideTimeout: setTimeout(() => {
|
|
340
|
+
cursor.element.removeAttribute("data-active");
|
|
341
|
+
}, 2000),
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return cursors.get(clientID)!;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const defaultRender = (user: { color: string; name: string }) => {
|
|
350
|
+
const clientState = [...awareness.getStates().entries()].find(
|
|
351
|
+
(state) => state[1].user === user
|
|
352
|
+
);
|
|
255
353
|
|
|
256
|
-
|
|
354
|
+
if (!clientState) {
|
|
355
|
+
throw new Error("Could not find client state for user");
|
|
356
|
+
}
|
|
257
357
|
|
|
258
|
-
|
|
259
|
-
label.setAttribute("style", `background-color: ${user.color}`);
|
|
260
|
-
label.insertBefore(document.createTextNode(user.name), null);
|
|
358
|
+
const clientID = clientState[0];
|
|
261
359
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
cursor.insertBefore(label, null);
|
|
266
|
-
cursor.insertBefore(nonbreakingSpace2, null);
|
|
267
|
-
return cursor;
|
|
360
|
+
return (
|
|
361
|
+
cursors.get(clientID) || createCursor(clientID, user.name, user.color)
|
|
362
|
+
).element;
|
|
268
363
|
};
|
|
269
364
|
tiptapExtensions.push(
|
|
270
365
|
CollaborationCursor.configure({
|
package/src/editor/editor.css
CHANGED
|
@@ -83,7 +83,6 @@ Tippy popups that are appended to document.body directly
|
|
|
83
83
|
border-right: 1px solid #0d0d0d;
|
|
84
84
|
margin-left: -1px;
|
|
85
85
|
margin-right: -1px;
|
|
86
|
-
pointer-events: none;
|
|
87
86
|
position: relative;
|
|
88
87
|
word-break: normal;
|
|
89
88
|
white-space: nowrap !important;
|
|
@@ -92,24 +91,40 @@ Tippy popups that are appended to document.body directly
|
|
|
92
91
|
/* Render the username above the caret */
|
|
93
92
|
.collaboration-cursor__label {
|
|
94
93
|
border-radius: 3px 3px 3px 0;
|
|
95
|
-
color: #0d0d0d;
|
|
96
94
|
font-size: 12px;
|
|
97
95
|
font-style: normal;
|
|
98
96
|
font-weight: 600;
|
|
99
|
-
left: -1px;
|
|
100
97
|
line-height: normal;
|
|
101
|
-
|
|
98
|
+
left: -1px;
|
|
99
|
+
overflow: hidden;
|
|
102
100
|
position: absolute;
|
|
103
|
-
top: -1.4em;
|
|
104
|
-
user-select: none;
|
|
105
101
|
white-space: nowrap;
|
|
102
|
+
|
|
103
|
+
color: transparent;
|
|
104
|
+
max-height: 4px;
|
|
105
|
+
max-width: 4px;
|
|
106
|
+
padding: 0;
|
|
107
|
+
top: 0;
|
|
108
|
+
|
|
109
|
+
transition: all 0.2s;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.collaboration-cursor__caret[data-active] > .collaboration-cursor__label {
|
|
114
|
+
color: #0d0d0d;
|
|
115
|
+
max-height: 1.1rem;
|
|
116
|
+
max-width: 20rem;
|
|
117
|
+
padding: 0.1rem 0.3rem;
|
|
118
|
+
top: -14px;
|
|
119
|
+
|
|
120
|
+
transition: all 0.2s;
|
|
106
121
|
}
|
|
107
122
|
|
|
108
123
|
/* .tableWrapper {
|
|
109
124
|
padding
|
|
110
125
|
} */
|
|
111
126
|
|
|
112
|
-
.
|
|
127
|
+
.bn-editor [data-content-type="table"] .tableWrapper {
|
|
113
128
|
position: relative;
|
|
114
129
|
top: -16px;
|
|
115
130
|
left: -16px;
|
|
@@ -119,7 +134,7 @@ Tippy popups that are appended to document.body directly
|
|
|
119
134
|
overflow-y: hidden;
|
|
120
135
|
}
|
|
121
136
|
|
|
122
|
-
.
|
|
137
|
+
.bn-editor [data-content-type="table"] .tableWrapper-inner {
|
|
123
138
|
/* position: relative; */
|
|
124
139
|
/* top: -16px;
|
|
125
140
|
left: -16px; */
|
|
@@ -127,17 +142,17 @@ Tippy popups that are appended to document.body directly
|
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
/* table related: */
|
|
130
|
-
.bn-editor table {
|
|
145
|
+
.bn-editor [data-content-type="table"] table {
|
|
131
146
|
width: auto !important;
|
|
132
147
|
word-break: break-word;
|
|
133
148
|
}
|
|
134
|
-
.bn-editor th,
|
|
135
|
-
.bn-editor td {
|
|
149
|
+
.bn-editor [data-content-type="table"] th,
|
|
150
|
+
.bn-editor [data-content-type="table"] td {
|
|
136
151
|
border: 1px solid #ddd;
|
|
137
|
-
padding:
|
|
152
|
+
padding: 5px 10px;
|
|
138
153
|
}
|
|
139
154
|
|
|
140
|
-
.bn-editor th {
|
|
155
|
+
.bn-editor [data-content-type="table"] th {
|
|
141
156
|
font-weight: bold;
|
|
142
157
|
text-align: left;
|
|
143
158
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Fragment, Schema, Slice } from "@tiptap/pm/model";
|
|
2
2
|
import { EditorView } from "@tiptap/pm/view";
|
|
3
3
|
|
|
4
|
+
import { getBlockInfoFromSelection } from "../api/getBlockInfoFromPos.js";
|
|
5
|
+
|
|
4
6
|
// helper function to remove a child from a fragment
|
|
5
7
|
function removeChild(node: Fragment, n: number) {
|
|
6
8
|
const children: any[] = [];
|
|
@@ -49,16 +51,25 @@ export function wrapTableRows(f: Fragment, schema: Schema) {
|
|
|
49
51
|
/**
|
|
50
52
|
* fix for https://github.com/ProseMirror/prosemirror/issues/1430#issuecomment-1822570821
|
|
51
53
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* This fix wraps pasted ProseMirror nodes in their own `blockContainer` nodes
|
|
55
|
+
* in most cases. This is to ensure that ProseMirror inserts them as separate
|
|
56
|
+
* blocks, which it sometimes doesn't do because it doesn't have enough context
|
|
57
|
+
* about the hierarchy of the pasted nodes. The issue can be seen when pasting
|
|
58
|
+
* e.g. an image or two consecutive paragraphs, where PM tries to nest the
|
|
59
|
+
* pasted block(s) when it shouldn't.
|
|
55
60
|
*
|
|
56
|
-
*
|
|
61
|
+
* However, the fix is not applied in a few cases. See `shouldApplyFix` for
|
|
62
|
+
* which cases are excluded.
|
|
57
63
|
*/
|
|
58
64
|
export function transformPasted(slice: Slice, view: EditorView) {
|
|
59
65
|
let f = Fragment.from(slice.content);
|
|
60
66
|
f = wrapTableRows(f, view.state.schema);
|
|
61
67
|
|
|
68
|
+
if (!shouldApplyFix(f, view)) {
|
|
69
|
+
// Don't apply the fix.
|
|
70
|
+
return new Slice(f, slice.openStart, slice.openEnd);
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
for (let i = 0; i < f.childCount; i++) {
|
|
63
74
|
if (f.child(i).type.spec.group === "blockContent") {
|
|
64
75
|
const content = [f.child(i)];
|
|
@@ -92,3 +103,45 @@ export function transformPasted(slice: Slice, view: EditorView) {
|
|
|
92
103
|
}
|
|
93
104
|
return new Slice(f, slice.openStart, slice.openEnd);
|
|
94
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Used in `transformPasted` to check if the fix there should be applied, i.e.
|
|
109
|
+
* if the pasted fragment should be wrapped in a `blockContainer` node. This
|
|
110
|
+
* will explicitly tell ProseMirror to treat it as a separate block.
|
|
111
|
+
*/
|
|
112
|
+
function shouldApplyFix(fragment: Fragment, view: EditorView) {
|
|
113
|
+
const nodeHasSingleChild = fragment.childCount === 1;
|
|
114
|
+
const nodeHasInlineContent =
|
|
115
|
+
fragment.firstChild?.type.spec.content === "inline*";
|
|
116
|
+
const nodeHasTableContent =
|
|
117
|
+
fragment.firstChild?.type.spec.content === "tableRow+";
|
|
118
|
+
|
|
119
|
+
if (nodeHasSingleChild) {
|
|
120
|
+
if (nodeHasInlineContent) {
|
|
121
|
+
// Case when we paste a single node with inline content, e.g. a paragraph
|
|
122
|
+
// or heading. We want to insert the content in-line for better UX instead
|
|
123
|
+
// of a separate block, so we return false.
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (nodeHasTableContent) {
|
|
128
|
+
// Not ideal that we check selection here, as `transformPasted` is called
|
|
129
|
+
// for both paste and drop events. Drop events can potentially cause
|
|
130
|
+
// issues as they don't always happen at the current selection.
|
|
131
|
+
const blockInfo = getBlockInfoFromSelection(view.state);
|
|
132
|
+
if (blockInfo.isBlockContainer) {
|
|
133
|
+
const selectedBlockHasTableContent =
|
|
134
|
+
blockInfo.blockContent.node.type.spec.content === "tableRow+";
|
|
135
|
+
|
|
136
|
+
// Case for when we paste a single node with table content, i.e. a
|
|
137
|
+
// table. Normally, we return true as we want to ensure the table is
|
|
138
|
+
// inserted as a separate block. However, if the selection is in an
|
|
139
|
+
// existing table, we return false, as we want the content of the pasted
|
|
140
|
+
// table to be added to the existing one for better UX.
|
|
141
|
+
return !selectedBlockHasTableContent;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return true;
|
|
147
|
+
}
|