@blocknote/core 0.55.0 → 0.56.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/BlockNoteExtension-DjEkXkR5.cjs +2 -0
- package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +1 -0
- package/dist/{BlockNoteExtension-CbvDA0F7.js → BlockNoteExtension-TsTGtIeX.js} +34 -27
- package/dist/BlockNoteExtension-TsTGtIeX.js.map +1 -0
- package/dist/{UserStore-mj3fXW4D.cjs → UserStore-CTVzVGh-.cjs} +2 -2
- package/dist/{UserStore-mj3fXW4D.cjs.map → UserStore-CTVzVGh-.cjs.map} +1 -1
- package/dist/{UserStore-C4TzkGEn.js → UserStore-OZJP3K8T.js} +2 -2
- package/dist/{UserStore-C4TzkGEn.js.map → UserStore-OZJP3K8T.js.map} +1 -1
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/blocks-COVwe5Cf.cjs +12 -0
- package/dist/blocks-COVwe5Cf.cjs.map +1 -0
- package/dist/{blocks-DaEUT0O1.js → blocks-COYcDVg7.js} +1572 -1156
- package/dist/blocks-COYcDVg7.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.js +12 -12
- package/dist/{en-BAn9gxr-.js → en-Ch-vvt5e.js} +36 -2
- package/dist/en-Ch-vvt5e.js.map +1 -0
- package/dist/en-N5lu0-j8.cjs +2 -0
- package/dist/en-N5lu0-j8.cjs.map +1 -0
- package/dist/extensions-BbM81hHa.js +3069 -0
- package/dist/extensions-BbM81hHa.js.map +1 -0
- package/dist/extensions-D_WkAfSt.cjs +58 -0
- package/dist/extensions-D_WkAfSt.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +771 -23
- package/dist/locales.js.map +1 -1
- package/dist/src-4OQT3z5S.cjs +23 -0
- package/dist/src-4OQT3z5S.cjs.map +1 -0
- package/dist/{src-D5w0XAHX.js → src-BmLsLZfE.js} +1390 -1278
- package/dist/src-BmLsLZfE.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +1284 -554
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +189 -148
- package/dist/yjs.js.map +1 -1
- package/package.json +8 -8
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +45 -6
- package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +217 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +113 -9
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +151 -163
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +47 -31
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +122 -181
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +256 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +80 -40
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +71 -0
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +39 -31
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +221 -8
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +40 -8
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +272 -40
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +138 -117
- package/src/api/blockManipulation/getBlock/getBlock.ts +4 -11
- package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +173 -0
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +293 -0
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +145 -0
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +783 -0
- package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +180 -0
- package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +365 -0
- package/src/api/blockManipulation/selections/selection.ts +20 -53
- package/src/api/blockManipulation/selections/textCursorPosition.ts +17 -72
- package/src/api/blockManipulation/setupTestEnv.ts +38 -6
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +4 -4
- package/src/api/clipboard/toClipboard/copyExtension.ts +3 -3
- package/src/api/combineTransactionSteps.ts +22 -0
- package/src/api/exporters/html/externalHTMLExporter.ts +1 -1
- package/src/api/exporters/html/internalHTMLSerializer.ts +4 -4
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +111 -36
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +51 -21
- package/src/api/exporters/markdown/htmlToMarkdown.ts +12 -1
- package/src/api/exporters/markdown/markdownExporter.ts +1 -1
- package/src/api/getBlockInfoFromPos.test.ts +428 -3
- package/src/api/getBlockInfoFromPos.ts +531 -129
- package/src/api/getBlocksChangedByTransaction.test.ts +7 -7
- package/src/api/getBlocksChangedByTransaction.ts +3 -3
- package/src/api/{getChangedRange.ts → getChangedRangeWithAttrs.ts} +2 -2
- package/src/api/getChangedRanges.test.ts +391 -0
- package/src/api/getChangedRanges.ts +368 -0
- package/src/api/nodeConversions/blockToNode.ts +44 -16
- package/src/api/nodeConversions/fragmentToBlocks.ts +29 -44
- package/src/api/nodeConversions/nodeToBlock.ts +120 -68
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/markdown/autolink.ts +23 -0
- package/src/api/parsers/markdown/markdownToHtml.ts +115 -11
- package/src/blocks/Code/block.test.ts +4 -4
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +6 -1
- package/src/blocks/Heading/block.ts +54 -15
- package/src/blocks/ListItem/BulletListItem/block.ts +6 -4
- package/src/blocks/ListItem/CheckListItem/block.test.ts +2 -2
- package/src/blocks/ListItem/CheckListItem/block.ts +6 -4
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +14 -17
- package/src/blocks/ListItem/NumberedListItem/block.ts +6 -4
- package/src/blocks/ListItem/ToggleListItem/block.ts +23 -12
- package/src/blocks/Table/block.ts +2 -10
- package/src/blocks/ToggleWrapper/createToggleFrame.ts +126 -0
- package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +1056 -0
- package/src/blocks/defaultBlockTypeItems.test.ts +70 -0
- package/src/blocks/defaultBlockTypeItems.ts +99 -0
- package/src/blocks/defaultBlocks.test.ts +67 -0
- package/src/blocks/defaultBlocks.ts +7 -1
- package/src/blocks/index.ts +2 -1
- package/src/editor/Block.css +286 -154
- package/src/editor/BlockNoteEditor.node.test.ts +35 -0
- package/src/editor/BlockNoteEditor.test.ts +2 -2
- package/src/editor/BlockNoteEditor.ts +71 -9
- package/src/editor/BlockNoteExtension.ts +5 -5
- package/src/editor/blockColors.browser.test.ts +127 -0
- package/src/editor/editor.css +60 -0
- package/src/editor/managers/BlockManager.ts +4 -3
- package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +45 -0
- package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +209 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +10 -1
- package/src/editor/managers/ExtensionManager/index.ts +135 -68
- package/src/editor/managers/StateManager.ts +14 -4
- package/src/editor/transformPasted.ts +14 -13
- package/src/exporter/Exporter.test.ts +70 -1
- package/src/exporter/Exporter.ts +34 -4
- package/src/exporter/mapping.ts +41 -10
- package/src/extensions/DropCursor/DropCursor.ts +119 -6
- package/src/extensions/DropCursor/dropIntoChildren.ts +80 -0
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +7 -1
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +190 -0
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +41 -4
- package/src/extensions/Placeholder/Placeholder.test.ts +23 -0
- package/src/extensions/Placeholder/Placeholder.ts +8 -7
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +36 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +8 -4
- package/src/extensions/ReadOnly/ReadOnly.test.ts +181 -0
- package/src/extensions/ReadOnly/ReadOnly.ts +73 -0
- package/src/extensions/SideMenu/SideMenu.ts +401 -764
- package/src/extensions/SideMenu/blockDropHandling.ts +372 -0
- package/src/extensions/SideMenu/blockGeometry.browser.test.ts +148 -0
- package/src/extensions/SideMenu/blockGeometry.test.ts +46 -0
- package/src/extensions/SideMenu/blockGeometry.ts +53 -0
- package/src/extensions/SideMenu/dragging.ts +19 -32
- package/src/extensions/SideMenu/sideMenuHover.test.ts +36 -0
- package/src/extensions/SideMenu/sideMenuHover.ts +270 -0
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +5 -4
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +10 -1
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +36 -136
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +14 -4
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +1 -1
- package/src/extensions/SyntaxHighlighting/shiki.ts +1 -1
- package/src/extensions/TableHandles/TableHandles.ts +4 -6
- package/src/extensions/Versioning/Versioning.browser.test.ts +151 -0
- package/src/extensions/Versioning/Versioning.node.test.ts +177 -0
- package/src/extensions/Versioning/Versioning.ts +145 -612
- package/src/extensions/Versioning/__test__/result.ts +12 -0
- package/src/extensions/Versioning/comparison.test.ts +40 -0
- package/src/extensions/Versioning/createVersioning.test.ts +867 -0
- package/src/extensions/Versioning/createVersioning.ts +499 -0
- package/src/extensions/Versioning/formatVersionDate.ts +24 -0
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +533 -430
- package/src/extensions/Versioning/inMemoryVersioning.ts +246 -251
- package/src/extensions/Versioning/index.ts +4 -0
- package/src/extensions/Versioning/scrollScheduling.test.ts +51 -0
- package/src/extensions/Versioning/scrollToFirstChange.test.ts +320 -0
- package/src/extensions/Versioning/scrollToFirstChange.ts +139 -0
- package/src/extensions/Versioning/types.ts +219 -0
- package/src/extensions/Versioning/versioningState.ts +154 -0
- package/src/extensions/blockDOM.browser.test.ts +102 -0
- package/src/extensions/blockDOM.test.ts +178 -0
- package/src/extensions/blockDOM.ts +135 -0
- package/src/extensions/index.ts +2 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +1719 -53
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +645 -531
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +152 -0
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +4 -9
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +10 -24
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +22 -19
- package/src/fonts/inter.browser.test.ts +57 -0
- package/src/fonts/inter.css +111 -0
- package/src/i18n/locales/ar.ts +32 -0
- package/src/i18n/locales/de.ts +32 -0
- package/src/i18n/locales/en.ts +32 -0
- package/src/i18n/locales/es.ts +32 -0
- package/src/i18n/locales/fa.ts +32 -0
- package/src/i18n/locales/fr.ts +32 -0
- package/src/i18n/locales/he.ts +32 -0
- package/src/i18n/locales/hr.ts +32 -0
- package/src/i18n/locales/is.ts +32 -0
- package/src/i18n/locales/it.ts +32 -0
- package/src/i18n/locales/ja.ts +32 -0
- package/src/i18n/locales/ko.ts +32 -0
- package/src/i18n/locales/nl.ts +32 -0
- package/src/i18n/locales/no.ts +32 -0
- package/src/i18n/locales/pl.ts +32 -0
- package/src/i18n/locales/pt.ts +32 -0
- package/src/i18n/locales/ru.ts +32 -0
- package/src/i18n/locales/sk.ts +32 -0
- package/src/i18n/locales/uk.ts +32 -0
- package/src/i18n/locales/uz.ts +32 -0
- package/src/i18n/locales/vi.ts +32 -0
- package/src/i18n/locales/zh-tw.ts +32 -0
- package/src/i18n/locales/zh.ts +32 -0
- package/src/index.ts +13 -3
- package/src/pm-nodes/BlockContainer.test.ts +101 -0
- package/src/pm-nodes/BlockContainer.ts +110 -1
- package/src/pm-nodes/BlockGroup.ts +2 -1
- package/src/pm-nodes/README.md +2 -0
- package/src/schema/blocks/children.test.ts +288 -0
- package/src/schema/blocks/children.ts +136 -0
- package/src/schema/blocks/createSpec.browser.test.ts +176 -0
- package/src/schema/blocks/createSpec.test.ts +231 -0
- package/src/schema/blocks/createSpec.ts +493 -267
- package/src/schema/blocks/frame.test.ts +112 -0
- package/src/schema/blocks/frame.ts +337 -0
- package/src/schema/blocks/internal.ts +50 -17
- package/src/schema/blocks/keyboard.ts +154 -0
- package/src/schema/blocks/layoutBlockAttributes.ts +29 -0
- package/src/schema/blocks/meta.test.ts +53 -0
- package/src/schema/blocks/meta.ts +35 -0
- package/src/schema/blocks/renderFrame.test.ts +691 -0
- package/src/schema/blocks/types.ts +285 -21
- package/src/schema/blocks/validateChildren.ts +156 -0
- package/src/schema/dataAttributes.test.ts +72 -0
- package/src/schema/dataAttributes.ts +69 -0
- package/src/schema/index.ts +3 -0
- package/src/schema/inlineContent/internal.ts +7 -12
- package/src/schema/markGroups.ts +34 -2
- package/src/schema/schema.ts +8 -1
- package/src/user/userColors.test.ts +108 -0
- package/src/user/userColors.ts +42 -13
- package/src/y/comments/RESTYjsThreadStore.ts +1 -1
- package/src/y/comments/YjsThreadStore.test.ts +1 -1
- package/src/y/comments/YjsThreadStore.ts +27 -27
- package/src/y/comments/YjsThreadStoreBase.ts +2 -2
- package/src/y/comments/yjsHelpers.ts +11 -11
- package/src/y/extensions/AttributionExtension.test.ts +271 -2
- package/src/y/extensions/AttributionExtension.ts +146 -123
- package/src/y/extensions/DiffVersioningExtension.test.ts +67 -18
- package/src/y/extensions/DiffVersioningExtension.ts +95 -123
- package/src/y/extensions/EmptyDocBinding.test.ts +282 -0
- package/src/y/extensions/ForkYDoc.node.test.ts +77 -0
- package/src/y/extensions/ForkYDoc.test.ts +93 -2
- package/src/y/extensions/ForkYDoc.ts +22 -13
- package/src/y/extensions/History.test.ts +125 -0
- package/src/y/extensions/RelativePositionMapping.test.ts +35 -0
- package/src/y/extensions/RelativePositionMapping.ts +7 -11
- package/src/y/extensions/Versioning.node.test.ts +126 -0
- package/src/y/extensions/Versioning.test.ts +110 -401
- package/src/y/extensions/Versioning.ts +66 -107
- package/src/y/extensions/YAttributionMarks.ts +111 -9
- package/src/y/extensions/YCursorPlugin.ts +3 -0
- package/src/y/extensions/YSync.node.test.ts +75 -0
- package/src/y/extensions/YSync.ts +76 -4
- package/src/y/extensions/YSyncRemount.test.ts +99 -0
- package/src/y/extensions/blockMatchNodes.ts +20 -29
- package/src/y/extensions/index.ts +10 -26
- package/src/y/extensions/legacyYjsDocBinding.test.ts +652 -0
- package/src/y/extensions/nestingChanges.test.ts +326 -0
- package/src/y/extensions/persistentBlockGroups.test.ts +1709 -0
- package/src/y/extensions/persistentBlockGroups.ts +953 -0
- package/src/y/extensions/snapshotCodec.test.ts +105 -0
- package/src/y/extensions/snapshotCodec.ts +39 -0
- package/src/y/extensions/snapshotPreview.test.ts +201 -0
- package/src/y/extensions/snapshotPreview.ts +292 -0
- package/src/y/extensions/tableReshape.test.ts +121 -0
- package/src/y/extensions/v1BindingSnapshotDiff.test.ts +121 -0
- package/src/y/extensions/versionDiffAttribution.test.ts +944 -0
- package/src/y/extensions/versionDiffPerformance.test.ts +101 -0
- package/src/y/index.ts +1 -0
- package/src/y/utils.test.ts +289 -22
- package/src/y/utils.ts +167 -43
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +5 -5
- package/src/y/versioning/__test__/fixtures/activity-all.json +3 -3
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +2 -2
- package/src/y/versioning/__test__/yhub.test.ts +902 -721
- package/src/y/versioning/index.ts +6 -1
- package/src/y/versioning/yhub.ts +316 -603
- package/src/y/versioning/yhubClient.ts +345 -0
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +10 -0
- package/src/yjs/extensions/FixUpSchema.ts +11 -0
- package/src/yjs/extensions/ForkYDoc.browser.test.ts +84 -0
- package/src/yjs/extensions/ForkYDoc.node.test.ts +231 -0
- package/src/yjs/extensions/ForkYDoc.test.ts +68 -1
- package/src/yjs/extensions/ForkYDoc.ts +57 -39
- package/src/yjs/extensions/Versioning.test.ts +345 -530
- package/src/yjs/extensions/Versioning.ts +111 -68
- package/src/yjs/extensions/index.ts +1 -1
- package/src/yjs/index.ts +4 -0
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -1
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +24 -24
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +3 -2
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -2
- package/types/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.d.ts +34 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +1 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +460 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +15 -69
- package/types/src/api/combineTransactionSteps.d.ts +12 -0
- package/types/src/api/getBlockInfoFromPos.d.ts +218 -44
- package/types/src/api/{getChangedRange.d.ts → getChangedRangeWithAttrs.d.ts} +1 -1
- package/types/src/api/getChangedRanges.d.ts +23 -0
- package/types/src/api/getChangedRanges.test.d.ts +1 -0
- package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +0 -3
- package/types/src/api/parsers/markdown/autolink.d.ts +5 -0
- package/types/src/blocks/ToggleWrapper/createToggleFrame.d.ts +29 -0
- package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +1 -0
- package/types/src/blocks/defaultBlockTypeItems.d.ts +37 -0
- package/types/src/blocks/defaultBlockTypeItems.test.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.test.d.ts +1 -0
- package/types/src/blocks/index.d.ts +2 -1
- package/types/src/editor/BlockNoteEditor.d.ts +36 -8
- package/types/src/editor/BlockNoteEditor.node.test.d.ts +1 -0
- package/types/src/editor/blockColors.browser.test.d.ts +1 -0
- package/types/src/editor/managers/BlockManager.d.ts +4 -3
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +1 -0
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +1 -0
- package/types/src/editor/managers/ExtensionManager/index.d.ts +15 -3
- package/types/src/editor/managers/StateManager.d.ts +1 -1
- package/types/src/editor/transformPasted.d.ts +1 -1
- package/types/src/exporter/Exporter.d.ts +11 -4
- package/types/src/exporter/mapping.d.ts +13 -1
- package/types/src/extensions/DropCursor/DropCursor.d.ts +1 -1
- package/types/src/extensions/DropCursor/dropIntoChildren.d.ts +38 -0
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +1 -1
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +1 -0
- package/types/src/extensions/Placeholder/Placeholder.test.d.ts +1 -0
- package/types/src/extensions/ReadOnly/ReadOnly.d.ts +21 -0
- package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/SideMenu.d.ts +49 -88
- package/types/src/extensions/SideMenu/blockDropHandling.d.ts +11 -0
- package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/blockGeometry.d.ts +22 -0
- package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/dragging.d.ts +0 -4
- package/types/src/extensions/SideMenu/sideMenuHover.d.ts +58 -0
- package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +1 -0
- package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +1 -0
- package/types/src/extensions/Versioning/Versioning.d.ts +34 -311
- package/types/src/extensions/Versioning/Versioning.node.test.d.ts +1 -0
- package/types/src/extensions/Versioning/__test__/result.d.ts +3 -0
- package/types/src/extensions/Versioning/comparison.test.d.ts +1 -0
- package/types/src/extensions/Versioning/createVersioning.d.ts +32 -0
- package/types/src/extensions/Versioning/createVersioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/formatVersionDate.d.ts +7 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +64 -36
- package/types/src/extensions/Versioning/index.d.ts +4 -0
- package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +1 -0
- package/types/src/extensions/Versioning/scrollToFirstChange.d.ts +18 -0
- package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +1 -0
- package/types/src/extensions/Versioning/types.d.ts +239 -0
- package/types/src/extensions/Versioning/versioningState.d.ts +43 -0
- package/types/src/extensions/blockDOM.browser.test.d.ts +1 -0
- package/types/src/extensions/blockDOM.d.ts +37 -0
- package/types/src/extensions/blockDOM.test.d.ts +1 -0
- package/types/src/extensions/index.d.ts +2 -0
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +3 -0
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +1 -0
- package/types/src/fonts/inter.browser.test.d.ts +2 -0
- package/types/src/i18n/locales/en.d.ts +32 -0
- package/types/src/i18n/locales/fa.d.ts +32 -0
- package/types/src/i18n/locales/sk.d.ts +32 -0
- package/types/src/index.d.ts +6 -3
- package/types/src/pm-nodes/BlockContainer.d.ts +6 -0
- package/types/src/pm-nodes/BlockContainer.test.d.ts +1 -0
- package/types/src/schema/blocks/children.d.ts +39 -0
- package/types/src/schema/blocks/children.test.d.ts +1 -0
- package/types/src/schema/blocks/createSpec.browser.test.d.ts +1 -0
- package/types/src/schema/blocks/createSpec.d.ts +13 -0
- package/types/src/schema/blocks/frame.d.ts +109 -0
- package/types/src/schema/blocks/frame.test.d.ts +1 -0
- package/types/src/schema/blocks/internal.d.ts +6 -0
- package/types/src/schema/blocks/keyboard.d.ts +111 -0
- package/types/src/schema/blocks/layoutBlockAttributes.d.ts +9 -0
- package/types/src/schema/blocks/meta.d.ts +14 -0
- package/types/src/schema/blocks/meta.test.d.ts +1 -0
- package/types/src/schema/blocks/renderFrame.test.d.ts +1 -0
- package/types/src/schema/blocks/types.d.ts +228 -15
- package/types/src/schema/blocks/validateChildren.d.ts +5 -0
- package/types/src/schema/dataAttributes.d.ts +19 -0
- package/types/src/schema/dataAttributes.test.d.ts +1 -0
- package/types/src/schema/index.d.ts +3 -0
- package/types/src/schema/markGroups.d.ts +8 -0
- package/types/src/user/userColors.d.ts +24 -3
- package/types/src/user/userColors.test.d.ts +1 -0
- package/types/src/y/comments/RESTYjsThreadStore.d.ts +1 -1
- package/types/src/y/comments/YjsThreadStore.d.ts +1 -1
- package/types/src/y/comments/YjsThreadStoreBase.d.ts +2 -2
- package/types/src/y/comments/yjsHelpers.d.ts +5 -5
- package/types/src/y/extensions/AttributionExtension.d.ts +19 -21
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +9 -4
- package/types/src/y/extensions/EmptyDocBinding.test.d.ts +1 -0
- package/types/src/y/extensions/ForkYDoc.d.ts +3 -1
- package/types/src/y/extensions/ForkYDoc.node.test.d.ts +1 -0
- package/types/src/y/extensions/History.test.d.ts +1 -0
- package/types/src/y/extensions/Versioning.d.ts +4 -15
- package/types/src/y/extensions/Versioning.node.test.d.ts +1 -0
- package/types/src/y/extensions/YAttributionMarks.d.ts +13 -2
- package/types/src/y/extensions/YCursorPlugin.d.ts +1 -0
- package/types/src/y/extensions/YSync.d.ts +4 -18
- package/types/src/y/extensions/YSync.node.test.d.ts +1 -0
- package/types/src/y/extensions/YSyncRemount.test.d.ts +1 -0
- package/types/src/y/extensions/blockMatchNodes.d.ts +0 -22
- package/types/src/y/extensions/index.d.ts +27 -44
- package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +1 -0
- package/types/src/y/extensions/nestingChanges.test.d.ts +1 -0
- package/types/src/y/extensions/persistentBlockGroups.d.ts +189 -0
- package/types/src/y/extensions/persistentBlockGroups.test.d.ts +1 -0
- package/types/src/y/extensions/snapshotCodec.d.ts +13 -0
- package/types/src/y/extensions/snapshotCodec.test.d.ts +1 -0
- package/types/src/y/extensions/snapshotPreview.d.ts +21 -0
- package/types/src/y/extensions/snapshotPreview.test.d.ts +1 -0
- package/types/src/y/extensions/tableReshape.test.d.ts +1 -0
- package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +1 -0
- package/types/src/y/extensions/versionDiffAttribution.test.d.ts +1 -0
- package/types/src/y/extensions/versionDiffPerformance.test.d.ts +1 -0
- package/types/src/y/index.d.ts +1 -0
- package/types/src/y/utils.d.ts +39 -19
- package/types/src/y/versioning/index.d.ts +1 -1
- package/types/src/y/versioning/yhub.d.ts +69 -86
- package/types/src/y/versioning/yhubClient.d.ts +67 -0
- package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +2 -0
- package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +1 -0
- package/types/src/yjs/extensions/Versioning.d.ts +36 -22
- package/types/src/yjs/extensions/index.d.ts +2 -1
- package/types/src/yjs/index.d.ts +1 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +0 -2
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +0 -1
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +0 -1
- package/dist/blocks-DLgTreVu.cjs +0 -12
- package/dist/blocks-DLgTreVu.cjs.map +0 -1
- package/dist/blocks-DaEUT0O1.js.map +0 -1
- package/dist/en-BAn9gxr-.js.map +0 -1
- package/dist/en-CHnrV5l8.cjs +0 -2
- package/dist/en-CHnrV5l8.cjs.map +0 -1
- package/dist/extensions-B1JQURVF.js +0 -2138
- package/dist/extensions-B1JQURVF.js.map +0 -1
- package/dist/extensions-CZkqKzJO.cjs +0 -58
- package/dist/extensions-CZkqKzJO.cjs.map +0 -1
- package/dist/src-D5w0XAHX.js.map +0 -1
- package/dist/src-th5uZEvx.cjs +0 -23
- package/dist/src-th5uZEvx.cjs.map +0 -1
- package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +0 -173
- package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +0 -63
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +0 -197
- package/src/blocks/utils/listItemEnterHandler.ts +0 -43
- package/src/extensions/Versioning/Versioning.test.ts +0 -435
- package/src/extensions/getDraggableBlockFromElement.ts +0 -19
- package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +0 -32
- package/types/src/blocks/ListItem/ListItemKeyboardShortcuts.d.ts +0 -2
- package/types/src/blocks/ToggleWrapper/createToggleWrapper.d.ts +0 -15
- package/types/src/blocks/utils/listItemEnterHandler.d.ts +0 -2
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +0 -5
- /package/types/src/{extensions/Versioning/Versioning.test.d.ts → api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts} +0 -0
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { At as e,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { r as
|
|
5
|
-
import { t as
|
|
6
|
-
import { DOMParser as
|
|
7
|
-
import { ReplaceAroundStep as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { CellSelection as
|
|
12
|
-
import { Plugin as
|
|
13
|
-
import { digestString as
|
|
14
|
-
import { InputRule as
|
|
15
|
-
import { keydownHandler as
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Gapcursor as
|
|
1
|
+
import { At as e, Cr as t, Dn as n, Dr as r, En as i, Er as a, Fr as o, Gn as s, Hn as c, Ht as l, Ir as u, Mn as d, Mr as f, Nr as p, On as m, Or as h, Ot as g, Pn as _, Pr as v, Qt as ee, Sr as te, St as ne, Tn as re, Tr as y, Un as ie, Xt as ae, Zt as oe, _n as se, _r as ce, bn as le, br as b, dr as ue, er as de, f as fe, fn as pe, fr as me, gn as he, gr as ge, hn as _e, hr as ve, kn as ye, kr as x, kt as S, m as be, mr as xe, pr as Se, t as Ce, tr as C, vr as w, wn as we, wr as Te, wt as Ee, xn as De, xr as T, yr as E, yt as Oe } from "./blocks-COYcDVg7.js";
|
|
2
|
+
import { r as ke, s as Ae, t as je } from "./BlockNoteExtension-TsTGtIeX.js";
|
|
3
|
+
import { C as Me, D as Ne, E as Pe, I as Fe, L as Ie, M as Le, N as Re, O as ze, P as Be, R as Ve, S as He, T as Ue, U as D, V as We, _ as Ge, b as Ke, g as qe, k as Je, l as Ye, u as Xe, v as Ze, w as Qe, x as $e, z as et } from "./extensions-BbM81hHa.js";
|
|
4
|
+
import { r as tt } from "./UserStore-OZJP3K8T.js";
|
|
5
|
+
import { t as nt } from "./en-Ch-vvt5e.js";
|
|
6
|
+
import { DOMParser as rt, DOMSerializer as it, Fragment as O, NodeRange as at, Slice as k } from "prosemirror-model";
|
|
7
|
+
import { ReplaceAroundStep as ot, ReplaceStep as st, canJoin as ct, liftTarget as lt } from "prosemirror-transform";
|
|
8
|
+
import { NodeSelection as A, Plugin as j, Selection as M, TextSelection as N } from "prosemirror-state";
|
|
9
|
+
import { DOMParser as ut, Fragment as P, Slice as F } from "@tiptap/pm/model";
|
|
10
|
+
import { Editor as dt, Extension as I, Mark as ft, Node as L, createDocument as pt, extensions as R, findChildrenInRange as mt, findParentNodeClosestToPos as ht, getAttributes as gt, getMarkRange as _t, getMarksBetween as vt, getSchema as yt, isNodeSelection as bt, markPasteRule as xt, mergeAttributes as St, posToDOMRect as Ct, selectionToInsertionEnd as wt } from "@tiptap/core";
|
|
11
|
+
import { CellSelection as z, TableMap as Tt } from "prosemirror-tables";
|
|
12
|
+
import { Plugin as B, PluginKey as V } from "@tiptap/pm/state";
|
|
13
|
+
import { digestString as Et } from "lib0/hash/fnv1a";
|
|
14
|
+
import { InputRule as Dt, inputRules as Ot } from "@handlewithcare/prosemirror-inputrules";
|
|
15
|
+
import { keydownHandler as kt } from "@tiptap/pm/keymap";
|
|
16
|
+
import { Text as At } from "@tiptap/extension-text";
|
|
17
|
+
import { Gapcursor as jt } from "@tiptap/extensions/gap-cursor";
|
|
18
18
|
//#region src/schema/blocks/types.ts
|
|
19
|
-
function
|
|
19
|
+
function Mt(e) {
|
|
20
20
|
return typeof e == "string" ? e : e.map((e) => typeof e == "string" ? e : e.text).join("");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/schema/inlineContent/createSpec.ts
|
|
24
|
-
function
|
|
24
|
+
function Nt(e) {
|
|
25
25
|
return e.matches("[data-editable]") ? e : e.querySelector("[data-editable]") || e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function Pt(e, t) {
|
|
28
|
+
return ut.fromSchema(t).parse(e, {
|
|
29
29
|
topNode: t.nodes.paragraph.create(),
|
|
30
30
|
preserveWhitespace: !0
|
|
31
31
|
}).content;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function Ft(e, t) {
|
|
34
34
|
let n = [];
|
|
35
35
|
return e.forEach((e) => {
|
|
36
36
|
if (e.isText) n.push(e);
|
|
@@ -40,19 +40,19 @@ function yt(e, t) {
|
|
|
40
40
|
}
|
|
41
41
|
}), P.fromArray(n);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function It(e, t, n) {
|
|
44
44
|
let r = e.content === "plain" || n && e.content === "styled" ? (t) => (r, i) => {
|
|
45
45
|
let a = n?.({
|
|
46
46
|
el: r,
|
|
47
47
|
schema: i
|
|
48
48
|
});
|
|
49
|
-
if (a !== void 0) return e.content === "plain" ?
|
|
50
|
-
let o =
|
|
51
|
-
return e.content === "plain" ?
|
|
49
|
+
if (a !== void 0) return e.content === "plain" ? Ft(a, i) : a;
|
|
50
|
+
let o = Pt(t(r), i);
|
|
51
|
+
return e.content === "plain" ? Ft(o, i) : o;
|
|
52
52
|
} : void 0, i = [{
|
|
53
53
|
tag: `[data-inline-content-type="${e.type}"]`,
|
|
54
|
-
contentElement: (e) =>
|
|
55
|
-
getContent: r ? (e, t) => r(
|
|
54
|
+
contentElement: (e) => Nt(e),
|
|
55
|
+
getContent: r ? (e, t) => r(Nt)(e, t) : void 0
|
|
56
56
|
}];
|
|
57
57
|
return t && i.push({
|
|
58
58
|
tag: "*",
|
|
@@ -65,8 +65,8 @@ function bt(e, t, n) {
|
|
|
65
65
|
getContent: r ? (e, t) => r((e) => e)(e, t) : void 0
|
|
66
66
|
}), i;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
let n =
|
|
68
|
+
function Lt(e, t) {
|
|
69
|
+
let n = L.create({
|
|
70
70
|
name: e.type,
|
|
71
71
|
inline: !0,
|
|
72
72
|
group: "inline",
|
|
@@ -76,283 +76,529 @@ function xt(e, t) {
|
|
|
76
76
|
code: t.meta?.code,
|
|
77
77
|
content: e.content === "styled" ? "inline*" : e.content === "plain" ? "text*" : "",
|
|
78
78
|
marks() {
|
|
79
|
-
return e.content === "plain" ?
|
|
79
|
+
return e.content === "plain" ? Ae(this.editor) : void 0;
|
|
80
80
|
},
|
|
81
81
|
addAttributes() {
|
|
82
|
-
return
|
|
82
|
+
return pe(e.propSchema);
|
|
83
83
|
},
|
|
84
84
|
addKeyboardShortcuts() {
|
|
85
|
-
return
|
|
85
|
+
return oe(e);
|
|
86
86
|
},
|
|
87
87
|
parseHTML() {
|
|
88
|
-
return
|
|
88
|
+
return It(e, t.parse, t.parseContent);
|
|
89
89
|
},
|
|
90
90
|
renderHTML({ node: n }) {
|
|
91
91
|
let r = this.options.editor, i = t.render.call({
|
|
92
92
|
renderType: "dom",
|
|
93
93
|
props: void 0
|
|
94
|
-
},
|
|
95
|
-
return
|
|
94
|
+
}, m(n, r.schema.inlineContentSchema, r.schema.styleSchema), () => {}, r, n, () => void 0);
|
|
95
|
+
return ae(i, e.type, n.attrs, e.propSchema);
|
|
96
96
|
},
|
|
97
97
|
addNodeView() {
|
|
98
98
|
return (n) => {
|
|
99
|
-
let { node: r, getPos: i } = n,
|
|
99
|
+
let { node: r, getPos: i } = n, a = this.options.editor, o = t.render.call({
|
|
100
100
|
renderType: "nodeView",
|
|
101
101
|
props: n
|
|
102
|
-
},
|
|
103
|
-
let t =
|
|
104
|
-
n &&
|
|
105
|
-
},
|
|
106
|
-
return
|
|
102
|
+
}, m(r, a.schema.inlineContentSchema, a.schema.styleSchema), (e) => {
|
|
103
|
+
let t = S([e], a.pmSchema), n = i();
|
|
104
|
+
n && a.transact((e) => e.replaceWith(n, n + r.nodeSize, t));
|
|
105
|
+
}, a, r, i), s = ae(o, e.type, r.attrs, e.propSchema);
|
|
106
|
+
return ie(s), s;
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
return
|
|
110
|
+
return ee(n, e.propSchema, {
|
|
111
111
|
...t,
|
|
112
112
|
toExternalHTML: t.toExternalHTML,
|
|
113
113
|
render(n, r, i) {
|
|
114
|
-
let
|
|
115
|
-
return
|
|
114
|
+
let a = S([n], i.pmSchema)[0], o = t.render(n, r, i, a, () => void 0);
|
|
115
|
+
return ae(o, e.type, n.props, e.propSchema);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
121
|
-
function
|
|
122
|
-
let
|
|
123
|
-
let t =
|
|
121
|
+
function H(e, r, i, a = "before") {
|
|
122
|
+
let o = typeof i == "string" ? i : i.id, s = _(e), c = r.map((e) => {
|
|
123
|
+
let t = g(e, s);
|
|
124
124
|
return t.check(), t;
|
|
125
|
-
}), l =
|
|
126
|
-
if (!l) throw Error(`Block with ID ${
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
}), l = D(o, e.doc);
|
|
126
|
+
if (!l) throw Error(`Block with ID ${o} not found`);
|
|
127
|
+
if (c.length === 0) return [];
|
|
128
|
+
let u = t(e.doc, w(e.doc, l.posBeforeNode), a, c[0].type);
|
|
129
|
+
if (!u) throw Error(`Cannot insert blocks at "${a}" of block "${o}": no valid position for them`);
|
|
130
|
+
if (u.wrapIn && !u.wrapIn.validContent(O.from(c))) throw Error(`Cannot insert blocks at "${a}" of block "${o}": a "${u.wrapIn.name}" doesn't accept them`);
|
|
131
|
+
let d = u.wrapIn ? O.from(u.wrapIn.create(null, c)) : O.from(c), f = e.doc.resolve(u.pos);
|
|
132
|
+
if (!f.parent.canReplace(f.index(), f.index(), d)) throw Error(`Cannot insert blocks at "${a}" of block "${o}": a "${f.parent.type.name}" doesn't accept them`);
|
|
133
|
+
return e.step(new st(u.pos, u.pos, new k(d, 0, 0))), c.map((t) => n(t, e.doc));
|
|
129
134
|
}
|
|
130
135
|
//#endregion
|
|
131
|
-
//#region src/api/blockManipulation/
|
|
132
|
-
function
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
let n = t.firstChild;
|
|
137
|
-
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
138
|
-
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
139
|
-
}
|
|
140
|
-
function St(e, t) {
|
|
141
|
-
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
142
|
-
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
143
|
-
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
144
|
-
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
145
|
-
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
146
|
-
R(i) && e.delete(r, r + i.nodeSize);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function z(e, t) {
|
|
150
|
-
St(e, t);
|
|
151
|
-
let n = e.doc.resolve(t).nodeAfter;
|
|
152
|
-
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
153
|
-
if (n.childCount > 2) return;
|
|
154
|
-
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
155
|
-
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
156
|
-
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
157
|
-
let s = R(i), c = R(o);
|
|
158
|
-
if (s && c) {
|
|
159
|
-
e.delete(t, t + n.nodeSize);
|
|
160
|
-
return;
|
|
136
|
+
//#region src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts
|
|
137
|
+
function U(e) {
|
|
138
|
+
if (e.type.name === "blockContainer") {
|
|
139
|
+
let t = e.firstChild;
|
|
140
|
+
return e.childCount === 1 && !!t && t.type.name === "paragraph" && t.childCount === 0;
|
|
161
141
|
}
|
|
162
|
-
|
|
163
|
-
|
|
142
|
+
return v(e.type) ? e.childCount === 1 ? U(e.firstChild) : e.childCount === 0 && u(e.type.spec.blockConfig?.children) >= 1 : !1;
|
|
143
|
+
}
|
|
144
|
+
function Rt(e, t) {
|
|
145
|
+
let n = e.doc.resolve(t).nodeAfter;
|
|
146
|
+
if (!n || !v(n.type)) throw Error("Invalid layoutBlockPos: does not point to a layout block node.");
|
|
147
|
+
if (o(n.type)) return;
|
|
148
|
+
let r = n.type.spec.blockConfig?.children;
|
|
149
|
+
if (r && "dissolve" in r && r.dissolve === !1) return;
|
|
150
|
+
let i = u(n.type.spec.blockConfig?.children), a = [], s = [];
|
|
151
|
+
if (n.forEach((e, n) => {
|
|
152
|
+
if (!U(e)) a.push({
|
|
153
|
+
node: e,
|
|
154
|
+
offset: n
|
|
155
|
+
});
|
|
156
|
+
else if (v(e.type)) {
|
|
157
|
+
let r = t + 1 + n;
|
|
158
|
+
s.push({
|
|
159
|
+
from: r,
|
|
160
|
+
to: r + e.nodeSize
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}), a.length >= i) {
|
|
164
|
+
for (let { from: t, to: n } of s.reverse()) e.delete(t, n);
|
|
164
165
|
return;
|
|
165
166
|
}
|
|
166
|
-
if (
|
|
167
|
-
|
|
167
|
+
if (a.length === 1) {
|
|
168
|
+
let [{ node: r, offset: i }] = a, s = t + 1 + i, c = o(r.type) ? {
|
|
169
|
+
from: s + 1,
|
|
170
|
+
to: s + r.nodeSize - 1
|
|
171
|
+
} : {
|
|
172
|
+
from: s,
|
|
173
|
+
to: s + r.nodeSize
|
|
174
|
+
};
|
|
175
|
+
e.step(new ot(t, t + n.nodeSize, c.from, c.to, k.empty, 0, !1));
|
|
168
176
|
return;
|
|
169
177
|
}
|
|
178
|
+
let c = [];
|
|
179
|
+
for (let { node: e } of a) o(e.type) ? e.forEach((e) => c.push(e)) : c.push(e);
|
|
180
|
+
e.replaceWith(t, t + n.nodeSize, O.from(c));
|
|
181
|
+
}
|
|
182
|
+
function zt(e, t) {
|
|
183
|
+
[...t].sort((e, t) => t.depth - e.depth).forEach(({ id: t }) => {
|
|
184
|
+
let n = D(t, e.doc);
|
|
185
|
+
n && v(n.node.type) && Rt(e, n.posBeforeNode);
|
|
186
|
+
});
|
|
170
187
|
}
|
|
171
188
|
//#endregion
|
|
172
189
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
173
|
-
function
|
|
174
|
-
let
|
|
175
|
-
let t =
|
|
190
|
+
function W(e, t, i, a = {}) {
|
|
191
|
+
let o = _(e), s = i.map((e) => {
|
|
192
|
+
let t = g(e, o);
|
|
176
193
|
return t.check(), t;
|
|
177
|
-
}),
|
|
178
|
-
if (e.doc.descendants((t,
|
|
179
|
-
if (
|
|
194
|
+
}), c = new Set(t.map((e) => typeof e == "string" ? e : e.id)), l = [], u = [], d = typeof t[0] == "string" ? t[0] : t[0].id, f = e.steps.length, p = (t) => e.mapping.slice(f).map(t);
|
|
195
|
+
if (e.doc.descendants((t, a) => {
|
|
196
|
+
if (c.size === 0) return !1;
|
|
180
197
|
if (!t.type.isInGroup("bnBlock")) return !0;
|
|
181
|
-
let
|
|
182
|
-
if (!
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
let
|
|
190
|
-
f.node().type.name === "column" ? l.add(f.before(-1)) : f.node().type.name === "columnList" && l.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(r - d, r - d + t.nodeSize);
|
|
191
|
-
let p = e.doc.nodeSize;
|
|
192
|
-
return d += a - p, !1;
|
|
193
|
-
}), s.size > 0) {
|
|
194
|
-
let e = [...s].join("\n");
|
|
198
|
+
let o = r(t, e.doc);
|
|
199
|
+
if (!c.has(o)) return !0;
|
|
200
|
+
l.push(n(t, e.doc)), c.delete(o), i.length > 0 && o === d && e.insert(p(a), s);
|
|
201
|
+
let f = e.doc.resolve(p(a));
|
|
202
|
+
for (let e of ce(f.doc, f.pos)) u.some((t) => t.id === e.id) || u.push(e);
|
|
203
|
+
let m = f.node();
|
|
204
|
+
return m.type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && m.childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(f.pos, f.pos + t.nodeSize), !1;
|
|
205
|
+
}), c.size > 0) {
|
|
206
|
+
let e = [...c].join("\n");
|
|
195
207
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
196
208
|
}
|
|
197
|
-
return
|
|
198
|
-
insertedBlocks:
|
|
199
|
-
removedBlocks:
|
|
209
|
+
return a.fixLayoutBlocks !== !1 && zt(e, u), {
|
|
210
|
+
insertedBlocks: s.map((t) => n(t, e.doc)),
|
|
211
|
+
removedBlocks: l
|
|
200
212
|
};
|
|
201
213
|
}
|
|
202
214
|
//#endregion
|
|
215
|
+
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
|
|
216
|
+
var G = (e, t) => ({ tr: n, dispatch: r }) => (r && K(n, e, t), !0);
|
|
217
|
+
function K(e, t, r, i, a) {
|
|
218
|
+
let o = e.mapping.maps.length, s = w(e.doc, t), c = s.hasContent && s.blockNoteType === "table" ? Gt(e) : null, l = _(e);
|
|
219
|
+
if (i !== void 0 && a !== void 0 && i > a) throw Error("Invalid replaceFromPos or replaceToPos");
|
|
220
|
+
let u = r.type || s.blockNoteType, f = l.nodes[u], p = f.isInGroup("bnBlock") ? f : l.nodes.blockContainer, m = s.hasContent && i !== void 0 && i >= s.contentStart && i <= s.contentEnd ? i - s.contentStart : void 0, h = s.hasContent && a !== void 0 && a >= s.contentStart && a <= s.contentEnd ? a - s.contentStart : void 0;
|
|
221
|
+
if (s.hasContent !== f.isInGroup("blockContent") || !s.hasContent && !f.validContent(s.block.node.content)) {
|
|
222
|
+
let t = n(s.block.node, e.doc), i = d(l)[u], a, o = [...t.children];
|
|
223
|
+
Array.isArray(t.content) && t.content.length && (i.content === "inline" || i.content === "plain" ? a = t.content : v(f) && o.unshift({
|
|
224
|
+
type: "paragraph",
|
|
225
|
+
content: t.content
|
|
226
|
+
}));
|
|
227
|
+
let c = g({
|
|
228
|
+
id: t.id,
|
|
229
|
+
...a ? { content: a } : {},
|
|
230
|
+
...o.length > 0 ? { children: o } : {},
|
|
231
|
+
...r
|
|
232
|
+
}, l);
|
|
233
|
+
c.check();
|
|
234
|
+
let p = e.doc.resolve(s.block.beforePos);
|
|
235
|
+
if (!p.parent.canReplace(p.index(), p.index(), O.from(c))) throw Error(`Cannot update block to "${u}": a "${p.parent.type.name}" doesn't accept it`);
|
|
236
|
+
e.replaceWith(s.block.beforePos, s.block.afterPos, c);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
Ut(r, e, s), s.hasContent && Bt(r, e, l.nodes[s.blockNoteType], f, s, m, h), q(e, s.block.beforePos, p, { ...r.props }), c && s.hasContent && Kt(e, e.mapping.slice(o).map(s.content.beforePos), c);
|
|
240
|
+
}
|
|
241
|
+
function Bt(t, n, r, i, a, o, s) {
|
|
242
|
+
let c = _(n), l = "keep";
|
|
243
|
+
if (t.content) {
|
|
244
|
+
if (typeof t.content == "string") l = S([t.content], c, i.name);
|
|
245
|
+
else if (Array.isArray(t.content)) l = S(t.content, c, i.name);
|
|
246
|
+
else if (t.content.type === "tableContent") l = e(t.content, c);
|
|
247
|
+
else throw new C(t.content.type);
|
|
248
|
+
} else {
|
|
249
|
+
let e = a.content.node.content;
|
|
250
|
+
if (r.spec.content !== "" && i.spec.content !== r.spec.content && !i.validContent(e)) {
|
|
251
|
+
if (i.inlineContent && r.inlineContent) {
|
|
252
|
+
let e = a.content.node.textContent;
|
|
253
|
+
l = e.length > 0 ? [c.text(e)] : [];
|
|
254
|
+
} else l = [];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (l === "keep") q(n, a.content.beforePos, i, { ...t.props });
|
|
258
|
+
else if (o !== void 0 || s !== void 0) {
|
|
259
|
+
let e = Ht(n, a.content.beforePos, i, { ...t.props }), r = e + 1 + (o ?? 0), c = e + 1 + (s ?? a.content.node.content.size), u = n.doc.resolve(e).depth, d = n.doc.resolve(r).depth, f = n.doc.resolve(c).depth;
|
|
260
|
+
n.replace(r, c, new k(O.from(l), d - u - 1, f - u - 1));
|
|
261
|
+
} else i === r || i.validContent(a.content.node.content) ? Vt(n, Ht(n, a.content.beforePos, i, { ...t.props }), O.from(l)) : n.replaceWith(a.content.beforePos, a.content.afterPos, i.createChecked({
|
|
262
|
+
...a.content.node.attrs,
|
|
263
|
+
...t.props
|
|
264
|
+
}, l));
|
|
265
|
+
}
|
|
266
|
+
function Vt(e, t, n) {
|
|
267
|
+
let r = e.doc.nodeAt(t);
|
|
268
|
+
if (!r) throw RangeError("No node at given position");
|
|
269
|
+
let i = r.content, a = t + 1;
|
|
270
|
+
if (r.isTextblock) {
|
|
271
|
+
let t = i.findDiffStart(n);
|
|
272
|
+
if (t === null) return;
|
|
273
|
+
let { a: r, b: o } = i.findDiffEnd(n), s = Math.max(0, t - r, t - o);
|
|
274
|
+
s > 0 && (r += s, o += s), e.replace(a + t, a + r, new k(n.cut(t, o), 0, 0));
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
let o = i.childCount, s = n.childCount, c = 0;
|
|
278
|
+
for (; c < o && c < s && i.child(c).eq(n.child(c));) c++;
|
|
279
|
+
let l = o, u = s;
|
|
280
|
+
for (; l > c && u > c && i.child(l - 1).eq(n.child(u - 1));) l--, u--;
|
|
281
|
+
if (c === l && c === u) return;
|
|
282
|
+
let d = a;
|
|
283
|
+
for (let e = 0; e < c; e++) d += i.child(e).nodeSize;
|
|
284
|
+
let f = d;
|
|
285
|
+
for (let e = c; e < l; e++) f += i.child(e).nodeSize;
|
|
286
|
+
let p = [];
|
|
287
|
+
for (let e = c; e < u; e++) p.push(n.child(e));
|
|
288
|
+
e.step(new st(d, f, new k(O.from(p), 0, 0)));
|
|
289
|
+
}
|
|
290
|
+
function q(e, t, n, r) {
|
|
291
|
+
let i = e.doc.nodeAt(t);
|
|
292
|
+
if (!i) throw RangeError("No node at given position");
|
|
293
|
+
let a = n.spec.attrs ?? {}, o = {};
|
|
294
|
+
for (let e of Object.keys(r)) e in a && (o[e] = r[e]);
|
|
295
|
+
let s = {
|
|
296
|
+
...i.attrs,
|
|
297
|
+
...o
|
|
298
|
+
};
|
|
299
|
+
if (i.type === n) {
|
|
300
|
+
for (let n of Object.keys(s)) s[n] !== i.attrs[n] && e.setNodeAttribute(t, n, s[n]);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
e.setNodeMarkup(t, n, s);
|
|
304
|
+
}
|
|
305
|
+
function Ht(e, t, n, r) {
|
|
306
|
+
let i = e.mapping.maps.length;
|
|
307
|
+
return q(e, t, n, r), e.mapping.slice(i).map(t, -1);
|
|
308
|
+
}
|
|
309
|
+
function Ut(e, t, n) {
|
|
310
|
+
let r = _(t);
|
|
311
|
+
if (e.children !== void 0 && e.children.length > 0) {
|
|
312
|
+
let i = e.children.map((e) => {
|
|
313
|
+
let t = g(e, r);
|
|
314
|
+
return t.check(), t;
|
|
315
|
+
});
|
|
316
|
+
n.children ? Vt(t, n.children.beforePos, O.from(i)) : n.hasContent && t.insert(n.content.afterPos, p(r, i));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function Wt(e, t, r, i, a) {
|
|
320
|
+
let o = typeof t == "string" ? t : t.id, s = D(o, e.doc);
|
|
321
|
+
if (!s) throw Error(`Block with ID ${o} not found`);
|
|
322
|
+
K(e, s.posBeforeNode, r, i, a);
|
|
323
|
+
let c = e.doc.resolve(s.posBeforeNode).nodeAfter;
|
|
324
|
+
if (!c) throw Error(`Block with ID ${o} not found after update`);
|
|
325
|
+
return n(c, e.doc);
|
|
326
|
+
}
|
|
327
|
+
function Gt(e) {
|
|
328
|
+
let t = "selection" in e ? e.selection : null;
|
|
329
|
+
if (!(t instanceof N)) return null;
|
|
330
|
+
let n = e.doc.resolve(t.head), r = -1, i = -1;
|
|
331
|
+
for (let e = n.depth; e >= 0; e--) {
|
|
332
|
+
let t = n.node(e).type.name;
|
|
333
|
+
if (r < 0 && (t === "tableCell" || t === "tableHeader") && (r = e), t === "table") {
|
|
334
|
+
i = e;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (r < 0 || i < 0) return null;
|
|
339
|
+
let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
|
|
340
|
+
if (!s || s.type.name !== "table") return null;
|
|
341
|
+
let c = Tt.get(s), l = a - (o + 1), u = c.map.indexOf(l);
|
|
342
|
+
if (u < 0) return null;
|
|
343
|
+
let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
|
|
344
|
+
return {
|
|
345
|
+
row: d,
|
|
346
|
+
col: f,
|
|
347
|
+
offset: Math.max(0, t.head - p)
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function Kt(e, t, n) {
|
|
351
|
+
let r = e.doc.nodeAt(t);
|
|
352
|
+
if (!r || r.type.name !== "table") return !1;
|
|
353
|
+
let i = Tt.get(r), a = Math.max(0, Math.min(n.row, i.height - 1)), o = Math.max(0, Math.min(n.col, i.width - 1)), s = a * i.width + o, c = i.map[s];
|
|
354
|
+
if (c == null) return !1;
|
|
355
|
+
let l = t + 1 + c + 1, u = e.doc.nodeAt(l), d = l + 1, f = u ? u.content.size : 0, p = d + Math.max(0, Math.min(n.offset, f));
|
|
356
|
+
return "selection" in e && e.setSelection(N.create(e.doc, p)), !0;
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/pm-nodes/BlockContainer.ts
|
|
360
|
+
var qt = [["textColor", "data-text-color"], ["backgroundColor", "data-background-color"]];
|
|
361
|
+
function Jt(e) {
|
|
362
|
+
return typeof e == "string" && e !== "default";
|
|
363
|
+
}
|
|
364
|
+
function Yt(e) {
|
|
365
|
+
return qt.some(([t]) => Jt(e[t]));
|
|
366
|
+
}
|
|
367
|
+
function J(e, t) {
|
|
368
|
+
for (let [n, r] of qt) {
|
|
369
|
+
let i = t?.[n];
|
|
370
|
+
Jt(i) ? e.setAttribute(r, i) : e.removeAttribute(r);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
var Xt = {
|
|
374
|
+
blockColor: "data-block-color",
|
|
375
|
+
blockStyle: "data-block-style",
|
|
376
|
+
id: "data-id",
|
|
377
|
+
depth: "data-depth",
|
|
378
|
+
depthChange: "data-depth-change"
|
|
379
|
+
}, Zt = L.create({
|
|
380
|
+
name: "blockContainer",
|
|
381
|
+
group: "blockGroupChild bnBlock",
|
|
382
|
+
content: "blockContent blockGroup?",
|
|
383
|
+
priority: 50,
|
|
384
|
+
defining: !0,
|
|
385
|
+
marks() {
|
|
386
|
+
return s(this.editor);
|
|
387
|
+
},
|
|
388
|
+
parseHTML() {
|
|
389
|
+
return [{
|
|
390
|
+
tag: "div[data-node-type=" + this.name + "]",
|
|
391
|
+
getAttrs: (e) => {
|
|
392
|
+
if (typeof e == "string") return !1;
|
|
393
|
+
let t = {};
|
|
394
|
+
for (let [n, r] of Object.entries(Xt)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
395
|
+
return t;
|
|
396
|
+
},
|
|
397
|
+
contentElement: (e) => he(e) ?? e
|
|
398
|
+
}, {
|
|
399
|
+
tag: "div[data-node-type=\"blockOuter\"]",
|
|
400
|
+
skip: !0
|
|
401
|
+
}];
|
|
402
|
+
},
|
|
403
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
404
|
+
let t = document.createElement("div");
|
|
405
|
+
t.className = "bn-block-outer", t.setAttribute("data-node-type", "blockOuter");
|
|
406
|
+
for (let [n, r] of Object.entries(e)) n !== "class" && t.setAttribute(n, r);
|
|
407
|
+
let n = {
|
|
408
|
+
...this.options.domAttributes?.block || {},
|
|
409
|
+
...e
|
|
410
|
+
}, r = document.createElement("div");
|
|
411
|
+
r.className = de("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
412
|
+
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
413
|
+
return t.appendChild(r), {
|
|
414
|
+
dom: t,
|
|
415
|
+
contentDOM: r
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
addNodeView() {
|
|
419
|
+
return ((e) => {
|
|
420
|
+
let { dom: t, contentDOM: n } = this.type.spec.toDOM(e.node), r = this.options.editor, i = _e({
|
|
421
|
+
props: e,
|
|
422
|
+
editor: r,
|
|
423
|
+
blockNode: (e) => e.firstChild,
|
|
424
|
+
unframed: n
|
|
425
|
+
});
|
|
426
|
+
i.dom !== n && n.appendChild(i.dom);
|
|
427
|
+
let a = e.node.firstChild.attrs;
|
|
428
|
+
return Yt(a) && J(n, a), {
|
|
429
|
+
dom: t,
|
|
430
|
+
contentDOM: i.slot,
|
|
431
|
+
update(e, t, r) {
|
|
432
|
+
let a = i.node;
|
|
433
|
+
return !e.sameMarkup(a) || !i.update(e, t, r) ? !1 : (e.firstChild.sameMarkup(a.firstChild) || J(n, e.firstChild.attrs), !0);
|
|
434
|
+
},
|
|
435
|
+
...se(i)
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
//#endregion
|
|
203
441
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
204
|
-
function
|
|
205
|
-
let
|
|
206
|
-
if (!
|
|
207
|
-
if (typeof
|
|
208
|
-
else if (Array.isArray(
|
|
209
|
-
else if (
|
|
210
|
-
else throw new
|
|
211
|
-
let
|
|
212
|
-
for (let
|
|
213
|
-
let
|
|
214
|
-
if (
|
|
215
|
-
let
|
|
442
|
+
function Qt(t, n, r, i, a) {
|
|
443
|
+
let o;
|
|
444
|
+
if (!n) throw Error("blockContent is required");
|
|
445
|
+
if (typeof n == "string") o = S([n], t.pmSchema, i);
|
|
446
|
+
else if (Array.isArray(n)) o = S(n, t.pmSchema, i);
|
|
447
|
+
else if (n.type === "tableContent") o = e(n, t.pmSchema);
|
|
448
|
+
else throw new C(n.type);
|
|
449
|
+
let s = (a?.document ?? document).createDocumentFragment();
|
|
450
|
+
for (let e of o) if (e.type.name !== "text" && t.schema.inlineContentSchema[e.type.name]) {
|
|
451
|
+
let n = t.schema.inlineContentSpecs[e.type.name].implementation;
|
|
452
|
+
if (n) {
|
|
453
|
+
let i = m(e, t.schema.inlineContentSchema, t.schema.styleSchema), o = n.render.call({
|
|
216
454
|
renderType: "dom",
|
|
217
455
|
props: void 0
|
|
218
|
-
},
|
|
456
|
+
}, i, () => {}, t);
|
|
219
457
|
if (o) {
|
|
220
|
-
if (
|
|
221
|
-
let
|
|
222
|
-
o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(
|
|
458
|
+
if (s.appendChild(o.dom), o.contentDOM) {
|
|
459
|
+
let t = r.serializeFragment(e.content, a);
|
|
460
|
+
o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(t);
|
|
223
461
|
}
|
|
224
462
|
continue;
|
|
225
463
|
}
|
|
226
464
|
}
|
|
227
|
-
} else if (
|
|
228
|
-
let n = document.createTextNode(
|
|
229
|
-
for (let r of
|
|
230
|
-
let
|
|
231
|
-
|
|
465
|
+
} else if (e.type.name === "text") {
|
|
466
|
+
let n = document.createTextNode(e.textContent);
|
|
467
|
+
for (let r of e.marks.toReversed()) if (r.type.name in t.schema.styleSpecs) {
|
|
468
|
+
let e = t.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, t);
|
|
469
|
+
e.contentDOM.appendChild(n), n = e.dom;
|
|
232
470
|
} else {
|
|
233
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
471
|
+
let e = r.type.spec.toDOM(r, !0), t = it.renderSpec(document, e);
|
|
234
472
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
235
473
|
}
|
|
236
|
-
|
|
474
|
+
s.appendChild(n);
|
|
237
475
|
} else {
|
|
238
|
-
let
|
|
239
|
-
|
|
476
|
+
let t = r.serializeFragment(O.from([e]), a);
|
|
477
|
+
s.appendChild(t);
|
|
240
478
|
}
|
|
241
|
-
return
|
|
479
|
+
return s;
|
|
242
480
|
}
|
|
243
|
-
function
|
|
481
|
+
function $t(e, t, n, r) {
|
|
244
482
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
245
483
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
246
|
-
let o = t.children || [], s = e.blockImplementations[t.type].implementation
|
|
247
|
-
renderType: "dom",
|
|
248
|
-
props: void 0
|
|
249
|
-
}, {
|
|
484
|
+
let o = t.children || [], s = e.blockImplementations[t.type].implementation, c = {
|
|
250
485
|
...t,
|
|
251
486
|
props: a,
|
|
252
487
|
children: o
|
|
253
|
-
}
|
|
254
|
-
if (
|
|
255
|
-
let i =
|
|
256
|
-
|
|
488
|
+
};
|
|
489
|
+
if (v(e.pmSchema.nodes[t.type])) {
|
|
490
|
+
let i = De(e, c);
|
|
491
|
+
if (!i) throw Error(`Layout block "${t.type}" drew no frame. This is a bug in BlockNote.`);
|
|
492
|
+
return o.length > 0 && i.slot.append(en(e, o, n, r)), i.dom;
|
|
257
493
|
}
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
494
|
+
if (!s.render) throw Error(`Block "${t.type}" has no \`render\`. This is a bug in BlockNote.`);
|
|
495
|
+
let l = s.render.call({
|
|
496
|
+
renderType: "dom",
|
|
497
|
+
props: void 0
|
|
498
|
+
}, c, e);
|
|
499
|
+
if (l.contentDOM && t.content) {
|
|
500
|
+
let i = Qt(e, t.content, n, t.type, r);
|
|
501
|
+
l.contentDOM.appendChild(i);
|
|
264
502
|
}
|
|
265
|
-
let
|
|
503
|
+
let u = i.spec?.toDOM?.(i.create({
|
|
266
504
|
id: t.id,
|
|
267
505
|
...a
|
|
268
506
|
}));
|
|
269
|
-
|
|
507
|
+
u.contentDOM && J(u.contentDOM, a);
|
|
508
|
+
let d = u.contentDOM, f = De(e, c);
|
|
509
|
+
return f && (le(f.slot), u.contentDOM?.appendChild(f.dom), d = f.slot), d?.appendChild(l.dom), o.length > 0 && d?.appendChild(tn(e, o, n, r)), u.dom;
|
|
270
510
|
}
|
|
271
|
-
function
|
|
511
|
+
function en(e, t, n, r) {
|
|
272
512
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
273
513
|
for (let a of t) {
|
|
274
|
-
let t =
|
|
514
|
+
let t = $t(e, a, n, r);
|
|
275
515
|
i.appendChild(t);
|
|
276
516
|
}
|
|
277
517
|
return i;
|
|
278
518
|
}
|
|
279
|
-
var
|
|
280
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
519
|
+
var tn = (e, t, n, r) => {
|
|
520
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = en(e, t, n, r);
|
|
281
521
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
282
|
-
},
|
|
522
|
+
}, nn = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
283
523
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
284
524
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
285
525
|
else {
|
|
286
526
|
let n = t.getAttribute("data-index");
|
|
287
527
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
288
528
|
}
|
|
289
|
-
}), e),
|
|
529
|
+
}), e), rn = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
290
530
|
e.disabled = !0;
|
|
291
|
-
}), e),
|
|
292
|
-
e.setAttribute("
|
|
293
|
-
}), e),
|
|
531
|
+
}), e), an = (e) => (e.querySelectorAll(".bn-toggle-button[aria-expanded=\"false\"]").forEach((e) => {
|
|
532
|
+
e.setAttribute("aria-expanded", "true");
|
|
533
|
+
}), e), on = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
294
534
|
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
295
|
-
}), e),
|
|
535
|
+
}), e), sn = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
296
536
|
let t = document.createElement("div");
|
|
297
537
|
t.className = "tableWrapper";
|
|
298
538
|
let n = document.createElement("div");
|
|
299
539
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
300
|
-
}), e),
|
|
540
|
+
}), e), cn = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
301
541
|
let t = document.createElement("span");
|
|
302
542
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
303
|
-
}), e),
|
|
304
|
-
let n =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
543
|
+
}), e), ln = (e, t) => {
|
|
544
|
+
let n = it.fromSchema(e), r = [
|
|
545
|
+
nn,
|
|
546
|
+
rn,
|
|
547
|
+
an,
|
|
548
|
+
on,
|
|
549
|
+
sn,
|
|
550
|
+
cn
|
|
311
551
|
];
|
|
312
552
|
return { serializeBlocks: (e, i) => {
|
|
313
|
-
let a =
|
|
553
|
+
let a = tn(t, e, n, i);
|
|
314
554
|
for (let e of r) a = e(a);
|
|
315
555
|
return a.outerHTML;
|
|
316
556
|
} };
|
|
317
|
-
},
|
|
557
|
+
}, un = (e) => {
|
|
318
558
|
let t = 0;
|
|
319
559
|
for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
|
|
320
560
|
return Math.abs(t);
|
|
321
|
-
},
|
|
561
|
+
}, Y = [
|
|
322
562
|
{
|
|
323
563
|
light: "#fff0c2",
|
|
324
564
|
dark: "#8a6d1a"
|
|
325
565
|
},
|
|
326
566
|
{
|
|
327
|
-
light: "#
|
|
328
|
-
dark: "#
|
|
567
|
+
light: "#cdeffd",
|
|
568
|
+
dark: "#0b6a8a"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
light: "#d6defd",
|
|
572
|
+
dark: "#2948b3"
|
|
329
573
|
},
|
|
330
574
|
{
|
|
331
|
-
light: "#
|
|
332
|
-
dark: "#
|
|
575
|
+
light: "#eadcfb",
|
|
576
|
+
dark: "#6b2fa3"
|
|
333
577
|
},
|
|
334
578
|
{
|
|
335
|
-
light: "#
|
|
336
|
-
dark: "#
|
|
579
|
+
light: "#f1e2d3",
|
|
580
|
+
dark: "#7a4a1e"
|
|
337
581
|
},
|
|
338
582
|
{
|
|
339
|
-
light: "#
|
|
340
|
-
dark: "#
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
583
|
+
light: "#dfe4ea",
|
|
584
|
+
dark: "#46525f"
|
|
585
|
+
}
|
|
586
|
+
], dn = (e) => Y[un(e) % Y.length], fn = (e) => {
|
|
587
|
+
if (e?.color) return {
|
|
588
|
+
light: e.colorLight ?? `color-mix(in srgb, ${e.color} 30%, white)`,
|
|
589
|
+
dark: e.color
|
|
590
|
+
};
|
|
591
|
+
}, pn = (e, t) => {
|
|
592
|
+
if (!t || t.length === 0) return Y[0];
|
|
593
|
+
let n = t[0];
|
|
594
|
+
return fn(e.getUser(n)) ?? dn(n);
|
|
595
|
+
}, mn = (e) => Et(e).toString(16).padStart(8, "0"), hn = (e) => {
|
|
596
|
+
let t = mn(e);
|
|
351
597
|
return {
|
|
352
598
|
light: `--user-color-${t}-light`,
|
|
353
599
|
dark: `--user-color-${t}-dark`
|
|
354
600
|
};
|
|
355
|
-
},
|
|
601
|
+
}, gn = class {
|
|
356
602
|
callbacks = {};
|
|
357
603
|
on(e, t) {
|
|
358
604
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -371,193 +617,195 @@ var Et = (e, t, n, r) => {
|
|
|
371
617
|
};
|
|
372
618
|
//#endregion
|
|
373
619
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
374
|
-
function
|
|
620
|
+
function _n(e, t) {
|
|
621
|
+
return e.flatMap((e) => o(t.nodes[e.type]) ? _n(e.children, t) : [e]);
|
|
622
|
+
}
|
|
623
|
+
function vn(e) {
|
|
375
624
|
return e.transact((e) => {
|
|
376
|
-
let t =
|
|
377
|
-
if (e.selection instanceof
|
|
625
|
+
let t = T(e, e.selection.anchor), n = r(t.block.node, e.doc);
|
|
626
|
+
if (e.selection instanceof z) return {
|
|
378
627
|
type: "cell",
|
|
379
628
|
anchorBlockId: n,
|
|
380
|
-
anchorCellOffset: e.selection.$anchorCell.pos - t.
|
|
381
|
-
headCellOffset: e.selection.$headCell.pos - t.
|
|
629
|
+
anchorCellOffset: e.selection.$anchorCell.pos - t.block.beforePos,
|
|
630
|
+
headCellOffset: e.selection.$headCell.pos - t.block.beforePos
|
|
382
631
|
};
|
|
383
|
-
if (e.selection instanceof
|
|
632
|
+
if (e.selection instanceof A) return {
|
|
384
633
|
type: "node",
|
|
385
634
|
anchorBlockId: n
|
|
386
635
|
};
|
|
387
636
|
{
|
|
388
|
-
let
|
|
637
|
+
let i = T(e, e.selection.head);
|
|
389
638
|
return {
|
|
390
639
|
type: "text",
|
|
391
640
|
anchorBlockId: n,
|
|
392
|
-
headBlockId:
|
|
393
|
-
anchorOffset: e.selection.anchor - t.
|
|
394
|
-
headOffset: e.selection.head -
|
|
641
|
+
headBlockId: r(i.block.node, e.doc),
|
|
642
|
+
anchorOffset: e.selection.anchor - t.block.beforePos,
|
|
643
|
+
headOffset: e.selection.head - i.block.beforePos
|
|
395
644
|
};
|
|
396
645
|
}
|
|
397
646
|
});
|
|
398
647
|
}
|
|
399
|
-
function
|
|
400
|
-
let n =
|
|
648
|
+
function yn(e, t) {
|
|
649
|
+
let n = D(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
401
650
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
402
651
|
let r;
|
|
403
|
-
if (t.type === "cell") r =
|
|
404
|
-
else if (t.type === "node")
|
|
405
|
-
|
|
406
|
-
|
|
652
|
+
if (t.type === "cell") r = z.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
653
|
+
else if (t.type === "node") {
|
|
654
|
+
let t = w(e.doc, n);
|
|
655
|
+
r = A.create(e.doc, t.hasContent ? t.content.beforePos : n);
|
|
656
|
+
} else {
|
|
657
|
+
let i = D(t.headBlockId, e.doc)?.posBeforeNode;
|
|
407
658
|
if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
408
659
|
r = N.create(e.doc, n + t.anchorOffset, i + t.headOffset);
|
|
409
660
|
}
|
|
410
661
|
e.setSelection(r);
|
|
411
662
|
}
|
|
412
|
-
function
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
function U(e, t, n, r) {
|
|
416
|
-
e.transact((e) => {
|
|
417
|
-
B(e, t, [], { fixColumns: !1 }), L(e, Vt(t), n, r);
|
|
663
|
+
function bn(e, t, n, r) {
|
|
664
|
+
e.transact((i) => {
|
|
665
|
+
W(i, t, [], { fixLayoutBlocks: !1 }), H(i, _n(t, e.pmSchema), n, r);
|
|
418
666
|
});
|
|
419
667
|
}
|
|
420
|
-
function
|
|
668
|
+
function xn(e, t, n) {
|
|
421
669
|
e.transact((r) => {
|
|
422
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
423
|
-
|
|
670
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = vn(e);
|
|
671
|
+
bn(e, i, t, n), yn(r, a);
|
|
424
672
|
});
|
|
425
673
|
}
|
|
426
|
-
function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
referenceBlock: r,
|
|
444
|
-
placement: i
|
|
445
|
-
} : Gt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
446
|
-
}
|
|
447
|
-
function Kt(e, t) {
|
|
448
|
-
e.transact(() => {
|
|
449
|
-
let n;
|
|
450
|
-
if (t) {
|
|
451
|
-
if (n = e.getBlock(t), !n) return;
|
|
452
|
-
} else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
|
|
453
|
-
let r = Wt(e, e.getPrevBlock(n), e.getParentBlock(n));
|
|
454
|
-
r && (t ? U(e, [n], r.referenceBlock, r.placement) : Ht(e, r.referenceBlock, r.placement));
|
|
455
|
-
});
|
|
674
|
+
function Sn(e, t) {
|
|
675
|
+
let n = _n([t], e.pmSchema)[0], r = n && e.pmSchema.nodes[n.type];
|
|
676
|
+
return r && v(r) ? r : e.pmSchema.nodes.blockContainer;
|
|
677
|
+
}
|
|
678
|
+
function Cn(e, n, r, i, a) {
|
|
679
|
+
let o = r === "up" ? "before" : "after", s = r === "up" ? "after" : "before";
|
|
680
|
+
for (; i || a;) {
|
|
681
|
+
let c = i && i.children.length > 0, l = i ? c ? i.children[r === "up" ? i.children.length - 1 : 0] : i : a, u = c ? s : o;
|
|
682
|
+
if (e.transact((e) => {
|
|
683
|
+
let r = D(l.id, e.doc);
|
|
684
|
+
return r !== void 0 && t(e.doc, w(e.doc, r.posBeforeNode), u, n) !== null;
|
|
685
|
+
})) return {
|
|
686
|
+
referenceBlock: l,
|
|
687
|
+
placement: u
|
|
688
|
+
};
|
|
689
|
+
a = e.getParentBlock(l), i = u === s ? l : r === "up" ? e.getPrevBlock(l) : e.getNextBlock(l);
|
|
690
|
+
}
|
|
456
691
|
}
|
|
457
|
-
function
|
|
692
|
+
function wn(e, t, n) {
|
|
458
693
|
e.transact(() => {
|
|
459
|
-
let
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
r && (t ? U(e, [n], r.referenceBlock, r.placement) : Ht(e, r.referenceBlock, r.placement));
|
|
694
|
+
let r;
|
|
695
|
+
if (n) {
|
|
696
|
+
let t = e.getBlock(n);
|
|
697
|
+
if (!t) return;
|
|
698
|
+
r = [t];
|
|
699
|
+
} else r = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
|
|
700
|
+
let i = r[t === "up" ? 0 : r.length - 1], a = Cn(e, Sn(e, r[0]), t, t === "up" ? e.getPrevBlock(i) : e.getNextBlock(i), e.getParentBlock(i));
|
|
701
|
+
a && (n ? bn(e, r, a.referenceBlock, a.placement) : xn(e, a.referenceBlock, a.placement));
|
|
468
702
|
});
|
|
469
703
|
}
|
|
704
|
+
function Tn(e, t) {
|
|
705
|
+
wn(e, "up", t);
|
|
706
|
+
}
|
|
707
|
+
function En(e, t) {
|
|
708
|
+
wn(e, "down", t);
|
|
709
|
+
}
|
|
470
710
|
//#endregion
|
|
471
711
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
472
|
-
function
|
|
473
|
-
|
|
712
|
+
function Dn(e, t) {
|
|
713
|
+
return e.childCount > 0 && e.type.isInGroup("childContainer") && e.type.contentMatch.matchType(t) !== null;
|
|
714
|
+
}
|
|
715
|
+
function On(e, t, n) {
|
|
716
|
+
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => Dn(e, t));
|
|
474
717
|
if (!a) return !1;
|
|
475
718
|
let o = a.startIndex;
|
|
476
719
|
if (o === 0) return !1;
|
|
477
720
|
let s = a.parent.child(o - 1);
|
|
478
721
|
if (s.type !== t) return !1;
|
|
479
|
-
let c = s.lastChild && s.lastChild.type === n
|
|
480
|
-
return e.step(new
|
|
722
|
+
let c = s.lastChild && s.lastChild.type === n ? 2 : 1, l = new k(O.from(t.create(null, O.from(n.create()))), c, 0), u = a.start, d = a.end;
|
|
723
|
+
return e.step(new ot(u - c, d, u, d, l, 2 - c, !0)).scrollIntoView(), !0;
|
|
481
724
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
725
|
+
function kn(e) {
|
|
726
|
+
return (t) => On(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup);
|
|
484
727
|
}
|
|
485
|
-
function
|
|
728
|
+
function An(e) {
|
|
729
|
+
return e.transact(kn(e));
|
|
730
|
+
}
|
|
731
|
+
function jn(e, t, n, r) {
|
|
486
732
|
let i = r.end, a = r.$to.end(r.depth);
|
|
487
733
|
if (i < a) {
|
|
488
734
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
489
|
-
e.step(new
|
|
735
|
+
e.step(new ot(i - (s ? 2 : 1), a, i, a, new k(O.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new at(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
|
|
490
736
|
}
|
|
491
|
-
let o =
|
|
737
|
+
let o = lt(r);
|
|
492
738
|
if (o == null) return !1;
|
|
493
739
|
e.lift(r, o);
|
|
494
740
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
495
|
-
return
|
|
496
|
-
}
|
|
497
|
-
function
|
|
498
|
-
let { $from:
|
|
499
|
-
|
|
741
|
+
return ct(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
742
|
+
}
|
|
743
|
+
function Mn(e, t, n, r) {
|
|
744
|
+
let { $from: i, $to: a } = e.selection, o = i.blockRange(a, (e) => Dn(e, t));
|
|
745
|
+
if (!o) return !1;
|
|
746
|
+
let s = i.node(o.depth - 1);
|
|
747
|
+
return s.type === t && !r(s) ? !1 : s.type === t && jn(e, t, n, o);
|
|
748
|
+
}
|
|
749
|
+
function Nn(e) {
|
|
750
|
+
return (t) => Mn(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup, (r) => {
|
|
751
|
+
let i = n(r, t.doc);
|
|
752
|
+
return e.schema.blockSpecs[i.type].implementation.keyboard(i).childrenCanOutdent;
|
|
753
|
+
});
|
|
500
754
|
}
|
|
501
|
-
function
|
|
502
|
-
return e.transact((
|
|
755
|
+
function Pn(e) {
|
|
756
|
+
return e.transact(Nn(e));
|
|
503
757
|
}
|
|
504
|
-
function
|
|
505
|
-
return e.
|
|
506
|
-
let { bnBlock: t } = v(e);
|
|
507
|
-
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
508
|
-
});
|
|
758
|
+
function Fn(e) {
|
|
759
|
+
return e.canExec((t) => kn(e)(t.tr));
|
|
509
760
|
}
|
|
510
|
-
function
|
|
511
|
-
return e.
|
|
512
|
-
let { bnBlock: t } = v(e);
|
|
513
|
-
return e.doc.resolve(t.beforePos).depth > 1;
|
|
514
|
-
});
|
|
761
|
+
function In(e) {
|
|
762
|
+
return e.canExec((t) => Nn(e)(t.tr));
|
|
515
763
|
}
|
|
516
764
|
//#endregion
|
|
517
765
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
518
|
-
function
|
|
519
|
-
let
|
|
520
|
-
if (
|
|
521
|
-
}
|
|
522
|
-
function
|
|
523
|
-
let
|
|
524
|
-
if (!
|
|
525
|
-
let
|
|
526
|
-
if (
|
|
527
|
-
}
|
|
528
|
-
function
|
|
529
|
-
let
|
|
530
|
-
if (!
|
|
531
|
-
let
|
|
532
|
-
if (
|
|
533
|
-
}
|
|
534
|
-
function
|
|
535
|
-
let
|
|
536
|
-
if (!
|
|
537
|
-
let
|
|
538
|
-
if (
|
|
766
|
+
function Ln(e, t) {
|
|
767
|
+
let r = typeof t == "string" ? t : t.id, i = D(r, e);
|
|
768
|
+
if (i) return n(i.node, e);
|
|
769
|
+
}
|
|
770
|
+
function Rn(e, t) {
|
|
771
|
+
let r = typeof t == "string" ? t : t.id, i = D(r, e);
|
|
772
|
+
if (!i) return;
|
|
773
|
+
let a = e.resolve(i.posBeforeNode).nodeBefore;
|
|
774
|
+
if (a) return n(a, e);
|
|
775
|
+
}
|
|
776
|
+
function zn(e, t) {
|
|
777
|
+
let r = typeof t == "string" ? t : t.id, i = D(r, e);
|
|
778
|
+
if (!i) return;
|
|
779
|
+
let a = e.resolve(i.posBeforeNode + i.node.nodeSize).nodeAfter;
|
|
780
|
+
if (a) return n(a, e);
|
|
781
|
+
}
|
|
782
|
+
function Bn(e, t) {
|
|
783
|
+
let r = typeof t == "string" ? t : t.id, i = D(r, e);
|
|
784
|
+
if (!i) return;
|
|
785
|
+
let a = h(e, i.posBeforeNode);
|
|
786
|
+
if (a) return n(a.block.node, e);
|
|
539
787
|
}
|
|
540
788
|
//#endregion
|
|
541
789
|
//#region src/editor/managers/BlockManager.ts
|
|
542
|
-
var
|
|
790
|
+
var Vn = class {
|
|
543
791
|
editor;
|
|
544
792
|
constructor(e) {
|
|
545
793
|
this.editor = e;
|
|
546
794
|
}
|
|
547
795
|
get document() {
|
|
548
|
-
return this.editor.transact((e) =>
|
|
796
|
+
return this.editor.transact((e) => i(e.doc));
|
|
549
797
|
}
|
|
550
798
|
getBlock(e) {
|
|
551
|
-
return this.editor.transact((t) =>
|
|
799
|
+
return this.editor.transact((t) => Ln(t.doc, e));
|
|
552
800
|
}
|
|
553
801
|
getPrevBlock(e) {
|
|
554
|
-
return this.editor.transact((t) =>
|
|
802
|
+
return this.editor.transact((t) => Rn(t.doc, e));
|
|
555
803
|
}
|
|
556
804
|
getNextBlock(e) {
|
|
557
|
-
return this.editor.transact((t) =>
|
|
805
|
+
return this.editor.transact((t) => zn(t.doc, e));
|
|
558
806
|
}
|
|
559
807
|
getParentBlock(e) {
|
|
560
|
-
return this.editor.transact((t) =>
|
|
808
|
+
return this.editor.transact((t) => Bn(t.doc, e));
|
|
561
809
|
}
|
|
562
810
|
forEachBlock(e, t = !1) {
|
|
563
811
|
let n = this.document.slice();
|
|
@@ -569,36 +817,36 @@ var an = class {
|
|
|
569
817
|
r(n);
|
|
570
818
|
}
|
|
571
819
|
insertBlocks(e, t, n = "before") {
|
|
572
|
-
return this.editor.transact((r) =>
|
|
820
|
+
return this.editor.transact((r) => H(r, e, t, n));
|
|
573
821
|
}
|
|
574
|
-
updateBlock(
|
|
575
|
-
return this.editor.transact((
|
|
822
|
+
updateBlock(e, t) {
|
|
823
|
+
return this.editor.transact((n) => Wt(n, e, t));
|
|
576
824
|
}
|
|
577
825
|
removeBlocks(e) {
|
|
578
|
-
return this.editor.transact((t) =>
|
|
826
|
+
return this.editor.transact((t) => W(t, e, []).removedBlocks);
|
|
579
827
|
}
|
|
580
828
|
replaceBlocks(e, t) {
|
|
581
|
-
return this.editor.transact((n) =>
|
|
829
|
+
return this.editor.transact((n) => W(n, e, t));
|
|
582
830
|
}
|
|
583
831
|
canNestBlock() {
|
|
584
|
-
return
|
|
832
|
+
return Fn(this.editor);
|
|
585
833
|
}
|
|
586
834
|
nestBlock() {
|
|
587
|
-
|
|
835
|
+
An(this.editor);
|
|
588
836
|
}
|
|
589
837
|
canUnnestBlock() {
|
|
590
|
-
return
|
|
838
|
+
return In(this.editor);
|
|
591
839
|
}
|
|
592
840
|
unnestBlock() {
|
|
593
|
-
|
|
841
|
+
Pn(this.editor);
|
|
594
842
|
}
|
|
595
843
|
moveBlocksUp(e) {
|
|
596
|
-
return
|
|
844
|
+
return Tn(this.editor, e);
|
|
597
845
|
}
|
|
598
846
|
moveBlocksDown(e) {
|
|
599
|
-
return
|
|
847
|
+
return En(this.editor, e);
|
|
600
848
|
}
|
|
601
|
-
},
|
|
849
|
+
}, Hn = class extends gn {
|
|
602
850
|
editor;
|
|
603
851
|
constructor(e) {
|
|
604
852
|
super(), this.editor = e, e.on("create", () => {
|
|
@@ -656,14 +904,14 @@ var an = class {
|
|
|
656
904
|
}
|
|
657
905
|
onChange(e, t = !0) {
|
|
658
906
|
return this.on("onChange", ({ transaction: n, appendedTransactions: r }) => {
|
|
659
|
-
|
|
660
|
-
return
|
|
907
|
+
(t || !Un(n)) && e(this.editor, { getChanges() {
|
|
908
|
+
return et(n, r);
|
|
661
909
|
} });
|
|
662
910
|
});
|
|
663
911
|
}
|
|
664
912
|
onSelectionChange(e, t = !1) {
|
|
665
913
|
return this.on("onSelectionChange", ({ transaction: n }) => {
|
|
666
|
-
|
|
914
|
+
(t || !Un(n)) && e(this.editor);
|
|
667
915
|
});
|
|
668
916
|
}
|
|
669
917
|
onFocusChange(e, t) {
|
|
@@ -679,30 +927,30 @@ var an = class {
|
|
|
679
927
|
return this.on("onUnmount", e);
|
|
680
928
|
}
|
|
681
929
|
};
|
|
682
|
-
function
|
|
930
|
+
function Un(e) {
|
|
683
931
|
return !!e.getMeta("y-sync$");
|
|
684
932
|
}
|
|
685
933
|
//#endregion
|
|
686
934
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
687
|
-
function
|
|
935
|
+
function Wn(e) {
|
|
688
936
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
689
937
|
}
|
|
690
|
-
function
|
|
938
|
+
function Gn(e) {
|
|
691
939
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
692
940
|
}
|
|
693
|
-
function
|
|
941
|
+
function Kn(e) {
|
|
694
942
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
695
|
-
let t =
|
|
943
|
+
let t = Wn(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
696
944
|
e.remove(), r.forEach((e) => {
|
|
697
945
|
e.remove();
|
|
698
946
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
699
|
-
if (
|
|
947
|
+
if (Gn(t)) return;
|
|
700
948
|
let n = document.createElement("li");
|
|
701
949
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
702
950
|
}), n.childNodes.length === 0 && n.remove();
|
|
703
951
|
});
|
|
704
952
|
}
|
|
705
|
-
function
|
|
953
|
+
function qn(e) {
|
|
706
954
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
707
955
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
708
956
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -710,25 +958,25 @@ function dn(e) {
|
|
|
710
958
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
711
959
|
});
|
|
712
960
|
}
|
|
713
|
-
var
|
|
714
|
-
function
|
|
715
|
-
return
|
|
961
|
+
var Jn = null;
|
|
962
|
+
function Yn() {
|
|
963
|
+
return Jn ||= document.implementation.createHTMLDocument("title");
|
|
716
964
|
}
|
|
717
|
-
function
|
|
965
|
+
function Xn(e) {
|
|
718
966
|
if (typeof e == "string") {
|
|
719
|
-
let t =
|
|
967
|
+
let t = Yn().createElement("div");
|
|
720
968
|
t.innerHTML = e, e = t;
|
|
721
969
|
}
|
|
722
|
-
return
|
|
970
|
+
return Kn(e), qn(e), e;
|
|
723
971
|
}
|
|
724
972
|
//#endregion
|
|
725
973
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
726
|
-
function
|
|
974
|
+
function Zn(e) {
|
|
727
975
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
728
976
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
729
977
|
return !1;
|
|
730
978
|
}
|
|
731
|
-
function
|
|
979
|
+
function Qn(e) {
|
|
732
980
|
let t = /* @__PURE__ */ new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
733
981
|
let r = n.parentElement;
|
|
734
982
|
for (; r && r !== e;) {
|
|
@@ -740,12 +988,12 @@ function gn(e) {
|
|
|
740
988
|
for (; i = n.nextNode();) r.push(i);
|
|
741
989
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
742
990
|
}
|
|
743
|
-
function
|
|
744
|
-
|
|
991
|
+
function $n(e) {
|
|
992
|
+
Zn(e) || Qn(e);
|
|
745
993
|
}
|
|
746
994
|
//#endregion
|
|
747
995
|
//#region src/api/parsers/html/parseHTML.ts
|
|
748
|
-
function
|
|
996
|
+
function er(e) {
|
|
749
997
|
let t = [];
|
|
750
998
|
for (let n of e) if (n.type === "text") {
|
|
751
999
|
let e = n.text.split("").join("");
|
|
@@ -755,80 +1003,106 @@ function vn(e) {
|
|
|
755
1003
|
});
|
|
756
1004
|
} else Array.isArray(n.content) ? t.push({
|
|
757
1005
|
...n,
|
|
758
|
-
content:
|
|
1006
|
+
content: er(n.content)
|
|
759
1007
|
}) : t.push(n);
|
|
760
1008
|
return t;
|
|
761
1009
|
}
|
|
762
|
-
function
|
|
763
|
-
for (let t of e) Array.isArray(t.content) && (t.content =
|
|
1010
|
+
function tr(e) {
|
|
1011
|
+
for (let t of e) Array.isArray(t.content) && (t.content = er(t.content)), t.children.length > 0 && tr(t.children);
|
|
764
1012
|
}
|
|
765
|
-
function
|
|
766
|
-
let
|
|
767
|
-
|
|
768
|
-
let
|
|
769
|
-
for (let e = 0; e <
|
|
770
|
-
return
|
|
1013
|
+
function nr(e, t) {
|
|
1014
|
+
let r = Xn(e);
|
|
1015
|
+
$n(r);
|
|
1016
|
+
let i = rt.fromSchema(t).parse(r, { topNode: t.nodes.blockGroup.create() }), a = [];
|
|
1017
|
+
for (let e = 0; e < i.childCount; e++) a.push(n(i.child(e), i));
|
|
1018
|
+
return tr(a), a;
|
|
771
1019
|
}
|
|
772
1020
|
//#endregion
|
|
773
1021
|
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
774
|
-
function
|
|
1022
|
+
function X(e) {
|
|
775
1023
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
776
1024
|
}
|
|
777
|
-
function
|
|
1025
|
+
function rr(e) {
|
|
778
1026
|
return e ? /\w/.test(e) : !1;
|
|
779
1027
|
}
|
|
780
|
-
function
|
|
1028
|
+
function ir(e, t, n) {
|
|
781
1029
|
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
782
|
-
return
|
|
1030
|
+
return rr(r) && rr(i);
|
|
783
1031
|
}
|
|
784
|
-
function
|
|
1032
|
+
function ar(e, t) {
|
|
785
1033
|
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
786
1034
|
let n = e[t + 1];
|
|
787
1035
|
return n === "\n" ? {
|
|
788
1036
|
html: "<br>\n",
|
|
789
1037
|
end: t + 2
|
|
790
1038
|
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
791
|
-
html:
|
|
1039
|
+
html: X(n),
|
|
792
1040
|
end: t + 2
|
|
793
1041
|
} : null;
|
|
794
1042
|
}
|
|
795
|
-
function
|
|
796
|
-
return e[t] === "`" ?
|
|
1043
|
+
function or(e, t) {
|
|
1044
|
+
return e[t] === "`" ? Tr(e, t) : null;
|
|
797
1045
|
}
|
|
798
|
-
function
|
|
799
|
-
return e[t] !== "!" || e[t + 1] !== "[" ? null :
|
|
1046
|
+
function sr(e, t) {
|
|
1047
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : Er(e, t);
|
|
800
1048
|
}
|
|
801
|
-
function
|
|
802
|
-
return e[t] === "[" ?
|
|
1049
|
+
function cr(e, t) {
|
|
1050
|
+
return e[t] === "[" ? Dr(e, t) : null;
|
|
803
1051
|
}
|
|
804
|
-
function
|
|
805
|
-
|
|
1052
|
+
function lr(e, t) {
|
|
1053
|
+
let n = e.substring(t);
|
|
1054
|
+
if (e[t] === "<") {
|
|
1055
|
+
let e = n.match(/^<([a-zA-Z][a-zA-Z0-9+.-]{1,31}:[^\s<>]*)>/);
|
|
1056
|
+
if (e) {
|
|
1057
|
+
let n = e[1];
|
|
1058
|
+
return {
|
|
1059
|
+
html: `<a href="${X(n)}">${X(n)}</a>`,
|
|
1060
|
+
end: t + e[0].length
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
let r = n.match(/^<([^\s<>]+)>/), i = r?.[1], a = i ? Me(i).find((e) => e.type === "email" && e.start === 0 && e.end === i.length) : void 0;
|
|
1064
|
+
return r && i && a ? {
|
|
1065
|
+
html: `<a href="${X(a.href)}">${X(i)}</a>`,
|
|
1066
|
+
end: t + r[0].length
|
|
1067
|
+
} : null;
|
|
1068
|
+
}
|
|
1069
|
+
if (t > 0 && /[a-zA-Z0-9_]/.test(e[t - 1])) return null;
|
|
1070
|
+
let r = n.match(/^(https?:\/\/|www\.)[^\s<>]+/i);
|
|
1071
|
+
if (!r) return null;
|
|
1072
|
+
let i = He(r[0]);
|
|
1073
|
+
return i ? {
|
|
1074
|
+
html: `<a href="${X(i.href)}">${X(i.value)}</a>`,
|
|
1075
|
+
end: t + i.value.length
|
|
1076
|
+
} : null;
|
|
806
1077
|
}
|
|
807
|
-
function
|
|
808
|
-
return e[t]
|
|
1078
|
+
function ur(e, t, n) {
|
|
1079
|
+
return e[t] !== "~" || e[t + 1] !== "~" ? null : Q(e, t, "~~", "<del>", "</del>", n);
|
|
809
1080
|
}
|
|
810
|
-
function
|
|
811
|
-
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !
|
|
1081
|
+
function dr(e, t, n) {
|
|
1082
|
+
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !ir(e, t, 3) ? Q(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>", n) : null;
|
|
812
1083
|
}
|
|
813
|
-
function
|
|
814
|
-
return e[t] === "*" || e[t] === "_" && !
|
|
1084
|
+
function fr(e, t, n) {
|
|
1085
|
+
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !ir(e, t, 2) ? Q(e, t, e.substring(t, t + 2), "<strong>", "</strong>", n) : null;
|
|
815
1086
|
}
|
|
816
|
-
function
|
|
1087
|
+
function pr(e, t, n) {
|
|
1088
|
+
return e[t] === "*" || e[t] === "_" && !ir(e, t, 1) ? Q(e, t, e[t], "<em>", "</em>", n) : null;
|
|
1089
|
+
}
|
|
1090
|
+
function mr(e, t) {
|
|
817
1091
|
return e[t] === "\n" ? {
|
|
818
1092
|
html: "<br>\n",
|
|
819
1093
|
end: t + 1
|
|
820
1094
|
} : null;
|
|
821
1095
|
}
|
|
822
|
-
var
|
|
823
|
-
function
|
|
1096
|
+
var hr = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, gr = /^<!--[\s\S]*?-->/, _r = /^<!\[CDATA\[[\s\S]*?\]\]>/, vr = /^<\?[\s\S]*?\?>/, yr = /^<![A-Za-z][\s\S]*?>/;
|
|
1097
|
+
function br(e, t) {
|
|
824
1098
|
if (e[t] !== "<") return null;
|
|
825
1099
|
let n = e.substring(t);
|
|
826
1100
|
for (let e of [
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1101
|
+
gr,
|
|
1102
|
+
_r,
|
|
1103
|
+
vr,
|
|
1104
|
+
yr,
|
|
1105
|
+
hr
|
|
832
1106
|
]) {
|
|
833
1107
|
let r = n.match(e);
|
|
834
1108
|
if (r) return {
|
|
@@ -838,42 +1112,48 @@ function Fn(e, t) {
|
|
|
838
1112
|
}
|
|
839
1113
|
return null;
|
|
840
1114
|
}
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1115
|
+
var xr = /* @__PURE__ */ new Set("\\`![~*_\n<");
|
|
1116
|
+
function Sr(e, t) {
|
|
1117
|
+
let n = e[t];
|
|
1118
|
+
return xr.has(n) ? !0 : n === "h" ? e.startsWith("http://", t) || e.startsWith("https://", t) : n === "w" && e.startsWith("www.", t);
|
|
1119
|
+
}
|
|
1120
|
+
var Cr = [
|
|
1121
|
+
ar,
|
|
1122
|
+
or,
|
|
1123
|
+
sr,
|
|
1124
|
+
cr,
|
|
1125
|
+
lr,
|
|
1126
|
+
ur,
|
|
1127
|
+
dr,
|
|
1128
|
+
fr,
|
|
1129
|
+
pr,
|
|
1130
|
+
br,
|
|
1131
|
+
mr
|
|
1132
|
+
], wr = Cr.filter((e) => e !== cr && e !== lr);
|
|
1133
|
+
function Z(e, t = !0) {
|
|
1134
|
+
let n = "", r = 0, i = t ? Cr : wr;
|
|
1135
|
+
for (; r < e.length;) {
|
|
1136
|
+
if (e[r] === "\n" && r >= 2 && e[r - 1] === " " && e[r - 2] === " ") {
|
|
1137
|
+
n = n.replace(/ +$/, ""), n += "<br>\n", r++;
|
|
858
1138
|
continue;
|
|
859
1139
|
}
|
|
860
|
-
let
|
|
861
|
-
if (
|
|
862
|
-
let
|
|
863
|
-
if (
|
|
864
|
-
|
|
1140
|
+
let a = !1;
|
|
1141
|
+
if (Sr(e, r)) for (let o of i) {
|
|
1142
|
+
let i = o(e, r, t);
|
|
1143
|
+
if (i) {
|
|
1144
|
+
n += i.html, r = i.end, a = !0;
|
|
865
1145
|
break;
|
|
866
1146
|
}
|
|
867
1147
|
}
|
|
868
|
-
if (!
|
|
869
|
-
let
|
|
870
|
-
for (
|
|
871
|
-
|
|
1148
|
+
if (!a) {
|
|
1149
|
+
let t = r;
|
|
1150
|
+
for (r++; r < e.length && !Sr(e, r);) r++;
|
|
1151
|
+
n += X(e.substring(t, r));
|
|
872
1152
|
}
|
|
873
1153
|
}
|
|
874
|
-
return
|
|
1154
|
+
return n;
|
|
875
1155
|
}
|
|
876
|
-
function
|
|
1156
|
+
function Tr(e, t) {
|
|
877
1157
|
let n = 0, r = t;
|
|
878
1158
|
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
879
1159
|
let i = r;
|
|
@@ -883,46 +1163,46 @@ function Rn(e, t) {
|
|
|
883
1163
|
if (t === n) {
|
|
884
1164
|
let t = e.substring(r, a);
|
|
885
1165
|
return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
|
|
886
|
-
html: `<code>${
|
|
1166
|
+
html: `<code>${X(t)}</code>`,
|
|
887
1167
|
end: i
|
|
888
1168
|
};
|
|
889
1169
|
}
|
|
890
1170
|
} else i++;
|
|
891
1171
|
return null;
|
|
892
1172
|
}
|
|
893
|
-
function
|
|
894
|
-
let n =
|
|
1173
|
+
function Er(e, t) {
|
|
1174
|
+
let n = Or(e, t + 1);
|
|
895
1175
|
if (n === -1) return null;
|
|
896
1176
|
let r = t + 2;
|
|
897
1177
|
if (e[n + 1] !== "(") return null;
|
|
898
|
-
let i = n + 2, a =
|
|
1178
|
+
let i = n + 2, a = kr(e, i - 1);
|
|
899
1179
|
if (a === -1) return null;
|
|
900
|
-
let o = e.substring(r, n), { url: s, title:
|
|
901
|
-
if (
|
|
902
|
-
let e = o ||
|
|
1180
|
+
let o = e.substring(r, n), { url: s, title: l } = Ar(e.substring(i, a));
|
|
1181
|
+
if (c(s)) {
|
|
1182
|
+
let e = o || l;
|
|
903
1183
|
return {
|
|
904
|
-
html: `<video src="${
|
|
1184
|
+
html: `<video src="${X(s)}"${e ? ` data-name="${X(e)}"` : ""} data-url="${X(s)}" controls></video>`,
|
|
905
1185
|
end: a + 1
|
|
906
1186
|
};
|
|
907
1187
|
}
|
|
908
|
-
let
|
|
1188
|
+
let u = l === void 0 ? "" : ` title="${X(l)}"`;
|
|
909
1189
|
return {
|
|
910
|
-
html: `<img src="${
|
|
1190
|
+
html: `<img src="${X(s)}" alt="${X(o)}"${u}>`,
|
|
911
1191
|
end: a + 1
|
|
912
1192
|
};
|
|
913
1193
|
}
|
|
914
|
-
function
|
|
915
|
-
let n = t + 1, r =
|
|
1194
|
+
function Dr(e, t) {
|
|
1195
|
+
let n = t + 1, r = Or(e, t);
|
|
916
1196
|
if (r === -1 || e[r + 1] !== "(") return null;
|
|
917
|
-
let i = r + 2, a =
|
|
1197
|
+
let i = r + 2, a = kr(e, r + 1);
|
|
918
1198
|
if (a === -1) return null;
|
|
919
|
-
let o = e.substring(n, r), { url: s, title: c } =
|
|
1199
|
+
let o = e.substring(n, r), { url: s, title: c } = Ar(e.substring(i, a)), l = c === void 0 ? "" : ` title="${X(c)}"`;
|
|
920
1200
|
return {
|
|
921
|
-
html: `<a href="${
|
|
1201
|
+
html: `<a href="${X(s)}"${l}>${Z(o, !1)}</a>`,
|
|
922
1202
|
end: a + 1
|
|
923
1203
|
};
|
|
924
1204
|
}
|
|
925
|
-
function
|
|
1205
|
+
function Or(e, t) {
|
|
926
1206
|
let n = 0;
|
|
927
1207
|
for (let r = t; r < e.length; r++) {
|
|
928
1208
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -933,7 +1213,7 @@ function Vn(e, t) {
|
|
|
933
1213
|
}
|
|
934
1214
|
return -1;
|
|
935
1215
|
}
|
|
936
|
-
function
|
|
1216
|
+
function kr(e, t) {
|
|
937
1217
|
let n = 0;
|
|
938
1218
|
for (let r = t; r < e.length; r++) {
|
|
939
1219
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -944,7 +1224,7 @@ function Hn(e, t) {
|
|
|
944
1224
|
}
|
|
945
1225
|
return -1;
|
|
946
1226
|
}
|
|
947
|
-
function
|
|
1227
|
+
function Ar(e) {
|
|
948
1228
|
e = e.trim();
|
|
949
1229
|
let t, n;
|
|
950
1230
|
if (e.startsWith("<")) {
|
|
@@ -974,45 +1254,45 @@ function Un(e) {
|
|
|
974
1254
|
title: r
|
|
975
1255
|
};
|
|
976
1256
|
}
|
|
977
|
-
function
|
|
978
|
-
let
|
|
979
|
-
if (
|
|
980
|
-
let
|
|
981
|
-
for (;
|
|
982
|
-
if (e[
|
|
983
|
-
|
|
1257
|
+
function Q(e, t, n, r, i, a) {
|
|
1258
|
+
let o = n.length, s = t + o;
|
|
1259
|
+
if (s >= e.length || e[s] === " " || e[s] === " ") return null;
|
|
1260
|
+
let c = s;
|
|
1261
|
+
for (; c < e.length;) {
|
|
1262
|
+
if (e[c] === "\\" && c + 1 < e.length) {
|
|
1263
|
+
c += 2;
|
|
984
1264
|
continue;
|
|
985
1265
|
}
|
|
986
|
-
if (e.substring(
|
|
987
|
-
if (e[
|
|
988
|
-
|
|
1266
|
+
if (e.substring(c, c + o) === n) {
|
|
1267
|
+
if (e[c - 1] === " " || e[c - 1] === " ") {
|
|
1268
|
+
c++;
|
|
989
1269
|
continue;
|
|
990
1270
|
}
|
|
991
|
-
if (
|
|
992
|
-
|
|
1271
|
+
if (o === 1 && (c > 0 && e[c - 1] === n[0] && !(c >= 2 && e[c - 2] === "\\") || c + o < e.length && e[c + o] === n[0])) {
|
|
1272
|
+
c++;
|
|
993
1273
|
continue;
|
|
994
1274
|
}
|
|
995
|
-
let t = e.substring(
|
|
1275
|
+
let t = e.substring(s, c);
|
|
996
1276
|
if (t.length === 0) {
|
|
997
|
-
|
|
1277
|
+
c++;
|
|
998
1278
|
continue;
|
|
999
1279
|
}
|
|
1000
1280
|
return {
|
|
1001
|
-
html: r +
|
|
1002
|
-
end:
|
|
1281
|
+
html: r + Z(t, a) + i,
|
|
1282
|
+
end: c + o
|
|
1003
1283
|
};
|
|
1004
1284
|
}
|
|
1005
|
-
|
|
1285
|
+
c++;
|
|
1006
1286
|
}
|
|
1007
1287
|
return null;
|
|
1008
1288
|
}
|
|
1009
|
-
var
|
|
1010
|
-
function
|
|
1289
|
+
var jr = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
|
|
1290
|
+
function Mr(e) {
|
|
1011
1291
|
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
1012
1292
|
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
1013
|
-
return t ?
|
|
1293
|
+
return t ? jr.has(t[1].toLowerCase()) : !1;
|
|
1014
1294
|
}
|
|
1015
|
-
function
|
|
1295
|
+
function Nr(e) {
|
|
1016
1296
|
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
1017
1297
|
for (; r < t.length;) {
|
|
1018
1298
|
let e = t[r];
|
|
@@ -1071,7 +1351,7 @@ function Kn(e) {
|
|
|
1071
1351
|
continue;
|
|
1072
1352
|
}
|
|
1073
1353
|
}
|
|
1074
|
-
let s =
|
|
1354
|
+
let s = Pr(t, r);
|
|
1075
1355
|
if (s) {
|
|
1076
1356
|
n.push(s.token), r = s.nextLine, i = !1;
|
|
1077
1357
|
continue;
|
|
@@ -1127,7 +1407,7 @@ function Kn(e) {
|
|
|
1127
1407
|
}), i = !1;
|
|
1128
1408
|
continue;
|
|
1129
1409
|
}
|
|
1130
|
-
if (
|
|
1410
|
+
if (Mr(e)) {
|
|
1131
1411
|
let e = [];
|
|
1132
1412
|
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
1133
1413
|
n.push({
|
|
@@ -1139,7 +1419,7 @@ function Kn(e) {
|
|
|
1139
1419
|
let l = [e];
|
|
1140
1420
|
for (r++; r < t.length;) {
|
|
1141
1421
|
let e = t[r];
|
|
1142
|
-
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) ||
|
|
1422
|
+
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Mr(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
|
|
1143
1423
|
l.push(e), r++;
|
|
1144
1424
|
}
|
|
1145
1425
|
n.push({
|
|
@@ -1149,15 +1429,15 @@ function Kn(e) {
|
|
|
1149
1429
|
}
|
|
1150
1430
|
return n;
|
|
1151
1431
|
}
|
|
1152
|
-
function
|
|
1432
|
+
function Pr(e, t) {
|
|
1153
1433
|
if (t + 1 >= e.length) return null;
|
|
1154
1434
|
let n = e[t], r = e[t + 1];
|
|
1155
1435
|
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1156
|
-
let i =
|
|
1436
|
+
let i = Fr(n), a = Ir(r), o = [], s = t + 2;
|
|
1157
1437
|
for (; s < e.length;) {
|
|
1158
1438
|
let t = e[s];
|
|
1159
1439
|
if (!t.includes("|")) break;
|
|
1160
|
-
o.push(
|
|
1440
|
+
o.push(Fr(t)), s++;
|
|
1161
1441
|
}
|
|
1162
1442
|
return {
|
|
1163
1443
|
token: {
|
|
@@ -1169,37 +1449,37 @@ function qn(e, t) {
|
|
|
1169
1449
|
nextLine: s
|
|
1170
1450
|
};
|
|
1171
1451
|
}
|
|
1172
|
-
function
|
|
1452
|
+
function Fr(e) {
|
|
1173
1453
|
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1174
1454
|
for (let e = 0; e < r.length; e++) r[e] === "\\" && e + 1 < r.length && r[e + 1] === "|" ? (a += "|", e++) : r[e] === "|" ? (i.push(a.trim()), a = "") : a += r[e];
|
|
1175
1455
|
return i.push(a.trim()), i;
|
|
1176
1456
|
}
|
|
1177
|
-
function
|
|
1178
|
-
return
|
|
1457
|
+
function Ir(e) {
|
|
1458
|
+
return Fr(e).map((e) => {
|
|
1179
1459
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1180
1460
|
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1181
1461
|
});
|
|
1182
1462
|
}
|
|
1183
|
-
function
|
|
1463
|
+
function Lr(e) {
|
|
1184
1464
|
let t = "", n = 0;
|
|
1185
1465
|
for (; n < e.length;) {
|
|
1186
1466
|
let r = e[n];
|
|
1187
1467
|
switch (r.type) {
|
|
1188
1468
|
case "heading": {
|
|
1189
1469
|
let e = r;
|
|
1190
|
-
t += `<h${e.level}>${
|
|
1470
|
+
t += `<h${e.level}>${Z(e.content)}</h${e.level}>`, n++;
|
|
1191
1471
|
break;
|
|
1192
1472
|
}
|
|
1193
1473
|
case "paragraph":
|
|
1194
|
-
t += `<p>${
|
|
1474
|
+
t += `<p>${Z(r.content)}</p>`, n++;
|
|
1195
1475
|
break;
|
|
1196
1476
|
case "codeBlock": {
|
|
1197
|
-
let e = r, i = e.language ? ` data-language="${
|
|
1198
|
-
t += `<pre><code${i}>${
|
|
1477
|
+
let e = r, i = e.language ? ` data-language="${X(e.language)}"` : "";
|
|
1478
|
+
t += `<pre><code${i}>${X(e.code)}</code></pre>`, n++;
|
|
1199
1479
|
break;
|
|
1200
1480
|
}
|
|
1201
1481
|
case "blockquote": {
|
|
1202
|
-
let e =
|
|
1482
|
+
let e = Lr(Nr(r.content));
|
|
1203
1483
|
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1204
1484
|
break;
|
|
1205
1485
|
}
|
|
@@ -1207,12 +1487,12 @@ function Xn(e) {
|
|
|
1207
1487
|
t += "<hr>", n++;
|
|
1208
1488
|
break;
|
|
1209
1489
|
case "listItem": {
|
|
1210
|
-
let r =
|
|
1490
|
+
let r = Rr(e, n);
|
|
1211
1491
|
t += r.html, n = r.nextIndex;
|
|
1212
1492
|
break;
|
|
1213
1493
|
}
|
|
1214
1494
|
case "table":
|
|
1215
|
-
t +=
|
|
1495
|
+
t += Br(r), n++;
|
|
1216
1496
|
break;
|
|
1217
1497
|
case "rawHtml":
|
|
1218
1498
|
t += r.content, n++;
|
|
@@ -1222,10 +1502,10 @@ function Xn(e) {
|
|
|
1222
1502
|
}
|
|
1223
1503
|
return t;
|
|
1224
1504
|
}
|
|
1225
|
-
function
|
|
1505
|
+
function Rr(e, t) {
|
|
1226
1506
|
let n = "", r = t, i = null;
|
|
1227
1507
|
for (; r < e.length && e[r].type === "listItem";) {
|
|
1228
|
-
let t = e[r], a =
|
|
1508
|
+
let t = e[r], a = zr(t.listType);
|
|
1229
1509
|
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1230
1510
|
if (a === "ordered") {
|
|
1231
1511
|
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
@@ -1235,11 +1515,11 @@ function Zn(e, t) {
|
|
|
1235
1515
|
}
|
|
1236
1516
|
if (t.listType === "task") {
|
|
1237
1517
|
let e = t.checked ? " checked" : "";
|
|
1238
|
-
n += `<li><input type="checkbox" disabled${e}><p>${
|
|
1239
|
-
} else n += `<li><p>${
|
|
1518
|
+
n += `<li><input type="checkbox" disabled${e}><p>${Z(t.content)}</p>`;
|
|
1519
|
+
} else n += `<li><p>${Z(t.content)}</p>`;
|
|
1240
1520
|
if (t.childContent) {
|
|
1241
|
-
let e =
|
|
1242
|
-
n +=
|
|
1521
|
+
let e = Nr(t.childContent);
|
|
1522
|
+
n += Lr(e);
|
|
1243
1523
|
}
|
|
1244
1524
|
n += "</li>", r++;
|
|
1245
1525
|
}
|
|
@@ -1248,16 +1528,16 @@ function Zn(e, t) {
|
|
|
1248
1528
|
nextIndex: r
|
|
1249
1529
|
};
|
|
1250
1530
|
}
|
|
1251
|
-
function
|
|
1531
|
+
function zr(e) {
|
|
1252
1532
|
return e === "ordered" ? "ordered" : "bullet";
|
|
1253
1533
|
}
|
|
1254
|
-
function
|
|
1534
|
+
function Br(e) {
|
|
1255
1535
|
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1256
1536
|
if (!n) {
|
|
1257
1537
|
t += "<thead><tr>";
|
|
1258
1538
|
for (let n = 0; n < r; n++) {
|
|
1259
1539
|
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1260
|
-
t += `<th${i}>${
|
|
1540
|
+
t += `<th${i}>${Z(e.headers[n])}</th>`;
|
|
1261
1541
|
}
|
|
1262
1542
|
t += "</tr></thead>";
|
|
1263
1543
|
}
|
|
@@ -1267,7 +1547,7 @@ function $n(e) {
|
|
|
1267
1547
|
t += "<tr>";
|
|
1268
1548
|
for (let i = 0; i < r; i++) {
|
|
1269
1549
|
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1270
|
-
t += `<td${o}>${
|
|
1550
|
+
t += `<td${o}>${Z(r)}</td>`;
|
|
1271
1551
|
}
|
|
1272
1552
|
t += "</tr>";
|
|
1273
1553
|
}
|
|
@@ -1275,38 +1555,38 @@ function $n(e) {
|
|
|
1275
1555
|
}
|
|
1276
1556
|
return t += "</table>", t;
|
|
1277
1557
|
}
|
|
1278
|
-
function
|
|
1279
|
-
return
|
|
1558
|
+
function Vr(e) {
|
|
1559
|
+
return Lr(Nr(e));
|
|
1280
1560
|
}
|
|
1281
1561
|
//#endregion
|
|
1282
1562
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1283
|
-
function
|
|
1284
|
-
return
|
|
1563
|
+
function Hr(e) {
|
|
1564
|
+
return Vr(e);
|
|
1285
1565
|
}
|
|
1286
|
-
function
|
|
1287
|
-
return
|
|
1566
|
+
function Ur(e, t) {
|
|
1567
|
+
return nr(Hr(e), t);
|
|
1288
1568
|
}
|
|
1289
1569
|
//#endregion
|
|
1290
1570
|
//#region src/editor/managers/ExportManager.ts
|
|
1291
|
-
var
|
|
1571
|
+
var Wr = class {
|
|
1292
1572
|
editor;
|
|
1293
1573
|
constructor(e) {
|
|
1294
1574
|
this.editor = e;
|
|
1295
1575
|
}
|
|
1296
1576
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
1297
|
-
return
|
|
1577
|
+
return We(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
1298
1578
|
}
|
|
1299
1579
|
blocksToFullHTML(e = this.editor.document) {
|
|
1300
|
-
return
|
|
1580
|
+
return ln(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
1301
1581
|
}
|
|
1302
1582
|
tryParseHTMLToBlocks(e) {
|
|
1303
|
-
return
|
|
1583
|
+
return nr(e, this.editor.pmSchema);
|
|
1304
1584
|
}
|
|
1305
1585
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1306
|
-
return
|
|
1586
|
+
return Ke(e, this.editor.pmSchema, this.editor, {});
|
|
1307
1587
|
}
|
|
1308
1588
|
tryParseMarkdownToBlocks(e) {
|
|
1309
|
-
return
|
|
1589
|
+
return Ur(e, this.editor.pmSchema);
|
|
1310
1590
|
}
|
|
1311
1591
|
pasteHTML(e, t = !1) {
|
|
1312
1592
|
let n = e;
|
|
@@ -1320,42 +1600,29 @@ var rr = class {
|
|
|
1320
1600
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
1321
1601
|
}
|
|
1322
1602
|
pasteMarkdown(e) {
|
|
1323
|
-
let t =
|
|
1603
|
+
let t = Hr(e);
|
|
1324
1604
|
return this.pasteHTML(t);
|
|
1325
1605
|
}
|
|
1326
1606
|
};
|
|
1327
1607
|
//#endregion
|
|
1328
1608
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1329
|
-
function
|
|
1330
|
-
let {
|
|
1331
|
-
return
|
|
1332
|
-
block:
|
|
1333
|
-
prevBlock: r === null ? void 0 :
|
|
1334
|
-
nextBlock: i === null ? void 0 :
|
|
1335
|
-
parentBlock: a === void 0 ? void 0 :
|
|
1609
|
+
function Gr(e) {
|
|
1610
|
+
let { block: t } = b(e), r = e.doc.resolve(t.beforePos).nodeBefore, i = e.doc.resolve(t.afterPos).nodeAfter, a = h(e.doc, t.beforePos)?.block.node;
|
|
1611
|
+
return {
|
|
1612
|
+
block: n(t.node, e.doc),
|
|
1613
|
+
prevBlock: r === null ? void 0 : n(r, e.doc),
|
|
1614
|
+
nextBlock: i === null ? void 0 : n(i, e.doc),
|
|
1615
|
+
parentBlock: a === void 0 ? void 0 : n(a, e.doc)
|
|
1336
1616
|
};
|
|
1337
1617
|
}
|
|
1338
|
-
function
|
|
1339
|
-
let r = typeof t == "string" ? t : t.id, i =
|
|
1340
|
-
if (!
|
|
1341
|
-
|
|
1342
|
-
if (s.isBlockContainer) {
|
|
1343
|
-
let t = s.blockContent;
|
|
1344
|
-
if (l === "none") {
|
|
1345
|
-
e.setSelection(j.create(e.doc, t.beforePos));
|
|
1346
|
-
return;
|
|
1347
|
-
}
|
|
1348
|
-
if (l === "inline" || l === "plain") n === "start" ? e.setSelection(N.create(e.doc, t.beforePos + 1)) : e.setSelection(N.create(e.doc, t.afterPos - 1));
|
|
1349
|
-
else if (l === "table") n === "start" ? e.setSelection(N.create(e.doc, t.beforePos + 4)) : e.setSelection(N.create(e.doc, t.afterPos - 4));
|
|
1350
|
-
else throw new _(l);
|
|
1351
|
-
} else {
|
|
1352
|
-
let t = n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild;
|
|
1353
|
-
ar(e, x(t, e.doc), n);
|
|
1354
|
-
}
|
|
1618
|
+
function Kr(e, t, n = "start") {
|
|
1619
|
+
let r = typeof t == "string" ? t : t.id, i = D(r, e.doc);
|
|
1620
|
+
if (!i) throw Error(`Block with ID ${r} not found`);
|
|
1621
|
+
e.setSelection(ge(e.doc, E(i.node, i.posBeforeNode), n));
|
|
1355
1622
|
}
|
|
1356
1623
|
//#endregion
|
|
1357
1624
|
//#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
|
|
1358
|
-
var
|
|
1625
|
+
var qr = [
|
|
1359
1626
|
"vscode-editor-data",
|
|
1360
1627
|
"blocknote/html",
|
|
1361
1628
|
"text/markdown",
|
|
@@ -1365,91 +1632,91 @@ var or = [
|
|
|
1365
1632
|
];
|
|
1366
1633
|
//#endregion
|
|
1367
1634
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1368
|
-
function
|
|
1635
|
+
function Jr(e, t) {
|
|
1369
1636
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1370
1637
|
return e === t;
|
|
1371
1638
|
}
|
|
1372
|
-
function
|
|
1639
|
+
function Yr(e, t) {
|
|
1373
1640
|
let n = e.split("/"), r = t.split("/");
|
|
1374
1641
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1375
1642
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1376
1643
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1377
1644
|
}
|
|
1378
|
-
function
|
|
1645
|
+
function Xr(e, t, n, r = "after") {
|
|
1379
1646
|
let i;
|
|
1380
1647
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1381
1648
|
}
|
|
1382
|
-
async function
|
|
1649
|
+
async function Zr(e, t) {
|
|
1383
1650
|
if (!t.uploadFile) {
|
|
1384
1651
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1385
1652
|
return;
|
|
1386
1653
|
}
|
|
1387
1654
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1388
1655
|
if (n === null) return;
|
|
1389
|
-
let
|
|
1390
|
-
for (let e of
|
|
1391
|
-
|
|
1656
|
+
let i = null;
|
|
1657
|
+
for (let e of qr) if (n.types.includes(e)) {
|
|
1658
|
+
i = e;
|
|
1392
1659
|
break;
|
|
1393
1660
|
}
|
|
1394
|
-
if (
|
|
1395
|
-
let
|
|
1396
|
-
if (
|
|
1661
|
+
if (i !== "Files") return;
|
|
1662
|
+
let a = n.items;
|
|
1663
|
+
if (a) {
|
|
1397
1664
|
e.preventDefault();
|
|
1398
|
-
for (let n = 0; n <
|
|
1399
|
-
let
|
|
1400
|
-
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta
|
|
1401
|
-
let
|
|
1402
|
-
if (o && (!
|
|
1403
|
-
|
|
1665
|
+
for (let n = 0; n < a.length; n++) {
|
|
1666
|
+
let i = "file";
|
|
1667
|
+
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta.fileBlockAccept || []) {
|
|
1668
|
+
let r = t.startsWith("."), o = a[n].getAsFile();
|
|
1669
|
+
if (o && (!r && o.type && Yr(a[n].type, t) || r && Jr("." + o.name.split(".").pop(), t))) {
|
|
1670
|
+
i = e.config.type;
|
|
1404
1671
|
break;
|
|
1405
1672
|
}
|
|
1406
1673
|
}
|
|
1407
|
-
let
|
|
1408
|
-
if (
|
|
1674
|
+
let o = a[n].getAsFile();
|
|
1675
|
+
if (o) {
|
|
1409
1676
|
let n = {
|
|
1410
|
-
type:
|
|
1411
|
-
props: { name:
|
|
1412
|
-
},
|
|
1677
|
+
type: i,
|
|
1678
|
+
props: { name: o.name }
|
|
1679
|
+
}, a;
|
|
1413
1680
|
if (e.type === "paste") {
|
|
1414
1681
|
let e = t.getTextCursorPosition().block;
|
|
1415
|
-
|
|
1682
|
+
a = Xr(t, e, n);
|
|
1416
1683
|
} else if (e.type === "drop") {
|
|
1417
|
-
let
|
|
1684
|
+
let i = {
|
|
1418
1685
|
left: e.clientX,
|
|
1419
1686
|
top: e.clientY
|
|
1420
|
-
},
|
|
1421
|
-
if (!
|
|
1422
|
-
|
|
1423
|
-
let
|
|
1424
|
-
if (
|
|
1687
|
+
}, o = t.prosemirrorView.posAtCoords(i);
|
|
1688
|
+
if (!o) return;
|
|
1689
|
+
a = t.transact((e) => {
|
|
1690
|
+
let a = T(e, o.pos), s = r(a.block.node, e.doc), c = (t.domElement?.querySelector(`[data-id="${s}"]`))?.getBoundingClientRect(), l = t.getBlock(s);
|
|
1691
|
+
if (l) return Xr(t, l, n, c && (c.top + c.bottom) / 2 > i.top ? "before" : "after");
|
|
1425
1692
|
});
|
|
1426
1693
|
} else return;
|
|
1427
|
-
if (!
|
|
1428
|
-
let
|
|
1429
|
-
t.updateBlock(
|
|
1694
|
+
if (!a) return;
|
|
1695
|
+
let s = await t.uploadFile(o, a), c = typeof s == "string" ? { props: { url: s } } : { ...s };
|
|
1696
|
+
t.updateBlock(a, c);
|
|
1430
1697
|
}
|
|
1431
1698
|
}
|
|
1432
1699
|
}
|
|
1433
1700
|
}
|
|
1434
1701
|
//#endregion
|
|
1435
1702
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1436
|
-
var
|
|
1703
|
+
var Qr = (e) => I.create({
|
|
1437
1704
|
name: "dropFile",
|
|
1438
1705
|
addProseMirrorPlugins() {
|
|
1439
|
-
return [new
|
|
1706
|
+
return [new j({ props: { handleDOMEvents: { drop(t, n) {
|
|
1440
1707
|
if (!e.isEditable) return;
|
|
1441
1708
|
let r = null;
|
|
1442
|
-
for (let e of
|
|
1709
|
+
for (let e of qr) if (n.dataTransfer.types.includes(e)) {
|
|
1443
1710
|
r = e;
|
|
1444
1711
|
break;
|
|
1445
1712
|
}
|
|
1446
|
-
return r === null || r === "Files" && (
|
|
1713
|
+
return r === null || r === "Files" && (Zr(n, e), !0);
|
|
1447
1714
|
} } } })];
|
|
1448
1715
|
}
|
|
1449
|
-
}),
|
|
1716
|
+
}), $r = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, ei = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, ti = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, ni = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, ri = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, ii = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, ai = /\n{2} {0,3}-{2,48}\n{2}/, oi = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, si = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, ci = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, li = /^\s*\|(.+\|)+\s*$/m, ui = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, di = /^\s*\|(.+\|)+\s*$/m, fi = (e) => $r.test(e) || ei.test(e) || ti.test(e) || ni.test(e) || ri.test(e) || ii.test(e) || ai.test(e) || oi.test(e) || si.test(e) || ci.test(e) || li.test(e) || ui.test(e) || di.test(e);
|
|
1450
1717
|
//#endregion
|
|
1451
1718
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1452
|
-
function
|
|
1719
|
+
function pi(e, t) {
|
|
1453
1720
|
let { schema: n } = t.state;
|
|
1454
1721
|
if (!e.clipboardData) return !1;
|
|
1455
1722
|
let r = e.clipboardData.getData("text/plain");
|
|
@@ -1459,39 +1726,39 @@ function Er(e, t) {
|
|
|
1459
1726
|
}
|
|
1460
1727
|
//#endregion
|
|
1461
1728
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1462
|
-
function
|
|
1729
|
+
function mi({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1463
1730
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1464
1731
|
let n = e.clipboardData?.getData("text/plain");
|
|
1465
1732
|
if (n) return t.pasteText(n), !0;
|
|
1466
1733
|
}
|
|
1467
1734
|
let i;
|
|
1468
|
-
for (let t of
|
|
1735
|
+
for (let t of qr) if (e.clipboardData.types.includes(t)) {
|
|
1469
1736
|
i = t;
|
|
1470
1737
|
break;
|
|
1471
1738
|
}
|
|
1472
1739
|
if (!i) return !0;
|
|
1473
1740
|
if (i === "vscode-editor-data") {
|
|
1474
|
-
if (
|
|
1741
|
+
if (pi(e, t.prosemirrorView)) return !0;
|
|
1475
1742
|
i = "text/plain";
|
|
1476
1743
|
}
|
|
1477
|
-
if (i === "Files") return
|
|
1744
|
+
if (i === "Files") return Zr(e, t), !0;
|
|
1478
1745
|
let a = e.clipboardData.getData(i);
|
|
1479
1746
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1480
1747
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1481
1748
|
if (n) {
|
|
1482
1749
|
let n = e.clipboardData.getData("text/plain");
|
|
1483
|
-
if (
|
|
1750
|
+
if (fi(n)) return t.pasteMarkdown(n), !0;
|
|
1484
1751
|
}
|
|
1485
1752
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1486
1753
|
}
|
|
1487
|
-
var
|
|
1754
|
+
var hi = (e, t) => I.create({
|
|
1488
1755
|
name: "pasteFromClipboard",
|
|
1489
1756
|
addProseMirrorPlugins() {
|
|
1490
|
-
return [new
|
|
1757
|
+
return [new j({ props: { handleDOMEvents: { paste(n, r) {
|
|
1491
1758
|
if (r.preventDefault(), e.isEditable) return t({
|
|
1492
1759
|
event: r,
|
|
1493
1760
|
editor: e,
|
|
1494
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1761
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => mi({
|
|
1495
1762
|
event: r,
|
|
1496
1763
|
editor: e,
|
|
1497
1764
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -1503,20 +1770,20 @@ var Or = (e, t) => D.create({
|
|
|
1503
1770
|
});
|
|
1504
1771
|
//#endregion
|
|
1505
1772
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1506
|
-
function
|
|
1507
|
-
let r = !1, i = e.state.selection instanceof
|
|
1773
|
+
function gi(e, t, n) {
|
|
1774
|
+
let r = !1, i = e.state.selection instanceof z;
|
|
1508
1775
|
if (!i) {
|
|
1509
1776
|
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
1510
1777
|
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
1511
1778
|
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
1512
1779
|
}
|
|
1513
|
-
let a, o =
|
|
1780
|
+
let a, o = We(e.state.schema, n);
|
|
1514
1781
|
if (i) {
|
|
1515
1782
|
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
1516
|
-
let e =
|
|
1783
|
+
let e = re(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1517
1784
|
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
1518
1785
|
} else if (r) {
|
|
1519
|
-
let e =
|
|
1786
|
+
let e = we(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1520
1787
|
a = o.exportInlineContent(e, {});
|
|
1521
1788
|
} else {
|
|
1522
1789
|
let e = Ie(t);
|
|
@@ -1524,16 +1791,16 @@ function kr(e, t, n) {
|
|
|
1524
1791
|
}
|
|
1525
1792
|
return a;
|
|
1526
1793
|
}
|
|
1527
|
-
function
|
|
1528
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
1529
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i =
|
|
1794
|
+
function $(e, t) {
|
|
1795
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new A(t.doc.resolve(e.state.selection.from - 1))));
|
|
1796
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = gi(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.schema.blockSpecs[s];
|
|
1530
1797
|
return {
|
|
1531
1798
|
clipboardHTML: n,
|
|
1532
1799
|
externalHTML: i,
|
|
1533
|
-
markdown: a.sameParent(o) && c?.implementation.meta
|
|
1800
|
+
markdown: a.sameParent(o) && c?.implementation.meta.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : $e(i)
|
|
1534
1801
|
};
|
|
1535
1802
|
}
|
|
1536
|
-
var
|
|
1803
|
+
var _i = (e) => {
|
|
1537
1804
|
if (e.state.selection.empty) return !0;
|
|
1538
1805
|
let t = window.getSelection();
|
|
1539
1806
|
if (t && !t.isCollapsed) {
|
|
@@ -1544,37 +1811,37 @@ var jr = (e) => {
|
|
|
1544
1811
|
}
|
|
1545
1812
|
}
|
|
1546
1813
|
return !1;
|
|
1547
|
-
},
|
|
1814
|
+
}, vi = (e, t, n) => {
|
|
1548
1815
|
n.preventDefault(), n.clipboardData.clearData();
|
|
1549
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1816
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = $(t, e);
|
|
1550
1817
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
1551
|
-
},
|
|
1818
|
+
}, yi = (e) => I.create({
|
|
1552
1819
|
name: "copyToClipboard",
|
|
1553
1820
|
addProseMirrorPlugins() {
|
|
1554
|
-
return [new
|
|
1821
|
+
return [new j({ props: { handleDOMEvents: {
|
|
1555
1822
|
copy(t, n) {
|
|
1556
|
-
return
|
|
1823
|
+
return _i(t) || vi(e, t, n), !0;
|
|
1557
1824
|
},
|
|
1558
1825
|
cut(t, n) {
|
|
1559
|
-
return
|
|
1826
|
+
return _i(t) ? !0 : (vi(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
1560
1827
|
},
|
|
1561
1828
|
dragstart(t, n) {
|
|
1562
1829
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1563
|
-
e.transact((e) => e.setSelection(new
|
|
1564
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1830
|
+
e.transact((e) => e.setSelection(new A(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1831
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = $(t, e);
|
|
1565
1832
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1566
1833
|
}
|
|
1567
1834
|
} } })];
|
|
1568
1835
|
}
|
|
1569
|
-
}),
|
|
1836
|
+
}), bi = I.create({
|
|
1570
1837
|
name: "blockBackgroundColor",
|
|
1571
1838
|
addGlobalAttributes() {
|
|
1572
1839
|
return [{
|
|
1573
1840
|
types: ["tableCell", "tableHeader"],
|
|
1574
|
-
attributes: { backgroundColor:
|
|
1841
|
+
attributes: { backgroundColor: ne() }
|
|
1575
1842
|
}];
|
|
1576
1843
|
}
|
|
1577
|
-
}),
|
|
1844
|
+
}), xi = L.create({
|
|
1578
1845
|
name: "hardBreak",
|
|
1579
1846
|
inline: !0,
|
|
1580
1847
|
group: "inline",
|
|
@@ -1585,295 +1852,326 @@ var jr = (e) => {
|
|
|
1585
1852
|
return [{ tag: "br" }];
|
|
1586
1853
|
},
|
|
1587
1854
|
renderHTML({ HTMLAttributes: e }) {
|
|
1588
|
-
return ["br",
|
|
1855
|
+
return ["br", St(this.options.HTMLAttributes, e)];
|
|
1589
1856
|
},
|
|
1590
1857
|
renderText() {
|
|
1591
1858
|
return "\n";
|
|
1592
1859
|
}
|
|
1593
|
-
})
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
if (
|
|
1601
|
-
let i = n
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
}, Lr = (e, t) => {
|
|
1609
|
-
for (; t.childContainer;) {
|
|
1610
|
-
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1611
|
-
t = b(e.resolve(r));
|
|
1860
|
+
});
|
|
1861
|
+
//#endregion
|
|
1862
|
+
//#region src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts
|
|
1863
|
+
function Si(e, t) {
|
|
1864
|
+
return e.contentKind === "inline" && t.contentKind === "inline" ? t.content.node.content : void 0;
|
|
1865
|
+
}
|
|
1866
|
+
function Ci(e, t, n, r) {
|
|
1867
|
+
if (!n.children) return !1;
|
|
1868
|
+
let i = Si(n, r);
|
|
1869
|
+
if (i === void 0 || i.size > 0 && !n.content.node.type.validContent(n.content.node.content.append(i))) return !1;
|
|
1870
|
+
if (t) {
|
|
1871
|
+
let a = e.tr;
|
|
1872
|
+
n.children.node.childCount === 1 && !r.children ? a.delete(n.children.beforePos, n.children.afterPos) : a.replaceWith(r.block.beforePos, r.block.afterPos, r.children?.node.content ?? O.empty);
|
|
1873
|
+
let o = n.contentEnd;
|
|
1874
|
+
i.size > 0 && a.insert(o, i), a.setSelection(M.near(a.doc.resolve(o), -1)), t(a.scrollIntoView());
|
|
1612
1875
|
}
|
|
1613
|
-
return
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1876
|
+
return !0;
|
|
1877
|
+
}
|
|
1878
|
+
var wi = (e) => ({ state: t, dispatch: n }) => {
|
|
1879
|
+
let r = w(t.doc, e);
|
|
1880
|
+
if (!r.hasContent) return !1;
|
|
1881
|
+
let i = x(t.doc, r.block.beforePos);
|
|
1882
|
+
if (!i) {
|
|
1883
|
+
let e = h(t.doc, r.block.beforePos);
|
|
1884
|
+
return e?.hasContent ? Ci(t, n, e, r) : !1;
|
|
1885
|
+
}
|
|
1886
|
+
let a = Te(i);
|
|
1887
|
+
if (!a.hasContent || Si(a, r) === void 0) return !1;
|
|
1888
|
+
if (a.isContentEmpty && a.content.node.sameMarkup(r.content.node)) {
|
|
1889
|
+
if (n) {
|
|
1890
|
+
let e = t.tr.delete(r.block.beforePos, r.block.afterPos).replaceWith(a.block.beforePos, a.block.afterPos, r.block.node);
|
|
1891
|
+
e.setSelection(N.create(e.doc, a.contentStart)), n(e.scrollIntoView());
|
|
1621
1892
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
t(
|
|
1893
|
+
return !0;
|
|
1894
|
+
}
|
|
1895
|
+
if (n && r.children) {
|
|
1896
|
+
let e = t.doc.resolve(r.children.childrenStart).blockRange(t.doc.resolve(r.children.childrenEnd));
|
|
1897
|
+
if (!e) throw Error("Children of a block are expected to form a block range");
|
|
1898
|
+
t.tr.lift(e, t.doc.resolve(r.block.beforePos).depth);
|
|
1899
|
+
}
|
|
1900
|
+
return n && n(t.tr.delete(a.contentEnd, r.contentStart)), !0;
|
|
1901
|
+
}, Ti = (e, t, n, r) => ({ state: i, dispatch: a }) => !a || Ei(i.tr, e, t, n, r), Ei = (e, t, n, r, i) => {
|
|
1902
|
+
let a = y(e.doc, t), o = E(a.node, a.posBeforeNode);
|
|
1903
|
+
if (!o.hasContent) return !1;
|
|
1904
|
+
let s = _(e), c = [{
|
|
1905
|
+
type: o.block.node.type,
|
|
1906
|
+
attrs: r ? {
|
|
1907
|
+
...o.block.node.attrs,
|
|
1908
|
+
id: void 0
|
|
1909
|
+
} : {}
|
|
1910
|
+
}, {
|
|
1911
|
+
type: n ? o.content.node.type : s.nodes.paragraph,
|
|
1912
|
+
attrs: r ? { ...o.content.node.attrs } : {}
|
|
1913
|
+
}], l = i && t !== o.contentStart ? o.children : void 0;
|
|
1914
|
+
if (l && e.delete(l.beforePos, l.afterPos), e.split(t, 2, c), l) {
|
|
1915
|
+
let t = e.doc.nodeAt(o.block.beforePos);
|
|
1916
|
+
if (!t?.firstChild) throw Error("Split lost its original block");
|
|
1917
|
+
e.insert(o.block.beforePos + 1 + t.firstChild.nodeSize, l.node);
|
|
1626
1918
|
}
|
|
1627
1919
|
return !0;
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1920
|
+
};
|
|
1921
|
+
//#endregion
|
|
1922
|
+
//#region src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts
|
|
1923
|
+
function Di(e, t, n) {
|
|
1924
|
+
let r = ce(e.doc, t.beforePos);
|
|
1925
|
+
e.delete(t.beforePos, t.afterPos);
|
|
1926
|
+
let i = e.mapping.map(n);
|
|
1927
|
+
e.insert(i, t.node);
|
|
1928
|
+
let a = e.steps.length;
|
|
1929
|
+
zt(e, r), e.setSelection(N.near(e.doc.resolve(e.mapping.slice(a).map(i) + 1)));
|
|
1930
|
+
}
|
|
1931
|
+
function Oi(e, t, n, r = n.block) {
|
|
1932
|
+
return e.insertContentAt(n.block.afterPos, n.children?.node.content || O.empty).deleteRange({
|
|
1933
|
+
from: r.beforePos,
|
|
1934
|
+
to: r.afterPos
|
|
1935
|
+
}).insertContentAt(t.contentEnd, Si(t, n) ?? null).setTextSelection(t.contentEnd).scrollIntoView().run();
|
|
1936
|
+
}
|
|
1937
|
+
var ki = I.create({
|
|
1634
1938
|
priority: 50,
|
|
1635
1939
|
addKeyboardShortcuts() {
|
|
1636
|
-
let e =
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
})
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
return e.selection.from === r.beforePos + 1 && W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup);
|
|
1940
|
+
let e = this.options.editor;
|
|
1941
|
+
function r(t, r) {
|
|
1942
|
+
let i = n(t, r);
|
|
1943
|
+
return e.schema.blockSpecs[i.type].implementation.keyboard(i);
|
|
1944
|
+
}
|
|
1945
|
+
function i(e) {
|
|
1946
|
+
return (t) => r(t, e).childrenCanOutdent;
|
|
1947
|
+
}
|
|
1948
|
+
let o = () => this.editor.commands.first(({ chain: e, commands: n }) => [
|
|
1949
|
+
() => n.deleteSelection(),
|
|
1950
|
+
() => n.undoInputRule(),
|
|
1951
|
+
() => n.command(({ state: e }) => {
|
|
1952
|
+
let t = b(e);
|
|
1953
|
+
if (!t.hasContent || e.selection.from !== t.contentStart) return !1;
|
|
1954
|
+
let i = r(t.block.node, e.doc).resetsTo, a = t.content.node;
|
|
1955
|
+
return a.type.name === i.type && Object.entries(i.props ?? {}).every(([e, t]) => a.attrs[e] === t) ? !1 : n.command(G(t.block.beforePos, i));
|
|
1653
1956
|
}),
|
|
1654
|
-
() =>
|
|
1655
|
-
let n =
|
|
1656
|
-
if (!n.
|
|
1657
|
-
let {
|
|
1658
|
-
if (
|
|
1659
|
-
let
|
|
1660
|
-
return
|
|
1957
|
+
() => n.command(({ state: t }) => {
|
|
1958
|
+
let n = b(t);
|
|
1959
|
+
if (!n.hasContent) return !1;
|
|
1960
|
+
let { block: r } = n, i = x(t.doc, n.block.beforePos);
|
|
1961
|
+
if (i && !i.hasContent) return !1;
|
|
1962
|
+
let a = t.selection.from === n.contentStart, o = t.selection.empty, s = r.beforePos;
|
|
1963
|
+
return a && o ? e().command(wi(s)).scrollIntoView().run() : !1;
|
|
1661
1964
|
}),
|
|
1662
|
-
() =>
|
|
1663
|
-
let
|
|
1664
|
-
if (!
|
|
1665
|
-
let i =
|
|
1666
|
-
if (
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1965
|
+
() => n.command(({ state: e, tr: n, dispatch: r }) => {
|
|
1966
|
+
let i = b(e);
|
|
1967
|
+
if (!i.hasContent || e.selection.from !== i.contentStart) return !1;
|
|
1968
|
+
let a = i.block.node.type, o = x(n.doc, i.block.beforePos), s;
|
|
1969
|
+
if (o) {
|
|
1970
|
+
if (o.hasContent) return !1;
|
|
1971
|
+
} else {
|
|
1972
|
+
let e = n.doc.resolve(i.block.beforePos);
|
|
1973
|
+
if (!v(e.parent.type)) return !1;
|
|
1974
|
+
let t = n.doc.resolve(e.before()), r = t.nodeBefore;
|
|
1975
|
+
v(t.parent.type) && r && v(r.type) ? o = E(r, t.pos - r.nodeSize) : s = xe(n.doc, t.pos, a);
|
|
1670
1976
|
}
|
|
1671
|
-
return !
|
|
1977
|
+
return o && (s = t(n.doc, o, "last-child", a)?.pos), s !== void 0 && (r && Di(n, i.block, s), !0);
|
|
1672
1978
|
}),
|
|
1673
|
-
() =>
|
|
1674
|
-
let r =
|
|
1675
|
-
if (!r.
|
|
1676
|
-
let i =
|
|
1677
|
-
|
|
1678
|
-
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1679
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), z(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(N.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(N.near(t.doc.resolve(o.pos))))), !0;
|
|
1979
|
+
() => n.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1980
|
+
let r = b(e);
|
|
1981
|
+
if (!r.hasContent || !e.selection.empty || r.contentKind !== "inline" || !r.isContentEmpty) return !1;
|
|
1982
|
+
let i = x(e.doc, r.block.beforePos), a = i ? void 0 : h(e.doc, r.block.beforePos), o = i ? Te(i) : a;
|
|
1983
|
+
return o?.hasContent ? (n && (a?.children?.node.childCount === 1 && !r.children ? t.delete(a.children.beforePos, a.children.afterPos) : t.replaceWith(r.block.beforePos, r.block.afterPos, r.children?.node.content ?? O.empty), t.setSelection(o.contentKind === "none" ? A.create(t.doc, o.content.beforePos) : N.near(t.doc.resolve(o.contentEnd), -1)), t.scrollIntoView()), !0) : !1;
|
|
1680
1984
|
}),
|
|
1681
|
-
() =>
|
|
1682
|
-
let
|
|
1683
|
-
if (!
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
if (
|
|
1689
|
-
let a = e();
|
|
1690
|
-
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
1691
|
-
let e = n.bnBlock.beforePos - 1 - 1 - 1 - 1 - 1;
|
|
1692
|
-
a = a.setTextSelection(e);
|
|
1693
|
-
} else if (i.blockContent.node.type.spec.content === "") a = a.setNodeSelection(i.blockContent.beforePos);
|
|
1694
|
-
else {
|
|
1695
|
-
let e = i.blockContent.afterPos - 1;
|
|
1696
|
-
a = a.setTextSelection(e);
|
|
1697
|
-
}
|
|
1698
|
-
return a.deleteRange({
|
|
1699
|
-
from: n.bnBlock.beforePos,
|
|
1700
|
-
to: n.bnBlock.afterPos
|
|
1701
|
-
}).scrollIntoView().run();
|
|
1985
|
+
() => n.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1986
|
+
let r = b(e);
|
|
1987
|
+
if (!r.hasContent) return !1;
|
|
1988
|
+
let i = e.selection.from === r.contentStart, a = e.selection.empty, o = x(e.doc, r.block.beforePos);
|
|
1989
|
+
if (o && i && a) {
|
|
1990
|
+
let e = Te(o);
|
|
1991
|
+
if (!e.hasContent) return !1;
|
|
1992
|
+
if (e.contentKind === "none" || e.contentKind === "inline" && e.isContentEmpty) return n && (t.delete(r.block.beforePos, r.block.afterPos), t.replaceWith(e.block.beforePos, e.block.afterPos, r.block.node), t.setSelection(N.near(t.doc.resolve(e.block.beforePos + 2))), t.scrollIntoView()), !0;
|
|
1702
1993
|
}
|
|
1703
1994
|
return !1;
|
|
1704
1995
|
}),
|
|
1705
|
-
() =>
|
|
1706
|
-
let n =
|
|
1707
|
-
|
|
1708
|
-
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = X(t.doc, n.bnBlock.beforePos);
|
|
1709
|
-
if (a && r && i) {
|
|
1710
|
-
let r = Lr(t.doc, a);
|
|
1711
|
-
if (!r.isBlockContainer) return !1;
|
|
1712
|
-
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1713
|
-
from: n.bnBlock.beforePos,
|
|
1714
|
-
to: n.bnBlock.afterPos
|
|
1715
|
-
}, r.bnBlock.afterPos).deleteRange({
|
|
1716
|
-
from: r.bnBlock.beforePos,
|
|
1717
|
-
to: r.bnBlock.afterPos
|
|
1718
|
-
}).run();
|
|
1719
|
-
}
|
|
1720
|
-
return !1;
|
|
1996
|
+
() => n.command(({ state: e, tr: t }) => {
|
|
1997
|
+
let n = b(e);
|
|
1998
|
+
return !n.hasContent || !e.selection.empty || e.selection.from !== n.contentStart ? !1 : Mn(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup, i(t.doc));
|
|
1721
1999
|
})
|
|
1722
|
-
]),
|
|
2000
|
+
]), s = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1723
2001
|
() => t.deleteSelection(),
|
|
1724
2002
|
() => t.command(({ state: t }) => {
|
|
1725
|
-
let n =
|
|
1726
|
-
if (!n.
|
|
1727
|
-
let {
|
|
1728
|
-
if (
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || w.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1732
|
-
from: i.beforePos,
|
|
1733
|
-
to: i.afterPos
|
|
1734
|
-
} : {
|
|
1735
|
-
from: s.bnBlock.beforePos,
|
|
1736
|
-
to: s.bnBlock.afterPos
|
|
1737
|
-
}).insertContentAt(t.selection.from, a && o ? n.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
1738
|
-
}
|
|
1739
|
-
return !1;
|
|
2003
|
+
let n = b(t);
|
|
2004
|
+
if (!n.hasContent || !n.children) return !1;
|
|
2005
|
+
let { children: r } = n;
|
|
2006
|
+
if (r.node.childCount === 0) return !1;
|
|
2007
|
+
let i = t.selection.from === n.contentEnd, a = t.selection.empty, o = w(t.doc, r.childrenStart);
|
|
2008
|
+
return o.hasContent && i && a ? Oi(e(), n, o, r.node.childCount === 1 ? r : o.block) : !1;
|
|
1740
2009
|
}),
|
|
1741
2010
|
() => t.command(({ state: t }) => {
|
|
1742
|
-
let n =
|
|
1743
|
-
if (!n.
|
|
1744
|
-
let {
|
|
1745
|
-
if (!
|
|
1746
|
-
let o = t.selection.from ===
|
|
1747
|
-
return o && s ? e().command(
|
|
2011
|
+
let n = b(t);
|
|
2012
|
+
if (!n.hasContent) return !1;
|
|
2013
|
+
let { block: r } = n, i = a(t.doc, n.block.beforePos);
|
|
2014
|
+
if (!i || !i.hasContent) return !1;
|
|
2015
|
+
let o = t.selection.from === n.contentEnd, s = t.selection.empty, c = r.afterPos;
|
|
2016
|
+
return o && s ? e().command(wi(c)).scrollIntoView().run() : !1;
|
|
1748
2017
|
}),
|
|
1749
2018
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1750
|
-
let r =
|
|
1751
|
-
if (!r.
|
|
1752
|
-
let i =
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
return !1;
|
|
1759
|
-
}),
|
|
1760
|
-
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1761
|
-
let r = v(e);
|
|
1762
|
-
if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1763
|
-
let i = t.doc.resolve(r.bnBlock.afterPos);
|
|
1764
|
-
if (i.nodeAfter || i.node().type.name !== "column") return !1;
|
|
1765
|
-
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1766
|
-
if (n) {
|
|
1767
|
-
let e = o.pos === s - 1 ? s : o.pos + 1, n = b(t.doc.resolve(e));
|
|
1768
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), z(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(N.near(t.doc.resolve(e)));
|
|
1769
|
-
}
|
|
1770
|
-
return !0;
|
|
2019
|
+
let r = b(e);
|
|
2020
|
+
if (!r.hasContent || e.selection.from !== r.contentEnd) return !1;
|
|
2021
|
+
let i = t.doc.resolve(r.block.afterPos);
|
|
2022
|
+
for (; !i.nodeAfter && i.depth > 0 && v(i.parent.type);) i = t.doc.resolve(i.after());
|
|
2023
|
+
let a = i.nodeAfter;
|
|
2024
|
+
if (!a || i.pos === r.block.afterPos && !v(a.type)) return !1;
|
|
2025
|
+
let o = te(E(a, i.pos));
|
|
2026
|
+
return o ? (n && Di(t, o.block, r.block.afterPos), !0) : !1;
|
|
1771
2027
|
}),
|
|
1772
2028
|
() => t.command(({ state: t }) => {
|
|
1773
|
-
let n =
|
|
1774
|
-
if (!n.
|
|
1775
|
-
let
|
|
1776
|
-
if (
|
|
1777
|
-
let i =
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
let r = Ir(e, t);
|
|
1781
|
-
if (r) return i(e, r.bnBlock.beforePos);
|
|
1782
|
-
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1783
|
-
if (!a || !a.isBlockContainer) return !1;
|
|
1784
|
-
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
|
|
1785
|
-
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || w.empty).deleteRange({
|
|
1786
|
-
from: a.bnBlock.beforePos,
|
|
1787
|
-
to: a.bnBlock.afterPos
|
|
1788
|
-
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
2029
|
+
let n = b(t);
|
|
2030
|
+
if (!n.hasContent) return !1;
|
|
2031
|
+
let r = t.selection.from === n.contentEnd, i = t.selection.empty;
|
|
2032
|
+
if (r && i) {
|
|
2033
|
+
let r, i = n;
|
|
2034
|
+
for (; i && (r = a(t.doc, i.block.beforePos), !r);) i = h(t.doc, i.block.beforePos);
|
|
2035
|
+
return !r || !r.hasContent ? !1 : Oi(e(), n, r, r.block);
|
|
1789
2036
|
}
|
|
1790
2037
|
return !1;
|
|
1791
2038
|
}),
|
|
1792
2039
|
() => t.command(({ state: t }) => {
|
|
1793
|
-
let n =
|
|
1794
|
-
if (!n.
|
|
1795
|
-
if (n.
|
|
1796
|
-
let r =
|
|
1797
|
-
if (!r || !r.
|
|
2040
|
+
let n = b(t);
|
|
2041
|
+
if (!n.hasContent) return !1;
|
|
2042
|
+
if (n.isContentEmpty && n.contentKind === "inline") {
|
|
2043
|
+
let r = a(t.doc, n.block.beforePos);
|
|
2044
|
+
if (!r || !r.hasContent) return !1;
|
|
1798
2045
|
let i = e();
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
} else i = r.blockContent.node.type.spec.content === "" ? i.setNodeSelection(r.blockContent.beforePos) : i.setTextSelection(r.blockContent.beforePos + 1);
|
|
1803
|
-
return i.deleteRange({
|
|
1804
|
-
from: n.bnBlock.beforePos,
|
|
1805
|
-
to: n.bnBlock.afterPos
|
|
2046
|
+
return i.command(({ tr: e }) => (e.setSelection(ge(e.doc, r, "start")), !0)), i.deleteRange({
|
|
2047
|
+
from: n.block.beforePos,
|
|
2048
|
+
to: n.block.afterPos
|
|
1806
2049
|
}).scrollIntoView().run();
|
|
1807
2050
|
}
|
|
1808
2051
|
return !1;
|
|
1809
2052
|
}),
|
|
1810
2053
|
() => t.command(({ state: t }) => {
|
|
1811
|
-
let n =
|
|
1812
|
-
if (!n.
|
|
1813
|
-
let r = t.selection.from === n.
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
from: a.bnBlock.beforePos,
|
|
1819
|
-
to: a.bnBlock.afterPos
|
|
1820
|
-
}).insertContentAt(n.bnBlock.afterPos, a.bnBlock.node.childCount === 2 ? t : null).run();
|
|
1821
|
-
}
|
|
1822
|
-
return !1;
|
|
2054
|
+
let n = b(t);
|
|
2055
|
+
if (!n.hasContent) return !1;
|
|
2056
|
+
let r = t.selection.from === n.contentEnd, i = t.selection.empty, o = a(t.doc, n.block.beforePos);
|
|
2057
|
+
return !o || !o.hasContent ? !1 : o && r && i && (o.contentKind === "none" || o.contentKind === "inline" && o.isContentEmpty) ? e().deleteRange({
|
|
2058
|
+
from: o.block.beforePos,
|
|
2059
|
+
to: o.block.afterPos
|
|
2060
|
+
}).insertContentAt(n.block.afterPos, o.children?.node.content ?? null).run() : !1;
|
|
1823
2061
|
})
|
|
1824
|
-
]),
|
|
2062
|
+
]), c = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
|
|
2063
|
+
() => t.command(({ state: e }) => {
|
|
2064
|
+
let n = b(e);
|
|
2065
|
+
if (!n.hasContent || !e.selection.empty || !n.isContentEmpty) return !1;
|
|
2066
|
+
let i = r(n.block.node, e.doc);
|
|
2067
|
+
return i.emptyEnterResets ? t.command(G(n.block.beforePos, i.resetsTo)) : !1;
|
|
2068
|
+
}),
|
|
1825
2069
|
() => t.command(({ state: e, tr: t }) => {
|
|
1826
|
-
let n =
|
|
1827
|
-
if (!n.
|
|
1828
|
-
let {
|
|
1829
|
-
|
|
2070
|
+
let n = b(e);
|
|
2071
|
+
if (!n.hasContent) return !1;
|
|
2072
|
+
let { block: a } = n, { depth: o } = e.doc.resolve(a.beforePos), s = e.selection.$anchor.parentOffset === 0, c = e.selection.anchor === e.selection.head, l = n.isContentEmpty;
|
|
2073
|
+
if (s && c && l && o > 1) {
|
|
2074
|
+
let n = h(e.doc, a.beforePos);
|
|
2075
|
+
return n && r(n.block.node, e.doc).emptyChildEnter !== "outdent" ? !1 : Mn(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup, i(t.doc));
|
|
2076
|
+
}
|
|
2077
|
+
return !1;
|
|
1830
2078
|
}),
|
|
1831
2079
|
() => t.command(({ state: t }) => {
|
|
1832
|
-
let
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1835
|
-
if (i?.config?.content === "plain") return n.insertText("\n", n.selection.head), !0;
|
|
2080
|
+
let i = b(t), a = this.options.editor.schema.blockSpecs[i.blockNoteType], o = r(i.block.node, t.doc);
|
|
2081
|
+
if (o.enter === "line-break" || e && o.shiftEnter === "line-break") {
|
|
2082
|
+
if (a?.config?.content === "plain") return n.insertText("\n", n.selection.head), !0;
|
|
1836
2083
|
let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
|
|
1837
2084
|
return n.insert(n.selection.head, n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
|
|
1838
2085
|
}
|
|
1839
2086
|
return !1;
|
|
1840
2087
|
}),
|
|
2088
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
2089
|
+
let i = b(e);
|
|
2090
|
+
if (!i.hasContent) return !1;
|
|
2091
|
+
let a = e.selection.anchor === e.selection.head, o = i.isContentEmpty;
|
|
2092
|
+
if (!a || !o) return !1;
|
|
2093
|
+
let s = t.doc.resolve(i.block.beforePos);
|
|
2094
|
+
if (t.doc.resolve(i.block.afterPos).nodeAfter !== null) return !1;
|
|
2095
|
+
let c = h(t.doc, i.block.beforePos);
|
|
2096
|
+
if (!c || r(c.block.node, t.doc).emptyChildEnter !== "exit-at-end" || s.index() === 0 && c.hasContent) return !1;
|
|
2097
|
+
let l = xe(t.doc, c.block.afterPos, e.schema.nodes.blockContainer, "after");
|
|
2098
|
+
return l !== void 0 && (n && (Di(t, i.block, l), t.scrollIntoView()), !0);
|
|
2099
|
+
}),
|
|
1841
2100
|
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1842
|
-
let
|
|
1843
|
-
if (!
|
|
1844
|
-
let {
|
|
1845
|
-
if (o && s && c) {
|
|
1846
|
-
let
|
|
2101
|
+
let i = b(e);
|
|
2102
|
+
if (!i.hasContent) return !1;
|
|
2103
|
+
let { block: a } = i, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.isContentEmpty;
|
|
2104
|
+
if (o && s && c && r(i.block.node, e.doc).enter !== "into-children") {
|
|
2105
|
+
let r = a.afterPos, o = r + 2;
|
|
1847
2106
|
if (t) {
|
|
1848
|
-
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0,
|
|
1849
|
-
n.insert(
|
|
2107
|
+
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, i.children?.node].filter((e) => e !== void 0));
|
|
2108
|
+
n.insert(r, t).setSelection(new N(n.doc.resolve(o))).scrollIntoView(), i.children && n.delete(i.children.beforePos, i.children.afterPos);
|
|
1850
2109
|
}
|
|
1851
2110
|
return !0;
|
|
1852
2111
|
}
|
|
1853
2112
|
return !1;
|
|
1854
2113
|
}),
|
|
2114
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
2115
|
+
let i = b(e);
|
|
2116
|
+
if (!i.hasContent || i.contentKind === "table" || !e.selection.empty || i.isContentEmpty || e.selection.from !== i.contentStart) return !1;
|
|
2117
|
+
if (n) {
|
|
2118
|
+
let n = r(i.block.node, e.doc).splitKeepsType ? i.content.node.type : e.schema.nodes.paragraph, a = e.schema.nodes.blockContainer.create(void 0, n.create());
|
|
2119
|
+
t.insert(i.block.beforePos, a).scrollIntoView();
|
|
2120
|
+
}
|
|
2121
|
+
return !0;
|
|
2122
|
+
}),
|
|
2123
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
2124
|
+
let i = b(e);
|
|
2125
|
+
if (!i.hasContent || r(i.block.node, e.doc).enter !== "into-children" || !e.selection.empty || e.selection.from < i.contentStart || e.selection.from > i.contentEnd) return !1;
|
|
2126
|
+
if (n) {
|
|
2127
|
+
let n = i.content.node.cut(e.selection.from - i.contentStart), r = e.schema.nodes.blockContainer.create(void 0, e.schema.nodes.paragraph.create(void 0, n.content));
|
|
2128
|
+
t.delete(e.selection.from, i.contentEnd);
|
|
2129
|
+
let a = w(t.doc, i.block.beforePos).children, o = a ? a.childrenStart : t.mapping.map(i.content.afterPos);
|
|
2130
|
+
t.insert(o, a ? r : e.schema.nodes.blockGroup.create(void 0, r)).setSelection(new N(t.doc.resolve(o + (a ? 2 : 3)))).scrollIntoView();
|
|
2131
|
+
}
|
|
2132
|
+
return !0;
|
|
2133
|
+
}),
|
|
1855
2134
|
() => t.command(({ state: e, chain: t }) => {
|
|
1856
|
-
let n =
|
|
1857
|
-
if (!n.
|
|
1858
|
-
let
|
|
1859
|
-
|
|
2135
|
+
let n = b(e);
|
|
2136
|
+
if (!n.hasContent) return !1;
|
|
2137
|
+
let i = e.selection.$anchor.parentOffset === 0;
|
|
2138
|
+
if (!n.isContentEmpty) {
|
|
2139
|
+
let a = r(n.block.node, e.doc), o = i || a.splitKeepsType;
|
|
2140
|
+
return t().deleteSelection().command(Ti(e.selection.from, o, i, a.splitKeepsChildren)).scrollIntoView().run(), !0;
|
|
2141
|
+
}
|
|
2142
|
+
return !1;
|
|
1860
2143
|
})
|
|
1861
|
-
]);
|
|
2144
|
+
]), l = this.options;
|
|
2145
|
+
function u(e) {
|
|
2146
|
+
let { editor: t, tabBehavior: n } = l;
|
|
2147
|
+
return n !== "prefer-indent" && (t.getExtension(be)?.store.state || t.getExtension(Oe)?.store.state !== void 0) ? !1 : e ? Pn(t) : An(t);
|
|
2148
|
+
}
|
|
1862
2149
|
return {
|
|
1863
|
-
Backspace:
|
|
1864
|
-
Delete:
|
|
1865
|
-
Enter: () =>
|
|
1866
|
-
"Shift-Enter": () =>
|
|
1867
|
-
Tab: () =>
|
|
1868
|
-
"Shift-Tab": () =>
|
|
2150
|
+
Backspace: o,
|
|
2151
|
+
Delete: s,
|
|
2152
|
+
Enter: () => c(),
|
|
2153
|
+
"Shift-Enter": () => c(!0),
|
|
2154
|
+
Tab: () => u(!1),
|
|
2155
|
+
"Shift-Tab": () => u(!0),
|
|
1869
2156
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1870
2157
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1871
2158
|
"Mod-z": () => this.options.editor.undo(),
|
|
1872
2159
|
"Mod-y": () => this.options.editor.redo(),
|
|
1873
|
-
"Shift-Mod-z": () => this.options.editor.redo()
|
|
2160
|
+
"Shift-Mod-z": () => this.options.editor.redo(),
|
|
2161
|
+
"Mod-a": () => {
|
|
2162
|
+
let e = this.editor.view, { doc: t, selection: n, tr: r } = e.state, i = N.between(M.atStart(t).$from, M.atEnd(t).$to);
|
|
2163
|
+
if (this.options.selectAllBehavior === "document") return e.dispatch(r.setSelection(i)), !0;
|
|
2164
|
+
let a, o = b(e.state);
|
|
2165
|
+
if (o.hasContent) {
|
|
2166
|
+
let e = o.contentStart, n = o.contentEnd, r = N.between(t.resolve(e), t.resolve(n));
|
|
2167
|
+
!r.empty && r.from >= e && r.to <= n && (a = r);
|
|
2168
|
+
}
|
|
2169
|
+
let s = !a || n.from < a.from || n.to > a.to || n.from === a.from && n.to === a.to;
|
|
2170
|
+
return a && !s ? r.setSelection(a).scrollIntoView() : r.setSelection(i), e.dispatch(r), !0;
|
|
2171
|
+
}
|
|
1874
2172
|
};
|
|
1875
2173
|
}
|
|
1876
|
-
}),
|
|
2174
|
+
}), Ai = I.create({
|
|
1877
2175
|
name: "textAlignment",
|
|
1878
2176
|
addGlobalAttributes() {
|
|
1879
2177
|
return [{
|
|
@@ -1885,7 +2183,7 @@ var jr = (e) => {
|
|
|
1885
2183
|
} }
|
|
1886
2184
|
}];
|
|
1887
2185
|
}
|
|
1888
|
-
}),
|
|
2186
|
+
}), ji = I.create({
|
|
1889
2187
|
name: "blockTextColor",
|
|
1890
2188
|
addGlobalAttributes() {
|
|
1891
2189
|
return [{
|
|
@@ -1894,198 +2192,43 @@ var jr = (e) => {
|
|
|
1894
2192
|
"tableCell",
|
|
1895
2193
|
"tableHeader"
|
|
1896
2194
|
],
|
|
1897
|
-
attributes: { textColor:
|
|
2195
|
+
attributes: { textColor: Ee() }
|
|
1898
2196
|
}];
|
|
1899
2197
|
}
|
|
1900
|
-
}),
|
|
1901
|
-
//#endregion
|
|
1902
|
-
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
1903
|
-
function Gr(e) {
|
|
1904
|
-
let t = [], n = [], r = 0;
|
|
1905
|
-
for (; r < e.length;) {
|
|
1906
|
-
let i = 0;
|
|
1907
|
-
for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
|
|
1908
|
-
if (i > 0) {
|
|
1909
|
-
t.push(n.join(""));
|
|
1910
|
-
let a = parseInt(e.substring(r, r + i), 10);
|
|
1911
|
-
for (; a-- > 0;) n.pop();
|
|
1912
|
-
r += i;
|
|
1913
|
-
} else n.push(e[r]), r++;
|
|
1914
|
-
}
|
|
1915
|
-
return t;
|
|
1916
|
-
}
|
|
1917
|
-
var Kr = new Set(Gr(Wr)), qr = /* @__PURE__ */ new Set(["localhost"]), Jr = /[.,;:!?"']+$/, Yr = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Xr = /mailto:[^\s]+/g, Zr = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Qr = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1918
|
-
function $r(e) {
|
|
1919
|
-
let t = e, n = !0;
|
|
1920
|
-
for (; n;) {
|
|
1921
|
-
n = !1;
|
|
1922
|
-
let e = t;
|
|
1923
|
-
t = t.replace(Jr, ""), t !== e && (n = !0);
|
|
1924
|
-
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1925
|
-
let i = ei(t, e);
|
|
1926
|
-
if (ei(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1927
|
-
else break;
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
return t;
|
|
1931
|
-
}
|
|
1932
|
-
function ei(e, t) {
|
|
1933
|
-
let n = 0;
|
|
1934
|
-
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1935
|
-
return n;
|
|
1936
|
-
}
|
|
1937
|
-
function ti(e) {
|
|
1938
|
-
let t = e.split(".");
|
|
1939
|
-
return t[t.length - 1].toLowerCase();
|
|
1940
|
-
}
|
|
1941
|
-
function ni(e) {
|
|
1942
|
-
let t = ti(e);
|
|
1943
|
-
return Kr.has(t);
|
|
1944
|
-
}
|
|
1945
|
-
function ri(e, t, n) {
|
|
1946
|
-
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
1947
|
-
}
|
|
1948
|
-
function ii(e, t) {
|
|
1949
|
-
if (!e) return [];
|
|
1950
|
-
let n = t?.defaultProtocol || "http", r = [];
|
|
1951
|
-
for (let t of e.matchAll(Yr)) r.push({
|
|
1952
|
-
type: "url",
|
|
1953
|
-
value: t[0],
|
|
1954
|
-
start: t.index,
|
|
1955
|
-
end: t.index + t[0].length
|
|
1956
|
-
});
|
|
1957
|
-
for (let t of e.matchAll(Xr)) r.push({
|
|
1958
|
-
type: "url",
|
|
1959
|
-
value: t[0],
|
|
1960
|
-
start: t.index,
|
|
1961
|
-
end: t.index + t[0].length
|
|
1962
|
-
});
|
|
1963
|
-
for (let t of e.matchAll(Zr)) r.push({
|
|
1964
|
-
type: "email",
|
|
1965
|
-
value: t[0],
|
|
1966
|
-
start: t.index,
|
|
1967
|
-
end: t.index + t[0].length
|
|
1968
|
-
});
|
|
1969
|
-
for (let t of e.matchAll(Qr)) r.push({
|
|
1970
|
-
type: "url",
|
|
1971
|
-
value: t[0],
|
|
1972
|
-
start: t.index,
|
|
1973
|
-
end: t.index + t[0].length
|
|
1974
|
-
});
|
|
1975
|
-
r.sort((e, t) => e.start - t.start || t.end - e.end);
|
|
1976
|
-
let i = [], a = -1;
|
|
1977
|
-
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
1978
|
-
let o = [];
|
|
1979
|
-
for (let e of i) {
|
|
1980
|
-
let t = $r(e.value);
|
|
1981
|
-
if (!t) continue;
|
|
1982
|
-
let r = e.start, i = r + t.length;
|
|
1983
|
-
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
1984
|
-
let e = new URL("http://" + t).hostname;
|
|
1985
|
-
if (!ni(e)) continue;
|
|
1986
|
-
}
|
|
1987
|
-
if (e.type === "email") {
|
|
1988
|
-
let e = t.split("@")[1];
|
|
1989
|
-
if (!ni(e)) continue;
|
|
1990
|
-
}
|
|
1991
|
-
let a = ri(t, e.type, n);
|
|
1992
|
-
o.push({
|
|
1993
|
-
type: e.type,
|
|
1994
|
-
value: t,
|
|
1995
|
-
isLink: !0,
|
|
1996
|
-
href: a,
|
|
1997
|
-
start: r,
|
|
1998
|
-
end: i
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
return o;
|
|
2002
|
-
}
|
|
2003
|
-
function ai(e, t = "http") {
|
|
2004
|
-
if (!e) return [$(e, 0, 0)];
|
|
2005
|
-
for (let [n, r] of [
|
|
2006
|
-
["(", ")"],
|
|
2007
|
-
["[", "]"],
|
|
2008
|
-
["{", "}"]
|
|
2009
|
-
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
2010
|
-
let i = e.slice(1, -1);
|
|
2011
|
-
if (Q(i)) return [
|
|
2012
|
-
$(n, 0, 1),
|
|
2013
|
-
oi(i, 1, 1 + i.length, t),
|
|
2014
|
-
$(r, 1 + i.length, e.length)
|
|
2015
|
-
];
|
|
2016
|
-
}
|
|
2017
|
-
if (e.endsWith(".") && e.length > 1) {
|
|
2018
|
-
let n = e.slice(0, -1);
|
|
2019
|
-
if (Q(n)) return [oi(n, 0, n.length, t), $(".", n.length, e.length)];
|
|
2020
|
-
}
|
|
2021
|
-
return Q(e) ? [oi(e, 0, e.length, t)] : [$(e, 0, e.length)];
|
|
2022
|
-
}
|
|
2023
|
-
function Q(e) {
|
|
2024
|
-
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || qr.has(e.toLowerCase())) return !0;
|
|
2025
|
-
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
2026
|
-
if (t) {
|
|
2027
|
-
let e = t[1].toLowerCase();
|
|
2028
|
-
if (Kr.has(e)) return !0;
|
|
2029
|
-
}
|
|
2030
|
-
return !1;
|
|
2031
|
-
}
|
|
2032
|
-
function oi(e, t, n, r) {
|
|
2033
|
-
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
2034
|
-
return {
|
|
2035
|
-
type: i,
|
|
2036
|
-
value: e,
|
|
2037
|
-
isLink: !0,
|
|
2038
|
-
href: ri(e, i, r),
|
|
2039
|
-
start: t,
|
|
2040
|
-
end: n
|
|
2041
|
-
};
|
|
2042
|
-
}
|
|
2043
|
-
function $(e, t, n) {
|
|
2044
|
-
return {
|
|
2045
|
-
type: "text",
|
|
2046
|
-
value: e,
|
|
2047
|
-
isLink: !1,
|
|
2048
|
-
href: e,
|
|
2049
|
-
start: t,
|
|
2050
|
-
end: n
|
|
2051
|
-
};
|
|
2052
|
-
}
|
|
2053
|
-
//#endregion
|
|
2054
|
-
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
2055
|
-
var si = "[\0- \xA0 -\u2029 ]", ci = new RegExp(si), li = RegExp(`${si}$`), ui = new RegExp(si, "g");
|
|
2198
|
+
}), Mi = "[\0- \xA0 -\u2029 ]", Ni = new RegExp(Mi), Pi = RegExp(`${Mi}$`), Fi = new RegExp(Mi, "g");
|
|
2056
2199
|
//#endregion
|
|
2057
2200
|
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
2058
|
-
function
|
|
2201
|
+
function Ii(e) {
|
|
2059
2202
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
2060
2203
|
}
|
|
2061
|
-
function
|
|
2062
|
-
return new
|
|
2063
|
-
key: new
|
|
2204
|
+
function Li(e) {
|
|
2205
|
+
return new B({
|
|
2206
|
+
key: new V("autolink"),
|
|
2064
2207
|
appendTransaction: (t, n, r) => {
|
|
2065
2208
|
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
2066
2209
|
if (!i || a) return;
|
|
2067
|
-
let { tr: o } = r, s =
|
|
2068
|
-
if (
|
|
2069
|
-
let n =
|
|
2210
|
+
let { tr: o } = r, s = Se(n.doc, t);
|
|
2211
|
+
if (me(s).forEach(({ newRange: t }) => {
|
|
2212
|
+
let n = mt(r.doc, t, (e) => e.isTextblock), i, a;
|
|
2070
2213
|
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
2071
2214
|
else if (n.length) {
|
|
2072
2215
|
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
2073
|
-
if (!
|
|
2216
|
+
if (!Pi.test(e)) return;
|
|
2074
2217
|
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
2075
2218
|
}
|
|
2076
2219
|
if (i && a) {
|
|
2077
|
-
let t = a.split(
|
|
2220
|
+
let t = a.split(Ni).filter(Boolean);
|
|
2078
2221
|
if (t.length <= 0) return;
|
|
2079
2222
|
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
2080
2223
|
if (!n) return;
|
|
2081
|
-
let c =
|
|
2082
|
-
if (!
|
|
2224
|
+
let c = Qe(n, e.defaultProtocol);
|
|
2225
|
+
if (!Ii(c)) return;
|
|
2083
2226
|
c.filter((e) => e.isLink).map((e) => ({
|
|
2084
2227
|
...e,
|
|
2085
2228
|
from: s + e.start + 1,
|
|
2086
2229
|
to: s + e.end + 1
|
|
2087
2230
|
})).filter((e) => !r.schema.marks.code || !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code)).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
|
|
2088
|
-
|
|
2231
|
+
vt(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
|
|
2089
2232
|
});
|
|
2090
2233
|
}
|
|
2091
2234
|
}), o.steps.length) return o;
|
|
@@ -2094,9 +2237,9 @@ function fi(e) {
|
|
|
2094
2237
|
}
|
|
2095
2238
|
//#endregion
|
|
2096
2239
|
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
2097
|
-
function
|
|
2098
|
-
return new
|
|
2099
|
-
key: new
|
|
2240
|
+
function Ri(e) {
|
|
2241
|
+
return new B({
|
|
2242
|
+
key: new V("handleClickLink"),
|
|
2100
2243
|
props: { handleClick: (t, n, r) => {
|
|
2101
2244
|
if (r.button !== 0 || !t.editable) return !1;
|
|
2102
2245
|
let i = null;
|
|
@@ -2112,16 +2255,16 @@ function pi(e) {
|
|
|
2112
2255
|
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
2113
2256
|
return e.onClick(r, e.editor) ?? !0;
|
|
2114
2257
|
}
|
|
2115
|
-
let a =
|
|
2258
|
+
let a = gt(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
2116
2259
|
return o ? (window.open(o, s), !0) : !1;
|
|
2117
2260
|
} }
|
|
2118
2261
|
});
|
|
2119
2262
|
}
|
|
2120
2263
|
//#endregion
|
|
2121
2264
|
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
2122
|
-
function
|
|
2123
|
-
return new
|
|
2124
|
-
key: new
|
|
2265
|
+
function zi(e) {
|
|
2266
|
+
return new B({
|
|
2267
|
+
key: new V("handlePasteLink"),
|
|
2125
2268
|
props: { handlePaste: (t, n, r) => {
|
|
2126
2269
|
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
2127
2270
|
if (c) return !1;
|
|
@@ -2129,26 +2272,26 @@ function mi(e) {
|
|
|
2129
2272
|
r.content.forEach((e) => {
|
|
2130
2273
|
l += e.textContent;
|
|
2131
2274
|
});
|
|
2132
|
-
let u =
|
|
2275
|
+
let u = Me(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
2133
2276
|
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
2134
2277
|
} }
|
|
2135
2278
|
});
|
|
2136
2279
|
}
|
|
2137
2280
|
//#endregion
|
|
2138
2281
|
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
2139
|
-
var
|
|
2140
|
-
function
|
|
2282
|
+
var Bi = "https", Vi = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
2283
|
+
function Hi(e) {
|
|
2141
2284
|
if (!e) return !0;
|
|
2142
|
-
let t = e.replace(
|
|
2143
|
-
return
|
|
2285
|
+
let t = e.replace(Fi, "");
|
|
2286
|
+
return Vi.test(t);
|
|
2144
2287
|
}
|
|
2145
|
-
function
|
|
2288
|
+
function Ui(e) {
|
|
2146
2289
|
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
2147
2290
|
if (t || n && !e.includes("@")) return !0;
|
|
2148
2291
|
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
2149
2292
|
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
2150
2293
|
}
|
|
2151
|
-
var
|
|
2294
|
+
var Wi = ft.create({
|
|
2152
2295
|
name: "link",
|
|
2153
2296
|
keepOnSplit: !1,
|
|
2154
2297
|
exitable: !0,
|
|
@@ -2163,7 +2306,7 @@ var yi = Ke.create({
|
|
|
2163
2306
|
},
|
|
2164
2307
|
editor: void 0,
|
|
2165
2308
|
onClick: void 0,
|
|
2166
|
-
isValidLink:
|
|
2309
|
+
isValidLink: Hi
|
|
2167
2310
|
};
|
|
2168
2311
|
},
|
|
2169
2312
|
addAttributes() {
|
|
@@ -2187,11 +2330,11 @@ var yi = Ke.create({
|
|
|
2187
2330
|
renderHTML({ HTMLAttributes: e }) {
|
|
2188
2331
|
return this.options.isValidLink(e.href) ? [
|
|
2189
2332
|
"a",
|
|
2190
|
-
|
|
2333
|
+
St(e, this.options.HTMLAttributes),
|
|
2191
2334
|
0
|
|
2192
2335
|
] : [
|
|
2193
2336
|
"a",
|
|
2194
|
-
|
|
2337
|
+
St({
|
|
2195
2338
|
...e,
|
|
2196
2339
|
href: ""
|
|
2197
2340
|
}, this.options.HTMLAttributes),
|
|
@@ -2200,12 +2343,12 @@ var yi = Ke.create({
|
|
|
2200
2343
|
},
|
|
2201
2344
|
addPasteRules() {
|
|
2202
2345
|
let e = this.options.isValidLink;
|
|
2203
|
-
return [
|
|
2346
|
+
return [xt({
|
|
2204
2347
|
find: (t) => {
|
|
2205
2348
|
let n = [];
|
|
2206
2349
|
if (t) {
|
|
2207
|
-
let r =
|
|
2208
|
-
for (let e of r)
|
|
2350
|
+
let r = Me(t, { defaultProtocol: Bi }).filter((t) => t.isLink && e(t.value));
|
|
2351
|
+
for (let e of r) Ui(e.value) && n.push({
|
|
2209
2352
|
text: e.value,
|
|
2210
2353
|
data: { href: e.href },
|
|
2211
2354
|
index: e.start
|
|
@@ -2219,82 +2362,38 @@ var yi = Ke.create({
|
|
|
2219
2362
|
},
|
|
2220
2363
|
addProseMirrorPlugins() {
|
|
2221
2364
|
let e = [];
|
|
2222
|
-
return e.push(
|
|
2365
|
+
return e.push(Li({
|
|
2223
2366
|
type: this.type,
|
|
2224
|
-
defaultProtocol:
|
|
2367
|
+
defaultProtocol: Bi,
|
|
2225
2368
|
validate: this.options.isValidLink,
|
|
2226
|
-
shouldAutoLink:
|
|
2227
|
-
})), e.push(
|
|
2369
|
+
shouldAutoLink: Ui
|
|
2370
|
+
})), e.push(Ri({
|
|
2228
2371
|
type: this.type,
|
|
2229
2372
|
tiptapEditor: this.editor,
|
|
2230
2373
|
editor: this.options.editor,
|
|
2231
2374
|
onClick: this.options.onClick
|
|
2232
|
-
})), e.push(
|
|
2375
|
+
})), e.push(zi({
|
|
2233
2376
|
editor: this.editor,
|
|
2234
|
-
defaultProtocol:
|
|
2377
|
+
defaultProtocol: Bi,
|
|
2235
2378
|
type: this.type,
|
|
2236
|
-
shouldAutoLink:
|
|
2379
|
+
shouldAutoLink: Ui,
|
|
2237
2380
|
isValidLink: this.options.isValidLink
|
|
2238
2381
|
})), e;
|
|
2239
2382
|
}
|
|
2240
|
-
}),
|
|
2383
|
+
}), Gi = je(({ editor: e, options: t }) => ({
|
|
2241
2384
|
key: "link",
|
|
2242
|
-
tiptapExtensions: [
|
|
2385
|
+
tiptapExtensions: [Wi.configure({
|
|
2243
2386
|
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
2244
2387
|
editor: e,
|
|
2245
2388
|
onClick: t.onClick,
|
|
2246
2389
|
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
2247
2390
|
})]
|
|
2248
|
-
})),
|
|
2249
|
-
blockColor: "data-block-color",
|
|
2250
|
-
blockStyle: "data-block-style",
|
|
2251
|
-
id: "data-id",
|
|
2252
|
-
depth: "data-depth",
|
|
2253
|
-
depthChange: "data-depth-change"
|
|
2254
|
-
}, Si = O.create({
|
|
2255
|
-
name: "blockContainer",
|
|
2256
|
-
group: "blockGroupChild bnBlock",
|
|
2257
|
-
content: "blockContent blockGroup?",
|
|
2258
|
-
priority: 50,
|
|
2259
|
-
defining: !0,
|
|
2260
|
-
marks() {
|
|
2261
|
-
return l(this.editor);
|
|
2262
|
-
},
|
|
2263
|
-
parseHTML() {
|
|
2264
|
-
return [{
|
|
2265
|
-
tag: "div[data-node-type=" + this.name + "]",
|
|
2266
|
-
getAttrs: (e) => {
|
|
2267
|
-
if (typeof e == "string") return !1;
|
|
2268
|
-
let t = {};
|
|
2269
|
-
for (let [n, r] of Object.entries(xi)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
2270
|
-
return t;
|
|
2271
|
-
}
|
|
2272
|
-
}, {
|
|
2273
|
-
tag: "div[data-node-type=\"blockOuter\"]",
|
|
2274
|
-
skip: !0
|
|
2275
|
-
}];
|
|
2276
|
-
},
|
|
2277
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
2278
|
-
let t = document.createElement("div");
|
|
2279
|
-
t.className = "bn-block-outer", t.setAttribute("data-node-type", "blockOuter");
|
|
2280
|
-
for (let [n, r] of Object.entries(e)) n !== "class" && t.setAttribute(n, r);
|
|
2281
|
-
let n = {
|
|
2282
|
-
...this.options.domAttributes?.block || {},
|
|
2283
|
-
...e
|
|
2284
|
-
}, r = document.createElement("div");
|
|
2285
|
-
r.className = h("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
2286
|
-
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2287
|
-
return t.appendChild(r), {
|
|
2288
|
-
dom: t,
|
|
2289
|
-
contentDOM: r
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
}), Ci = O.create({
|
|
2391
|
+
})), Ki = L.create({
|
|
2293
2392
|
name: "blockGroup",
|
|
2294
|
-
group:
|
|
2393
|
+
group: f,
|
|
2295
2394
|
content: "blockGroupChild+",
|
|
2296
2395
|
marks() {
|
|
2297
|
-
return
|
|
2396
|
+
return s(this.editor);
|
|
2298
2397
|
},
|
|
2299
2398
|
parseHTML() {
|
|
2300
2399
|
return [{
|
|
@@ -2307,99 +2406,97 @@ var yi = Ke.create({
|
|
|
2307
2406
|
...this.options.domAttributes?.blockGroup || {},
|
|
2308
2407
|
...e
|
|
2309
2408
|
}, n = document.createElement("div");
|
|
2310
|
-
n.className =
|
|
2409
|
+
n.className = de("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
|
|
2311
2410
|
for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
|
|
2312
2411
|
return {
|
|
2313
2412
|
dom: n,
|
|
2314
2413
|
contentDOM: n
|
|
2315
2414
|
};
|
|
2316
2415
|
}
|
|
2317
|
-
}),
|
|
2416
|
+
}), qi = L.create({
|
|
2318
2417
|
name: "doc",
|
|
2319
2418
|
topNode: !0,
|
|
2320
2419
|
content: "blockGroup",
|
|
2321
2420
|
marks() {
|
|
2322
|
-
return
|
|
2421
|
+
return s(this.editor);
|
|
2323
2422
|
}
|
|
2324
2423
|
});
|
|
2325
2424
|
//#endregion
|
|
2326
2425
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
2327
|
-
function
|
|
2426
|
+
function Ji(e, t) {
|
|
2328
2427
|
return [
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
types: [
|
|
2337
|
-
"blockContainer",
|
|
2338
|
-
"columnList",
|
|
2339
|
-
"column"
|
|
2340
|
-
],
|
|
2428
|
+
R.ClipboardTextSerializer,
|
|
2429
|
+
R.Commands,
|
|
2430
|
+
R.Editable,
|
|
2431
|
+
R.FocusEvents,
|
|
2432
|
+
R.Tabindex,
|
|
2433
|
+
jt,
|
|
2434
|
+
ue.configure({
|
|
2435
|
+
types: ["blockContainer", ...Object.values(e.schema.blockSpecs).filter((e) => e.config.layoutOnly === !0).map((e) => e.config.type)],
|
|
2341
2436
|
setIdAttribute: t.setIdAttribute,
|
|
2342
2437
|
isWithinEditor: e.isWithinEditor
|
|
2343
2438
|
}),
|
|
2344
|
-
|
|
2345
|
-
|
|
2439
|
+
xi,
|
|
2440
|
+
At,
|
|
2346
2441
|
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2442
|
+
ji,
|
|
2443
|
+
bi,
|
|
2444
|
+
Ai,
|
|
2445
|
+
I.create({
|
|
2351
2446
|
name: "OverrideEscape",
|
|
2352
|
-
addKeyboardShortcuts: () => ({ Escape: () => !e.getExtension(
|
|
2447
|
+
addKeyboardShortcuts: () => ({ Escape: () => !e.getExtension(fe)?.shown() && (e.blur(), !0) })
|
|
2353
2448
|
}),
|
|
2354
|
-
|
|
2355
|
-
|
|
2449
|
+
qi,
|
|
2450
|
+
Zt.configure({
|
|
2356
2451
|
editor: e,
|
|
2357
2452
|
domAttributes: t.domAttributes
|
|
2358
2453
|
}),
|
|
2359
|
-
|
|
2454
|
+
ki.configure({
|
|
2360
2455
|
editor: e,
|
|
2361
|
-
tabBehavior: t.tabBehavior
|
|
2456
|
+
tabBehavior: t.tabBehavior,
|
|
2457
|
+
selectAllBehavior: t.selectAllBehavior ?? "block-first"
|
|
2362
2458
|
}),
|
|
2363
|
-
|
|
2459
|
+
Ki.configure({ domAttributes: t.domAttributes }),
|
|
2364
2460
|
...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
|
|
2365
2461
|
...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
|
|
2366
2462
|
editor: e,
|
|
2367
2463
|
domAttributes: t.domAttributes
|
|
2368
2464
|
})] : []]),
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2465
|
+
yi(e),
|
|
2466
|
+
hi(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2467
|
+
Qr(e)
|
|
2372
2468
|
];
|
|
2373
2469
|
}
|
|
2374
|
-
function
|
|
2470
|
+
function Yi(e, t) {
|
|
2375
2471
|
let n = [
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2472
|
+
Ve(),
|
|
2473
|
+
Fe(t),
|
|
2474
|
+
Oe(t),
|
|
2475
|
+
be(t),
|
|
2476
|
+
Gi({
|
|
2381
2477
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
2382
2478
|
onClick: t.links?.onClick,
|
|
2383
2479
|
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
2384
2480
|
}),
|
|
2385
|
-
Ce(t),
|
|
2386
|
-
Ee(),
|
|
2387
|
-
Pe(t),
|
|
2388
2481
|
Le(t),
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2482
|
+
Je(),
|
|
2483
|
+
ze(t),
|
|
2484
|
+
Ue({ editable: t._tiptapOptions?.editable }),
|
|
2485
|
+
tt(t),
|
|
2486
|
+
Ze(t),
|
|
2487
|
+
Ge(),
|
|
2488
|
+
qe(),
|
|
2489
|
+
fe(t),
|
|
2490
|
+
Be(),
|
|
2491
|
+
Re(),
|
|
2492
|
+
Ne(),
|
|
2493
|
+
...t.trailingBlock === !1 ? [] : [Ye()]
|
|
2397
2494
|
];
|
|
2398
|
-
return "table" in e.schema.blockSpecs && n.push(
|
|
2495
|
+
return "table" in e.schema.blockSpecs && n.push(Xe(t)), t.animations !== !1 && n.push(Pe()), n;
|
|
2399
2496
|
}
|
|
2400
2497
|
//#endregion
|
|
2401
2498
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
2402
|
-
var
|
|
2499
|
+
var Xi = class {
|
|
2403
2500
|
editor;
|
|
2404
2501
|
options;
|
|
2405
2502
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
@@ -2407,45 +2504,43 @@ var Di = class {
|
|
|
2407
2504
|
abortMap = /* @__PURE__ */ new Map();
|
|
2408
2505
|
extensionFactories = /* @__PURE__ */ new Map();
|
|
2409
2506
|
extensionPlugins = /* @__PURE__ */ new Map();
|
|
2507
|
+
runtimeExtensions = /* @__PURE__ */ new Set();
|
|
2410
2508
|
blockNoteExtensionDependents = /* @__PURE__ */ new Map();
|
|
2411
2509
|
constructor(e, t) {
|
|
2412
2510
|
this.editor = e, this.options = t, e.onMount(() => {
|
|
2413
|
-
for (let
|
|
2414
|
-
let n = new window.AbortController(), r = t.mount({
|
|
2415
|
-
dom: e.prosemirrorView.dom,
|
|
2416
|
-
root: e.prosemirrorView.root,
|
|
2417
|
-
signal: n.signal
|
|
2418
|
-
});
|
|
2419
|
-
r && n.signal.addEventListener("abort", () => {
|
|
2420
|
-
r();
|
|
2421
|
-
}), this.abortMap.set(t, n);
|
|
2422
|
-
}
|
|
2511
|
+
for (let e of this.extensions) this.mountExtension(e);
|
|
2423
2512
|
}), e.onUnmount(() => {
|
|
2424
2513
|
for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
|
|
2425
2514
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
2426
|
-
for (let e of
|
|
2515
|
+
for (let e of Yi(this.editor, this.options)) this.addExtension(e);
|
|
2427
2516
|
for (let e of this.options.extensions ?? []) this.addExtension(e);
|
|
2428
2517
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
2429
2518
|
}
|
|
2519
|
+
mountExtension(e) {
|
|
2520
|
+
if (!e.mount || this.abortMap.has(e)) return;
|
|
2521
|
+
let t = new window.AbortController();
|
|
2522
|
+
this.abortMap.set(e, t);
|
|
2523
|
+
let n = e.mount({
|
|
2524
|
+
dom: this.editor.prosemirrorView.dom,
|
|
2525
|
+
root: this.editor.prosemirrorView.root,
|
|
2526
|
+
signal: t.signal
|
|
2527
|
+
});
|
|
2528
|
+
n && (t.signal.aborted ? n() : t.signal.addEventListener("abort", n, { once: !0 }));
|
|
2529
|
+
}
|
|
2430
2530
|
registerExtension(e) {
|
|
2431
2531
|
this.replaceExtension(void 0, e);
|
|
2432
2532
|
}
|
|
2433
2533
|
addExtension(e, t) {
|
|
2434
2534
|
let n;
|
|
2435
|
-
if (n = typeof e == "function" ? e({ editor: this.editor }) : e, !
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
}
|
|
2440
|
-
if (!this.extensions.some((e) => e.key === n.key)) {
|
|
2441
|
-
if (typeof e == "function") {
|
|
2442
|
-
let e = n[ge];
|
|
2443
|
-
typeof e == "function" && this.extensionFactories.set(e, n);
|
|
2444
|
-
}
|
|
2445
|
-
if (this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
|
|
2446
|
-
return n;
|
|
2447
|
-
}
|
|
2535
|
+
if (n = typeof e == "function" ? e({ editor: this.editor }) : e, !n || this.disabledExtensions.has(n.key)) return;
|
|
2536
|
+
if (t) {
|
|
2537
|
+
let e = this.blockNoteExtensionDependents.get(n.key);
|
|
2538
|
+
e || (e = /* @__PURE__ */ new Set(), this.blockNoteExtensionDependents.set(n.key, e)), e.add(t);
|
|
2448
2539
|
}
|
|
2540
|
+
if (this.extensions.some((e) => e.key === n.key)) return;
|
|
2541
|
+
let r = n[ke];
|
|
2542
|
+
if (typeof r == "function" && this.extensionFactories.set(r, n), this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
|
|
2543
|
+
return n;
|
|
2449
2544
|
}
|
|
2450
2545
|
resolveExtensions(e) {
|
|
2451
2546
|
let t = [];
|
|
@@ -2461,38 +2556,39 @@ var Di = class {
|
|
|
2461
2556
|
return t;
|
|
2462
2557
|
}
|
|
2463
2558
|
unregisterExtension(e) {
|
|
2464
|
-
this.
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2559
|
+
let t = [...new Set(this.resolveExtensions(e))].filter((e) => this.extensions.includes(e));
|
|
2560
|
+
return t.length && this.replaceExtension(t, []), Array.isArray(e) ? t : t[0];
|
|
2561
|
+
}
|
|
2562
|
+
replaceExtension(e, t, n) {
|
|
2563
|
+
let r = this.resolveExtensions(e);
|
|
2564
|
+
e && !r.length && console.warn("No extensions found to unregister", e);
|
|
2565
|
+
let i = !1, a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
2566
|
+
for (let t of r) this.extensions = this.extensions.filter((e) => e !== t), this.extensionFactories.forEach((e, n) => {
|
|
2471
2567
|
e === t && this.extensionFactories.delete(n);
|
|
2472
2568
|
}), this.abortMap.get(t)?.abort(), this.abortMap.delete(t), this.extensionPlugins.get(t)?.forEach((e) => {
|
|
2473
|
-
|
|
2569
|
+
a.add(e);
|
|
2474
2570
|
let t = e.spec?.key, n = typeof t == "object" && t ? t.key : t;
|
|
2475
|
-
typeof n == "string" &&
|
|
2476
|
-
}), this.extensionPlugins.delete(t), t.tiptapExtensions && !
|
|
2477
|
-
let
|
|
2478
|
-
for (let e of
|
|
2479
|
-
|
|
2571
|
+
typeof n == "string" && o.add(n);
|
|
2572
|
+
}), this.extensionPlugins.delete(t), this.runtimeExtensions.delete(t), t.tiptapExtensions && !i && (i = !0, console.warn(`Extension ${t.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`, e));
|
|
2573
|
+
let s = [].concat(t).filter(Boolean).map((e) => this.addExtension(e)).filter(Boolean), c = [];
|
|
2574
|
+
for (let e of s) this.runtimeExtensions.add(e), e?.tiptapExtensions && console.warn(`Extension ${e.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), e?.inputRules?.length && console.warn(`Extension ${e.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), this.getProsemirrorPluginsFromExtension(e).plugins.forEach((e) => {
|
|
2575
|
+
c.push(e);
|
|
2480
2576
|
});
|
|
2481
|
-
|
|
2482
|
-
if (
|
|
2483
|
-
if (
|
|
2577
|
+
if ((a.size || o.size || c.length || n?.resetPluginStateFor.length) && this.updatePlugins((e) => [...e.filter((e) => {
|
|
2578
|
+
if (a.has(e)) return !1;
|
|
2579
|
+
if (o.size) {
|
|
2484
2580
|
let t = e.spec?.key, n = typeof t == "object" && t ? t.key : t;
|
|
2485
|
-
if (typeof n == "string" &&
|
|
2581
|
+
if (typeof n == "string" && o.has(n)) return !1;
|
|
2486
2582
|
}
|
|
2487
2583
|
return !0;
|
|
2488
|
-
}), ...
|
|
2584
|
+
}), ...c], n?.resetPluginStateFor), !this.editor.headless) for (let e of s) this.mountExtension(e);
|
|
2489
2585
|
}
|
|
2490
|
-
updatePlugins(e) {
|
|
2491
|
-
let
|
|
2492
|
-
this.editor.prosemirrorView.updateState(
|
|
2586
|
+
updatePlugins(e, t) {
|
|
2587
|
+
let n = this.editor.prosemirrorState, r = new Set(t), i = (r.size ? n.reconfigure({ plugins: n.plugins.filter((e) => !e.spec.key || !r.has(e.spec.key)) }) : n).reconfigure({ plugins: e(n.plugins.slice()) });
|
|
2588
|
+
this.editor.prosemirrorView.updateState(i);
|
|
2493
2589
|
}
|
|
2494
2590
|
getTiptapExtensions() {
|
|
2495
|
-
let e =
|
|
2591
|
+
let e = Ji(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = l(this.extensions.map((e) => {
|
|
2496
2592
|
let t = this.blockNoteExtensionDependents.get(e.key);
|
|
2497
2593
|
return t?.size ? {
|
|
2498
2594
|
key: e.key,
|
|
@@ -2502,21 +2598,25 @@ var Di = class {
|
|
|
2502
2598
|
for (let r of this.extensions) {
|
|
2503
2599
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2504
2600
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
2505
|
-
a.length && e.push(
|
|
2601
|
+
a.length && e.push(I.create({
|
|
2506
2602
|
name: r.key,
|
|
2507
2603
|
priority: i,
|
|
2508
|
-
addProseMirrorPlugins: () =>
|
|
2604
|
+
addProseMirrorPlugins: () => this.runtimeExtensions.has(r) ? [] : this.extensionPlugins.get(r) ?? []
|
|
2509
2605
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
2510
2606
|
}
|
|
2511
|
-
e.push(
|
|
2607
|
+
e.push(I.create({
|
|
2608
|
+
name: "blocknote-runtime-extensions",
|
|
2609
|
+
priority: -Infinity,
|
|
2610
|
+
addProseMirrorPlugins: () => this.extensions.filter((e) => this.runtimeExtensions.has(e)).flatMap((e) => this.extensionPlugins.get(e) ?? [])
|
|
2611
|
+
})), e.push(I.create({
|
|
2512
2612
|
name: "blocknote-input-rules",
|
|
2513
2613
|
addProseMirrorPlugins() {
|
|
2514
2614
|
let e = [];
|
|
2515
2615
|
Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
|
|
2516
2616
|
e.push(...n.get(t));
|
|
2517
2617
|
});
|
|
2518
|
-
let t =
|
|
2519
|
-
return [t, new
|
|
2618
|
+
let t = Ot({ rules: e });
|
|
2619
|
+
return [t, new j({ props: { handleKeyDown(e, n) {
|
|
2520
2620
|
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2521
2621
|
let { $cursor: r } = e.state.selection;
|
|
2522
2622
|
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
@@ -2532,29 +2632,29 @@ var Di = class {
|
|
|
2532
2632
|
plugins: t,
|
|
2533
2633
|
inputRules: n
|
|
2534
2634
|
};
|
|
2535
|
-
if (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new
|
|
2536
|
-
let
|
|
2635
|
+
if (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new Dt(e.find, (t, n, i, a) => {
|
|
2636
|
+
let o = e.replace({
|
|
2537
2637
|
match: n,
|
|
2538
2638
|
range: {
|
|
2539
|
-
from:
|
|
2540
|
-
to:
|
|
2639
|
+
from: i,
|
|
2640
|
+
to: a
|
|
2541
2641
|
},
|
|
2542
2642
|
editor: this.editor
|
|
2543
2643
|
});
|
|
2544
|
-
if (
|
|
2545
|
-
let e = t.tr, n =
|
|
2546
|
-
return !n.
|
|
2644
|
+
if (o) {
|
|
2645
|
+
let e = t.tr, n = b(e);
|
|
2646
|
+
return !n.hasContent || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(i, a), K(e, n.block.beforePos, o), Kr(e, r(n.block.node, e.doc), "start"), e);
|
|
2547
2647
|
}
|
|
2548
2648
|
return null;
|
|
2549
2649
|
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length) {
|
|
2550
|
-
let n, r =
|
|
2650
|
+
let n, r = kt(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => {
|
|
2551
2651
|
if (!n) throw Error("Keyboard shortcut called outside handleKeyDown");
|
|
2552
2652
|
return t({
|
|
2553
2653
|
editor: this.editor,
|
|
2554
2654
|
event: n
|
|
2555
2655
|
});
|
|
2556
2656
|
}])));
|
|
2557
|
-
t.push(new
|
|
2657
|
+
t.push(new j({ props: { handleKeyDown: (e, t) => {
|
|
2558
2658
|
let i = n;
|
|
2559
2659
|
n = t;
|
|
2560
2660
|
try {
|
|
@@ -2583,7 +2683,7 @@ var Di = class {
|
|
|
2583
2683
|
};
|
|
2584
2684
|
//#endregion
|
|
2585
2685
|
//#region src/util/expandToWords.ts
|
|
2586
|
-
function
|
|
2686
|
+
function Zi(e, t) {
|
|
2587
2687
|
let { $from: n, $to: r } = t;
|
|
2588
2688
|
if (n.pos > n.start() && n.pos < e.content.size) {
|
|
2589
2689
|
let t = e.textBetween(n.pos, n.pos + 1);
|
|
@@ -2608,92 +2708,84 @@ function Oi(e, t) {
|
|
|
2608
2708
|
}
|
|
2609
2709
|
//#endregion
|
|
2610
2710
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2611
|
-
function
|
|
2711
|
+
function Qi(e) {
|
|
2612
2712
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2613
|
-
let t = e.doc.resolve(
|
|
2614
|
-
let
|
|
2615
|
-
if (!
|
|
2616
|
-
return
|
|
2617
|
-
},
|
|
2618
|
-
if (t.depth >
|
|
2619
|
-
|
|
2620
|
-
for (let e = t.depth; e >
|
|
2621
|
-
let n = t.index(e) + 1,
|
|
2622
|
-
for (let t = n; t <
|
|
2623
|
-
}
|
|
2624
|
-
} else
|
|
2625
|
-
for (let e =
|
|
2626
|
-
if (
|
|
2627
|
-
return { blocks:
|
|
2628
|
-
}
|
|
2629
|
-
function
|
|
2630
|
-
let r = typeof t == "string" ? t : t.id, i = typeof n == "string" ? n : n.id
|
|
2713
|
+
let t = e.doc.resolve(y(e.doc, e.selection.from).posBeforeNode), r = e.doc.resolve(y(e.doc, e.selection.to).posBeforeNode), i = (r, i) => {
|
|
2714
|
+
let a = t.posAtIndex(r, i), o = e.doc.resolve(a).nodeAfter;
|
|
2715
|
+
if (!o) throw Error(`Error getting selection - node not found at position ${a}`);
|
|
2716
|
+
return n(o, e.doc);
|
|
2717
|
+
}, a = [], o = t.sharedDepth(r.pos), s = t.index(o), c = r.index(o);
|
|
2718
|
+
if (t.depth > o) {
|
|
2719
|
+
a.push(n(t.nodeAfter, e.doc));
|
|
2720
|
+
for (let e = t.depth; e > o; e--) if (t.node(e).type.isInGroup("childContainer")) {
|
|
2721
|
+
let n = t.index(e) + 1, r = t.node(e).childCount;
|
|
2722
|
+
for (let t = n; t < r; t++) a.push(i(t, e));
|
|
2723
|
+
}
|
|
2724
|
+
} else a.push(i(s, o));
|
|
2725
|
+
for (let e = s + 1; e <= c; e++) a.push(i(e, o));
|
|
2726
|
+
if (a.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2727
|
+
return { blocks: a };
|
|
2728
|
+
}
|
|
2729
|
+
function $i(e, t, n) {
|
|
2730
|
+
let r = typeof t == "string" ? t : t.id, i = typeof n == "string" ? n : n.id;
|
|
2631
2731
|
if (r === i) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);
|
|
2632
|
-
let
|
|
2633
|
-
if (!
|
|
2634
|
-
let
|
|
2635
|
-
if (!
|
|
2636
|
-
let
|
|
2637
|
-
if (
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
if (m.content === "table") {
|
|
2645
|
-
let t = st.get(f.blockContent.node), n = f.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, f.blockContent.node) + 1;
|
|
2646
|
-
g = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
2647
|
-
} else g = f.blockContent.afterPos - 1;
|
|
2648
|
-
e.setSelection(N.create(e.doc, h, g));
|
|
2649
|
-
}
|
|
2650
|
-
function ji(e, t = !1) {
|
|
2651
|
-
let n = t ? Oi(e.doc, e.selection) : e.selection, i = n.$from, a = n.$to;
|
|
2652
|
-
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2653
|
-
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2654
|
-
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2732
|
+
let a = D(r, e.doc);
|
|
2733
|
+
if (!a) throw Error(`Block with ID ${r} not found`);
|
|
2734
|
+
let o = D(i, e.doc);
|
|
2735
|
+
if (!o) throw Error(`Block with ID ${i} not found`);
|
|
2736
|
+
let s = E(a.node, a.posBeforeNode), c = E(o.node, o.posBeforeNode), l = ve(s, "start");
|
|
2737
|
+
if (l === null) throw Error(`Attempting to set selection anchor in block without content (id ${r})`);
|
|
2738
|
+
let u = ve(c, "end");
|
|
2739
|
+
if (u === null) throw Error(`Attempting to set selection head in block without content (id ${i})`);
|
|
2740
|
+
e.setSelection(N.create(e.doc, l, u));
|
|
2741
|
+
}
|
|
2742
|
+
function ea(e, t = !1) {
|
|
2743
|
+
let n = t ? Zi(e.doc, e.selection) : e.selection, r = n.$from, i = n.$to;
|
|
2655
2744
|
for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
|
|
2656
|
-
|
|
2745
|
+
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2746
|
+
for (; r.parentOffset === 0 && r.depth > 0;) r = e.doc.resolve(r.pos - 1);
|
|
2747
|
+
for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0;) r = e.doc.resolve(r.pos + 1);
|
|
2748
|
+
let a = ye(e.doc.slice(r.pos, i.pos, !0));
|
|
2657
2749
|
return {
|
|
2658
2750
|
_meta: {
|
|
2659
|
-
startPos:
|
|
2660
|
-
endPos:
|
|
2751
|
+
startPos: r.pos,
|
|
2752
|
+
endPos: i.pos
|
|
2661
2753
|
},
|
|
2662
|
-
...
|
|
2754
|
+
...a
|
|
2663
2755
|
};
|
|
2664
2756
|
}
|
|
2665
2757
|
//#endregion
|
|
2666
2758
|
//#region src/editor/managers/SelectionManager.ts
|
|
2667
|
-
var
|
|
2759
|
+
var ta = class {
|
|
2668
2760
|
editor;
|
|
2669
2761
|
constructor(e) {
|
|
2670
2762
|
this.editor = e;
|
|
2671
2763
|
}
|
|
2672
2764
|
getSelection() {
|
|
2673
|
-
return this.editor.transact((e) =>
|
|
2765
|
+
return this.editor.transact((e) => Qi(e));
|
|
2674
2766
|
}
|
|
2675
2767
|
getSelectionCutBlocks(e = !1) {
|
|
2676
|
-
return this.editor.transact((t) =>
|
|
2768
|
+
return this.editor.transact((t) => ea(t, e));
|
|
2677
2769
|
}
|
|
2678
2770
|
setSelection(e, t) {
|
|
2679
|
-
return this.editor.transact((n) =>
|
|
2771
|
+
return this.editor.transact((n) => $i(n, e, t));
|
|
2680
2772
|
}
|
|
2681
2773
|
getTextCursorPosition() {
|
|
2682
|
-
return this.editor.transact((e) =>
|
|
2774
|
+
return this.editor.transact((e) => Gr(e));
|
|
2683
2775
|
}
|
|
2684
2776
|
setTextCursorPosition(e, t = "start") {
|
|
2685
|
-
return this.editor.transact((n) =>
|
|
2777
|
+
return this.editor.transact((n) => Kr(n, e, t));
|
|
2686
2778
|
}
|
|
2687
2779
|
getSelectionBoundingBox() {
|
|
2688
2780
|
if (!this.editor.prosemirrorView) return;
|
|
2689
2781
|
let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
|
|
2690
|
-
if (
|
|
2782
|
+
if (bt(e)) {
|
|
2691
2783
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2692
2784
|
if (e) return e.getBoundingClientRect();
|
|
2693
2785
|
}
|
|
2694
|
-
return
|
|
2786
|
+
return Ct(this.editor.prosemirrorView, n, r).toJSON();
|
|
2695
2787
|
}
|
|
2696
|
-
},
|
|
2788
|
+
}, na = class {
|
|
2697
2789
|
editor;
|
|
2698
2790
|
constructor(e) {
|
|
2699
2791
|
this.editor = e;
|
|
@@ -2746,6 +2838,10 @@ var Mi = class {
|
|
|
2746
2838
|
if (!this.editor.headless) throw Error("no editor, but also not headless?");
|
|
2747
2839
|
return !1;
|
|
2748
2840
|
}
|
|
2841
|
+
if (this.editor.headless) {
|
|
2842
|
+
let e = this.editor.getExtension(Ue)?.store.state;
|
|
2843
|
+
if (e) return e.isEditable && e.enabledSet.size === 0;
|
|
2844
|
+
}
|
|
2749
2845
|
return this.editor._tiptapEditor.isEditable === void 0 || this.editor._tiptapEditor.isEditable;
|
|
2750
2846
|
}
|
|
2751
2847
|
set isEditable(e) {
|
|
@@ -2753,7 +2849,7 @@ var Mi = class {
|
|
|
2753
2849
|
if (!this.editor.headless) throw Error("no editor, but also not headless?");
|
|
2754
2850
|
return;
|
|
2755
2851
|
}
|
|
2756
|
-
this.editor.
|
|
2852
|
+
this.editor.getExtension(Ue).setEditable(e);
|
|
2757
2853
|
}
|
|
2758
2854
|
undo() {
|
|
2759
2855
|
let e = this.editor.getExtension("yUndo");
|
|
@@ -2772,7 +2868,7 @@ var Mi = class {
|
|
|
2772
2868
|
};
|
|
2773
2869
|
//#endregion
|
|
2774
2870
|
//#region src/api/blockManipulation/insertContentAt.ts
|
|
2775
|
-
function
|
|
2871
|
+
function ra(e, t, n, r = { updateSelection: !0 }) {
|
|
2776
2872
|
let { from: i, to: a } = typeof t == "number" ? {
|
|
2777
2873
|
from: t,
|
|
2778
2874
|
to: t
|
|
@@ -2786,19 +2882,19 @@ function Pi(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2786
2882
|
let { parent: t } = e.doc.resolve(i);
|
|
2787
2883
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2788
2884
|
}
|
|
2789
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2885
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && wt(e, e.steps.length - 1, -1), !0;
|
|
2790
2886
|
}
|
|
2791
2887
|
//#endregion
|
|
2792
2888
|
//#region src/editor/managers/StyleManager.ts
|
|
2793
|
-
var
|
|
2889
|
+
var ia = class {
|
|
2794
2890
|
editor;
|
|
2795
2891
|
constructor(e) {
|
|
2796
2892
|
this.editor = e;
|
|
2797
2893
|
}
|
|
2798
2894
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2799
|
-
let n =
|
|
2895
|
+
let n = S(e, this.editor.pmSchema);
|
|
2800
2896
|
this.editor.transact((e) => {
|
|
2801
|
-
|
|
2897
|
+
ra(e, {
|
|
2802
2898
|
from: e.selection.from,
|
|
2803
2899
|
to: e.selection.to
|
|
2804
2900
|
}, n, { updateSelection: t });
|
|
@@ -2824,7 +2920,7 @@ var Fi = class {
|
|
|
2824
2920
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2825
2921
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2826
2922
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2827
|
-
else throw new
|
|
2923
|
+
else throw new C(e.propSchema);
|
|
2828
2924
|
}
|
|
2829
2925
|
}
|
|
2830
2926
|
removeStyles(e) {
|
|
@@ -2836,7 +2932,7 @@ var Fi = class {
|
|
|
2836
2932
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2837
2933
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2838
2934
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2839
|
-
else throw new
|
|
2935
|
+
else throw new C(e.propSchema);
|
|
2840
2936
|
}
|
|
2841
2937
|
}
|
|
2842
2938
|
getSelectedText() {
|
|
@@ -2844,7 +2940,7 @@ var Fi = class {
|
|
|
2844
2940
|
}
|
|
2845
2941
|
getLinkMarkAtPos(e) {
|
|
2846
2942
|
return this.editor.transact((t) => {
|
|
2847
|
-
let n = this.editor.pmSchema.marks.link, r =
|
|
2943
|
+
let n = this.editor.pmSchema.marks.link, r = _t(t.doc.resolve(e), n);
|
|
2848
2944
|
if (!r) return;
|
|
2849
2945
|
let i = t.doc.nodeAt(r.from)?.marks.find((e) => e.type === n);
|
|
2850
2946
|
if (i) return {
|
|
@@ -2885,22 +2981,22 @@ var Fi = class {
|
|
|
2885
2981
|
};
|
|
2886
2982
|
//#endregion
|
|
2887
2983
|
//#region src/editor/transformPasted.ts
|
|
2888
|
-
function
|
|
2889
|
-
return
|
|
2984
|
+
function aa(e) {
|
|
2985
|
+
return ht(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2890
2986
|
}
|
|
2891
|
-
function
|
|
2987
|
+
function oa(e, t) {
|
|
2892
2988
|
let n = t.nodes.hardBreak, r = P.empty;
|
|
2893
2989
|
return e.forEach((e) => {
|
|
2894
|
-
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(
|
|
2990
|
+
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(oa(e.content, t)), r = r.addToEnd(n.create()));
|
|
2895
2991
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
2896
2992
|
}
|
|
2897
|
-
function
|
|
2993
|
+
function sa(e, t) {
|
|
2898
2994
|
let n = [];
|
|
2899
2995
|
return e.forEach((e, r, i) => {
|
|
2900
2996
|
i !== t && n.push(e);
|
|
2901
2997
|
}), P.from(n);
|
|
2902
2998
|
}
|
|
2903
|
-
function
|
|
2999
|
+
function ca(e, t) {
|
|
2904
3000
|
let n = [];
|
|
2905
3001
|
for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow") {
|
|
2906
3002
|
if (n.length > 0 && n[n.length - 1].type.name === "table") {
|
|
@@ -2913,56 +3009,57 @@ function zi(e, t) {
|
|
|
2913
3009
|
} else n.push(e.child(r));
|
|
2914
3010
|
return e = P.from(n), e;
|
|
2915
3011
|
}
|
|
2916
|
-
function
|
|
3012
|
+
function la(e, t) {
|
|
2917
3013
|
let n = P.from(e.content);
|
|
2918
|
-
n =
|
|
2919
|
-
let r =
|
|
3014
|
+
n = ca(n, t.state.schema);
|
|
3015
|
+
let r = ua(n, t, e);
|
|
2920
3016
|
if (r) return r;
|
|
2921
|
-
|
|
3017
|
+
let i = t.state.schema.nodes.tableParagraph;
|
|
3018
|
+
if (i && aa(t)) {
|
|
2922
3019
|
let e = !1;
|
|
2923
3020
|
if (n.descendants((t) => {
|
|
2924
3021
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2925
|
-
}), !e && !
|
|
3022
|
+
}), !e && !i.validContent(n)) return new F(oa(n, t.state.schema), 0, 0);
|
|
2926
3023
|
}
|
|
2927
|
-
if (!
|
|
3024
|
+
if (!da(n, t)) return new F(n, e.openStart, e.openEnd);
|
|
2928
3025
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2929
3026
|
let r = [n.child(e)];
|
|
2930
3027
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
2931
3028
|
let t = n.child(e + 1).child(0).child(0);
|
|
2932
|
-
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n =
|
|
3029
|
+
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = sa(n, e + 1));
|
|
2933
3030
|
}
|
|
2934
3031
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2935
3032
|
n = n.replaceChild(e, i);
|
|
2936
3033
|
}
|
|
2937
3034
|
return new F(n, e.openStart, e.openEnd);
|
|
2938
3035
|
}
|
|
2939
|
-
function
|
|
2940
|
-
if (
|
|
2941
|
-
let r =
|
|
2942
|
-
if (!
|
|
2943
|
-
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
3036
|
+
function ua(e, t, n) {
|
|
3037
|
+
if (aa(t) || t.dragging) return null;
|
|
3038
|
+
let r = b(t.state);
|
|
3039
|
+
if (!r.hasContent || r.content.node.type.name === "paragraph" || r.contentKind !== "inline" || !r.isContentEmpty) return null;
|
|
3040
|
+
let i = r.content.node, a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2944
3041
|
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
2945
3042
|
let c = i.type.create(i.attrs, s.content), l = o.copy(o.content.replaceChild(0, c)), u = a.copy(a.content.replaceChild(0, l));
|
|
2946
3043
|
return new F(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2947
3044
|
}
|
|
2948
|
-
function
|
|
3045
|
+
function da(e, t) {
|
|
2949
3046
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2950
3047
|
if (n) {
|
|
2951
3048
|
if (r) return !1;
|
|
2952
3049
|
if (i) {
|
|
2953
|
-
let e =
|
|
2954
|
-
if (e.
|
|
3050
|
+
let e = b(t.state);
|
|
3051
|
+
if (e.hasContent) return e.contentKind !== "table";
|
|
2955
3052
|
}
|
|
2956
3053
|
}
|
|
2957
3054
|
return !0;
|
|
2958
3055
|
}
|
|
2959
3056
|
//#endregion
|
|
2960
3057
|
//#region src/editor/BlockNoteEditor.ts
|
|
2961
|
-
var
|
|
3058
|
+
var fa = {
|
|
2962
3059
|
enableInputRules: !0,
|
|
2963
3060
|
enablePasteRules: !0,
|
|
2964
3061
|
enableCoreExtensions: !1
|
|
2965
|
-
},
|
|
3062
|
+
}, pa = class e extends gn {
|
|
2966
3063
|
options;
|
|
2967
3064
|
pmSchema;
|
|
2968
3065
|
_tiptapEditor;
|
|
@@ -2982,7 +3079,7 @@ var Ui = {
|
|
|
2982
3079
|
return new e(t ?? {});
|
|
2983
3080
|
}
|
|
2984
3081
|
constructor(e) {
|
|
2985
|
-
super(), this.options = e, this.dictionary = e.dictionary ||
|
|
3082
|
+
super(), this.options = e, this.dictionary = e.dictionary || nt, this.settings = { tables: {
|
|
2986
3083
|
splitCells: e?.tables?.splitCells ?? !1,
|
|
2987
3084
|
cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
|
|
2988
3085
|
cellTextColor: e?.tables?.cellTextColor ?? !1,
|
|
@@ -2990,7 +3087,7 @@ var Ui = {
|
|
|
2990
3087
|
} };
|
|
2991
3088
|
let t = {
|
|
2992
3089
|
defaultStyles: !0,
|
|
2993
|
-
schema: e.schema ||
|
|
3090
|
+
schema: e.schema || Ce.create(),
|
|
2994
3091
|
...e,
|
|
2995
3092
|
placeholders: {
|
|
2996
3093
|
...this.dictionary.placeholders,
|
|
@@ -3008,10 +3105,11 @@ var Ui = {
|
|
|
3008
3105
|
}
|
|
3009
3106
|
};
|
|
3010
3107
|
}
|
|
3011
|
-
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new
|
|
3108
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Hn(this), this._extensionManager = new Xi(this, t);
|
|
3012
3109
|
let n = this._extensionManager.getTiptapExtensions(), r = {
|
|
3013
|
-
...
|
|
3110
|
+
...fa,
|
|
3014
3111
|
...t._tiptapOptions,
|
|
3112
|
+
editable: !0,
|
|
3015
3113
|
element: null,
|
|
3016
3114
|
autofocus: t.autofocus ?? !1,
|
|
3017
3115
|
extensions: n,
|
|
@@ -3027,29 +3125,29 @@ var Ui = {
|
|
|
3027
3125
|
tabIndex: "0",
|
|
3028
3126
|
...t._tiptapOptions?.editorProps?.attributes,
|
|
3029
3127
|
...t.domAttributes?.editor,
|
|
3030
|
-
class:
|
|
3128
|
+
class: de("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
3031
3129
|
},
|
|
3032
|
-
transformPasted:
|
|
3130
|
+
transformPasted: la
|
|
3033
3131
|
}
|
|
3034
3132
|
};
|
|
3035
3133
|
try {
|
|
3036
3134
|
let e = t.initialContent || [{
|
|
3037
3135
|
type: "paragraph",
|
|
3038
|
-
id:
|
|
3136
|
+
id: ue.options.generateID()
|
|
3039
3137
|
}];
|
|
3040
3138
|
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(e));
|
|
3041
|
-
let n =
|
|
3139
|
+
let n = yt(r.extensions);
|
|
3042
3140
|
n.cached.blockNoteEditor = this;
|
|
3043
|
-
let
|
|
3141
|
+
let i = e.map((e) => g(e, n, this.schema.styleSchema).toJSON()), a = pt({
|
|
3044
3142
|
type: "doc",
|
|
3045
3143
|
content: [{
|
|
3046
3144
|
type: "blockGroup",
|
|
3047
|
-
content:
|
|
3145
|
+
content: i
|
|
3048
3146
|
}]
|
|
3049
3147
|
}, n, r.parseOptions);
|
|
3050
|
-
this._tiptapEditor = new
|
|
3148
|
+
a.check(), this._tiptapEditor = new dt({
|
|
3051
3149
|
...r,
|
|
3052
|
-
content:
|
|
3150
|
+
content: a.toJSON()
|
|
3053
3151
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
3054
3152
|
} catch (e) {
|
|
3055
3153
|
throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
|
|
@@ -3058,7 +3156,9 @@ var Ui = {
|
|
|
3058
3156
|
this.headless = !1;
|
|
3059
3157
|
}), this._tiptapEditor.on("unmount", () => {
|
|
3060
3158
|
this.headless = !0;
|
|
3061
|
-
}), this.
|
|
3159
|
+
}), this._tiptapEditor.on("destroy", () => {
|
|
3160
|
+
this.emit("destroy");
|
|
3161
|
+
}), this._blockManager = new Vn(this), this._exportManager = new Wr(this), this._selectionManager = new ta(this), this._stateManager = new na(this), this._styleManager = new ia(this), this.emit("create");
|
|
3062
3162
|
}
|
|
3063
3163
|
_blockManager;
|
|
3064
3164
|
_eventManager;
|
|
@@ -3079,15 +3179,17 @@ var Ui = {
|
|
|
3079
3179
|
transact(e) {
|
|
3080
3180
|
return this._stateManager.transact(e);
|
|
3081
3181
|
}
|
|
3082
|
-
unregisterExtension
|
|
3182
|
+
unregisterExtension(e) {
|
|
3183
|
+
return this._extensionManager.unregisterExtension(e);
|
|
3184
|
+
}
|
|
3083
3185
|
registerExtension = (...e) => this._extensionManager.registerExtension(...e);
|
|
3084
3186
|
replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
|
|
3085
3187
|
getExtension = ((e) => this._extensionManager.getExtension(e));
|
|
3086
3188
|
mount = (e) => {
|
|
3087
|
-
this._tiptapEditor.mount({ mount: e });
|
|
3189
|
+
this._tiptapEditor.mount({ mount: e }), this._tiptapEditor.isEditorContentInitialized = !0;
|
|
3088
3190
|
};
|
|
3089
3191
|
unmount = () => {
|
|
3090
|
-
this._tiptapEditor.unmount();
|
|
3192
|
+
this._tiptapEditor.isEditorContentInitialized = !1, this._tiptapEditor.unmount();
|
|
3091
3193
|
};
|
|
3092
3194
|
get prosemirrorState() {
|
|
3093
3195
|
return this._stateManager.prosemirrorState;
|
|
@@ -3165,7 +3267,7 @@ var Ui = {
|
|
|
3165
3267
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
3166
3268
|
}
|
|
3167
3269
|
onBeforeChange(e) {
|
|
3168
|
-
return this._extensionManager.getExtension(
|
|
3270
|
+
return this._extensionManager.getExtension(Ve).subscribe(e);
|
|
3169
3271
|
}
|
|
3170
3272
|
getTextCursorPosition() {
|
|
3171
3273
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -3303,14 +3405,19 @@ var Ui = {
|
|
|
3303
3405
|
pasteMarkdown(e) {
|
|
3304
3406
|
return this._exportManager.pasteMarkdown(e);
|
|
3305
3407
|
}
|
|
3306
|
-
},
|
|
3408
|
+
}, ma = class {
|
|
3409
|
+
schema;
|
|
3307
3410
|
mappings;
|
|
3308
3411
|
options;
|
|
3309
3412
|
constructor(e, t, n) {
|
|
3310
|
-
this.mappings = t, this.options = n;
|
|
3413
|
+
this.schema = e, this.mappings = t, this.options = n;
|
|
3414
|
+
}
|
|
3415
|
+
placesChildren(e) {
|
|
3416
|
+
let t = this.mappings.blockMapping[e.type];
|
|
3417
|
+
return typeof t == "object" && !!t;
|
|
3311
3418
|
}
|
|
3312
3419
|
get dictionary() {
|
|
3313
|
-
return this.options.dictionary?.exporter ??
|
|
3420
|
+
return this.options.dictionary?.exporter ?? nt.exporter;
|
|
3314
3421
|
}
|
|
3315
3422
|
async resolveFile(e) {
|
|
3316
3423
|
if (!this.options?.resolveFileUrl) return this.fetchBlob(e);
|
|
@@ -3340,23 +3447,28 @@ var Ui = {
|
|
|
3340
3447
|
async mapBlock(e, t, n, r) {
|
|
3341
3448
|
let i = this.mappings.blockMapping[e.type];
|
|
3342
3449
|
if (!i) throw Error(`Exporter is missing a block mapping for block type "${e.type}". If this block comes from a separate package, spread that package's exporter mappings into your blockMapping.`);
|
|
3343
|
-
|
|
3450
|
+
if (typeof i == "function") {
|
|
3451
|
+
let r = this.schema.blockSpecs[e.type];
|
|
3452
|
+
if (r !== void 0 && r.config.layoutOnly === !0) throw Error(`The mapping for layout block type "${e.type}" must be a \`{ withChildren }\` mapping, which places the block's children.`);
|
|
3453
|
+
return i(e, this, t, n);
|
|
3454
|
+
}
|
|
3455
|
+
return i.withChildren(e, this, t, n, r ?? []);
|
|
3344
3456
|
}
|
|
3345
3457
|
};
|
|
3346
3458
|
//#endregion
|
|
3347
3459
|
//#region src/exporter/ExportImage.ts
|
|
3348
|
-
function
|
|
3460
|
+
function ha(e) {
|
|
3349
3461
|
if ("toBase64" in e && typeof e.toBase64 == "function") return e.toBase64();
|
|
3350
3462
|
let t = "";
|
|
3351
3463
|
for (let n of e) t += String.fromCharCode(n);
|
|
3352
3464
|
return btoa(t);
|
|
3353
3465
|
}
|
|
3354
|
-
function
|
|
3355
|
-
return `data:${e.mimeType};base64,${
|
|
3466
|
+
function ga(e) {
|
|
3467
|
+
return `data:${e.mimeType};base64,${ha(e.data)}`;
|
|
3356
3468
|
}
|
|
3357
3469
|
//#endregion
|
|
3358
3470
|
//#region src/exporter/mapping.ts
|
|
3359
|
-
function
|
|
3471
|
+
function _a(e) {
|
|
3360
3472
|
return {
|
|
3361
3473
|
createBlockMapping: (e) => e,
|
|
3362
3474
|
createInlineContentMapping: (e) => e,
|
|
@@ -3365,7 +3477,7 @@ function Ji(e) {
|
|
|
3365
3477
|
}
|
|
3366
3478
|
//#endregion
|
|
3367
3479
|
//#region src/util/combineByGroup.ts
|
|
3368
|
-
function
|
|
3480
|
+
function va(e, ...t) {
|
|
3369
3481
|
let n = [...e];
|
|
3370
3482
|
for (let e of t) for (let t of e) {
|
|
3371
3483
|
let e = n.findLastIndex((e) => e.group === t.group);
|
|
@@ -3374,6 +3486,6 @@ function Yi(e, ...t) {
|
|
|
3374
3486
|
return n;
|
|
3375
3487
|
}
|
|
3376
3488
|
//#endregion
|
|
3377
|
-
export {
|
|
3489
|
+
export { U as A, ln as C, K as D, G as E, Lt as M, It as N, W as O, Mt as P, fn as S, Wt as T, pn as _, ma as a, Y as b, $ as c, nr as d, Ln as f, gn as g, Rn as h, ga as i, H as j, Rt as k, Ur as l, Bn as m, _a as n, pa as o, zn as p, ha as r, Zi as s, va as t, Hr as u, mn as v, Gt as w, hn as x, dn as y };
|
|
3378
3490
|
|
|
3379
|
-
//# sourceMappingURL=src-
|
|
3491
|
+
//# sourceMappingURL=src-BmLsLZfE.js.map
|