@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
|
@@ -1,2138 +0,0 @@
|
|
|
1
|
-
import { Bt as e, Gt as t, Hn as n, Ht as r, It as i, Kt as a, Lt as o, Nt as s, Pt as c, Rt as l, Tn as u, Ut as d, Vt as f, Wt as p, _ as m, ar as h, h as g, qt as ee, r as te, v as _, wn as v, zt as ne } from "./blocks-Dol85hpH.js";
|
|
2
|
-
import { n as y, t as b } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
-
import { n as re } from "./UserStore-C4TzkGEn.js";
|
|
4
|
-
import { DOMSerializer as x, Fragment as S, Slice as ie } from "prosemirror-model";
|
|
5
|
-
import { Mapping as ae, dropPoint as oe } from "prosemirror-transform";
|
|
6
|
-
import { combineTransactionSteps as se, findChildrenInRange as ce, posToDOMRect as le } from "@tiptap/core";
|
|
7
|
-
import { uuidv4 as ue } from "lib0/random";
|
|
8
|
-
import { NodeSelection as de, Plugin as C, PluginKey as w, Selection as T, TextSelection as E } from "prosemirror-state";
|
|
9
|
-
import { DOMParser as fe, Slice as pe } from "@tiptap/pm/model";
|
|
10
|
-
import { CellSelection as me, addColumnAfter as he, addColumnBefore as ge, addRowAfter as _e, addRowBefore as ve, deleteColumn as ye, deleteRow as be, mergeCells as xe, splitCell as Se } from "prosemirror-tables";
|
|
11
|
-
import { Plugin as Ce, PluginKey as we, TextSelection as Te } from "@tiptap/pm/state";
|
|
12
|
-
import { Decoration as D, DecorationSet as O } from "prosemirror-view";
|
|
13
|
-
import Ee from "fast-deep-equal";
|
|
14
|
-
import { history as De, redo as Oe, undo as ke } from "@tiptap/pm/history";
|
|
15
|
-
import { createHighlightPlugin as Ae } from "prosemirror-highlight";
|
|
16
|
-
import { createParser as je } from "prosemirror-highlight/shiki";
|
|
17
|
-
function Me(e) {
|
|
18
|
-
let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
|
|
19
|
-
t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
|
|
20
|
-
}
|
|
21
|
-
function Ne(e, t, r, a) {
|
|
22
|
-
let s;
|
|
23
|
-
if (!t) throw Error("blockContent is required");
|
|
24
|
-
if (typeof t == "string") s = i([t], e.pmSchema, a?.blockType);
|
|
25
|
-
else if (Array.isArray(t)) s = i(t, e.pmSchema, a?.blockType);
|
|
26
|
-
else if (t.type === "tableContent") s = o(t, e.pmSchema);
|
|
27
|
-
else throw new n(t.type);
|
|
28
|
-
let c = (a?.document ?? document).createDocumentFragment();
|
|
29
|
-
for (let t of s) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
30
|
-
let n = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
31
|
-
if (n) {
|
|
32
|
-
let i = u(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = n.toExternalHTML ? n.toExternalHTML(i, e) : n.render.call({
|
|
33
|
-
renderType: "dom",
|
|
34
|
-
props: void 0
|
|
35
|
-
}, i, () => {}, e);
|
|
36
|
-
if (o) {
|
|
37
|
-
if (c.appendChild(o.dom), o.contentDOM) {
|
|
38
|
-
let e = r.serializeFragment(t.content, a);
|
|
39
|
-
o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(e);
|
|
40
|
-
}
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} else if (t.type.name === "text") {
|
|
45
|
-
let n = document.createTextNode(t.textContent);
|
|
46
|
-
for (let r of t.marks.toReversed()) if (r.type.name in e.schema.styleSpecs) {
|
|
47
|
-
let t = (e.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? e.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, e);
|
|
48
|
-
t.contentDOM.appendChild(n), n = t.dom;
|
|
49
|
-
} else {
|
|
50
|
-
let e = r.type.spec.toDOM(r, !0), t = x.renderSpec(document, e);
|
|
51
|
-
t.contentDOM.appendChild(n), n = t.dom;
|
|
52
|
-
}
|
|
53
|
-
c.appendChild(n);
|
|
54
|
-
} else {
|
|
55
|
-
let e = r.serializeFragment(S.from([t]), a);
|
|
56
|
-
c.appendChild(e);
|
|
57
|
-
}
|
|
58
|
-
return c.childNodes.length === 1 && c.firstChild?.nodeType === 1 && Me(c.firstChild), c;
|
|
59
|
-
}
|
|
60
|
-
function Pe(e, t, n, r, i, a, o, s) {
|
|
61
|
-
let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
|
|
62
|
-
for (let [e, r] of Object.entries(t.schema.blockSchema[n.type].propSchema)) !(e in u) && r.default !== void 0 && (u[e] = r.default);
|
|
63
|
-
let d = l.spec?.toDOM?.(l.create({
|
|
64
|
-
id: n.id,
|
|
65
|
-
...u
|
|
66
|
-
})), f = Array.from(d.dom.attributes), p = t.blockImplementations[n.type].implementation, m = p.toExternalHTML?.call({}, {
|
|
67
|
-
...n,
|
|
68
|
-
props: u
|
|
69
|
-
}, t, { nestingLevel: o }) || p.render.call({}, {
|
|
70
|
-
...n,
|
|
71
|
-
props: u
|
|
72
|
-
}, t), h = c.createDocumentFragment();
|
|
73
|
-
if (m.dom.classList.contains("bn-block-content")) {
|
|
74
|
-
let e = [...f, ...Array.from(m.dom.attributes)].filter((e) => e.name.startsWith("data") && e.name !== "data-content-type" && e.name !== "data-file-block" && e.name !== "data-node-view-wrapper" && e.name !== "data-node-type" && e.name !== "data-id" && e.name !== "data-editable");
|
|
75
|
-
for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
|
|
76
|
-
Me(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
|
|
77
|
-
} else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
|
|
78
|
-
if (m.contentDOM) {
|
|
79
|
-
if (n.content) {
|
|
80
|
-
let e = Ne(t, n.content, r, {
|
|
81
|
-
...s,
|
|
82
|
-
blockType: n.type
|
|
83
|
-
});
|
|
84
|
-
m.contentDOM.appendChild(e);
|
|
85
|
-
}
|
|
86
|
-
let e = t.pmSchema.nodes[n.type];
|
|
87
|
-
e?.inlineContent && !e.spec.code && m.contentDOM.childNodes.length === 0 && m.contentDOM.appendChild(c.createTextNode(""));
|
|
88
|
-
}
|
|
89
|
-
let g;
|
|
90
|
-
if (i.has(n.type) ? g = "OL" : a.has(n.type) && (g = "UL"), g) {
|
|
91
|
-
if (e.lastChild?.nodeName !== g) {
|
|
92
|
-
let t = c.createElement(g);
|
|
93
|
-
g === "OL" && "start" in u && u.start && u?.start !== 1 && t.setAttribute("start", String(u.start)), e.append(t);
|
|
94
|
-
}
|
|
95
|
-
e.lastChild.appendChild(h);
|
|
96
|
-
} else e.append(h);
|
|
97
|
-
if (n.children && n.children.length > 0) {
|
|
98
|
-
let l = c.createDocumentFragment();
|
|
99
|
-
if (Fe(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
|
|
100
|
-
"childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
var Fe = (e, t, n, r, i, a, o = 0, s) => {
|
|
104
|
-
for (let c of n) Pe(e, t, c, r, i, a, o, s);
|
|
105
|
-
}, Ie = (e, t, n, r, i, a) => {
|
|
106
|
-
let o = (a?.document ?? document).createDocumentFragment();
|
|
107
|
-
return Fe(o, e, t, n, r, i, 0, a), o;
|
|
108
|
-
}, k = (e, t) => {
|
|
109
|
-
let n = x.fromSchema(e);
|
|
110
|
-
return {
|
|
111
|
-
exportBlocks: (e, r) => {
|
|
112
|
-
let i = Ie(t, e, n, /* @__PURE__ */ new Set(["numberedListItem"]), /* @__PURE__ */ new Set([
|
|
113
|
-
"bulletListItem",
|
|
114
|
-
"checkListItem",
|
|
115
|
-
"toggleListItem"
|
|
116
|
-
]), r), a = document.createElement("div");
|
|
117
|
-
return a.append(i), a.innerHTML;
|
|
118
|
-
},
|
|
119
|
-
exportInlineContent: (e, r) => {
|
|
120
|
-
let i = Ne(t, e, n, r), a = document.createElement("div");
|
|
121
|
-
return a.append(i.cloneNode(!0)), a.innerHTML;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/api/getChangedRange.ts
|
|
127
|
-
function Le(e) {
|
|
128
|
-
let { mapping: t, steps: n } = e, r = Infinity, i = -Infinity;
|
|
129
|
-
for (let e = 0; e < t.maps.length; e++) {
|
|
130
|
-
let a = t.maps[e];
|
|
131
|
-
e && (r = a.map(r, 1), i = a.map(i, -1));
|
|
132
|
-
let o = !1;
|
|
133
|
-
if (a.forEach((e, t, n, a) => {
|
|
134
|
-
o = !0, r = Math.min(r, n), i = Math.max(i, a);
|
|
135
|
-
}), !o) {
|
|
136
|
-
let t = n[e];
|
|
137
|
-
typeof t.pos == "number" ? (r = Math.min(r, t.pos), i = Math.max(i, t.pos + 1)) : typeof t.from == "number" && typeof t.to == "number" && (r = Math.min(r, t.from), i = Math.max(i, t.to));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return r === Infinity ? null : {
|
|
141
|
-
from: r,
|
|
142
|
-
to: i
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/api/getBlocksChangedByTransaction.ts
|
|
147
|
-
function Re(e, t) {
|
|
148
|
-
if (t === 0) return;
|
|
149
|
-
let n = e.resolve(t);
|
|
150
|
-
for (let t = n.depth; t > 0; t--) {
|
|
151
|
-
let r = n.node(t);
|
|
152
|
-
if (c(r)) return h(r, e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function ze(e) {
|
|
156
|
-
return e.getMeta("paste") ? { type: "paste" } : e.getMeta("uiEvent") === "drop" ? { type: "drop" } : e.getMeta("history$") ? { type: e.getMeta("history$").redo ? "redo" : "undo" } : e.getMeta("y-sync$") ? e.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
157
|
-
}
|
|
158
|
-
function Be(e, t) {
|
|
159
|
-
let n = {}, r = {}, i = Math.max(0, Math.min(t.from, e.content.size)), a = Math.max(i, Math.min(t.to, e.content.size));
|
|
160
|
-
return e.nodesBetween(i, a, (t, i) => {
|
|
161
|
-
if (!c(t)) return !0;
|
|
162
|
-
let a = Re(e, i), o = a ?? "__root__";
|
|
163
|
-
r[o] || (r[o] = []);
|
|
164
|
-
let s = v(t, e), l = h(t, e);
|
|
165
|
-
return n[l] = {
|
|
166
|
-
block: s,
|
|
167
|
-
parentId: a
|
|
168
|
-
}, r[o].push(l), !0;
|
|
169
|
-
}), {
|
|
170
|
-
byId: n,
|
|
171
|
-
childrenByParent: r
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function Ve(e, t) {
|
|
175
|
-
let n = /* @__PURE__ */ new Set();
|
|
176
|
-
if (!e || !t) return n;
|
|
177
|
-
let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
|
|
178
|
-
if (a.length <= 1 || i.length <= 1) return n;
|
|
179
|
-
let o = {};
|
|
180
|
-
for (let e = 0; e < a.length; e++) o[a[e]] = e;
|
|
181
|
-
let s = i.map((e) => o[e]), c = s.length, l = [], u = [], d = Array(c).fill(-1), f = (e, t) => {
|
|
182
|
-
let n = 0, r = e.length;
|
|
183
|
-
for (; n < r;) {
|
|
184
|
-
let i = n + r >>> 1;
|
|
185
|
-
e[i] < t ? n = i + 1 : r = i;
|
|
186
|
-
}
|
|
187
|
-
return n;
|
|
188
|
-
};
|
|
189
|
-
for (let e = 0; e < c; e++) {
|
|
190
|
-
let t = s[e], n = f(l, t);
|
|
191
|
-
n > 0 && (d[e] = u[n - 1]), n === l.length ? (l.push(t), u.push(e)) : (l[n] = t, u[n] = e);
|
|
192
|
-
}
|
|
193
|
-
let p = /* @__PURE__ */ new Set(), m = u[u.length - 1] ?? -1;
|
|
194
|
-
for (; m !== -1;) p.add(m), m = d[m];
|
|
195
|
-
for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
|
|
196
|
-
return n;
|
|
197
|
-
}
|
|
198
|
-
function He(e, t = []) {
|
|
199
|
-
let n = ze(e), r = se(e.before, [e, ...t]), i = Le(r);
|
|
200
|
-
if (!i) return [];
|
|
201
|
-
let a = r.mapping.invert(), o = {
|
|
202
|
-
from: a.map(i.from, -1),
|
|
203
|
-
to: a.map(i.to, 1)
|
|
204
|
-
}, s = Be(r.before, o), c = Be(r.doc, i), l = [], u = /* @__PURE__ */ new Set();
|
|
205
|
-
Object.keys(c.byId).filter((e) => !(e in s.byId)).forEach((e) => {
|
|
206
|
-
l.push({
|
|
207
|
-
type: "insert",
|
|
208
|
-
block: c.byId[e].block,
|
|
209
|
-
source: n,
|
|
210
|
-
prevBlock: void 0
|
|
211
|
-
}), u.add(e);
|
|
212
|
-
}), Object.keys(s.byId).filter((e) => !(e in c.byId)).forEach((e) => {
|
|
213
|
-
l.push({
|
|
214
|
-
type: "delete",
|
|
215
|
-
block: s.byId[e].block,
|
|
216
|
-
source: n,
|
|
217
|
-
prevBlock: void 0
|
|
218
|
-
}), u.add(e);
|
|
219
|
-
}), Object.keys(c.byId).filter((e) => e in s.byId).forEach((e) => {
|
|
220
|
-
let t = s.byId[e], r = c.byId[e];
|
|
221
|
-
t.parentId === r.parentId ? Ee({
|
|
222
|
-
...t.block,
|
|
223
|
-
children: void 0
|
|
224
|
-
}, {
|
|
225
|
-
...r.block,
|
|
226
|
-
children: void 0
|
|
227
|
-
}) || (l.push({
|
|
228
|
-
type: "update",
|
|
229
|
-
block: r.block,
|
|
230
|
-
prevBlock: t.block,
|
|
231
|
-
source: n
|
|
232
|
-
}), u.add(e)) : (l.push({
|
|
233
|
-
type: "move",
|
|
234
|
-
block: r.block,
|
|
235
|
-
prevBlock: t.block,
|
|
236
|
-
source: n,
|
|
237
|
-
prevParent: t.parentId ? s.byId[t.parentId]?.block : void 0,
|
|
238
|
-
currentParent: r.parentId ? c.byId[r.parentId]?.block : void 0
|
|
239
|
-
}), u.add(e));
|
|
240
|
-
});
|
|
241
|
-
let d = s.childrenByParent, f = c.childrenByParent, p = /* @__PURE__ */ new Set([...Object.keys(d), ...Object.keys(f)]), m = /* @__PURE__ */ new Set();
|
|
242
|
-
return p.forEach((e) => {
|
|
243
|
-
let t = Ve(d[e], f[e]);
|
|
244
|
-
t.size !== 0 && t.forEach((t) => {
|
|
245
|
-
let r = s.byId[t], i = c.byId[t];
|
|
246
|
-
!r || !i || r.parentId === i.parentId && (u.has(t) || (r.parentId ?? "__root__") === e && (m.has(t) || (m.add(t), l.push({
|
|
247
|
-
type: "move",
|
|
248
|
-
block: i.block,
|
|
249
|
-
prevBlock: r.block,
|
|
250
|
-
source: n,
|
|
251
|
-
prevParent: r.parentId ? s.byId[r.parentId]?.block : void 0,
|
|
252
|
-
currentParent: i.parentId ? c.byId[i.parentId]?.block : void 0
|
|
253
|
-
}), u.add(t))));
|
|
254
|
-
});
|
|
255
|
-
}), l;
|
|
256
|
-
}
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region src/extensions/BlockChange/BlockChange.ts
|
|
259
|
-
var Ue = b(() => {
|
|
260
|
-
let e = [];
|
|
261
|
-
return {
|
|
262
|
-
key: "blockChange",
|
|
263
|
-
prosemirrorPlugins: [new C({
|
|
264
|
-
key: new w("blockChange"),
|
|
265
|
-
filterTransaction: (t) => {
|
|
266
|
-
let n;
|
|
267
|
-
return e.reduce((e, r) => e === !1 ? e : r({
|
|
268
|
-
getChanges() {
|
|
269
|
-
return n || (n = He(t), n);
|
|
270
|
-
},
|
|
271
|
-
tr: t
|
|
272
|
-
}) !== !1, !0);
|
|
273
|
-
}
|
|
274
|
-
})],
|
|
275
|
-
subscribe(t) {
|
|
276
|
-
return e.push(t), () => {
|
|
277
|
-
e.splice(e.indexOf(t), 1);
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
});
|
|
282
|
-
//#endregion
|
|
283
|
-
//#region src/extensions/DropCursor/utils.ts
|
|
284
|
-
function We(e, t) {
|
|
285
|
-
return !e || !t ? !1 : !!e.closest(`.${t}`);
|
|
286
|
-
}
|
|
287
|
-
function Ge(e, t, n, r, i) {
|
|
288
|
-
let a = e.state.doc.resolve(t.pos);
|
|
289
|
-
if (a.parent.inlineContent || t.orientation === "inline") return null;
|
|
290
|
-
let o = a.nodeBefore, s = a.nodeAfter;
|
|
291
|
-
if (!o && !s) return null;
|
|
292
|
-
let c = t.orientation === "block-vertical-left" || t.orientation === "block-vertical-right", l = c ? t.pos : t.pos - (o ? o.nodeSize : 0), u = e.nodeDOM(l);
|
|
293
|
-
if (!u) return null;
|
|
294
|
-
let d = u.getBoundingClientRect();
|
|
295
|
-
if (c) {
|
|
296
|
-
let e = n / 2 * r, i = t.orientation === "block-vertical-left" ? d.left : d.right;
|
|
297
|
-
return {
|
|
298
|
-
left: i - e,
|
|
299
|
-
right: i + e,
|
|
300
|
-
top: d.top,
|
|
301
|
-
bottom: d.bottom
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
let f = o ? d.bottom : d.top;
|
|
305
|
-
o && s && (f = (f + e.nodeDOM(t.pos).getBoundingClientRect().top) / 2);
|
|
306
|
-
let p = n / 2 * i;
|
|
307
|
-
return {
|
|
308
|
-
left: d.left,
|
|
309
|
-
right: d.right,
|
|
310
|
-
top: f - p,
|
|
311
|
-
bottom: f + p
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
function Ke(e, t, n, r) {
|
|
315
|
-
let i = e.coordsAtPos(t.pos), a = n / 2 * r;
|
|
316
|
-
return {
|
|
317
|
-
left: i.left - a,
|
|
318
|
-
right: i.left + a,
|
|
319
|
-
top: i.top,
|
|
320
|
-
bottom: i.bottom
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
function qe(e, t) {
|
|
324
|
-
e.classList.toggle("prosemirror-dropcursor-inline", t === "inline"), e.classList.toggle("prosemirror-dropcursor-block-horizontal", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-block-vertical-left", t === "block-vertical-left"), e.classList.toggle("prosemirror-dropcursor-block-vertical-right", t === "block-vertical-right"), e.classList.toggle("prosemirror-dropcursor-block", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-vertical", t === "block-vertical-left" || t === "block-vertical-right");
|
|
325
|
-
}
|
|
326
|
-
function Je(e) {
|
|
327
|
-
if (!e || e === document.body && getComputedStyle(e).position === "static") return {
|
|
328
|
-
parentLeft: -window.pageXOffset,
|
|
329
|
-
parentTop: -window.pageYOffset
|
|
330
|
-
};
|
|
331
|
-
let t = e.getBoundingClientRect(), n = t.width / e.offsetWidth, r = t.height / e.offsetHeight;
|
|
332
|
-
return {
|
|
333
|
-
parentLeft: t.left - e.scrollLeft * n,
|
|
334
|
-
parentTop: t.top - e.scrollTop * r
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/extensions/DropCursor/DropCursor.ts
|
|
339
|
-
var Ye = "bn-drag-exclude", Xe = b(({ editor: e, options: t }) => {
|
|
340
|
-
let n = null, r = null, i = -1, a = null, o = {
|
|
341
|
-
width: t.dropCursor?.width ?? 5,
|
|
342
|
-
color: t.dropCursor?.color ?? "#ddeeff",
|
|
343
|
-
exclude: t.dropCursor?.exclude ?? "bn-drag-exclude",
|
|
344
|
-
hooks: t.dropCursor?.hooks
|
|
345
|
-
}, s = (e) => {
|
|
346
|
-
(e?.pos !== n?.pos || e?.orientation !== n?.orientation) && (n = e, e == null ? (r && r.parentNode && r.parentNode.removeChild(r), r = null) : c());
|
|
347
|
-
}, c = () => {
|
|
348
|
-
if (!n) return;
|
|
349
|
-
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = Ge(t, n, o.width, s, c) ?? Ke(t, n, o.width, s), u = t.dom.offsetParent;
|
|
350
|
-
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), qe(r, n.orientation);
|
|
351
|
-
let { parentLeft: d, parentTop: f } = Je(u);
|
|
352
|
-
r.style.left = (l.left - d) / s + "px", r.style.top = (l.top - f) / c + "px", r.style.width = (l.right - l.left) / s + "px", r.style.height = (l.bottom - l.top) / c + "px";
|
|
353
|
-
}, l = (e) => {
|
|
354
|
-
clearTimeout(i), i = window.setTimeout(() => s(null), e);
|
|
355
|
-
}, u = (e) => {
|
|
356
|
-
let t = e;
|
|
357
|
-
a = t.target instanceof Element ? t.target : null;
|
|
358
|
-
}, d = (t) => {
|
|
359
|
-
let n = t;
|
|
360
|
-
if (a && We(a, o.exclude) || n.target instanceof Element && We(n.target, o.exclude)) return;
|
|
361
|
-
let r = e.prosemirrorView;
|
|
362
|
-
if (!r.editable) return;
|
|
363
|
-
let i = r.posAtCoords({
|
|
364
|
-
left: n.clientX,
|
|
365
|
-
top: n.clientY
|
|
366
|
-
}), c = i && i.inside >= 0 && r.state.doc.nodeAt(i.inside), u = c && c.type.spec.disableDropCursor, d = typeof u == "function" ? u(r, i, n) : u;
|
|
367
|
-
if (i && !d) {
|
|
368
|
-
let t = i.pos;
|
|
369
|
-
if (r.dragging && r.dragging.slice) {
|
|
370
|
-
let e = oe(r.state.doc, t, r.dragging.slice);
|
|
371
|
-
e != null && (t = e);
|
|
372
|
-
}
|
|
373
|
-
let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
|
|
374
|
-
pos: t,
|
|
375
|
-
orientation: a ? "block-horizontal" : "inline"
|
|
376
|
-
}, u = c;
|
|
377
|
-
if (o.hooks?.computeDropPosition) {
|
|
378
|
-
let t = o.hooks.computeDropPosition({
|
|
379
|
-
editor: e,
|
|
380
|
-
event: n,
|
|
381
|
-
view: r,
|
|
382
|
-
defaultPosition: c
|
|
383
|
-
});
|
|
384
|
-
if (t === null) {
|
|
385
|
-
s(null);
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
u = t;
|
|
389
|
-
}
|
|
390
|
-
s(u), l(5e3);
|
|
391
|
-
}
|
|
392
|
-
}, f = (t) => {
|
|
393
|
-
let n = t;
|
|
394
|
-
(!(n.relatedTarget instanceof Node) || !e.prosemirrorView.dom.contains(n.relatedTarget)) && s(null);
|
|
395
|
-
}, p = () => {
|
|
396
|
-
l(20);
|
|
397
|
-
}, m = () => {
|
|
398
|
-
l(20), a = null;
|
|
399
|
-
};
|
|
400
|
-
return {
|
|
401
|
-
key: "dropCursor",
|
|
402
|
-
mount({ signal: e, dom: t, root: n }) {
|
|
403
|
-
n.addEventListener("dragstart", u, {
|
|
404
|
-
capture: !0,
|
|
405
|
-
signal: e
|
|
406
|
-
}), t.addEventListener("dragover", d, { signal: e }), t.addEventListener("dragleave", f, { signal: e }), t.addEventListener("drop", p, { signal: e }), t.addEventListener("dragend", m, { signal: e }), e.addEventListener("abort", () => {
|
|
407
|
-
clearTimeout(i), s(null);
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
}), Ze = b(() => ({
|
|
412
|
-
key: "history",
|
|
413
|
-
prosemirrorPlugins: [De()],
|
|
414
|
-
undoCommand: ke,
|
|
415
|
-
redoCommand: Oe
|
|
416
|
-
})), Qe = new w("inline-content-boundary-edit");
|
|
417
|
-
function $e(e, t, n) {
|
|
418
|
-
if (!e.empty) return e.from <= n.from && e.to >= n.to;
|
|
419
|
-
let r = n.to - n.from === 1;
|
|
420
|
-
return t === "Backspace" ? r && e.from === n.to : r && e.from === n.from;
|
|
421
|
-
}
|
|
422
|
-
var et = b(() => ({
|
|
423
|
-
key: "inlineContentBoundaryEdit",
|
|
424
|
-
prosemirrorPlugins: [new C({
|
|
425
|
-
key: Qe,
|
|
426
|
-
props: { handleKeyDown: (e, t) => {
|
|
427
|
-
if (!e.editable) return !1;
|
|
428
|
-
let n = t.key.length === 1 && !t.ctrlKey && !t.metaKey;
|
|
429
|
-
if (!n && t.key !== "Backspace" && t.key !== "Delete") return !1;
|
|
430
|
-
let { selection: r } = e.state, i = r.$from.node();
|
|
431
|
-
if (!i.type.spec.inline) return !1;
|
|
432
|
-
let a = r.$from.before(), o = a + 1, s = a + 1 + i.content.size;
|
|
433
|
-
if (n && i.content.size === 0) {
|
|
434
|
-
let n = e.state.tr.insert(o, e.state.schema.text(t.key));
|
|
435
|
-
return n.setSelection(E.create(n.doc, o + t.key.length)), e.dispatch(n), !0;
|
|
436
|
-
}
|
|
437
|
-
if (i.content.size > 0 && $e(r, t.key, {
|
|
438
|
-
from: o,
|
|
439
|
-
to: s
|
|
440
|
-
})) {
|
|
441
|
-
let t = e.state.tr.delete(o, s);
|
|
442
|
-
return t.setSelection(E.create(t.doc, o)), e.dispatch(t), !0;
|
|
443
|
-
}
|
|
444
|
-
return !1;
|
|
445
|
-
} }
|
|
446
|
-
})]
|
|
447
|
-
})), tt = b(({ editor: e }) => {
|
|
448
|
-
function t(t) {
|
|
449
|
-
let n = e.prosemirrorView.nodeDOM(t);
|
|
450
|
-
for (; n && n.parentElement;) {
|
|
451
|
-
if (n.nodeName === "A") return n;
|
|
452
|
-
n = n.parentElement;
|
|
453
|
-
}
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
function n(t) {
|
|
457
|
-
let n = e.getLinkMarkAtPos(t);
|
|
458
|
-
if (n) return {
|
|
459
|
-
range: {
|
|
460
|
-
from: n.from,
|
|
461
|
-
to: n.to
|
|
462
|
-
},
|
|
463
|
-
mark: { attrs: { href: n.href } },
|
|
464
|
-
get text() {
|
|
465
|
-
return n.text;
|
|
466
|
-
},
|
|
467
|
-
get position() {
|
|
468
|
-
return le(e.prosemirrorView, n.from, n.to).toJSON();
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
function r() {
|
|
473
|
-
return e.transact((e) => {
|
|
474
|
-
if (e.selection.empty) return n(e.selection.anchor);
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
return {
|
|
478
|
-
key: "linkToolbar",
|
|
479
|
-
getLinkAtSelection: r,
|
|
480
|
-
getLinkElementAtPos: t,
|
|
481
|
-
getMarkAtPos(e, t) {
|
|
482
|
-
return n(e);
|
|
483
|
-
},
|
|
484
|
-
getLinkAtElement(t) {
|
|
485
|
-
return e.transact(() => n(e.prosemirrorView.posAtDOM(t, 0) + 1));
|
|
486
|
-
},
|
|
487
|
-
editLink(t, n, r = e.transact((e) => e.selection.anchor)) {
|
|
488
|
-
e.editLink(t, n, r);
|
|
489
|
-
},
|
|
490
|
-
deleteLink(t = e.transact((e) => e.selection.anchor)) {
|
|
491
|
-
e.deleteLink(t);
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
}), nt = [
|
|
495
|
-
"http",
|
|
496
|
-
"https",
|
|
497
|
-
"ftp",
|
|
498
|
-
"ftps",
|
|
499
|
-
"mailto",
|
|
500
|
-
"tel",
|
|
501
|
-
"callto",
|
|
502
|
-
"sms",
|
|
503
|
-
"cid",
|
|
504
|
-
"xmpp"
|
|
505
|
-
], rt = "https", it = new w("node-selection-keyboard"), at = b(() => ({
|
|
506
|
-
key: "nodeSelectionKeyboard",
|
|
507
|
-
prosemirrorPlugins: [new C({
|
|
508
|
-
key: it,
|
|
509
|
-
props: { handleKeyDown: (e, t) => {
|
|
510
|
-
if ("node" in e.state.selection) {
|
|
511
|
-
if (t.ctrlKey || t.metaKey) return !1;
|
|
512
|
-
if (t.key.length === 1) return t.preventDefault(), !0;
|
|
513
|
-
if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
|
|
514
|
-
let t = e.state.tr;
|
|
515
|
-
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new E(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return !1;
|
|
519
|
-
} }
|
|
520
|
-
})]
|
|
521
|
-
})), ot = new w("blocknote-placeholder"), st = b(({ editor: e, options: t }) => {
|
|
522
|
-
let n = t.placeholders;
|
|
523
|
-
return {
|
|
524
|
-
key: "placeholder",
|
|
525
|
-
prosemirrorPlugins: [new C({
|
|
526
|
-
key: ot,
|
|
527
|
-
view: (t) => {
|
|
528
|
-
let r = `placeholder-selector-${ue()}`;
|
|
529
|
-
t.dom.classList.add(r);
|
|
530
|
-
let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
|
|
531
|
-
a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
|
|
532
|
-
let o = i.sheet, s = (e = "") => `.${r} .bn-block-content${e}:has(.ProseMirror-trailingBreak:only-child):after`;
|
|
533
|
-
try {
|
|
534
|
-
let { default: e, emptyDocument: t, ...r } = n || {};
|
|
535
|
-
for (let [e, t] of Object.entries(r)) {
|
|
536
|
-
let n = `[data-content-type="${e}"]`;
|
|
537
|
-
o.insertRule(`${s(n)} { content: ${JSON.stringify(t)}; }`);
|
|
538
|
-
}
|
|
539
|
-
o.insertRule(`${s("[data-is-only-empty-block]")} { content: ${JSON.stringify(t)}; }`), o.insertRule(`${s("[data-is-empty-and-focused]")} { content: ${JSON.stringify(e)}; }`);
|
|
540
|
-
} catch (e) {
|
|
541
|
-
console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)", e);
|
|
542
|
-
}
|
|
543
|
-
return { destroy: () => {
|
|
544
|
-
t.root instanceof window.ShadowRoot ? t.root.removeChild(i) : t.root.head.removeChild(i);
|
|
545
|
-
} };
|
|
546
|
-
},
|
|
547
|
-
props: { decorations: (t) => {
|
|
548
|
-
let { doc: n, selection: r } = t;
|
|
549
|
-
if (!e.isEditable || !r.empty || r.$from.parent.type.spec.code) return;
|
|
550
|
-
let i = [];
|
|
551
|
-
t.doc.content.size === 6 && i.push(D.node(2, 4, { "data-is-only-empty-block": "true" }));
|
|
552
|
-
let a = r.$anchor, o = a.parent;
|
|
553
|
-
if (o.content.size === 0) {
|
|
554
|
-
let e = a.before();
|
|
555
|
-
i.push(D.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
|
|
556
|
-
}
|
|
557
|
-
return O.create(n, i);
|
|
558
|
-
} }
|
|
559
|
-
})]
|
|
560
|
-
};
|
|
561
|
-
}), ct = b(({ editor: e }) => {
|
|
562
|
-
let t = new ae(), n = 0;
|
|
563
|
-
function r() {
|
|
564
|
-
t = new ae(), n = 0;
|
|
565
|
-
}
|
|
566
|
-
let i = typeof FinalizationRegistry < "u" ? new FinalizationRegistry(() => {
|
|
567
|
-
n--, n === 0 && r();
|
|
568
|
-
}) : null;
|
|
569
|
-
return e.on("create", () => {
|
|
570
|
-
e._tiptapEditor.on("transaction", ({ transaction: e }) => {
|
|
571
|
-
n !== 0 && t.appendMapping(e.mapping);
|
|
572
|
-
}), e._tiptapEditor.on("destroy", () => {
|
|
573
|
-
r();
|
|
574
|
-
});
|
|
575
|
-
}), {
|
|
576
|
-
key: "positionMapping",
|
|
577
|
-
mapPosition: (e, r = "left") => {
|
|
578
|
-
n++;
|
|
579
|
-
let a = t.maps.length, o = () => t.slice(a).map(e, r === "left" ? -1 : 1);
|
|
580
|
-
return i && i.register(o, void 0), o;
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
}), lt = new w("previous-blocks"), ut = {
|
|
584
|
-
index: "index",
|
|
585
|
-
level: "level",
|
|
586
|
-
type: "type",
|
|
587
|
-
depth: "depth",
|
|
588
|
-
"depth-change": "depth-change"
|
|
589
|
-
}, dt = b(() => {
|
|
590
|
-
let e;
|
|
591
|
-
return {
|
|
592
|
-
key: "previousBlockType",
|
|
593
|
-
prosemirrorPlugins: [new C({
|
|
594
|
-
key: lt,
|
|
595
|
-
view(t) {
|
|
596
|
-
return {
|
|
597
|
-
update: async (t, n) => {
|
|
598
|
-
this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
|
|
599
|
-
t.dispatch(t.state.tr.setMeta(lt, { clearUpdate: !0 }));
|
|
600
|
-
}, 0));
|
|
601
|
-
},
|
|
602
|
-
destroy: () => {
|
|
603
|
-
e && clearTimeout(e);
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
},
|
|
607
|
-
state: {
|
|
608
|
-
init() {
|
|
609
|
-
return {
|
|
610
|
-
prevTransactionOldBlockAttrs: {},
|
|
611
|
-
currentTransactionOldBlockAttrs: {},
|
|
612
|
-
updatedBlocks: /* @__PURE__ */ new Set()
|
|
613
|
-
};
|
|
614
|
-
},
|
|
615
|
-
apply(e, t, n, r) {
|
|
616
|
-
if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged) return t;
|
|
617
|
-
let i = Le(e);
|
|
618
|
-
if (!i) return t;
|
|
619
|
-
let a = e.mapping.invert(), o = {
|
|
620
|
-
from: a.map(i.from, -1),
|
|
621
|
-
to: a.map(i.to, 1)
|
|
622
|
-
}, s = {}, c = ce(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [h(e.node, n.doc), e])), u = ce(r.doc, i, (e) => e.attrs.id);
|
|
623
|
-
for (let e of u) {
|
|
624
|
-
let i = h(e.node, r.doc), a = l.get(i), o = a?.node.firstChild, c = e.node.firstChild;
|
|
625
|
-
if (a && o && c) {
|
|
626
|
-
let l = {
|
|
627
|
-
index: c.attrs.index,
|
|
628
|
-
level: c.attrs.level,
|
|
629
|
-
type: c.type.name,
|
|
630
|
-
depth: r.doc.resolve(e.pos).depth
|
|
631
|
-
}, u = {
|
|
632
|
-
index: o.attrs.index,
|
|
633
|
-
level: o.attrs.level,
|
|
634
|
-
type: o.type.name,
|
|
635
|
-
depth: n.doc.resolve(a.pos).depth
|
|
636
|
-
};
|
|
637
|
-
s[i] = u, t.currentTransactionOldBlockAttrs[i] = u, (u.index !== l.index || u.level !== l.level || u.type !== l.type || u.depth !== l.depth) && (u["depth-change"] = u.depth - l.depth, t.updatedBlocks.add(i));
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
return t.prevTransactionOldBlockAttrs = s, t;
|
|
641
|
-
}
|
|
642
|
-
},
|
|
643
|
-
props: { decorations(e) {
|
|
644
|
-
let t = this.getState(e);
|
|
645
|
-
if (t.updatedBlocks.size === 0) return;
|
|
646
|
-
let n = [];
|
|
647
|
-
return e.doc.descendants((r, i) => {
|
|
648
|
-
if (!r.attrs.id) return;
|
|
649
|
-
let a = h(r, e.doc);
|
|
650
|
-
if (!t.updatedBlocks.has(a)) return;
|
|
651
|
-
let o = t.currentTransactionOldBlockAttrs[a], s = {};
|
|
652
|
-
for (let [e, t] of Object.entries(o)) s["data-prev-" + ut[e]] = t || "none";
|
|
653
|
-
n.push(D.node(i, i + r.nodeSize, { ...s }));
|
|
654
|
-
}), O.create(e.doc, n);
|
|
655
|
-
} }
|
|
656
|
-
})]
|
|
657
|
-
};
|
|
658
|
-
});
|
|
659
|
-
//#endregion
|
|
660
|
-
//#region src/extensions/getDraggableBlockFromElement.ts
|
|
661
|
-
function ft(e, t) {
|
|
662
|
-
for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
|
|
663
|
-
if (e.getAttribute?.("data-node-type") === "blockContainer") return {
|
|
664
|
-
node: e,
|
|
665
|
-
id: e.getAttribute("data-id")
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region src/api/exporters/markdown/htmlToMarkdown.ts
|
|
670
|
-
function pt(e) {
|
|
671
|
-
let t = document.createElement("div");
|
|
672
|
-
return t.innerHTML = e, A(t, {
|
|
673
|
-
indent: "",
|
|
674
|
-
inListItem: !1
|
|
675
|
-
}).trim() + "\n";
|
|
676
|
-
}
|
|
677
|
-
function A(e, t) {
|
|
678
|
-
let n = "", r = Array.from(e.childNodes);
|
|
679
|
-
for (let e = 0; e < r.length; e++) {
|
|
680
|
-
let i = r[e];
|
|
681
|
-
n += j(i, t);
|
|
682
|
-
}
|
|
683
|
-
return n;
|
|
684
|
-
}
|
|
685
|
-
function j(e, t) {
|
|
686
|
-
if (e.nodeType === 3) return e.textContent || "";
|
|
687
|
-
if (e.nodeType !== 1) return "";
|
|
688
|
-
let n = e;
|
|
689
|
-
switch (n.tagName.toLowerCase()) {
|
|
690
|
-
case "p": return mt(n, t);
|
|
691
|
-
case "h1":
|
|
692
|
-
case "h2":
|
|
693
|
-
case "h3":
|
|
694
|
-
case "h4":
|
|
695
|
-
case "h5":
|
|
696
|
-
case "h6": return ht(n, t);
|
|
697
|
-
case "blockquote": return gt(n, t);
|
|
698
|
-
case "pre": return _t(n, t);
|
|
699
|
-
case "ul": return St(n, t);
|
|
700
|
-
case "ol": return Ct(n, t);
|
|
701
|
-
case "table": return Et(n, t);
|
|
702
|
-
case "hr": return t.indent + "***\n\n";
|
|
703
|
-
case "math": return yt(n, t);
|
|
704
|
-
case "img": return kt(n, t);
|
|
705
|
-
case "video": return At(n, t);
|
|
706
|
-
case "audio": return jt(n, t);
|
|
707
|
-
case "embed": return Mt(n, t);
|
|
708
|
-
case "figure": return Nt(n, t);
|
|
709
|
-
case "a": return F(n, t);
|
|
710
|
-
case "details": return It(n, t);
|
|
711
|
-
case "div": return A(n, t);
|
|
712
|
-
case "br": return "";
|
|
713
|
-
default: return A(n, t);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
function mt(e, t) {
|
|
717
|
-
let n = Lt(L(e));
|
|
718
|
-
return t.inListItem ? n : t.indent + n + "\n\n";
|
|
719
|
-
}
|
|
720
|
-
function ht(e, t) {
|
|
721
|
-
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = L(e);
|
|
722
|
-
return t.indent + r + i + "\n\n";
|
|
723
|
-
}
|
|
724
|
-
function gt(e, t) {
|
|
725
|
-
let n = Array.from(e.children).filter((e) => {
|
|
726
|
-
let t = e.tagName.toLowerCase();
|
|
727
|
-
return [
|
|
728
|
-
"p",
|
|
729
|
-
"ul",
|
|
730
|
-
"ol",
|
|
731
|
-
"pre",
|
|
732
|
-
"blockquote",
|
|
733
|
-
"table",
|
|
734
|
-
"hr"
|
|
735
|
-
].includes(t);
|
|
736
|
-
}), r;
|
|
737
|
-
if (n.length > 0) {
|
|
738
|
-
let e = [];
|
|
739
|
-
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(L(t)) : e.push(j(t, {
|
|
740
|
-
indent: "",
|
|
741
|
-
inListItem: !1
|
|
742
|
-
}).trim());
|
|
743
|
-
r = e.join("\n\n");
|
|
744
|
-
} else r = L(e);
|
|
745
|
-
return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
|
|
746
|
-
}
|
|
747
|
-
function _t(e, t) {
|
|
748
|
-
let n = e.querySelector("code");
|
|
749
|
-
if (!n) return "";
|
|
750
|
-
let r = n.getAttribute("data-language") || xt(n.className) || "", i = bt(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
|
|
751
|
-
return i ? [
|
|
752
|
-
o + r,
|
|
753
|
-
...(i.endsWith("\n") ? i.slice(0, -1) : i).split("\n"),
|
|
754
|
-
o
|
|
755
|
-
].map((e) => e && t.indent + e).join("\n") + "\n\n" : t.indent + o + r + "\n" + t.indent + o + "\n\n";
|
|
756
|
-
}
|
|
757
|
-
function vt(e) {
|
|
758
|
-
return (e.querySelector("annotation[encoding=\"application/x-tex\"]")?.textContent ?? e.textContent ?? "").trim();
|
|
759
|
-
}
|
|
760
|
-
function yt(e, t) {
|
|
761
|
-
return [
|
|
762
|
-
"$$",
|
|
763
|
-
...vt(e).split("\n"),
|
|
764
|
-
"$$"
|
|
765
|
-
].map((e) => e && t.indent + e).join("\n") + "\n\n";
|
|
766
|
-
}
|
|
767
|
-
function bt(e) {
|
|
768
|
-
let t = "";
|
|
769
|
-
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += bt(n));
|
|
770
|
-
return t;
|
|
771
|
-
}
|
|
772
|
-
function xt(e) {
|
|
773
|
-
let t = e.match(/language-(\S+)/);
|
|
774
|
-
return t ? t[1] : "";
|
|
775
|
-
}
|
|
776
|
-
function St(e, t) {
|
|
777
|
-
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
|
|
778
|
-
for (let e of r) n += wt(e, "bullet", t);
|
|
779
|
-
return t.inListItem || (n += "\n"), n;
|
|
780
|
-
}
|
|
781
|
-
function Ct(e, t) {
|
|
782
|
-
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
|
|
783
|
-
for (let e = 0; e < r.length; e++) {
|
|
784
|
-
let a = i + e;
|
|
785
|
-
n += wt(r[e], "ordered", t, a);
|
|
786
|
-
}
|
|
787
|
-
return t.inListItem || (n += "\n"), n;
|
|
788
|
-
}
|
|
789
|
-
function wt(e, t, n, r) {
|
|
790
|
-
let i = null, a = null;
|
|
791
|
-
for (let t of Array.from(e.children)) {
|
|
792
|
-
let e = t.tagName.toLowerCase();
|
|
793
|
-
e === "input" && t.type === "checkbox" && (i = t), e === "details" && (a = t);
|
|
794
|
-
}
|
|
795
|
-
let o, s;
|
|
796
|
-
i ? (o = `* ${i.checked ? "[x]" : "[ ]"} `, s = 2) : t === "ordered" ? (o = `${r}. `, s = o.length) : (o = "* ", s = 2);
|
|
797
|
-
let c, l;
|
|
798
|
-
if (a) {
|
|
799
|
-
let e = a.querySelector("summary")?.querySelector("p");
|
|
800
|
-
l = a, c = e ? L(e) : "";
|
|
801
|
-
} else l = Tt(e, i), c = l ? L(l) : "";
|
|
802
|
-
let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
|
|
803
|
-
indent: d,
|
|
804
|
-
inListItem: !0
|
|
805
|
-
};
|
|
806
|
-
if (a) {
|
|
807
|
-
let e = a.querySelector("summary");
|
|
808
|
-
for (let t of Array.from(a.children)) if (t !== e) {
|
|
809
|
-
if (t.tagName.toLowerCase() === "p") {
|
|
810
|
-
let e = L(t);
|
|
811
|
-
u += "\n" + d + e + "\n";
|
|
812
|
-
} else u += j(t, f);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
let p = Array.from(e.children);
|
|
816
|
-
for (let e of p) {
|
|
817
|
-
let t = e.tagName.toLowerCase();
|
|
818
|
-
if (e !== l && e !== i && t !== "input") {
|
|
819
|
-
if (t === "ul" || t === "ol") u += j(e, f);
|
|
820
|
-
else if (t === "p") {
|
|
821
|
-
let t = L(e);
|
|
822
|
-
u += "\n" + d + t + "\n";
|
|
823
|
-
} else u += "\n" + j(e, f);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
return u;
|
|
827
|
-
}
|
|
828
|
-
function Tt(e, t) {
|
|
829
|
-
for (let n of Array.from(e.children)) {
|
|
830
|
-
if (n === t || n.tagName.toLowerCase() === "input") continue;
|
|
831
|
-
let e = n.tagName.toLowerCase();
|
|
832
|
-
if (e === "p" || e === "span") return n;
|
|
833
|
-
}
|
|
834
|
-
return null;
|
|
835
|
-
}
|
|
836
|
-
function Et(e, t) {
|
|
837
|
-
let n = e.querySelector("colgroup"), r = 0;
|
|
838
|
-
n && (r = n.querySelectorAll("col").length);
|
|
839
|
-
let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
|
|
840
|
-
o.forEach((e, t) => {
|
|
841
|
-
s[t] || (s[t] = []);
|
|
842
|
-
let n = e.querySelectorAll("th, td"), i = 0;
|
|
843
|
-
n.forEach((e) => {
|
|
844
|
-
for (; s[t][i] !== void 0;) i++;
|
|
845
|
-
t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
|
|
846
|
-
let n = Dt(L(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
|
|
847
|
-
for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
|
|
848
|
-
let r = t + e;
|
|
849
|
-
s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
|
|
850
|
-
}
|
|
851
|
-
i += r;
|
|
852
|
-
}), s[t] && (r = Math.max(r, s[t].length));
|
|
853
|
-
});
|
|
854
|
-
for (let e of s) {
|
|
855
|
-
let t = [];
|
|
856
|
-
for (let n = 0; n < r; n++) t.push(e && e[n] !== void 0 ? e[n] ?? "" : "");
|
|
857
|
-
i.push(t);
|
|
858
|
-
}
|
|
859
|
-
if (i.length === 0) return "";
|
|
860
|
-
let c = [];
|
|
861
|
-
for (let e = 0; e < r; e++) {
|
|
862
|
-
let t = 3;
|
|
863
|
-
for (let n of i) {
|
|
864
|
-
let r = e < n.length ? n[e].length : 0;
|
|
865
|
-
t = Math.max(t, r);
|
|
866
|
-
}
|
|
867
|
-
c.push(Math.max(t, 10));
|
|
868
|
-
}
|
|
869
|
-
let l = "";
|
|
870
|
-
if (a) {
|
|
871
|
-
l += t.indent + M(i[0], c, r) + "\n", l += t.indent + Ot(c, r) + "\n";
|
|
872
|
-
for (let e = 1; e < i.length; e++) l += t.indent + M(i[e], c, r) + "\n";
|
|
873
|
-
} else {
|
|
874
|
-
let e = Array(r).fill("");
|
|
875
|
-
l += t.indent + M(e, c, r) + "\n", l += t.indent + Ot(c, r) + "\n";
|
|
876
|
-
for (let e of i) l += t.indent + M(e, c, r) + "\n";
|
|
877
|
-
}
|
|
878
|
-
return l += "\n", l;
|
|
879
|
-
}
|
|
880
|
-
function Dt(e) {
|
|
881
|
-
return e.replace(/\|/g, "\\|");
|
|
882
|
-
}
|
|
883
|
-
function M(e, t, n) {
|
|
884
|
-
let r = [];
|
|
885
|
-
for (let i = 0; i < n; i++) {
|
|
886
|
-
let n = i < e.length ? e[i] : "";
|
|
887
|
-
r.push(" " + n.padEnd(t[i]) + " ");
|
|
888
|
-
}
|
|
889
|
-
return "|" + r.join("|") + "|";
|
|
890
|
-
}
|
|
891
|
-
function Ot(e, t) {
|
|
892
|
-
let n = [];
|
|
893
|
-
for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
|
|
894
|
-
return "|" + n.join("|") + "|";
|
|
895
|
-
}
|
|
896
|
-
function kt(e, t) {
|
|
897
|
-
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
898
|
-
return n ? t.indent + `\n\n` : "\n\n";
|
|
899
|
-
}
|
|
900
|
-
function At(e, t) {
|
|
901
|
-
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
902
|
-
return n ? t.indent + `\n\n` : "\n\n";
|
|
903
|
-
}
|
|
904
|
-
function jt(e, t) {
|
|
905
|
-
let n = e.getAttribute("src") || "";
|
|
906
|
-
return n ? t.indent + `<audio src="${P(n)}" controls></audio>\n\n` : "\n\n";
|
|
907
|
-
}
|
|
908
|
-
function Mt(e, t) {
|
|
909
|
-
let n = e.getAttribute("src") || "";
|
|
910
|
-
return n ? t.indent + `[](${n})\n\n` : "\n\n";
|
|
911
|
-
}
|
|
912
|
-
function Nt(e, t) {
|
|
913
|
-
let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
|
|
914
|
-
return n ? N("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? N("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? N("audio", i.getAttribute("src") || "", "", o, t) : a ? F(a, t) : "";
|
|
915
|
-
}
|
|
916
|
-
function N(e, t, n, r, i) {
|
|
917
|
-
if (!t) return "";
|
|
918
|
-
if (!r && e !== "audio") return i.indent + `\n\n`;
|
|
919
|
-
let a = n && n !== r ? e === "img" ? ` alt="${P(n)}"` : e === "video" ? ` data-name="${P(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${P(t)}">` : `<${e} src="${P(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${Pt(r)}</figcaption>` : "";
|
|
920
|
-
return i.indent + `<figure>${o}${s}</figure>\n\n`;
|
|
921
|
-
}
|
|
922
|
-
function P(e) {
|
|
923
|
-
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
924
|
-
}
|
|
925
|
-
function Pt(e) {
|
|
926
|
-
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
927
|
-
}
|
|
928
|
-
function F(e, t) {
|
|
929
|
-
let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
|
|
930
|
-
return n ? t.indent + I(r, n) + "\n\n" : t.indent + r + "\n\n";
|
|
931
|
-
}
|
|
932
|
-
function I(e, t) {
|
|
933
|
-
return !e || e === t ? t : `[${e}](${Ft(t)})`;
|
|
934
|
-
}
|
|
935
|
-
function Ft(e) {
|
|
936
|
-
return e.replace(/[\\()]/g, "\\$&");
|
|
937
|
-
}
|
|
938
|
-
function It(e, t) {
|
|
939
|
-
let n = e.querySelector("summary");
|
|
940
|
-
if (!n) return A(e, t);
|
|
941
|
-
let r = n.querySelector("h1, h2, h3, h4, h5, h6");
|
|
942
|
-
if (r) {
|
|
943
|
-
let i = ht(r, t);
|
|
944
|
-
for (let r of Array.from(e.children)) r !== n && (i += j(r, t));
|
|
945
|
-
return i;
|
|
946
|
-
}
|
|
947
|
-
return A(n, t);
|
|
948
|
-
}
|
|
949
|
-
function L(e) {
|
|
950
|
-
let t = "";
|
|
951
|
-
for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += n.textContent || "";
|
|
952
|
-
else if (n.nodeType === 1) {
|
|
953
|
-
let e = n;
|
|
954
|
-
switch (e.tagName.toLowerCase()) {
|
|
955
|
-
case "strong":
|
|
956
|
-
case "b": {
|
|
957
|
-
let { content: n, trailing: r } = R(L(e));
|
|
958
|
-
t += n ? `**${n}**${r}` : r;
|
|
959
|
-
break;
|
|
960
|
-
}
|
|
961
|
-
case "em":
|
|
962
|
-
case "i": {
|
|
963
|
-
let { content: n, trailing: r } = R(L(e));
|
|
964
|
-
t += n ? `*${n}*${r}` : r;
|
|
965
|
-
break;
|
|
966
|
-
}
|
|
967
|
-
case "s":
|
|
968
|
-
case "del":
|
|
969
|
-
t += `~~${L(e)}~~`;
|
|
970
|
-
break;
|
|
971
|
-
case "code": {
|
|
972
|
-
let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
|
|
973
|
-
t += i + (a ? ` ${n} ` : n) + i;
|
|
974
|
-
break;
|
|
975
|
-
}
|
|
976
|
-
case "u":
|
|
977
|
-
t += L(e);
|
|
978
|
-
break;
|
|
979
|
-
case "a": {
|
|
980
|
-
let n = e.getAttribute("href") || "", r = L(e);
|
|
981
|
-
t += I(r, n);
|
|
982
|
-
break;
|
|
983
|
-
}
|
|
984
|
-
case "br":
|
|
985
|
-
t += "\\\n";
|
|
986
|
-
break;
|
|
987
|
-
case "math": {
|
|
988
|
-
let n = vt(e).split("\n").map((e) => e.trim()).join(" ");
|
|
989
|
-
t += `$${n}$`;
|
|
990
|
-
break;
|
|
991
|
-
}
|
|
992
|
-
case "span":
|
|
993
|
-
t += L(e);
|
|
994
|
-
break;
|
|
995
|
-
case "img": {
|
|
996
|
-
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
997
|
-
t += ``;
|
|
998
|
-
break;
|
|
999
|
-
}
|
|
1000
|
-
case "video": {
|
|
1001
|
-
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
1002
|
-
t += ``;
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
case "p":
|
|
1006
|
-
t += L(e);
|
|
1007
|
-
break;
|
|
1008
|
-
case "input": break;
|
|
1009
|
-
default: t += L(e);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
return t;
|
|
1013
|
-
}
|
|
1014
|
-
function R(e) {
|
|
1015
|
-
let t = e.match(/^(.*?)(\s*)$/);
|
|
1016
|
-
return t ? {
|
|
1017
|
-
content: t[1],
|
|
1018
|
-
trailing: t[2]
|
|
1019
|
-
} : {
|
|
1020
|
-
content: e,
|
|
1021
|
-
trailing: ""
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
function Lt(e) {
|
|
1025
|
-
let t = e.replace(/^(\\\n)+/, "");
|
|
1026
|
-
return t = t.replace(/(\\\n)+$/, ""), t;
|
|
1027
|
-
}
|
|
1028
|
-
//#endregion
|
|
1029
|
-
//#region src/api/exporters/markdown/markdownExporter.ts
|
|
1030
|
-
function z(e) {
|
|
1031
|
-
return pt(e.split("").join(""));
|
|
1032
|
-
}
|
|
1033
|
-
function Rt(e, t, n, r) {
|
|
1034
|
-
return z(k(t, n).exportBlocks(e, r));
|
|
1035
|
-
}
|
|
1036
|
-
//#endregion
|
|
1037
|
-
//#region src/api/nodeConversions/fragmentToBlocks.ts
|
|
1038
|
-
function B(e) {
|
|
1039
|
-
let t = [];
|
|
1040
|
-
return e.descendants((e) => e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup" ? !0 : e.type.name === "columnList" && e.childCount === 1 ? (e.firstChild?.forEach((n) => {
|
|
1041
|
-
t.push(v(n, e));
|
|
1042
|
-
}), !1) : !e.type.isInGroup("bnBlock") || (t.push(v(e, e)), !1)), t;
|
|
1043
|
-
}
|
|
1044
|
-
//#endregion
|
|
1045
|
-
//#region src/extensions/SideMenu/MultipleNodeSelection.ts
|
|
1046
|
-
var V = class e extends T {
|
|
1047
|
-
nodes;
|
|
1048
|
-
constructor(e, t) {
|
|
1049
|
-
super(e, t);
|
|
1050
|
-
let n = e.node();
|
|
1051
|
-
this.nodes = [], e.doc.nodesBetween(e.pos, t.pos, (e, t, r) => {
|
|
1052
|
-
if (r !== null && r.eq(n)) return this.nodes.push(e), !1;
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
static create(t, n, r = n) {
|
|
1056
|
-
return new e(t.resolve(n), t.resolve(r));
|
|
1057
|
-
}
|
|
1058
|
-
content() {
|
|
1059
|
-
return new ie(S.from(this.nodes), 0, 0);
|
|
1060
|
-
}
|
|
1061
|
-
eq(t) {
|
|
1062
|
-
if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
|
|
1063
|
-
for (let e = 0; e < this.nodes.length; e++) if (!this.nodes[e].eq(t.nodes[e])) return !1;
|
|
1064
|
-
return !0;
|
|
1065
|
-
}
|
|
1066
|
-
map(t, n) {
|
|
1067
|
-
let r = n.mapResult(this.from), i = n.mapResult(this.to);
|
|
1068
|
-
return i.deleted ? T.near(t.resolve(r.pos)) : r.deleted ? T.near(t.resolve(i.pos)) : new e(t.resolve(r.pos), t.resolve(i.pos));
|
|
1069
|
-
}
|
|
1070
|
-
toJSON() {
|
|
1071
|
-
return {
|
|
1072
|
-
type: "multiple-node",
|
|
1073
|
-
anchor: this.anchor,
|
|
1074
|
-
head: this.head
|
|
1075
|
-
};
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
T.jsonID("multiple-node", V);
|
|
1079
|
-
//#endregion
|
|
1080
|
-
//#region src/extensions/SideMenu/dragging.ts
|
|
1081
|
-
var H;
|
|
1082
|
-
function zt(e, t) {
|
|
1083
|
-
let n, r, i = t.resolve(e.from).node().type.spec.group === "blockContent", a = t.resolve(e.to).node().type.spec.group === "blockContent", o = Math.min(e.$anchor.depth, e.$head.depth);
|
|
1084
|
-
if (i && a) {
|
|
1085
|
-
let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
|
|
1086
|
-
n = t.resolve(i - 1).pos, r = t.resolve(a + 1).pos;
|
|
1087
|
-
} else n = e.from, r = e.to;
|
|
1088
|
-
return {
|
|
1089
|
-
from: n,
|
|
1090
|
-
to: r
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
function Bt(e, t, n = t) {
|
|
1094
|
-
t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
|
|
1095
|
-
let r = e.domAtPos(t).node.cloneNode(!0), i = e.domAtPos(t).node, a = (e, t) => Array.prototype.indexOf.call(e.children, t), o = a(i, e.domAtPos(t + 1).node.parentElement), s = a(i, e.domAtPos(n - 1).node.parentElement);
|
|
1096
|
-
for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
|
|
1097
|
-
Vt(e.root), H = r, H.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
|
|
1098
|
-
let c = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
|
|
1099
|
-
H.className = H.className + " bn-drag-preview " + c, e.root instanceof ShadowRoot ? e.root.appendChild(H) : e.root.body.appendChild(H);
|
|
1100
|
-
}
|
|
1101
|
-
function Vt(e) {
|
|
1102
|
-
H !== void 0 && (e instanceof ShadowRoot ? e.removeChild(H) : e.body.removeChild(H), H = void 0);
|
|
1103
|
-
}
|
|
1104
|
-
function Ht(e, t, n) {
|
|
1105
|
-
if (!e.dataTransfer || n.headless) return;
|
|
1106
|
-
let r = n.prosemirrorView, i = s(t.id, r.state.doc);
|
|
1107
|
-
if (!i) throw Error(`Block with ID ${t.id} not found`);
|
|
1108
|
-
let a = i.posBeforeNode;
|
|
1109
|
-
if (a != null) {
|
|
1110
|
-
let t = r.state.selection, i = r.state.doc, { from: o, to: s } = zt(t, i), c = o <= a && a < s, l = t.$anchor.node() !== t.$head.node() || t instanceof V;
|
|
1111
|
-
c && l ? (r.dispatch(r.state.tr.setSelection(V.create(i, o, s))), Bt(r, o, s)) : (r.dispatch(r.state.tr.setSelection(de.create(r.state.doc, a))), Bt(r, a));
|
|
1112
|
-
let u = r.state.selection.content(), d = n.pmSchema, f = r.serializeForClipboard(u).dom.innerHTML, p = k(d, n), m = B(u.content), h = p.exportBlocks(m, {}), g = z(h);
|
|
1113
|
-
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(H, 0, 0);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
//#endregion
|
|
1117
|
-
//#region src/extensions/SideMenu/SideMenu.ts
|
|
1118
|
-
var Ut = 250;
|
|
1119
|
-
function U(e, t, n = !0) {
|
|
1120
|
-
let r = e.root.elementsFromPoint(t.left, t.top);
|
|
1121
|
-
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? U(e, {
|
|
1122
|
-
left: t.left + 50,
|
|
1123
|
-
top: t.top
|
|
1124
|
-
}, !1) : ft(i, e);
|
|
1125
|
-
}
|
|
1126
|
-
function Wt(e, t) {
|
|
1127
|
-
if (!t.dom.firstChild) return;
|
|
1128
|
-
let n = t.dom.firstChild.getBoundingClientRect(), r = U(t, {
|
|
1129
|
-
left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
|
|
1130
|
-
top: e.y
|
|
1131
|
-
});
|
|
1132
|
-
if (r) return U(t, {
|
|
1133
|
-
left: r.node.getBoundingClientRect().right - 10,
|
|
1134
|
-
top: e.y
|
|
1135
|
-
}, !1);
|
|
1136
|
-
}
|
|
1137
|
-
var Gt = class {
|
|
1138
|
-
editor;
|
|
1139
|
-
pmView;
|
|
1140
|
-
state;
|
|
1141
|
-
emitUpdate;
|
|
1142
|
-
mousePos;
|
|
1143
|
-
hoveredBlock;
|
|
1144
|
-
menuFrozen = !1;
|
|
1145
|
-
isDragOrigin = !1;
|
|
1146
|
-
constructor(e, t, n) {
|
|
1147
|
-
this.editor = e, this.pmView = t, this.emitUpdate = () => {
|
|
1148
|
-
if (!this.state) throw Error("Attempting to update uninitialized side menu");
|
|
1149
|
-
n(this.state);
|
|
1150
|
-
}, this.pmView.root.addEventListener("dragstart", this.onDragStart), this.pmView.root.addEventListener("dragover", this.onDragOver), this.pmView.root.addEventListener("drop", this.onDrop, !0), this.pmView.root.addEventListener("dragend", this.onDragEnd, !0), this.pmView.root.addEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.addEventListener("keydown", this.onKeyDown, !0);
|
|
1151
|
-
}
|
|
1152
|
-
updateState = (e) => {
|
|
1153
|
-
this.state = e, this.emitUpdate(this.state);
|
|
1154
|
-
};
|
|
1155
|
-
updateStateFromMousePos = () => {
|
|
1156
|
-
if (this.menuFrozen || !this.mousePos) return;
|
|
1157
|
-
let e = this.findClosestEditorElement({
|
|
1158
|
-
clientX: this.mousePos.x,
|
|
1159
|
-
clientY: this.mousePos.y
|
|
1160
|
-
});
|
|
1161
|
-
if (e?.element !== this.pmView.dom || e.distance > Ut) {
|
|
1162
|
-
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
let t = Wt(this.mousePos, this.pmView);
|
|
1166
|
-
if (!t || !this.editor.isEditable) {
|
|
1167
|
-
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
1168
|
-
return;
|
|
1169
|
-
}
|
|
1170
|
-
if (!(this.state?.show && this.hoveredBlock?.hasAttribute("data-id") && this.hoveredBlock?.getAttribute("data-id") === t.id) && (this.hoveredBlock = t.node, this.editor.isEditable)) {
|
|
1171
|
-
let e = t.node.getBoundingClientRect(), n = t.node.closest("[data-node-type=column]"), r = this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"));
|
|
1172
|
-
if (!r) {
|
|
1173
|
-
this.state?.show && (this.state.show = !1, this.hoveredBlock = void 0, this.emitUpdate(this.state));
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
this.state = {
|
|
1177
|
-
show: !0,
|
|
1178
|
-
referencePos: new DOMRect(n ? n.firstElementChild.getBoundingClientRect().x : this.pmView.dom.firstChild.getBoundingClientRect().x, e.y, e.width, e.height),
|
|
1179
|
-
block: r
|
|
1180
|
-
}, this.updateState(this.state);
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
onDragStart = (e) => {
|
|
1184
|
-
let t = e.dataTransfer?.getData("blocknote/html");
|
|
1185
|
-
if (!t || this.pmView.dragging) return;
|
|
1186
|
-
let n = document.createElement("div");
|
|
1187
|
-
n.innerHTML = t;
|
|
1188
|
-
let r = fe.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
|
|
1189
|
-
this.pmView.dragging = {
|
|
1190
|
-
slice: new pe(r.content, 0, 0),
|
|
1191
|
-
move: !0
|
|
1192
|
-
};
|
|
1193
|
-
};
|
|
1194
|
-
findClosestEditorElement = (e) => {
|
|
1195
|
-
let t = Array.from(this.pmView.root.querySelectorAll(".bn-editor"));
|
|
1196
|
-
if (t.length === 0) return null;
|
|
1197
|
-
let n = t[0], r = Number.MAX_VALUE;
|
|
1198
|
-
return t.forEach((t) => {
|
|
1199
|
-
let i = t.querySelector(".bn-block-group").getBoundingClientRect(), a = e.clientX < i.left ? i.left - e.clientX : e.clientX > i.right ? e.clientX - i.right : 0, o = e.clientY < i.top ? i.top - e.clientY : e.clientY > i.bottom ? e.clientY - i.bottom : 0, s = Math.sqrt(a ** 2 + o ** 2);
|
|
1200
|
-
s < r && (r = s, n = t);
|
|
1201
|
-
}), {
|
|
1202
|
-
element: n,
|
|
1203
|
-
distance: r
|
|
1204
|
-
};
|
|
1205
|
-
};
|
|
1206
|
-
onDragOver = (e) => {
|
|
1207
|
-
if (e.synthetic || !(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1208
|
-
let t = this.getDragEventContext(e);
|
|
1209
|
-
if (!t || !t.isDropPoint) {
|
|
1210
|
-
this.closeDropCursor();
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
t.isDropPoint && !t.isDropWithinEditorBounds && this.dispatchSyntheticEvent(e);
|
|
1214
|
-
};
|
|
1215
|
-
closeDropCursor = () => {
|
|
1216
|
-
let e = new Event("dragleave", { bubbles: !1 });
|
|
1217
|
-
e.synthetic = !0, this.pmView.dom.dispatchEvent(e);
|
|
1218
|
-
};
|
|
1219
|
-
getDragEventContext = (e) => {
|
|
1220
|
-
if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1221
|
-
let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
|
|
1222
|
-
if (!i || i.distance > Ut) return;
|
|
1223
|
-
let a = i.element === this.pmView.dom, o = a && i.distance === 0;
|
|
1224
|
-
if (!(!a && !r)) return {
|
|
1225
|
-
isDropPoint: a,
|
|
1226
|
-
isDropWithinEditorBounds: o,
|
|
1227
|
-
isDragOrigin: r
|
|
1228
|
-
};
|
|
1229
|
-
};
|
|
1230
|
-
onDrop = (e) => {
|
|
1231
|
-
if (e.synthetic || !(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1232
|
-
let t = this.getDragEventContext(e);
|
|
1233
|
-
if (!t) {
|
|
1234
|
-
this.closeDropCursor();
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
|
|
1238
|
-
if (!r && n && this.dispatchSyntheticEvent(e), n) {
|
|
1239
|
-
if (this.pmView.dragging) return;
|
|
1240
|
-
this.pmView.dispatch(this.pmView.state.tr.setSelection(Te.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
if (i) {
|
|
1244
|
-
setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
onDragEnd = (e) => {
|
|
1249
|
-
e.synthetic || (this.pmView.dragging = null);
|
|
1250
|
-
};
|
|
1251
|
-
onKeyDown = (e) => {
|
|
1252
|
-
this.state?.show && this.editor.isFocused() && (this.state.show = !1, this.emitUpdate(this.state));
|
|
1253
|
-
};
|
|
1254
|
-
onMouseMove = (e) => {
|
|
1255
|
-
if (this.menuFrozen || !Number.isFinite(e.clientX) || !Number.isFinite(e.clientY)) return;
|
|
1256
|
-
this.mousePos = {
|
|
1257
|
-
x: e.clientX,
|
|
1258
|
-
y: e.clientY
|
|
1259
|
-
};
|
|
1260
|
-
let t = this.pmView.dom.getBoundingClientRect();
|
|
1261
|
-
if (this.mousePos.x > t.left && this.mousePos.x < t.right && this.mousePos.y > t.top && this.mousePos.y < t.bottom && e && e.target && !this.editor.isWithinEditor(e.target)) {
|
|
1262
|
-
this.state?.show && (this.state.show = !1, this.emitUpdate(this.state));
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
this.updateStateFromMousePos();
|
|
1266
|
-
};
|
|
1267
|
-
dispatchSyntheticEvent(e) {
|
|
1268
|
-
let t = new Event(e.type, e), n = this.pmView.dom.firstChild.getBoundingClientRect();
|
|
1269
|
-
t.clientX = e.clientX, t.clientY = e.clientY, t.clientX = Math.min(Math.max(e.clientX, n.left), n.left + n.width), t.clientY = Math.min(Math.max(e.clientY, n.top), n.top + n.height), t.dataTransfer = e.dataTransfer, t.preventDefault = () => e.preventDefault(), t.synthetic = !0, this.pmView.dom.dispatchEvent(t);
|
|
1270
|
-
}
|
|
1271
|
-
update(e, t) {
|
|
1272
|
-
!t.doc.eq(this.pmView.state.doc) && this.state?.show && this.updateStateFromMousePos();
|
|
1273
|
-
}
|
|
1274
|
-
destroy() {
|
|
1275
|
-
this.state?.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.removeEventListener("dragstart", this.onDragStart), this.pmView.root.removeEventListener("dragover", this.onDragOver), this.pmView.root.removeEventListener("drop", this.onDrop, !0), this.pmView.root.removeEventListener("dragend", this.onDragEnd, !0), this.pmView.root.removeEventListener("keydown", this.onKeyDown, !0);
|
|
1276
|
-
}
|
|
1277
|
-
}, Kt = new we("SideMenuPlugin"), qt = b(({ editor: e }) => {
|
|
1278
|
-
let t, n = y(void 0);
|
|
1279
|
-
return {
|
|
1280
|
-
key: "sideMenu",
|
|
1281
|
-
store: n,
|
|
1282
|
-
prosemirrorPlugins: [new Ce({
|
|
1283
|
-
key: Kt,
|
|
1284
|
-
view: (r) => (t = new Gt(e, r, (e) => {
|
|
1285
|
-
n.setState({ ...e });
|
|
1286
|
-
}), t)
|
|
1287
|
-
})],
|
|
1288
|
-
blockDragStart(n, r) {
|
|
1289
|
-
t && (t.isDragOrigin = !0), Ht(n, r, e);
|
|
1290
|
-
},
|
|
1291
|
-
blockDragEnd() {
|
|
1292
|
-
Vt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
|
|
1293
|
-
},
|
|
1294
|
-
get menuFrozen() {
|
|
1295
|
-
return t.menuFrozen;
|
|
1296
|
-
},
|
|
1297
|
-
freezeMenu() {
|
|
1298
|
-
t.menuFrozen = !0, t.state.show = !0, t.emitUpdate(t.state);
|
|
1299
|
-
},
|
|
1300
|
-
unfreezeMenu() {
|
|
1301
|
-
t.menuFrozen = !1, t.state.show = !1, t.emitUpdate(t.state);
|
|
1302
|
-
},
|
|
1303
|
-
hideMenuIfNotFrozen() {
|
|
1304
|
-
!t.menuFrozen && t.state?.show && (t.state.show = !1, t.emitUpdate(t.state));
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
}), Jt = b(({ editor: e }) => {
|
|
1308
|
-
let t = y({
|
|
1309
|
-
popupOpen: void 0,
|
|
1310
|
-
selected: void 0
|
|
1311
|
-
}), n = (t) => !!e.schema.blockSpecs[t.type]?.implementation?.meta?.hasPreview, r = (e) => ({ editor: r }) => {
|
|
1312
|
-
let { block: i, prevBlock: a, nextBlock: o } = r.getTextCursorPosition();
|
|
1313
|
-
if (!n(i) || t.state.popupOpen === i.id) return !1;
|
|
1314
|
-
let s = e === "prev" ? a : o;
|
|
1315
|
-
return s ? (r.setTextCursorPosition(s.id, e === "prev" ? "end" : "start"), !0) : !1;
|
|
1316
|
-
};
|
|
1317
|
-
return {
|
|
1318
|
-
key: "sourceBlockWithPreview",
|
|
1319
|
-
store: t,
|
|
1320
|
-
keyboardShortcuts: {
|
|
1321
|
-
Enter: ({ editor: e }) => {
|
|
1322
|
-
let { block: r } = e.getTextCursorPosition();
|
|
1323
|
-
if (!n(r)) return !1;
|
|
1324
|
-
if (t.state.popupOpen === r.id && e.schema.blockSpecs[r.type]?.implementation?.meta?.hardBreakShortcut === "enter") {
|
|
1325
|
-
let t = e.prosemirrorView;
|
|
1326
|
-
return t.dispatch(t.state.tr.insertText("\n")), !0;
|
|
1327
|
-
}
|
|
1328
|
-
return e.setTextCursorPosition(r.id, "end"), t.setState((e) => ({
|
|
1329
|
-
...e,
|
|
1330
|
-
popupOpen: t.state.popupOpen === r.id ? void 0 : r.id
|
|
1331
|
-
})), !0;
|
|
1332
|
-
},
|
|
1333
|
-
Escape: ({ editor: e }) => {
|
|
1334
|
-
let { block: r } = e.getTextCursorPosition();
|
|
1335
|
-
return !n(r) || t.state.popupOpen !== r.id ? !1 : (e.setTextCursorPosition(r.id, "end"), t.setState((e) => ({
|
|
1336
|
-
...e,
|
|
1337
|
-
popupOpen: void 0
|
|
1338
|
-
})), !0);
|
|
1339
|
-
},
|
|
1340
|
-
"Mod-a": ({ editor: e }) => {
|
|
1341
|
-
let { block: r } = e.getTextCursorPosition();
|
|
1342
|
-
if (!n(r) || t.state.popupOpen !== r.id) return !1;
|
|
1343
|
-
let i = e.prosemirrorView, { $from: a } = i.state.selection;
|
|
1344
|
-
return a.parent.type.name === r.type && (i.dispatch(i.state.tr.setSelection(E.create(i.state.doc, a.start(), a.end()))), !0);
|
|
1345
|
-
},
|
|
1346
|
-
ArrowUp: r("prev"),
|
|
1347
|
-
ArrowLeft: r("prev"),
|
|
1348
|
-
ArrowDown: r("next"),
|
|
1349
|
-
ArrowRight: r("next")
|
|
1350
|
-
},
|
|
1351
|
-
mount: ({ dom: r, signal: i }) => {
|
|
1352
|
-
let a = e.onSelectionChange(() => {
|
|
1353
|
-
let { block: r } = e.getTextCursorPosition(), i = n(r) ? r.id : void 0, a = t.state.popupOpen && t.state.popupOpen !== r.id ? void 0 : t.state.popupOpen;
|
|
1354
|
-
(i !== t.state.selected || a !== t.state.popupOpen) && t.setState((e) => ({
|
|
1355
|
-
...e,
|
|
1356
|
-
selected: i,
|
|
1357
|
-
popupOpen: a
|
|
1358
|
-
}));
|
|
1359
|
-
});
|
|
1360
|
-
i.addEventListener("abort", a), r.addEventListener("keydown", (r) => {
|
|
1361
|
-
if (!e.isEditable) return;
|
|
1362
|
-
let { block: i } = e.getTextCursorPosition();
|
|
1363
|
-
if (!(!n(i) || t.state.popupOpen === i.id)) {
|
|
1364
|
-
if (r.key === "Backspace" || r.key === "Delete") {
|
|
1365
|
-
r.preventDefault(), r.stopImmediatePropagation(), e.removeBlocks([i.id]);
|
|
1366
|
-
return;
|
|
1367
|
-
}
|
|
1368
|
-
(r.key.length === 1 && !r.ctrlKey && !r.metaKey || r.key === "Tab") && (r.preventDefault(), r.stopImmediatePropagation());
|
|
1369
|
-
}
|
|
1370
|
-
}, {
|
|
1371
|
-
capture: !0,
|
|
1372
|
-
signal: i
|
|
1373
|
-
}), r.addEventListener("blur", () => t.setState((e) => ({
|
|
1374
|
-
...e,
|
|
1375
|
-
popupOpen: void 0
|
|
1376
|
-
})), {
|
|
1377
|
-
capture: !0,
|
|
1378
|
-
signal: i
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
}), Yt = b(({ editor: e }) => {
|
|
1383
|
-
let t = y({ selected: void 0 }), n = (t) => !!e.schema.inlineContentSpecs[t]?.implementation?.meta?.hasPreview, r = (e) => ({ editor: t }) => {
|
|
1384
|
-
let { $from: r } = t.prosemirrorState.selection, i = r.node();
|
|
1385
|
-
if (!n(i.type.name)) return !1;
|
|
1386
|
-
let a = t.prosemirrorView, o = T.near(a.state.doc.resolve(e === "before" ? r.before() : r.after()), e === "before" ? -1 : 1);
|
|
1387
|
-
return a.dispatch(a.state.tr.setSelection(o)), !0;
|
|
1388
|
-
};
|
|
1389
|
-
return {
|
|
1390
|
-
key: "sourceInlineContentWithPreview",
|
|
1391
|
-
store: t,
|
|
1392
|
-
keyboardShortcuts: {
|
|
1393
|
-
Enter: r("after"),
|
|
1394
|
-
"Shift-Enter": r("after"),
|
|
1395
|
-
Escape: r("after"),
|
|
1396
|
-
ArrowUp: r("before"),
|
|
1397
|
-
ArrowDown: r("after"),
|
|
1398
|
-
"Mod-a": ({ editor: e }) => {
|
|
1399
|
-
let { $from: t } = e.prosemirrorState.selection;
|
|
1400
|
-
if (!n(t.node().type.name)) return !1;
|
|
1401
|
-
let r = e.prosemirrorView;
|
|
1402
|
-
return r.dispatch(r.state.tr.setSelection(E.create(r.state.doc, t.start(), t.end()))), !0;
|
|
1403
|
-
}
|
|
1404
|
-
},
|
|
1405
|
-
mount: ({ dom: r, signal: i }) => {
|
|
1406
|
-
let a = e.onSelectionChange(() => {
|
|
1407
|
-
let { $from: r } = e.prosemirrorState.selection, i = r.node();
|
|
1408
|
-
t.setState({ selected: n(i.type.name) ? r.before() : void 0 });
|
|
1409
|
-
});
|
|
1410
|
-
i.addEventListener("abort", a), r.addEventListener("keydown", (t) => {
|
|
1411
|
-
if (t.key !== "ArrowUp" && t.key !== "ArrowDown") return;
|
|
1412
|
-
let { $from: i } = e.prosemirrorState.selection;
|
|
1413
|
-
n(i.node().type.name) || (r.classList.add("bn-suppress-source-popup-caret"), requestAnimationFrame(() => r.classList.remove("bn-suppress-source-popup-caret")));
|
|
1414
|
-
}, {
|
|
1415
|
-
capture: !0,
|
|
1416
|
-
signal: i
|
|
1417
|
-
}), r.addEventListener("blur", () => t.setState({ selected: void 0 }), {
|
|
1418
|
-
capture: !0,
|
|
1419
|
-
signal: i
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
}), Xt = Symbol.for("blocknote.shikiParser"), W = Symbol.for("blocknote.shikiHighlighterPromise"), Zt = [
|
|
1424
|
-
"text",
|
|
1425
|
-
"none",
|
|
1426
|
-
"plaintext",
|
|
1427
|
-
"txt"
|
|
1428
|
-
];
|
|
1429
|
-
function Qt(e, t, n) {
|
|
1430
|
-
let r = globalThis, i, a, o = /* @__PURE__ */ new Set();
|
|
1431
|
-
return Ae({
|
|
1432
|
-
parser: (t) => {
|
|
1433
|
-
if (!e.createHighlighter) return [];
|
|
1434
|
-
if (!i) return r[W] = r[W] || e.createHighlighter(), r[W].then((e) => {
|
|
1435
|
-
i = e;
|
|
1436
|
-
});
|
|
1437
|
-
let n = t.language;
|
|
1438
|
-
return !n || Zt.includes(n) || o.has(n) ? [] : i.getLoadedLanguages().includes(n) ? (a || (a = r[Xt] || je(i, $t(i)), r[Xt] = a), a(t)) : i.loadLanguage(n).catch(() => {
|
|
1439
|
-
o.add(n);
|
|
1440
|
-
});
|
|
1441
|
-
},
|
|
1442
|
-
languageExtractor: (e) => {
|
|
1443
|
-
let t = {
|
|
1444
|
-
type: e.type.name,
|
|
1445
|
-
props: e.attrs
|
|
1446
|
-
};
|
|
1447
|
-
return (n.blockSpecs[t.type] || n.inlineContentSpecs[t.type])?.implementation?.meta?.highlight?.(t) ?? void 0;
|
|
1448
|
-
},
|
|
1449
|
-
nodeTypes: t
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
function $t(e) {
|
|
1453
|
-
let t = e.getLoadedThemes(), n = t.find((e) => /light/i.test(e)), r = t.find((e) => /dark/i.test(e));
|
|
1454
|
-
if (n && r) return {
|
|
1455
|
-
themes: {
|
|
1456
|
-
light: n,
|
|
1457
|
-
dark: r
|
|
1458
|
-
},
|
|
1459
|
-
defaultColor: !1
|
|
1460
|
-
};
|
|
1461
|
-
}
|
|
1462
|
-
//#endregion
|
|
1463
|
-
//#region src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts
|
|
1464
|
-
function en(e) {
|
|
1465
|
-
let t = Object.values(e.blockSpecs).filter((e) => typeof e?.config == "object" && e.config.content === "plain" && !!e.implementation?.meta?.highlight).map((e) => e.config.type), n = Object.values(e.inlineContentSpecs).filter((e) => typeof e?.config == "object" && e.config.content === "plain" && !!e.implementation?.meta?.highlight).map((e) => e.config.type);
|
|
1466
|
-
return [...t, ...n];
|
|
1467
|
-
}
|
|
1468
|
-
var tn = b(({ editor: e, options: t }) => ({
|
|
1469
|
-
key: "syntaxHighlighting",
|
|
1470
|
-
prosemirrorPlugins: [Qt(t, en(e.schema), e.schema)]
|
|
1471
|
-
})), G;
|
|
1472
|
-
async function nn() {
|
|
1473
|
-
return G || (G = (async () => {
|
|
1474
|
-
let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
|
|
1475
|
-
return await n.init({ data: r }), {
|
|
1476
|
-
emojiMart: n,
|
|
1477
|
-
emojiData: r
|
|
1478
|
-
};
|
|
1479
|
-
})(), G);
|
|
1480
|
-
}
|
|
1481
|
-
async function rn(e, t) {
|
|
1482
|
-
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== te.text) return [];
|
|
1483
|
-
let { emojiData: n, emojiMart: r } = await nn();
|
|
1484
|
-
return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
|
|
1485
|
-
id: t.skins[0].native,
|
|
1486
|
-
onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
|
|
1487
|
-
}));
|
|
1488
|
-
}
|
|
1489
|
-
//#endregion
|
|
1490
|
-
//#region src/extensions/TableHandles/TableHandles.ts
|
|
1491
|
-
var K;
|
|
1492
|
-
function an(e) {
|
|
1493
|
-
K || (K = document.createElement("div"), K.innerHTML = "_", K.style.opacity = "0", K.style.height = "1px", K.style.width = "1px", e instanceof Document ? e.body.appendChild(K) : e.appendChild(K));
|
|
1494
|
-
}
|
|
1495
|
-
function on(e) {
|
|
1496
|
-
K &&= (e instanceof Document ? e.body.removeChild(K) : e.removeChild(K), void 0);
|
|
1497
|
-
}
|
|
1498
|
-
function q(e) {
|
|
1499
|
-
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
1500
|
-
}
|
|
1501
|
-
function sn(e) {
|
|
1502
|
-
let t = e;
|
|
1503
|
-
for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
|
|
1504
|
-
if (t.classList.contains("ProseMirror")) return;
|
|
1505
|
-
let e = t.parentNode;
|
|
1506
|
-
if (!e || !(e instanceof Element)) return;
|
|
1507
|
-
t = e;
|
|
1508
|
-
}
|
|
1509
|
-
return t.nodeName === "TD" || t.nodeName === "TH" ? {
|
|
1510
|
-
type: "cell",
|
|
1511
|
-
domNode: t,
|
|
1512
|
-
tbodyNode: t.closest("tbody")
|
|
1513
|
-
} : {
|
|
1514
|
-
type: "wrapper",
|
|
1515
|
-
domNode: t,
|
|
1516
|
-
tbodyNode: t.querySelector("tbody")
|
|
1517
|
-
};
|
|
1518
|
-
}
|
|
1519
|
-
function cn(e, t) {
|
|
1520
|
-
let n = t.querySelectorAll(e);
|
|
1521
|
-
for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
|
|
1522
|
-
}
|
|
1523
|
-
var ln = class {
|
|
1524
|
-
editor;
|
|
1525
|
-
pmView;
|
|
1526
|
-
state;
|
|
1527
|
-
emitUpdate;
|
|
1528
|
-
tableId;
|
|
1529
|
-
tablePos;
|
|
1530
|
-
tableElement;
|
|
1531
|
-
menuFrozen = !1;
|
|
1532
|
-
mouseState = "up";
|
|
1533
|
-
prevWasEditable = null;
|
|
1534
|
-
constructor(e, t, n) {
|
|
1535
|
-
this.editor = e, this.pmView = t, this.emitUpdate = () => {
|
|
1536
|
-
n(this.state);
|
|
1537
|
-
}, t.dom.addEventListener("mousemove", this.mouseMoveHandler), t.dom.addEventListener("mousedown", this.viewMousedownHandler), window.addEventListener("mouseup", this.mouseUpHandler), t.root.addEventListener("dragover", this.dragOverHandler), t.root.addEventListener("drop", this.dropHandler);
|
|
1538
|
-
}
|
|
1539
|
-
viewMousedownHandler = () => {
|
|
1540
|
-
this.mouseState = "down";
|
|
1541
|
-
};
|
|
1542
|
-
hideHandles = () => {
|
|
1543
|
-
this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1544
|
-
};
|
|
1545
|
-
mouseUpHandler = (e) => {
|
|
1546
|
-
this.mouseState = "up", this.mouseMoveHandler(e);
|
|
1547
|
-
};
|
|
1548
|
-
mouseMoveHandler = (e) => {
|
|
1549
|
-
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
|
|
1550
|
-
let t = sn(e.target);
|
|
1551
|
-
if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
|
|
1552
|
-
this.mouseState = "selecting", this.hideHandles();
|
|
1553
|
-
return;
|
|
1554
|
-
}
|
|
1555
|
-
if (!t || !this.editor.isEditable) {
|
|
1556
|
-
this.hideHandles();
|
|
1557
|
-
return;
|
|
1558
|
-
}
|
|
1559
|
-
if (!t.tbodyNode) return;
|
|
1560
|
-
let n = t.tbodyNode.getBoundingClientRect(), r = ft(t.domNode, this.pmView);
|
|
1561
|
-
if (!r) return;
|
|
1562
|
-
let { pmNodeInfo: i, doc: a } = this.editor.transact((e) => ({
|
|
1563
|
-
pmNodeInfo: s(r.id, e.doc),
|
|
1564
|
-
doc: e.doc
|
|
1565
|
-
}));
|
|
1566
|
-
if (!i) {
|
|
1567
|
-
this.hideHandles();
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1570
|
-
let o = v(i.node, a);
|
|
1571
|
-
if (!g(o, this.editor, "table")) {
|
|
1572
|
-
this.hideHandles();
|
|
1573
|
-
return;
|
|
1574
|
-
}
|
|
1575
|
-
let c = o;
|
|
1576
|
-
this.tablePos = i.posBeforeNode + 1, this.tableElement = r.node, this.tableId = r.id;
|
|
1577
|
-
let l = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
|
|
1578
|
-
if (t?.type === "wrapper") {
|
|
1579
|
-
let t = e.clientY >= n.bottom - 1 && e.clientY < n.bottom + 20, r = e.clientX >= n.right - 1 && e.clientX < n.right + 20, i = this.state?.block?.id !== c.id || e.clientX > n.right || e.clientY > n.bottom;
|
|
1580
|
-
this.state = {
|
|
1581
|
-
...this.state,
|
|
1582
|
-
show: !0,
|
|
1583
|
-
showAddOrRemoveRowsButton: t,
|
|
1584
|
-
showAddOrRemoveColumnsButton: r,
|
|
1585
|
-
referencePosTable: n,
|
|
1586
|
-
block: c,
|
|
1587
|
-
widgetContainer: l,
|
|
1588
|
-
colIndex: i ? void 0 : this.state?.colIndex,
|
|
1589
|
-
rowIndex: i ? void 0 : this.state?.rowIndex,
|
|
1590
|
-
referencePosCell: i ? void 0 : this.state?.referencePosCell
|
|
1591
|
-
};
|
|
1592
|
-
} else {
|
|
1593
|
-
let e = q(t.domNode), i = q(t.domNode.parentElement), a = t.domNode.getBoundingClientRect();
|
|
1594
|
-
if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === i && this.state.colIndex === e) return;
|
|
1595
|
-
this.state = {
|
|
1596
|
-
show: !0,
|
|
1597
|
-
showAddOrRemoveColumnsButton: e === c.content.rows[0].cells.length - 1,
|
|
1598
|
-
showAddOrRemoveRowsButton: i === c.content.rows.length - 1,
|
|
1599
|
-
referencePosTable: n,
|
|
1600
|
-
block: c,
|
|
1601
|
-
draggingState: void 0,
|
|
1602
|
-
referencePosCell: a,
|
|
1603
|
-
colIndex: e,
|
|
1604
|
-
rowIndex: i,
|
|
1605
|
-
widgetContainer: l
|
|
1606
|
-
};
|
|
1607
|
-
}
|
|
1608
|
-
return this.emitUpdate(), !1;
|
|
1609
|
-
};
|
|
1610
|
-
dragOverHandler = (e) => {
|
|
1611
|
-
if (this.state?.draggingState === void 0) return;
|
|
1612
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move", cn(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
|
|
1613
|
-
let t = {
|
|
1614
|
-
left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
|
|
1615
|
-
top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
|
|
1616
|
-
}, n = this.pmView.root.elementsFromPoint(t.left, t.top).filter((e) => e.tagName === "TD" || e.tagName === "TH");
|
|
1617
|
-
if (n.length === 0) return;
|
|
1618
|
-
let r = n[0], i = !1, a = q(r.parentElement), o = q(r), s = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, c = (this.state.draggingState.draggedCellOrientation === "row" ? a : o) !== s;
|
|
1619
|
-
(this.state.rowIndex !== a || this.state.colIndex !== o) && (this.state.rowIndex = a, this.state.colIndex = o, this.state.referencePosCell = r.getBoundingClientRect(), i = !0);
|
|
1620
|
-
let l = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
|
|
1621
|
-
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(J, !0));
|
|
1622
|
-
};
|
|
1623
|
-
dropHandler = (t) => {
|
|
1624
|
-
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
|
|
1625
|
-
if (this.state.rowIndex === void 0 || this.state.colIndex === void 0) throw Error("Attempted to drop table row or column, but no table block was hovered prior.");
|
|
1626
|
-
t.preventDefault();
|
|
1627
|
-
let { draggingState: n, colIndex: r, rowIndex: i } = this.state;
|
|
1628
|
-
this.state.draggingState = void 0;
|
|
1629
|
-
let o = this.state.block.content.columnWidths;
|
|
1630
|
-
if (n.draggedCellOrientation === "row") {
|
|
1631
|
-
if (!f(this.state.block, n.originalIndex, i)) return !1;
|
|
1632
|
-
let e = ee(this.state.block, n.originalIndex, i);
|
|
1633
|
-
this.editor.updateBlock(this.state.block, {
|
|
1634
|
-
type: "table",
|
|
1635
|
-
content: {
|
|
1636
|
-
...this.state.block.content,
|
|
1637
|
-
rows: e
|
|
1638
|
-
}
|
|
1639
|
-
});
|
|
1640
|
-
} else {
|
|
1641
|
-
if (!e(this.state.block, n.originalIndex, r)) return !1;
|
|
1642
|
-
let t = a(this.state.block, n.originalIndex, r), [i] = o.splice(n.originalIndex, 1);
|
|
1643
|
-
o.splice(r, 0, i), this.editor.updateBlock(this.state.block, {
|
|
1644
|
-
type: "table",
|
|
1645
|
-
content: {
|
|
1646
|
-
...this.state.block.content,
|
|
1647
|
-
columnWidths: o,
|
|
1648
|
-
rows: t
|
|
1649
|
-
}
|
|
1650
|
-
});
|
|
1651
|
-
}
|
|
1652
|
-
return this.editor.setTextCursorPosition(this.state.block.id), !0;
|
|
1653
|
-
};
|
|
1654
|
-
getTablePos(e) {
|
|
1655
|
-
if (this.tableId === void 0) return;
|
|
1656
|
-
let t = s(this.tableId, e);
|
|
1657
|
-
return t && t.posBeforeNode + 1;
|
|
1658
|
-
}
|
|
1659
|
-
update() {
|
|
1660
|
-
if (!this.state || !this.state.show) return;
|
|
1661
|
-
let e = this.editor.getBlock(this.state.block.id);
|
|
1662
|
-
if (!e || e.type !== "table" || !this.tableElement?.isConnected) {
|
|
1663
|
-
this.state = void 0, this.tableId = void 0, this.tablePos = void 0, this.tableElement = void 0, this.emitUpdate();
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
this.state.block = e, this.tablePos = this.getTablePos(this.pmView.state.doc);
|
|
1667
|
-
let { height: n, width: r } = t(this.state.block);
|
|
1668
|
-
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= n && (this.state.rowIndex = n - 1), this.state.colIndex >= r && (this.state.colIndex = r - 1));
|
|
1669
|
-
let i = this.tableElement.querySelector("tbody");
|
|
1670
|
-
if (!i) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
|
|
1671
|
-
if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
|
|
1672
|
-
let e = i.children[this.state.rowIndex].children[this.state.colIndex];
|
|
1673
|
-
e ? this.state.referencePosCell = e.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);
|
|
1674
|
-
}
|
|
1675
|
-
this.state.referencePosTable = i.getBoundingClientRect(), this.emitUpdate();
|
|
1676
|
-
}
|
|
1677
|
-
destroy() {
|
|
1678
|
-
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener("dragover", this.dragOverHandler), this.pmView.root.removeEventListener("drop", this.dropHandler);
|
|
1679
|
-
}
|
|
1680
|
-
}, J = new w("TableHandlesPlugin"), un = b(({ editor: t }) => {
|
|
1681
|
-
let n, i = y(void 0);
|
|
1682
|
-
return {
|
|
1683
|
-
key: "tableHandles",
|
|
1684
|
-
store: i,
|
|
1685
|
-
prosemirrorPlugins: [new C({
|
|
1686
|
-
key: J,
|
|
1687
|
-
view: (e) => (n = new ln(t, e, (e) => {
|
|
1688
|
-
i.setState(e?.block ? {
|
|
1689
|
-
...e,
|
|
1690
|
-
draggingState: e.draggingState ? { ...e.draggingState } : void 0
|
|
1691
|
-
} : void 0);
|
|
1692
|
-
}), n),
|
|
1693
|
-
props: { decorations: (t) => {
|
|
1694
|
-
if (n === void 0 || n.state === void 0 || n.state.draggingState === void 0) return;
|
|
1695
|
-
let r = n.getTablePos(t.doc);
|
|
1696
|
-
if (r === void 0) return;
|
|
1697
|
-
let i = n.state.draggingState.draggedCellOrientation === "row" ? n.state.rowIndex : n.state.colIndex;
|
|
1698
|
-
if (i === void 0) return;
|
|
1699
|
-
let a = [], { block: o, draggingState: s } = n.state, { originalIndex: c, draggedCellOrientation: l } = s;
|
|
1700
|
-
if (i === c || !o || l === "row" && !f(o, c, i) || l === "col" && !e(o, c, i)) return O.create(t.doc, a);
|
|
1701
|
-
let u = t.doc.resolve(r + 1);
|
|
1702
|
-
return n.state.draggingState.draggedCellOrientation === "row" ? p(n.state.block, i).forEach(({ row: e, col: n }) => {
|
|
1703
|
-
let r = t.doc.resolve(u.posAtIndex(e) + 1), o = t.doc.resolve(r.posAtIndex(n) + 1), s = o.node(), l = o.pos + (i > c ? s.nodeSize - 2 : 0);
|
|
1704
|
-
a.push(D.widget(l, () => {
|
|
1705
|
-
let e = document.createElement("div");
|
|
1706
|
-
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", i > c ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
|
|
1707
|
-
}));
|
|
1708
|
-
}) : d(n.state.block, i).forEach(({ row: e, col: n }) => {
|
|
1709
|
-
let r = t.doc.resolve(u.posAtIndex(e) + 1), o = t.doc.resolve(r.posAtIndex(n) + 1), s = o.node(), l = o.pos + (i > c ? s.nodeSize - 2 : 0);
|
|
1710
|
-
a.push(D.widget(l, () => {
|
|
1711
|
-
let e = document.createElement("div");
|
|
1712
|
-
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", i > c ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
|
|
1713
|
-
}));
|
|
1714
|
-
}), O.create(t.doc, a);
|
|
1715
|
-
} }
|
|
1716
|
-
})],
|
|
1717
|
-
colDragStart(e) {
|
|
1718
|
-
if (n === void 0 || n.state === void 0 || n.state.colIndex === void 0) throw Error("Attempted to drag table column, but no table block was hovered prior.");
|
|
1719
|
-
n.state.draggingState = {
|
|
1720
|
-
draggedCellOrientation: "col",
|
|
1721
|
-
originalIndex: n.state.colIndex,
|
|
1722
|
-
mousePos: e.clientX
|
|
1723
|
-
}, n.emitUpdate(), t.transact((e) => e.setMeta(J, {
|
|
1724
|
-
draggedCellOrientation: n.state.draggingState.draggedCellOrientation,
|
|
1725
|
-
originalIndex: n.state.colIndex,
|
|
1726
|
-
newIndex: n.state.colIndex,
|
|
1727
|
-
tablePos: n.tablePos
|
|
1728
|
-
})), !t.headless && (an(t.prosemirrorView.root), e.dataTransfer.setDragImage(K, 0, 0), e.dataTransfer.effectAllowed = "move");
|
|
1729
|
-
},
|
|
1730
|
-
rowDragStart(e) {
|
|
1731
|
-
if (n.state === void 0 || n.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1732
|
-
n.state.draggingState = {
|
|
1733
|
-
draggedCellOrientation: "row",
|
|
1734
|
-
originalIndex: n.state.rowIndex,
|
|
1735
|
-
mousePos: e.clientY
|
|
1736
|
-
}, n.emitUpdate(), t.transact((e) => e.setMeta(J, {
|
|
1737
|
-
draggedCellOrientation: n.state.draggingState.draggedCellOrientation,
|
|
1738
|
-
originalIndex: n.state.rowIndex,
|
|
1739
|
-
newIndex: n.state.rowIndex,
|
|
1740
|
-
tablePos: n.tablePos
|
|
1741
|
-
})), !t.headless && (an(t.prosemirrorView.root), e.dataTransfer.setDragImage(K, 0, 0), e.dataTransfer.effectAllowed = "copyMove");
|
|
1742
|
-
},
|
|
1743
|
-
dragEnd() {
|
|
1744
|
-
if (n.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1745
|
-
n.state.draggingState = void 0, n.emitUpdate(), t.transact((e) => e.setMeta(J, null)), !t.headless && on(t.prosemirrorView.root);
|
|
1746
|
-
},
|
|
1747
|
-
freezeHandles() {
|
|
1748
|
-
n.menuFrozen = !0;
|
|
1749
|
-
},
|
|
1750
|
-
unfreezeHandles() {
|
|
1751
|
-
n.menuFrozen = !1;
|
|
1752
|
-
},
|
|
1753
|
-
hideHandlesIfNotFrozen() {
|
|
1754
|
-
n.menuFrozen || n.hideHandles();
|
|
1755
|
-
},
|
|
1756
|
-
getCellsAtRowHandle(e, t) {
|
|
1757
|
-
return p(e, t);
|
|
1758
|
-
},
|
|
1759
|
-
getCellsAtColumnHandle(e, t) {
|
|
1760
|
-
return d(e, t);
|
|
1761
|
-
},
|
|
1762
|
-
setCellSelection(e, t, r = t) {
|
|
1763
|
-
if (!n) throw Error("Table handles view not initialized");
|
|
1764
|
-
let i = n.getTablePos(e.doc);
|
|
1765
|
-
if (i === void 0) throw Error("Attempted to select table cells, but the hovered table is no longer in the document.");
|
|
1766
|
-
let a = e.doc.resolve(i + 1), o = e.doc.resolve(a.posAtIndex(t.row) + 1), s = e.doc.resolve(o.posAtIndex(t.col)), c = e.doc.resolve(a.posAtIndex(r.row) + 1), l = e.doc.resolve(c.posAtIndex(r.col)), u = e.tr;
|
|
1767
|
-
return u.setSelection(new me(s, l)), e.apply(u);
|
|
1768
|
-
},
|
|
1769
|
-
addRowOrColumn(e, n) {
|
|
1770
|
-
t.exec((t, r) => {
|
|
1771
|
-
let i = this.setCellSelection(t, n.orientation === "row" ? {
|
|
1772
|
-
row: e,
|
|
1773
|
-
col: 0
|
|
1774
|
-
} : {
|
|
1775
|
-
row: 0,
|
|
1776
|
-
col: e
|
|
1777
|
-
});
|
|
1778
|
-
return n.orientation === "row" ? n.side === "above" ? ve(i, r) : _e(i, r) : n.side === "left" ? ge(i, r) : he(i, r);
|
|
1779
|
-
});
|
|
1780
|
-
},
|
|
1781
|
-
removeRowOrColumn(e, n) {
|
|
1782
|
-
return n === "row" ? t.exec((t, n) => {
|
|
1783
|
-
let r = this.setCellSelection(t, {
|
|
1784
|
-
row: e,
|
|
1785
|
-
col: 0
|
|
1786
|
-
});
|
|
1787
|
-
return be(r, n);
|
|
1788
|
-
}) : t.exec((t, n) => {
|
|
1789
|
-
let r = this.setCellSelection(t, {
|
|
1790
|
-
row: 0,
|
|
1791
|
-
col: e
|
|
1792
|
-
});
|
|
1793
|
-
return ye(r, n);
|
|
1794
|
-
});
|
|
1795
|
-
},
|
|
1796
|
-
mergeCells(e) {
|
|
1797
|
-
return t.exec((t, n) => {
|
|
1798
|
-
let r = e ? this.setCellSelection(t, e.relativeStartCell, e.relativeEndCell) : t;
|
|
1799
|
-
return xe(r, n);
|
|
1800
|
-
});
|
|
1801
|
-
},
|
|
1802
|
-
splitCell(e) {
|
|
1803
|
-
return t.exec((t, n) => {
|
|
1804
|
-
let r = e ? this.setCellSelection(t, e) : t;
|
|
1805
|
-
return Se(r, n);
|
|
1806
|
-
});
|
|
1807
|
-
},
|
|
1808
|
-
getCellSelection() {
|
|
1809
|
-
return t.transact((e) => {
|
|
1810
|
-
let t = e.selection, n = t.$from, r = t.$to;
|
|
1811
|
-
if (_(t)) {
|
|
1812
|
-
let { ranges: e } = t;
|
|
1813
|
-
e.forEach((e) => {
|
|
1814
|
-
n = e.$from.min(n ?? e.$from), r = e.$to.max(r ?? e.$to);
|
|
1815
|
-
});
|
|
1816
|
-
} else {
|
|
1817
|
-
let i = t.$from.pos - t.$from.parentOffset - 1, a = t.$to.pos - t.$to.parentOffset - 1;
|
|
1818
|
-
if (i < 0 || a < 0 || (n = e.doc.resolve(i), r = e.doc.resolve(a), !m(n.parent) || !m(r.parent))) return;
|
|
1819
|
-
}
|
|
1820
|
-
let i = e.doc.resolve(n.pos - n.parentOffset - 1), a = e.doc.resolve(r.pos - r.parentOffset - 1), o = e.doc.resolve(i.pos - i.parentOffset - 1), s = n.index(i.depth), c = i.index(o.depth), l = r.index(a.depth), u = a.index(o.depth), d = [];
|
|
1821
|
-
for (let e = c; e <= u; e++) for (let t = s; t <= l; t++) d.push({
|
|
1822
|
-
row: e,
|
|
1823
|
-
col: t
|
|
1824
|
-
});
|
|
1825
|
-
return {
|
|
1826
|
-
from: {
|
|
1827
|
-
row: c,
|
|
1828
|
-
col: s
|
|
1829
|
-
},
|
|
1830
|
-
to: {
|
|
1831
|
-
row: u,
|
|
1832
|
-
col: l
|
|
1833
|
-
},
|
|
1834
|
-
cells: d
|
|
1835
|
-
};
|
|
1836
|
-
});
|
|
1837
|
-
},
|
|
1838
|
-
getMergeDirection(e) {
|
|
1839
|
-
return t.transact((t) => {
|
|
1840
|
-
let n = _(t.selection) ? t.selection : void 0;
|
|
1841
|
-
if (!n || !e || n.ranges.length <= 1) return;
|
|
1842
|
-
let r = this.getCellSelection();
|
|
1843
|
-
if (r) return ne(r.from, r.to, e) ? "vertical" : "horizontal";
|
|
1844
|
-
});
|
|
1845
|
-
},
|
|
1846
|
-
cropEmptyRowsOrColumns(e, t) {
|
|
1847
|
-
return r(e, t);
|
|
1848
|
-
},
|
|
1849
|
-
addRowsOrColumns(e, t, n) {
|
|
1850
|
-
return l(e, t, n);
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
|
-
}), Y = new w("trailingNode");
|
|
1854
|
-
function X(e) {
|
|
1855
|
-
let t = e.lastChild, n = t?.firstChild;
|
|
1856
|
-
return t?.type.name !== "blockContainer" || n?.type.name !== "paragraph" || n.content.size !== 0;
|
|
1857
|
-
}
|
|
1858
|
-
function dn(e) {
|
|
1859
|
-
if (!e.type.schema.nodes.column) {
|
|
1860
|
-
let t = e.lastChild;
|
|
1861
|
-
return t && X(t) ? [e.content.size - 1] : [];
|
|
1862
|
-
}
|
|
1863
|
-
let t = [];
|
|
1864
|
-
return e.descendants((e, n, r) => !e.isTextblock && ((e.type.name === "column" || e.type.name === "blockGroup" && r?.type.name === "doc") && X(e) && t.push(n + e.nodeSize - 1), !0)), t;
|
|
1865
|
-
}
|
|
1866
|
-
var fn = b(({ editor: e }) => {
|
|
1867
|
-
function t(t) {
|
|
1868
|
-
return D.widget(t, () => {
|
|
1869
|
-
let t = document.createElement("div");
|
|
1870
|
-
return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (n) => {
|
|
1871
|
-
n.preventDefault();
|
|
1872
|
-
let r = e.prosemirrorView;
|
|
1873
|
-
if (!r) return;
|
|
1874
|
-
let i = r.state.doc.resolve(r.posAtDOM(t, 0)).parent.lastChild?.attrs.id;
|
|
1875
|
-
i && (e.transact((t) => {
|
|
1876
|
-
let [n] = e.insertBlocks([{ type: "paragraph" }], i, "after");
|
|
1877
|
-
e.setTextCursorPosition(n, "start"), t.scrollIntoView();
|
|
1878
|
-
}), r.focus());
|
|
1879
|
-
}), t;
|
|
1880
|
-
}, { side: 1 });
|
|
1881
|
-
}
|
|
1882
|
-
function n(e, n, r) {
|
|
1883
|
-
let i = n.map(e.mapping, e.doc), a = new Set(r ? dn(e.doc) : []), o = /* @__PURE__ */ new Set(), s = [];
|
|
1884
|
-
for (let e of i.find()) a.has(e.from) && !o.has(e.from) ? o.add(e.from) : s.push(e);
|
|
1885
|
-
let c = [...a].filter((e) => !o.has(e)), l = i;
|
|
1886
|
-
return s.length > 0 && (l = l.remove(s)), c.length > 0 && (l = l.add(e.doc, c.map(t))), l;
|
|
1887
|
-
}
|
|
1888
|
-
return {
|
|
1889
|
-
key: "trailingNode",
|
|
1890
|
-
prosemirrorPlugins: [new C({
|
|
1891
|
-
key: Y,
|
|
1892
|
-
state: {
|
|
1893
|
-
init: (t, r) => n(r.tr, O.empty, e.isEditable),
|
|
1894
|
-
apply: (t, r) => !t.docChanged && !t.getMeta(Y) ? r : n(t, r, e.isEditable)
|
|
1895
|
-
},
|
|
1896
|
-
view(e) {
|
|
1897
|
-
let t = e.editable;
|
|
1898
|
-
return { update(e) {
|
|
1899
|
-
e.editable !== t && (t = e.editable, e.dispatch(e.state.tr.setMeta(Y, !0)));
|
|
1900
|
-
} };
|
|
1901
|
-
},
|
|
1902
|
-
props: {
|
|
1903
|
-
decorations: (e) => Y.getState(e),
|
|
1904
|
-
handleKeyDown: (t, n) => {
|
|
1905
|
-
if (n.key !== "ArrowRight" && n.key !== "ArrowDown") return !1;
|
|
1906
|
-
let { selection: r } = t.state;
|
|
1907
|
-
if (!r.empty) return !1;
|
|
1908
|
-
let i = T.atEnd(t.state.doc);
|
|
1909
|
-
if (r.$head.pos !== i.$head.pos) return !1;
|
|
1910
|
-
let a = t.state.doc.lastChild;
|
|
1911
|
-
return !e.isEditable || !a || !X(a) ? !1 : (n.preventDefault(), !0);
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
})]
|
|
1915
|
-
};
|
|
1916
|
-
}), Z = Symbol("bn-current-version");
|
|
1917
|
-
function Q(e) {
|
|
1918
|
-
return [...e].sort((e, t) => t.createdAt - e.createdAt);
|
|
1919
|
-
}
|
|
1920
|
-
function $(e) {
|
|
1921
|
-
let t = typeof e == "object" ? e.id : e;
|
|
1922
|
-
throw Error(`Snapshot not found: ${String(t)}`);
|
|
1923
|
-
}
|
|
1924
|
-
var pn = b(({ options: e, editor: t }) => {
|
|
1925
|
-
let { endpoints: n, preview: r, getCurrentDocument: i, serializeCurrentContent: a, resolveUsers: o } = typeof e == "function" ? e(t) : e, s = typeof n == "function" ? n(t) : n, c = re(o), l = y({
|
|
1926
|
-
snapshots: [],
|
|
1927
|
-
previewedSnapshotId: void 0,
|
|
1928
|
-
compareToSnapshotId: void 0
|
|
1929
|
-
}), u = (e) => {
|
|
1930
|
-
let t = typeof e == "object" ? e.id : e;
|
|
1931
|
-
return l.state.snapshots.find((e) => e.id === t);
|
|
1932
|
-
}, d = async () => {
|
|
1933
|
-
let e = Q(await s.list());
|
|
1934
|
-
return l.setState((t) => ({
|
|
1935
|
-
...t,
|
|
1936
|
-
snapshots: e
|
|
1937
|
-
})), e;
|
|
1938
|
-
}, f = async (e, t) => {
|
|
1939
|
-
let n = u(e);
|
|
1940
|
-
n || $(e);
|
|
1941
|
-
let i = t?.compareTo ? u(t.compareTo) : void 0;
|
|
1942
|
-
l.setState((e) => ({
|
|
1943
|
-
...e,
|
|
1944
|
-
previewedSnapshotId: n.id,
|
|
1945
|
-
compareToSnapshotId: i?.id
|
|
1946
|
-
}));
|
|
1947
|
-
let a, o;
|
|
1948
|
-
i && (a = await s.getContent(i), s.getAttributions && (o = await s.getAttributions(n, i)));
|
|
1949
|
-
let c = await s.getContent(n);
|
|
1950
|
-
r.enterPreview(c, a, o, {
|
|
1951
|
-
snapshot: n,
|
|
1952
|
-
compareTo: i
|
|
1953
|
-
});
|
|
1954
|
-
}, p = async (e) => {
|
|
1955
|
-
if (!a) throw Error("previewCurrentVersion requires `serializeCurrentContent` to be provided to the VersioningExtension options.");
|
|
1956
|
-
let t = e?.compareTo ? u(e.compareTo) : void 0;
|
|
1957
|
-
l.setState((e) => ({
|
|
1958
|
-
...e,
|
|
1959
|
-
previewedSnapshotId: Z,
|
|
1960
|
-
compareToSnapshotId: t?.id
|
|
1961
|
-
}));
|
|
1962
|
-
let n = {
|
|
1963
|
-
id: Z,
|
|
1964
|
-
createdAt: Date.now(),
|
|
1965
|
-
updatedAt: Date.now()
|
|
1966
|
-
}, i, o;
|
|
1967
|
-
t && (i = await s.getContent(t), s.getAttributions && (o = await s.getAttributions(n, t)));
|
|
1968
|
-
let c = await a();
|
|
1969
|
-
r.enterPreview(c, i, o, {
|
|
1970
|
-
snapshot: n,
|
|
1971
|
-
compareTo: t
|
|
1972
|
-
});
|
|
1973
|
-
}, m = () => {
|
|
1974
|
-
l.setState((e) => ({
|
|
1975
|
-
...e,
|
|
1976
|
-
previewedSnapshotId: void 0,
|
|
1977
|
-
compareToSnapshotId: void 0
|
|
1978
|
-
})), r.exitPreview();
|
|
1979
|
-
};
|
|
1980
|
-
return {
|
|
1981
|
-
key: "versioning",
|
|
1982
|
-
store: l,
|
|
1983
|
-
userStore: c,
|
|
1984
|
-
list: async () => await d(),
|
|
1985
|
-
get canCompare() {
|
|
1986
|
-
return r.supportsComparison !== !1;
|
|
1987
|
-
},
|
|
1988
|
-
canCreate: s.create !== void 0,
|
|
1989
|
-
create: s.create ? async (e) => {
|
|
1990
|
-
let t = await s.create(i(), {
|
|
1991
|
-
name: e?.name,
|
|
1992
|
-
restoredFromSnapshot: u(e?.restoredFromSnapshot)
|
|
1993
|
-
});
|
|
1994
|
-
l.setState((e) => ({
|
|
1995
|
-
...e,
|
|
1996
|
-
snapshots: Q([...e.snapshots, t])
|
|
1997
|
-
}));
|
|
1998
|
-
let n = await s.list();
|
|
1999
|
-
return l.setState((e) => ({
|
|
2000
|
-
...e,
|
|
2001
|
-
snapshots: Q(n.some((e) => e.id === t.id) ? n : [...n, t])
|
|
2002
|
-
})), t;
|
|
2003
|
-
} : void 0,
|
|
2004
|
-
canRestore: s.restore !== void 0,
|
|
2005
|
-
restore: s.restore ? async (e) => {
|
|
2006
|
-
m();
|
|
2007
|
-
let t = u(e);
|
|
2008
|
-
t || $(e);
|
|
2009
|
-
let n = await s.restore(i(), t);
|
|
2010
|
-
return r.applyRestore(n), await d(), n;
|
|
2011
|
-
} : void 0,
|
|
2012
|
-
canRename: s.rename !== void 0,
|
|
2013
|
-
rename: s.rename ? async (e, t) => {
|
|
2014
|
-
let n = u(e);
|
|
2015
|
-
n || $(e), await s.rename(n, t), l.setState((n) => ({
|
|
2016
|
-
...n,
|
|
2017
|
-
snapshots: n.snapshots.map((n) => n.id === e ? {
|
|
2018
|
-
...n,
|
|
2019
|
-
name: t,
|
|
2020
|
-
updatedAt: Date.now()
|
|
2021
|
-
} : n)
|
|
2022
|
-
}));
|
|
2023
|
-
} : void 0,
|
|
2024
|
-
canRemove: s.remove !== void 0,
|
|
2025
|
-
remove: s.remove ? async (e) => {
|
|
2026
|
-
let t = u(e);
|
|
2027
|
-
t || $(e), (l.state.previewedSnapshotId === t.id || l.state.compareToSnapshotId === t.id) && m(), await s.remove(t), l.setState((e) => ({
|
|
2028
|
-
...e,
|
|
2029
|
-
snapshots: e.snapshots.filter((e) => e.id !== t.id)
|
|
2030
|
-
})), await d();
|
|
2031
|
-
} : void 0,
|
|
2032
|
-
previewSnapshot: f,
|
|
2033
|
-
canPreviewCurrent: a !== void 0,
|
|
2034
|
-
previewCurrentVersion: a ? p : void 0,
|
|
2035
|
-
exitPreview: m
|
|
2036
|
-
};
|
|
2037
|
-
});
|
|
2038
|
-
//#endregion
|
|
2039
|
-
//#region src/extensions/Versioning/inMemoryVersioning.ts
|
|
2040
|
-
function mn(e) {
|
|
2041
|
-
return e.id === Z ? "Current version" : e.name ?? "Unnamed version";
|
|
2042
|
-
}
|
|
2043
|
-
function hn(e) {
|
|
2044
|
-
let t, n = !1, r = (t) => {
|
|
2045
|
-
e.replaceBlocks(e.document, t);
|
|
2046
|
-
}, i = () => e.getExtension("diffVersioning");
|
|
2047
|
-
return {
|
|
2048
|
-
get supportsComparison() {
|
|
2049
|
-
return i() !== void 0;
|
|
2050
|
-
},
|
|
2051
|
-
enterPreview(a, o, s, c) {
|
|
2052
|
-
t === void 0 && (t = e.document);
|
|
2053
|
-
let l = i();
|
|
2054
|
-
if (o && l) {
|
|
2055
|
-
l.renderDiff(a, o, c && mn(c.snapshot)), n = !0;
|
|
2056
|
-
return;
|
|
2057
|
-
}
|
|
2058
|
-
n = !1, r(a);
|
|
2059
|
-
},
|
|
2060
|
-
exitPreview() {
|
|
2061
|
-
if (t !== void 0) {
|
|
2062
|
-
let e = i();
|
|
2063
|
-
n && e ? e.clearDiff(t) : r(t), t = void 0, n = !1;
|
|
2064
|
-
}
|
|
2065
|
-
},
|
|
2066
|
-
applyRestore(e) {
|
|
2067
|
-
let a = i();
|
|
2068
|
-
n && a ? a.clearDiff(e) : r(e), t = void 0, n = !1;
|
|
2069
|
-
}
|
|
2070
|
-
};
|
|
2071
|
-
}
|
|
2072
|
-
function gn() {
|
|
2073
|
-
let e = [], t = /* @__PURE__ */ new Map(), n = 1, r = 0;
|
|
2074
|
-
function i() {
|
|
2075
|
-
return r = Math.max(Date.now(), r + 1), r;
|
|
2076
|
-
}
|
|
2077
|
-
return {
|
|
2078
|
-
async list() {
|
|
2079
|
-
return Q([...e]);
|
|
2080
|
-
},
|
|
2081
|
-
async create(r, a) {
|
|
2082
|
-
let o = i(), s = String(n++), c = {
|
|
2083
|
-
id: s,
|
|
2084
|
-
name: a?.name,
|
|
2085
|
-
createdAt: o,
|
|
2086
|
-
updatedAt: o
|
|
2087
|
-
};
|
|
2088
|
-
return e.push(c), t.set(s, structuredClone(r)), c;
|
|
2089
|
-
},
|
|
2090
|
-
async restore(r, a) {
|
|
2091
|
-
let o = String(a.id), s = t.get(o);
|
|
2092
|
-
if (!s) throw Error(`Snapshot ${o} not found`);
|
|
2093
|
-
let c = i(), l = String(n++), u = {
|
|
2094
|
-
id: l,
|
|
2095
|
-
name: "Before restore",
|
|
2096
|
-
createdAt: c,
|
|
2097
|
-
updatedAt: c,
|
|
2098
|
-
restoredFromSnapshotId: o
|
|
2099
|
-
};
|
|
2100
|
-
return e.push(u), t.set(l, structuredClone(r)), structuredClone(s);
|
|
2101
|
-
},
|
|
2102
|
-
async getContent(e) {
|
|
2103
|
-
let n = String(e.id), r = t.get(n);
|
|
2104
|
-
if (!r) throw Error(`Snapshot ${n} not found`);
|
|
2105
|
-
return structuredClone(r);
|
|
2106
|
-
},
|
|
2107
|
-
async rename(t, n) {
|
|
2108
|
-
let r = e.find((e) => e.id === t.id);
|
|
2109
|
-
if (!r) throw Error(`Snapshot ${String(t.id)} not found`);
|
|
2110
|
-
r.name = n, r.updatedAt = i();
|
|
2111
|
-
},
|
|
2112
|
-
async remove(n) {
|
|
2113
|
-
let r = e.findIndex((e) => e.id === n.id);
|
|
2114
|
-
if (r === -1) throw Error(`Snapshot ${String(n.id)} not found`);
|
|
2115
|
-
e.splice(r, 1), t.delete(String(n.id));
|
|
2116
|
-
}
|
|
2117
|
-
};
|
|
2118
|
-
}
|
|
2119
|
-
function _n(e) {
|
|
2120
|
-
let t = gn();
|
|
2121
|
-
return {
|
|
2122
|
-
endpoints: {
|
|
2123
|
-
...t,
|
|
2124
|
-
list: async () => [{
|
|
2125
|
-
id: Z,
|
|
2126
|
-
createdAt: Date.now(),
|
|
2127
|
-
updatedAt: Date.now()
|
|
2128
|
-
}, ...await t.list()]
|
|
2129
|
-
},
|
|
2130
|
-
preview: hn(e),
|
|
2131
|
-
getCurrentDocument: () => e.document,
|
|
2132
|
-
serializeCurrentContent: () => e.document
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
//#endregion
|
|
2136
|
-
export { Ze as A, ct as C, nt as D, rt as E, k as F, Xe as M, Ue as N, tt as O, He as P, dt as S, at as T, Gt as _, pn as a, Rt as b, un as c, rn as d, tn as f, qt as g, Jt as h, Z as i, Ye as j, et as k, ln as l, Yt as m, _n as n, Q as o, en as p, gn as r, fn as s, hn as t, J as u, Kt as v, st as w, z as x, B as y };
|
|
2137
|
-
|
|
2138
|
-
//# sourceMappingURL=extensions-D6JcJCwd.js.map
|