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