phormat 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -0
- package/dist/assets/example-test.svelte +228 -0
- package/dist/debug/JsonDebug.svelte +19 -0
- package/dist/debug/JsonDebug.svelte.d.ts +6 -0
- package/dist/debug/JsonDebugNode.svelte +138 -0
- package/dist/debug/JsonDebugNode.svelte.d.ts +11 -0
- package/dist/demo/documentLifecycle.d.ts +57 -0
- package/dist/demo/documentLifecycle.js +196 -0
- package/dist/demo/index.d.ts +2 -0
- package/dist/demo/index.js +2 -0
- package/dist/editor/BlockEditor.svelte +112 -0
- package/dist/editor/BlockEditor.svelte.d.ts +7 -0
- package/dist/editor/BlockRow.svelte +76 -0
- package/dist/editor/BlockRow.svelte.d.ts +20 -0
- package/dist/editor/Editor.svelte +103 -0
- package/dist/editor/Editor.svelte.d.ts +7 -0
- package/dist/editor/MarkdownEditor.svelte.d.ts +160 -0
- package/dist/editor/MarkdownEditor.svelte.js +1119 -0
- package/dist/editor/NestedRowChrome.svelte +160 -0
- package/dist/editor/NestedRowChrome.svelte.d.ts +20 -0
- package/dist/editor/PhormatEditor.svelte +206 -0
- package/dist/editor/PhormatEditor.svelte.d.ts +26 -0
- package/dist/editor/RawMarkdownPanel.svelte +39 -0
- package/dist/editor/RawMarkdownPanel.svelte.d.ts +6 -0
- package/dist/editor/block-specs/BlockSpecMissing.svelte +12 -0
- package/dist/editor/block-specs/BlockSpecMissing.svelte.d.ts +7 -0
- package/dist/editor/block-specs/blockquote/BlockquoteRenderer.svelte +32 -0
- package/dist/editor/block-specs/blockquote/BlockquoteRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/blockquote/commands.d.ts +2 -0
- package/dist/editor/block-specs/blockquote/commands.js +65 -0
- package/dist/editor/block-specs/blockquote/index.d.ts +6 -0
- package/dist/editor/block-specs/blockquote/index.js +5 -0
- package/dist/editor/block-specs/blockquote/inlineSecondPass.d.ts +6 -0
- package/dist/editor/block-specs/blockquote/inlineSecondPass.js +35 -0
- package/dist/editor/block-specs/blockquote/parse.d.ts +16 -0
- package/dist/editor/block-specs/blockquote/parse.js +188 -0
- package/dist/editor/block-specs/blockquote/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/blockquote/reconcile.js +9 -0
- package/dist/editor/block-specs/blockquote/serialize.d.ts +6 -0
- package/dist/editor/block-specs/blockquote/serialize.js +55 -0
- package/dist/editor/block-specs/blockquote/types.d.ts +20 -0
- package/dist/editor/block-specs/blockquote/types.js +1 -0
- package/dist/editor/block-specs/blockquoteSpec.d.ts +4 -0
- package/dist/editor/block-specs/blockquoteSpec.js +37 -0
- package/dist/editor/block-specs/callout/CalloutRenderer.svelte +38 -0
- package/dist/editor/block-specs/callout/CalloutRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/callout/CalloutTypeIcon.svelte +14 -0
- package/dist/editor/block-specs/callout/CalloutTypeIcon.svelte.d.ts +7 -0
- package/dist/editor/block-specs/callout/commands.d.ts +2 -0
- package/dist/editor/block-specs/callout/commands.js +65 -0
- package/dist/editor/block-specs/callout/icons.d.ts +10 -0
- package/dist/editor/block-specs/callout/icons.js +52 -0
- package/dist/editor/block-specs/callout/index.d.ts +9 -0
- package/dist/editor/block-specs/callout/index.js +7 -0
- package/dist/editor/block-specs/callout/inlineSecondPass.d.ts +6 -0
- package/dist/editor/block-specs/callout/inlineSecondPass.js +9 -0
- package/dist/editor/block-specs/callout/parse.d.ts +9 -0
- package/dist/editor/block-specs/callout/parse.js +83 -0
- package/dist/editor/block-specs/callout/parseBody.d.ts +6 -0
- package/dist/editor/block-specs/callout/parseBody.js +290 -0
- package/dist/editor/block-specs/callout/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/callout/reconcile.js +8 -0
- package/dist/editor/block-specs/callout/serialize.d.ts +5 -0
- package/dist/editor/block-specs/callout/serialize.js +65 -0
- package/dist/editor/block-specs/callout/types.d.ts +7 -0
- package/dist/editor/block-specs/callout/types.js +1 -0
- package/dist/editor/block-specs/calloutSpec.d.ts +2 -0
- package/dist/editor/block-specs/calloutSpec.js +23 -0
- package/dist/editor/block-specs/codeFence/CodeFenceRenderer.svelte +18 -0
- package/dist/editor/block-specs/codeFence/CodeFenceRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/codeFence/commands.d.ts +2 -0
- package/dist/editor/block-specs/codeFence/commands.js +1 -0
- package/dist/editor/block-specs/codeFence/index.d.ts +5 -0
- package/dist/editor/block-specs/codeFence/index.js +4 -0
- package/dist/editor/block-specs/codeFence/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/codeFence/inlineSecondPass.js +5 -0
- package/dist/editor/block-specs/codeFence/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/codeFence/reconcile.js +5 -0
- package/dist/editor/block-specs/codeFence/serialize.d.ts +2 -0
- package/dist/editor/block-specs/codeFence/serialize.js +8 -0
- package/dist/editor/block-specs/codeFence/types.d.ts +6 -0
- package/dist/editor/block-specs/codeFence/types.js +1 -0
- package/dist/editor/block-specs/codeFenceSpec.d.ts +2 -0
- package/dist/editor/block-specs/codeFenceSpec.js +23 -0
- package/dist/editor/block-specs/columns/ColumnsRenderer.svelte +18 -0
- package/dist/editor/block-specs/columns/ColumnsRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/columns/EditableColumns.svelte +16 -0
- package/dist/editor/block-specs/columns/EditableColumns.svelte.d.ts +4 -0
- package/dist/editor/block-specs/columns/commands.d.ts +2 -0
- package/dist/editor/block-specs/columns/commands.js +1 -0
- package/dist/editor/block-specs/columns/index.d.ts +6 -0
- package/dist/editor/block-specs/columns/index.js +5 -0
- package/dist/editor/block-specs/columns/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/columns/inlineSecondPass.js +5 -0
- package/dist/editor/block-specs/columns/parse.d.ts +20 -0
- package/dist/editor/block-specs/columns/parse.js +111 -0
- package/dist/editor/block-specs/columns/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/columns/reconcile.js +6 -0
- package/dist/editor/block-specs/columns/serialize.d.ts +2 -0
- package/dist/editor/block-specs/columns/serialize.js +16 -0
- package/dist/editor/block-specs/columns/types.d.ts +4 -0
- package/dist/editor/block-specs/columns/types.js +1 -0
- package/dist/editor/block-specs/columnsSpec.d.ts +2 -0
- package/dist/editor/block-specs/columnsSpec.js +24 -0
- package/dist/editor/block-specs/heading/HeaderRenderer.svelte +30 -0
- package/dist/editor/block-specs/heading/HeaderRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/heading/commands.d.ts +2 -0
- package/dist/editor/block-specs/heading/commands.js +41 -0
- package/dist/editor/block-specs/heading/edit.d.ts +10 -0
- package/dist/editor/block-specs/heading/edit.js +33 -0
- package/dist/editor/block-specs/heading/index.d.ts +7 -0
- package/dist/editor/block-specs/heading/index.js +6 -0
- package/dist/editor/block-specs/heading/inlineSecondPass.d.ts +4 -0
- package/dist/editor/block-specs/heading/inlineSecondPass.js +20 -0
- package/dist/editor/block-specs/heading/parse.d.ts +5 -0
- package/dist/editor/block-specs/heading/parse.js +18 -0
- package/dist/editor/block-specs/heading/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/heading/reconcile.js +8 -0
- package/dist/editor/block-specs/heading/serialize.d.ts +2 -0
- package/dist/editor/block-specs/heading/serialize.js +9 -0
- package/dist/editor/block-specs/heading/types.d.ts +5 -0
- package/dist/editor/block-specs/heading/types.js +1 -0
- package/dist/editor/block-specs/headingSpec.d.ts +2 -0
- package/dist/editor/block-specs/headingSpec.js +28 -0
- package/dist/editor/block-specs/horizontalRule/HorizontalRuleRenderer.svelte +15 -0
- package/dist/editor/block-specs/horizontalRule/HorizontalRuleRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/horizontalRule/commands.d.ts +2 -0
- package/dist/editor/block-specs/horizontalRule/commands.js +1 -0
- package/dist/editor/block-specs/horizontalRule/index.d.ts +6 -0
- package/dist/editor/block-specs/horizontalRule/index.js +5 -0
- package/dist/editor/block-specs/horizontalRule/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/horizontalRule/inlineSecondPass.js +5 -0
- package/dist/editor/block-specs/horizontalRule/parse.d.ts +2 -0
- package/dist/editor/block-specs/horizontalRule/parse.js +15 -0
- package/dist/editor/block-specs/horizontalRule/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/horizontalRule/reconcile.js +5 -0
- package/dist/editor/block-specs/horizontalRule/serialize.d.ts +2 -0
- package/dist/editor/block-specs/horizontalRule/serialize.js +3 -0
- package/dist/editor/block-specs/horizontalRule/types.d.ts +3 -0
- package/dist/editor/block-specs/horizontalRule/types.js +1 -0
- package/dist/editor/block-specs/horizontalRuleSpec.d.ts +2 -0
- package/dist/editor/block-specs/horizontalRuleSpec.js +24 -0
- package/dist/editor/block-specs/list/ListRenderer.svelte +70 -0
- package/dist/editor/block-specs/list/ListRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/list/commands.d.ts +2 -0
- package/dist/editor/block-specs/list/commands.js +65 -0
- package/dist/editor/block-specs/list/index.d.ts +6 -0
- package/dist/editor/block-specs/list/index.js +5 -0
- package/dist/editor/block-specs/list/inlineSecondPass.d.ts +6 -0
- package/dist/editor/block-specs/list/inlineSecondPass.js +78 -0
- package/dist/editor/block-specs/list/parse.d.ts +11 -0
- package/dist/editor/block-specs/list/parse.js +312 -0
- package/dist/editor/block-specs/list/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/list/reconcile.js +6 -0
- package/dist/editor/block-specs/list/serialize.d.ts +4 -0
- package/dist/editor/block-specs/list/serialize.js +83 -0
- package/dist/editor/block-specs/list/types.d.ts +27 -0
- package/dist/editor/block-specs/list/types.js +1 -0
- package/dist/editor/block-specs/listSpec.d.ts +4 -0
- package/dist/editor/block-specs/listSpec.js +24 -0
- package/dist/editor/block-specs/paragraph/ParagraphRenderer.svelte +22 -0
- package/dist/editor/block-specs/paragraph/ParagraphRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/paragraph/commands.d.ts +2 -0
- package/dist/editor/block-specs/paragraph/commands.js +41 -0
- package/dist/editor/block-specs/paragraph/edit.d.ts +10 -0
- package/dist/editor/block-specs/paragraph/edit.js +69 -0
- package/dist/editor/block-specs/paragraph/index.d.ts +7 -0
- package/dist/editor/block-specs/paragraph/index.js +6 -0
- package/dist/editor/block-specs/paragraph/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/paragraph/inlineSecondPass.js +25 -0
- package/dist/editor/block-specs/paragraph/parse.d.ts +9 -0
- package/dist/editor/block-specs/paragraph/parse.js +76 -0
- package/dist/editor/block-specs/paragraph/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/paragraph/reconcile.js +9 -0
- package/dist/editor/block-specs/paragraph/serialize.d.ts +4 -0
- package/dist/editor/block-specs/paragraph/serialize.js +39 -0
- package/dist/editor/block-specs/paragraph/types.d.ts +10 -0
- package/dist/editor/block-specs/paragraph/types.js +1 -0
- package/dist/editor/block-specs/paragraphSpec.d.ts +2 -0
- package/dist/editor/block-specs/paragraphSpec.js +24 -0
- package/dist/editor/block-specs/registry.d.ts +10 -0
- package/dist/editor/block-specs/registry.js +34 -0
- package/dist/editor/block-specs/table/TableRenderer.svelte +53 -0
- package/dist/editor/block-specs/table/TableRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/table/commands.d.ts +2 -0
- package/dist/editor/block-specs/table/commands.js +1 -0
- package/dist/editor/block-specs/table/edit.d.ts +10 -0
- package/dist/editor/block-specs/table/edit.js +127 -0
- package/dist/editor/block-specs/table/editCommands.d.ts +18 -0
- package/dist/editor/block-specs/table/editCommands.js +87 -0
- package/dist/editor/block-specs/table/index.d.ts +8 -0
- package/dist/editor/block-specs/table/index.js +6 -0
- package/dist/editor/block-specs/table/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/table/inlineSecondPass.js +22 -0
- package/dist/editor/block-specs/table/parse.d.ts +17 -0
- package/dist/editor/block-specs/table/parse.js +181 -0
- package/dist/editor/block-specs/table/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/table/reconcile.js +6 -0
- package/dist/editor/block-specs/table/serialize.d.ts +3 -0
- package/dist/editor/block-specs/table/serialize.js +32 -0
- package/dist/editor/block-specs/table/types.d.ts +11 -0
- package/dist/editor/block-specs/table/types.js +1 -0
- package/dist/editor/block-specs/tableSpec.d.ts +2 -0
- package/dist/editor/block-specs/tableSpec.js +25 -0
- package/dist/editor/block-specs/toc/EditableToc.svelte +16 -0
- package/dist/editor/block-specs/toc/EditableToc.svelte.d.ts +4 -0
- package/dist/editor/block-specs/toc/TocRenderer.svelte +22 -0
- package/dist/editor/block-specs/toc/TocRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/toc/commands.d.ts +2 -0
- package/dist/editor/block-specs/toc/commands.js +1 -0
- package/dist/editor/block-specs/toc/index.d.ts +6 -0
- package/dist/editor/block-specs/toc/index.js +5 -0
- package/dist/editor/block-specs/toc/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/toc/inlineSecondPass.js +5 -0
- package/dist/editor/block-specs/toc/parse.d.ts +10 -0
- package/dist/editor/block-specs/toc/parse.js +43 -0
- package/dist/editor/block-specs/toc/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/toc/reconcile.js +5 -0
- package/dist/editor/block-specs/toc/serialize.d.ts +2 -0
- package/dist/editor/block-specs/toc/serialize.js +6 -0
- package/dist/editor/block-specs/toc/types.d.ts +8 -0
- package/dist/editor/block-specs/toc/types.js +1 -0
- package/dist/editor/block-specs/tocSpec.d.ts +2 -0
- package/dist/editor/block-specs/tocSpec.js +24 -0
- package/dist/editor/block-specs/toggle/ToggleRenderer.svelte +19 -0
- package/dist/editor/block-specs/toggle/ToggleRenderer.svelte.d.ts +21 -0
- package/dist/editor/block-specs/toggle/commands.d.ts +2 -0
- package/dist/editor/block-specs/toggle/commands.js +1 -0
- package/dist/editor/block-specs/toggle/index.d.ts +7 -0
- package/dist/editor/block-specs/toggle/index.js +5 -0
- package/dist/editor/block-specs/toggle/inlineSecondPass.d.ts +3 -0
- package/dist/editor/block-specs/toggle/inlineSecondPass.js +5 -0
- package/dist/editor/block-specs/toggle/parse.d.ts +9 -0
- package/dist/editor/block-specs/toggle/parse.js +78 -0
- package/dist/editor/block-specs/toggle/reconcile.d.ts +2 -0
- package/dist/editor/block-specs/toggle/reconcile.js +6 -0
- package/dist/editor/block-specs/toggle/serialize.d.ts +4 -0
- package/dist/editor/block-specs/toggle/serialize.js +13 -0
- package/dist/editor/block-specs/toggle/types.d.ts +5 -0
- package/dist/editor/block-specs/toggle/types.js +1 -0
- package/dist/editor/block-specs/toggleSpec.d.ts +2 -0
- package/dist/editor/block-specs/toggleSpec.js +24 -0
- package/dist/editor/block-specs/types.d.ts +26 -0
- package/dist/editor/block-specs/types.js +1 -0
- package/dist/editor/blocks/EditableBlockquote.svelte +52 -0
- package/dist/editor/blocks/EditableBlockquote.svelte.d.ts +10 -0
- package/dist/editor/blocks/EditableBlockquoteNodes.svelte +134 -0
- package/dist/editor/blocks/EditableBlockquoteNodes.svelte.d.ts +14 -0
- package/dist/editor/blocks/EditableBlockquoteParagraph.svelte +44 -0
- package/dist/editor/blocks/EditableBlockquoteParagraph.svelte.d.ts +12 -0
- package/dist/editor/blocks/EditableCallout.svelte +182 -0
- package/dist/editor/blocks/EditableCallout.svelte.d.ts +11 -0
- package/dist/editor/blocks/EditableCalloutListItemRow.svelte +169 -0
- package/dist/editor/blocks/EditableCalloutListItemRow.svelte.d.ts +15 -0
- package/dist/editor/blocks/EditableCalloutNodes.svelte +91 -0
- package/dist/editor/blocks/EditableCalloutNodes.svelte.d.ts +13 -0
- package/dist/editor/blocks/EditableCalloutParagraph.svelte +39 -0
- package/dist/editor/blocks/EditableCalloutParagraph.svelte.d.ts +12 -0
- package/dist/editor/blocks/EditableCodeBlock.svelte +43 -0
- package/dist/editor/blocks/EditableCodeBlock.svelte.d.ts +10 -0
- package/dist/editor/blocks/EditableHeading.svelte +161 -0
- package/dist/editor/blocks/EditableHeading.svelte.d.ts +10 -0
- package/dist/editor/blocks/EditableHorizontalRule.svelte +20 -0
- package/dist/editor/blocks/EditableHorizontalRule.svelte.d.ts +10 -0
- package/dist/editor/blocks/EditableInlineSurface.svelte +423 -0
- package/dist/editor/blocks/EditableInlineSurface.svelte.d.ts +26 -0
- package/dist/editor/blocks/EditableList.svelte +77 -0
- package/dist/editor/blocks/EditableList.svelte.d.ts +17 -0
- package/dist/editor/blocks/EditableListItemRow.svelte +231 -0
- package/dist/editor/blocks/EditableListItemRow.svelte.d.ts +19 -0
- package/dist/editor/blocks/EditableParagraph.svelte +208 -0
- package/dist/editor/blocks/EditableParagraph.svelte.d.ts +10 -0
- package/dist/editor/blocks/EditableParagraphNodes.svelte +89 -0
- package/dist/editor/blocks/EditableParagraphNodes.svelte.d.ts +15 -0
- package/dist/editor/blocks/EditableTable.svelte +83 -0
- package/dist/editor/blocks/EditableTable.svelte.d.ts +10 -0
- package/dist/editor/blocks/EditableTableCell.svelte +89 -0
- package/dist/editor/blocks/EditableTableCell.svelte.d.ts +15 -0
- package/dist/editor/blocks/EditableToggle.svelte +94 -0
- package/dist/editor/blocks/EditableToggle.svelte.d.ts +10 -0
- package/dist/editor/commandMenu.d.ts +18 -0
- package/dist/editor/commandMenu.js +83 -0
- package/dist/editor/commandRegistry.d.ts +48 -0
- package/dist/editor/commandRegistry.js +133 -0
- package/dist/editor/context/assetBaseUrl.d.ts +6 -0
- package/dist/editor/context/assetBaseUrl.js +20 -0
- package/dist/editor/dom/editorHistoryKeydown.d.ts +6 -0
- package/dist/editor/dom/editorHistoryKeydown.js +31 -0
- package/dist/editor/dom/plainEnterKeydown.d.ts +12 -0
- package/dist/editor/dom/plainEnterKeydown.js +53 -0
- package/dist/editor/dom/plaintextCaret.d.ts +12 -0
- package/dist/editor/dom/plaintextCaret.js +61 -0
- package/dist/editor/dom/syncDocumentSelectionFocus.d.ts +17 -0
- package/dist/editor/dom/syncDocumentSelectionFocus.js +56 -0
- package/dist/editor/draftPersistence.d.ts +27 -0
- package/dist/editor/draftPersistence.js +83 -0
- package/dist/editor/editorHistoryHandle.d.ts +16 -0
- package/dist/editor/editorHistoryHandle.js +22 -0
- package/dist/editor/inlineChrome/InlineChromeCoordinator.svelte +174 -0
- package/dist/editor/inlineChrome/InlineChromeCoordinator.svelte.d.ts +8 -0
- package/dist/editor/inlineChrome/InlineFormattingToolbar.svelte +181 -0
- package/dist/editor/inlineChrome/InlineFormattingToolbar.svelte.d.ts +3 -0
- package/dist/editor/inlineChrome/inlineChromeActions.d.ts +17 -0
- package/dist/editor/inlineChrome/inlineChromeActions.js +148 -0
- package/dist/editor/inlineChrome/inlineChromeState.svelte.d.ts +23 -0
- package/dist/editor/inlineChrome/inlineChromeState.svelte.js +21 -0
- package/dist/editor/inlineChrome/inlineToolbarIcons.d.ts +14 -0
- package/dist/editor/inlineChrome/inlineToolbarIcons.js +14 -0
- package/dist/editor/inlineChrome/inlineWrapActive.d.ts +3 -0
- package/dist/editor/inlineChrome/inlineWrapActive.js +19 -0
- package/dist/editor/inlineChrome/selectionRect.d.ts +2 -0
- package/dist/editor/inlineChrome/selectionRect.js +23 -0
- package/dist/editor/model/blockEditCommands.d.ts +73 -0
- package/dist/editor/model/blockEditCommands.js +719 -0
- package/dist/editor/model/blockTree.d.ts +39 -0
- package/dist/editor/model/blockTree.js +185 -0
- package/dist/editor/model/blockTreeDrop.d.ts +9 -0
- package/dist/editor/model/blockTreeDrop.js +295 -0
- package/dist/editor/model/blockTreeMutations.d.ts +10 -0
- package/dist/editor/model/blockTreeMutations.js +68 -0
- package/dist/editor/model/calloutEditCommands.d.ts +39 -0
- package/dist/editor/model/calloutEditCommands.js +305 -0
- package/dist/editor/model/documentSelection.d.ts +8 -0
- package/dist/editor/model/documentSelection.js +56 -0
- package/dist/editor/model/documentSelectionFromSource.d.ts +3 -0
- package/dist/editor/model/documentSelectionFromSource.js +45 -0
- package/dist/editor/model/documentToRenderBlocks.d.ts +3 -0
- package/dist/editor/model/documentToRenderBlocks.js +13 -0
- package/dist/editor/model/editorPipeline.bench.d.ts +1 -0
- package/dist/editor/model/editorPipeline.bench.js +27 -0
- package/dist/editor/model/editorTransactions.d.ts +20 -0
- package/dist/editor/model/editorTransactions.js +68 -0
- package/dist/editor/model/emptyParagraph.d.ts +11 -0
- package/dist/editor/model/emptyParagraph.js +25 -0
- package/dist/editor/model/enterCommands.d.ts +16 -0
- package/dist/editor/model/enterCommands.js +288 -0
- package/dist/editor/model/extensionSyntaxWarnings.d.ts +29 -0
- package/dist/editor/model/extensionSyntaxWarnings.js +122 -0
- package/dist/editor/model/findBlockAtSourceOffset.d.ts +3 -0
- package/dist/editor/model/findBlockAtSourceOffset.js +20 -0
- package/dist/editor/model/fixtures/serialization-fidelity/reorder-gaps.svelte +4 -0
- package/dist/editor/model/focusOutcome.d.ts +25 -0
- package/dist/editor/model/focusOutcome.js +1 -0
- package/dist/editor/model/incrementalReparse.d.ts +16 -0
- package/dist/editor/model/incrementalReparse.js +111 -0
- package/dist/editor/model/index.d.ts +22 -0
- package/dist/editor/model/index.js +19 -0
- package/dist/editor/model/inlineDraftCommit.d.ts +17 -0
- package/dist/editor/model/inlineDraftCommit.js +187 -0
- package/dist/editor/model/inlineDraftMerge.d.ts +8 -0
- package/dist/editor/model/inlineDraftMerge.js +81 -0
- package/dist/editor/model/inlineEditCommands.d.ts +28 -0
- package/dist/editor/model/inlineEditCommands.js +581 -0
- package/dist/editor/model/inlinePlain.d.ts +3 -0
- package/dist/editor/model/inlinePlain.js +28 -0
- package/dist/editor/model/inlineSecondPass.d.ts +4 -0
- package/dist/editor/model/inlineSecondPass.js +47 -0
- package/dist/editor/model/line-utils.d.ts +14 -0
- package/dist/editor/model/line-utils.js +38 -0
- package/dist/editor/model/listEditCommands.d.ts +56 -0
- package/dist/editor/model/listEditCommands.js +299 -0
- package/dist/editor/model/nestedContainerTransactions.d.ts +36 -0
- package/dist/editor/model/nestedContainerTransactions.js +336 -0
- package/dist/editor/model/parseMarkdownDocument.d.ts +2 -0
- package/dist/editor/model/parseMarkdownDocument.js +324 -0
- package/dist/editor/model/quoteEditCommands.d.ts +39 -0
- package/dist/editor/model/quoteEditCommands.js +323 -0
- package/dist/editor/model/reconcileBlockIds.d.ts +9 -0
- package/dist/editor/model/reconcileBlockIds.js +297 -0
- package/dist/editor/model/reparseOptions.d.ts +12 -0
- package/dist/editor/model/reparseOptions.js +1 -0
- package/dist/editor/model/resolveEnterPlainSnapshot.d.ts +6 -0
- package/dist/editor/model/resolveEnterPlainSnapshot.js +23 -0
- package/dist/editor/model/richInlines.d.ts +16 -0
- package/dist/editor/model/richInlines.js +494 -0
- package/dist/editor/model/serializeInlineNodes.d.ts +3 -0
- package/dist/editor/model/serializeInlineNodes.js +45 -0
- package/dist/editor/model/serializeMarkdownDocument.d.ts +30 -0
- package/dist/editor/model/serializeMarkdownDocument.js +150 -0
- package/dist/editor/model/structureParseWarnings.d.ts +10 -0
- package/dist/editor/model/structureParseWarnings.js +60 -0
- package/dist/editor/model/syntheticInlineRanges.d.ts +3 -0
- package/dist/editor/model/syntheticInlineRanges.js +36 -0
- package/dist/editor/model/types.d.ts +185 -0
- package/dist/editor/model/types.js +26 -0
- package/dist/editor/plugins/autolinks/AutolinkRenderer.svelte +20 -0
- package/dist/editor/plugins/autolinks/AutolinkRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/autolinks/index.d.ts +2 -0
- package/dist/editor/plugins/autolinks/index.js +4 -0
- package/dist/editor/plugins/autolinks/parse-autolinks.d.ts +2 -0
- package/dist/editor/plugins/autolinks/parse-autolinks.js +68 -0
- package/dist/editor/plugins/autolinks/types.d.ts +6 -0
- package/dist/editor/plugins/autolinks/types.js +1 -0
- package/dist/editor/plugins/emphasis/EmphasisRenderer.svelte +15 -0
- package/dist/editor/plugins/emphasis/EmphasisRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/emphasis/index.d.ts +2 -0
- package/dist/editor/plugins/emphasis/index.js +4 -0
- package/dist/editor/plugins/emphasis/parse-emphasis.d.ts +2 -0
- package/dist/editor/plugins/emphasis/parse-emphasis.js +188 -0
- package/dist/editor/plugins/emphasis/types.d.ts +24 -0
- package/dist/editor/plugins/emphasis/types.js +1 -0
- package/dist/editor/plugins/escaping/EscapingRenderer.svelte +18 -0
- package/dist/editor/plugins/escaping/EscapingRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/escaping/index.d.ts +2 -0
- package/dist/editor/plugins/escaping/index.js +4 -0
- package/dist/editor/plugins/escaping/parse-escaping.d.ts +6 -0
- package/dist/editor/plugins/escaping/parse-escaping.js +26 -0
- package/dist/editor/plugins/escaping/types.d.ts +10 -0
- package/dist/editor/plugins/escaping/types.js +1 -0
- package/dist/editor/plugins/extended-task-list/ExtendedTaskListRenderer.svelte +25 -0
- package/dist/editor/plugins/extended-task-list/ExtendedTaskListRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/extended-task-list/index.d.ts +2 -0
- package/dist/editor/plugins/extended-task-list/index.js +4 -0
- package/dist/editor/plugins/extended-task-list/parse-extended-task-list.d.ts +2 -0
- package/dist/editor/plugins/extended-task-list/parse-extended-task-list.js +35 -0
- package/dist/editor/plugins/extended-task-list/types.d.ts +6 -0
- package/dist/editor/plugins/extended-task-list/types.js +1 -0
- package/dist/editor/plugins/highlight/HighlightRenderer.svelte +16 -0
- package/dist/editor/plugins/highlight/HighlightRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/highlight/index.d.ts +2 -0
- package/dist/editor/plugins/highlight/index.js +4 -0
- package/dist/editor/plugins/highlight/parse-highlights.d.ts +4 -0
- package/dist/editor/plugins/highlight/parse-highlights.js +49 -0
- package/dist/editor/plugins/highlight/types.d.ts +6 -0
- package/dist/editor/plugins/highlight/types.js +1 -0
- package/dist/editor/plugins/index.d.ts +1 -0
- package/dist/editor/plugins/index.js +1 -0
- package/dist/editor/plugins/links-images/LinksImagesRenderer.svelte +53 -0
- package/dist/editor/plugins/links-images/LinksImagesRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/links-images/index.d.ts +2 -0
- package/dist/editor/plugins/links-images/index.js +4 -0
- package/dist/editor/plugins/links-images/parse-image-layout.d.ts +28 -0
- package/dist/editor/plugins/links-images/parse-image-layout.js +147 -0
- package/dist/editor/plugins/links-images/parse-links-images.d.ts +25 -0
- package/dist/editor/plugins/links-images/parse-links-images.js +236 -0
- package/dist/editor/plugins/links-images/resolve-asset-url.d.ts +5 -0
- package/dist/editor/plugins/links-images/resolve-asset-url.js +21 -0
- package/dist/editor/plugins/links-images/types.d.ts +11 -0
- package/dist/editor/plugins/links-images/types.js +1 -0
- package/dist/editor/plugins/mention/MentionRenderer.svelte +18 -0
- package/dist/editor/plugins/mention/MentionRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/mention/index.d.ts +2 -0
- package/dist/editor/plugins/mention/index.js +4 -0
- package/dist/editor/plugins/mention/parse-mentions.d.ts +2 -0
- package/dist/editor/plugins/mention/parse-mentions.js +54 -0
- package/dist/editor/plugins/mention/types.d.ts +14 -0
- package/dist/editor/plugins/mention/types.js +1 -0
- package/dist/editor/plugins/raw-text/RawTextRenderer.svelte +19 -0
- package/dist/editor/plugins/raw-text/RawTextRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/raw-text/index.d.ts +2 -0
- package/dist/editor/plugins/raw-text/index.js +4 -0
- package/dist/editor/plugins/raw-text/types.d.ts +4 -0
- package/dist/editor/plugins/raw-text/types.js +1 -0
- package/dist/editor/plugins/shared/InlineNodes.svelte +113 -0
- package/dist/editor/plugins/shared/InlineNodes.svelte.d.ts +21 -0
- package/dist/editor/plugins/shared/InlineNodesEdit.svelte +78 -0
- package/dist/editor/plugins/shared/InlineNodesEdit.svelte.d.ts +21 -0
- package/dist/editor/plugins/strikethrough/StrikethroughRenderer.svelte +9 -0
- package/dist/editor/plugins/strikethrough/StrikethroughRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/strikethrough/index.d.ts +2 -0
- package/dist/editor/plugins/strikethrough/index.js +4 -0
- package/dist/editor/plugins/strikethrough/parse-strikethrough.d.ts +3 -0
- package/dist/editor/plugins/strikethrough/parse-strikethrough.js +38 -0
- package/dist/editor/plugins/strikethrough/types.d.ts +4 -0
- package/dist/editor/plugins/strikethrough/types.js +1 -0
- package/dist/editor/plugins/synced-block/SyncedBlockRenderer.svelte +16 -0
- package/dist/editor/plugins/synced-block/SyncedBlockRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/synced-block/index.d.ts +2 -0
- package/dist/editor/plugins/synced-block/index.js +4 -0
- package/dist/editor/plugins/synced-block/parse-synced-blocks.d.ts +2 -0
- package/dist/editor/plugins/synced-block/parse-synced-blocks.js +15 -0
- package/dist/editor/plugins/synced-block/types.d.ts +4 -0
- package/dist/editor/plugins/synced-block/types.js +1 -0
- package/dist/editor/plugins/types.d.ts +19 -0
- package/dist/editor/plugins/types.js +1 -0
- package/dist/editor/plugins/wiki-link/WikiLinkRenderer.svelte +15 -0
- package/dist/editor/plugins/wiki-link/WikiLinkRenderer.svelte.d.ts +21 -0
- package/dist/editor/plugins/wiki-link/index.d.ts +2 -0
- package/dist/editor/plugins/wiki-link/index.js +4 -0
- package/dist/editor/plugins/wiki-link/parse-wiki-links.d.ts +2 -0
- package/dist/editor/plugins/wiki-link/parse-wiki-links.js +30 -0
- package/dist/editor/plugins/wiki-link/types.d.ts +8 -0
- package/dist/editor/plugins/wiki-link/types.js +1 -0
- package/dist/editor/taskCheckboxStates.d.ts +5 -0
- package/dist/editor/taskCheckboxStates.js +28 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/styles/index.css +6 -0
- package/package.json +84 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { normalizeBlockSliceReplacement } from './blockEditCommands';
|
|
2
|
+
import { findBlockInDocument, siblingIndexOffset } from './blockTree';
|
|
3
|
+
import { listEnterAtPlain } from './listEditCommands';
|
|
4
|
+
import { findQuoteBlockPath, quoteEnterAtPlain, quoteSiblingIndexOffset } from './quoteEditCommands';
|
|
5
|
+
import { serializeEditorBlock } from './serializeMarkdownDocument';
|
|
6
|
+
import { listRegionStructMutation, quoteStructMutationTransaction, calloutStructMutationTransaction, calloutExitTransaction } from './nestedContainerTransactions';
|
|
7
|
+
import { calloutBlockquoteEnterAtPlain, calloutListItemEnterAtPlain, calloutParagraphEnterAtPlain, calloutSiblingIndexOffset } from './calloutEditCommands';
|
|
8
|
+
import { splitBlockAtPlainOffset, buildEmptyParagraphInsertTransaction } from './blockEditCommands';
|
|
9
|
+
import { resolveEnterPlainSnapshot } from './resolveEnterPlainSnapshot';
|
|
10
|
+
const EMPTY_PARAGRAPH_AFTER = '\n\n \n\n';
|
|
11
|
+
function sliceReplaceTransaction(source, range, nextMarkdown, caret, txId) {
|
|
12
|
+
const text = normalizeBlockSliceReplacement(source, range.start, range.end, nextMarkdown);
|
|
13
|
+
return {
|
|
14
|
+
ok: true,
|
|
15
|
+
transaction: {
|
|
16
|
+
id: txId,
|
|
17
|
+
operations: [{ type: 'replaceSlice', range, text }],
|
|
18
|
+
selection: { anchor: caret, focus: caret }
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function buildQuoteExitTransaction(source, doc, blockIndex, quoteBlockId, rootAfterExit) {
|
|
23
|
+
const block = doc.blocks[blockIndex];
|
|
24
|
+
if (!block || block.type !== 'blockquote')
|
|
25
|
+
return { ok: false, error: 'Expected blockquote.' };
|
|
26
|
+
if (block.sourceRange.start < 0)
|
|
27
|
+
return { ok: false, error: 'Cannot edit synthetic block.' };
|
|
28
|
+
const quoteMd = serializeEditorBlock(rootAfterExit, source);
|
|
29
|
+
const replacement = quoteMd + EMPTY_PARAGRAPH_AFTER;
|
|
30
|
+
const caret = block.sourceRange.start + quoteMd.length + 4;
|
|
31
|
+
return sliceReplaceTransaction(source, { start: block.sourceRange.start, end: block.sourceRange.end }, replacement, caret, `quote-exit:${quoteBlockId}`);
|
|
32
|
+
}
|
|
33
|
+
function enterOutcomeFromTopLevelSplit(block, blockIndex, source, split, txId) {
|
|
34
|
+
if (!split.ok)
|
|
35
|
+
return split;
|
|
36
|
+
const rangeLen = block.sourceRange.end - block.sourceRange.start;
|
|
37
|
+
const replacement = split.source.slice(block.sourceRange.start, block.sourceRange.start + (split.source.length - source.length + rangeLen));
|
|
38
|
+
const built = sliceReplaceTransaction(source, { start: block.sourceRange.start, end: block.sourceRange.end }, replacement, split.selection.anchor, txId);
|
|
39
|
+
if (!built.ok)
|
|
40
|
+
return built;
|
|
41
|
+
return {
|
|
42
|
+
ok: true,
|
|
43
|
+
kind: 'transaction',
|
|
44
|
+
transaction: built.transaction,
|
|
45
|
+
focus: { mode: 'siblingOffset', anchorBlockId: block.id, offset: 1 },
|
|
46
|
+
dirtyTopLevelIndex: blockIndex
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function buildEmptyParagraphSiblingOutcome(source, doc, blockIndex, after, txId) {
|
|
50
|
+
const block = doc.blocks[blockIndex];
|
|
51
|
+
if (!block)
|
|
52
|
+
return { ok: false, error: 'Invalid block index.' };
|
|
53
|
+
const built = buildEmptyParagraphInsertTransaction(source, doc, blockIndex, after, txId);
|
|
54
|
+
if (!built.ok)
|
|
55
|
+
return built;
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
kind: 'transaction',
|
|
59
|
+
transaction: built.transaction,
|
|
60
|
+
focus: after
|
|
61
|
+
? { mode: 'siblingOffset', anchorBlockId: block.id, offset: 1 }
|
|
62
|
+
: { mode: 'blockId', blockId: block.id, plain: { start: 0, end: 0 } },
|
|
63
|
+
dirtyTopLevelIndex: blockIndex
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function buildTopLevelBlockEnter(source, doc, blockIndex, plainOffset, plainText, kind) {
|
|
67
|
+
const block = doc.blocks[blockIndex];
|
|
68
|
+
if (!block)
|
|
69
|
+
return { ok: false, error: 'Invalid block index.' };
|
|
70
|
+
if (block.sourceRange.start < 0) {
|
|
71
|
+
return { ok: false, error: 'Block is not splittable.' };
|
|
72
|
+
}
|
|
73
|
+
const { plain: editPlain, offset: splitAt } = resolveEnterPlainSnapshot(block, plainText, plainOffset, kind);
|
|
74
|
+
if (kind === 'paragraph' && block.type === 'paragraph' && editPlain.trim() === '') {
|
|
75
|
+
return buildEmptyParagraphSiblingOutcome(source, doc, blockIndex, true, `paragraph-empty-enter:${block.id}`);
|
|
76
|
+
}
|
|
77
|
+
if (splitAt === 0) {
|
|
78
|
+
return buildEmptyParagraphSiblingOutcome(source, doc, blockIndex, false, `${kind}-enter-bol:${block.id}`);
|
|
79
|
+
}
|
|
80
|
+
if (splitAt >= editPlain.length) {
|
|
81
|
+
return buildEmptyParagraphSiblingOutcome(source, doc, blockIndex, true, `${kind}-enter-eol:${block.id}`);
|
|
82
|
+
}
|
|
83
|
+
if (kind === 'paragraph' && block.type === 'paragraph') {
|
|
84
|
+
const split = splitBlockAtPlainOffset(source, doc, blockIndex, splitAt, 'paragraph');
|
|
85
|
+
return enterOutcomeFromTopLevelSplit(block, blockIndex, source, split, `paragraph-enter:${block.id}`);
|
|
86
|
+
}
|
|
87
|
+
if (kind === 'heading' && block.type === 'heading') {
|
|
88
|
+
const split = splitBlockAtPlainOffset(source, doc, blockIndex, splitAt, 'heading');
|
|
89
|
+
return enterOutcomeFromTopLevelSplit(block, blockIndex, source, split, `heading-enter:${block.id}`);
|
|
90
|
+
}
|
|
91
|
+
return { ok: false, error: 'Split not supported for this block type.' };
|
|
92
|
+
}
|
|
93
|
+
function buildListItemEnter(source, doc, itemId, plainOffset, plainText) {
|
|
94
|
+
const loc = findBlockInDocument(doc, itemId);
|
|
95
|
+
if (!loc || loc.block.type !== 'listItem') {
|
|
96
|
+
return { ok: false, error: 'List item not found.' };
|
|
97
|
+
}
|
|
98
|
+
const result = listEnterAtPlain(doc.blocks, itemId, plainOffset, plainText, source);
|
|
99
|
+
if (!result)
|
|
100
|
+
return { ok: false, error: 'List enter failed.' };
|
|
101
|
+
if (result.demoteToParagraph) {
|
|
102
|
+
const built = listRegionStructMutation(source, doc, itemId, () => result.blocks, `list-demote:${itemId}`, result.focusBlockId);
|
|
103
|
+
if (!built.ok)
|
|
104
|
+
return built;
|
|
105
|
+
return {
|
|
106
|
+
ok: true,
|
|
107
|
+
kind: 'transaction',
|
|
108
|
+
transaction: built.transaction,
|
|
109
|
+
focus: {
|
|
110
|
+
mode: 'blockId',
|
|
111
|
+
blockId: result.focusBlockId,
|
|
112
|
+
plain: { start: 0, end: 0 }
|
|
113
|
+
},
|
|
114
|
+
dirtyTopLevelIndex: loc.topLevelIndex
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const focusOffset = siblingIndexOffset(result.blocks, itemId, result.focusBlockId);
|
|
118
|
+
const built = listRegionStructMutation(source, doc, itemId, () => result.blocks, `list-enter:${itemId}`, result.focusBlockId);
|
|
119
|
+
if (!built.ok)
|
|
120
|
+
return built;
|
|
121
|
+
return {
|
|
122
|
+
ok: true,
|
|
123
|
+
kind: 'transaction',
|
|
124
|
+
transaction: built.transaction,
|
|
125
|
+
focus: focusOffset !== null
|
|
126
|
+
? { mode: 'siblingOffset', anchorBlockId: itemId, offset: focusOffset }
|
|
127
|
+
: { mode: 'blockId', blockId: result.focusBlockId },
|
|
128
|
+
dirtyTopLevelIndex: loc.topLevelIndex
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function buildBlockquoteEnter(source, doc, blockId, plainOffset, plainText) {
|
|
132
|
+
const loc = findBlockInDocument(doc, blockId);
|
|
133
|
+
if (!loc || loc.block.type !== 'blockquote') {
|
|
134
|
+
return { ok: false, error: 'Blockquote node not found.' };
|
|
135
|
+
}
|
|
136
|
+
const root = doc.blocks[loc.topLevelIndex];
|
|
137
|
+
if (!root || root.type !== 'blockquote') {
|
|
138
|
+
return { ok: false, error: 'Expected top-level blockquote.' };
|
|
139
|
+
}
|
|
140
|
+
const quotePath = findQuoteBlockPath(root, blockId);
|
|
141
|
+
if (quotePath === null)
|
|
142
|
+
return { ok: false, error: 'Blockquote path not found.' };
|
|
143
|
+
const result = quoteEnterAtPlain(root, quotePath, plainOffset, plainText, source);
|
|
144
|
+
if (!result)
|
|
145
|
+
return { ok: false, error: 'Blockquote enter failed.' };
|
|
146
|
+
if (result.exitToParagraph) {
|
|
147
|
+
const built = buildQuoteExitTransaction(source, doc, loc.topLevelIndex, blockId, result.root);
|
|
148
|
+
if (!built.ok)
|
|
149
|
+
return built;
|
|
150
|
+
return {
|
|
151
|
+
ok: true,
|
|
152
|
+
kind: 'transaction',
|
|
153
|
+
transaction: built.transaction,
|
|
154
|
+
focus: { mode: 'sourceOffset', offset: built.transaction.selection.anchor },
|
|
155
|
+
dirtyTopLevelIndex: loc.topLevelIndex
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const focusOffset = quoteSiblingIndexOffset(root, blockId, result.focusBlockId);
|
|
159
|
+
const built = quoteStructMutationTransaction(source, doc, loc.topLevelIndex, blockId, () => result.root, `quote-enter:${blockId}`, result.focusBlockId);
|
|
160
|
+
if (!built.ok)
|
|
161
|
+
return built;
|
|
162
|
+
return {
|
|
163
|
+
ok: true,
|
|
164
|
+
kind: 'transaction',
|
|
165
|
+
transaction: built.transaction,
|
|
166
|
+
focus: focusOffset !== null
|
|
167
|
+
? { mode: 'siblingOffset', anchorBlockId: blockId, offset: focusOffset }
|
|
168
|
+
: { mode: 'blockId', blockId: result.focusBlockId },
|
|
169
|
+
dirtyTopLevelIndex: loc.topLevelIndex
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function buildCalloutExitTransaction(source, doc, blockIndex, rootAfterExit) {
|
|
173
|
+
const built = calloutExitTransaction(source, doc, blockIndex, rootAfterExit);
|
|
174
|
+
if (!built.ok)
|
|
175
|
+
return built;
|
|
176
|
+
return {
|
|
177
|
+
ok: true,
|
|
178
|
+
kind: 'transaction',
|
|
179
|
+
transaction: built.transaction,
|
|
180
|
+
focus: { mode: 'sourceOffset', offset: built.transaction.selection.anchor },
|
|
181
|
+
dirtyTopLevelIndex: blockIndex
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function buildCalloutParagraphEnter(source, doc, blockIndex, blockId, plainOffset, plainText) {
|
|
185
|
+
const root = doc.blocks[blockIndex];
|
|
186
|
+
if (!root || root.type !== 'callout')
|
|
187
|
+
return { ok: false, error: 'Expected callout.' };
|
|
188
|
+
const result = calloutParagraphEnterAtPlain(root, blockId, plainOffset, plainText);
|
|
189
|
+
if (!result)
|
|
190
|
+
return { ok: false, error: 'Callout paragraph enter failed.' };
|
|
191
|
+
if (result.exitToParagraph) {
|
|
192
|
+
return buildCalloutExitTransaction(source, doc, blockIndex, result.root);
|
|
193
|
+
}
|
|
194
|
+
const focusOffset = calloutSiblingIndexOffset(root, blockId, result.focusBlockId);
|
|
195
|
+
const built = calloutStructMutationTransaction(source, doc, blockIndex, blockId, () => result.root, `callout-paragraph-enter:${blockId}`, result.focusBlockId);
|
|
196
|
+
if (!built.ok)
|
|
197
|
+
return built;
|
|
198
|
+
return {
|
|
199
|
+
ok: true,
|
|
200
|
+
kind: 'transaction',
|
|
201
|
+
transaction: built.transaction,
|
|
202
|
+
focus: focusOffset !== null
|
|
203
|
+
? { mode: 'siblingOffset', anchorBlockId: blockId, offset: focusOffset }
|
|
204
|
+
: { mode: 'blockId', blockId: result.focusBlockId },
|
|
205
|
+
dirtyTopLevelIndex: blockIndex
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function buildCalloutListItemEnter(source, doc, blockIndex, itemId, plainOffset, plainText) {
|
|
209
|
+
const root = doc.blocks[blockIndex];
|
|
210
|
+
if (!root || root.type !== 'callout')
|
|
211
|
+
return { ok: false, error: 'Expected callout.' };
|
|
212
|
+
const result = calloutListItemEnterAtPlain(root, itemId, plainOffset, plainText, source);
|
|
213
|
+
if (!result)
|
|
214
|
+
return { ok: false, error: 'Callout list enter failed.' };
|
|
215
|
+
if (result.exitToParagraph) {
|
|
216
|
+
return buildCalloutExitTransaction(source, doc, blockIndex, result.root);
|
|
217
|
+
}
|
|
218
|
+
const focusOffset = calloutSiblingIndexOffset(root, itemId, result.focusBlockId);
|
|
219
|
+
const built = calloutStructMutationTransaction(source, doc, blockIndex, itemId, () => result.root, `callout-list-enter:${itemId}`, result.focusBlockId);
|
|
220
|
+
if (!built.ok)
|
|
221
|
+
return built;
|
|
222
|
+
return {
|
|
223
|
+
ok: true,
|
|
224
|
+
kind: 'transaction',
|
|
225
|
+
transaction: built.transaction,
|
|
226
|
+
focus: focusOffset !== null
|
|
227
|
+
? { mode: 'siblingOffset', anchorBlockId: itemId, offset: focusOffset }
|
|
228
|
+
: { mode: 'blockId', blockId: result.focusBlockId },
|
|
229
|
+
dirtyTopLevelIndex: blockIndex
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function buildCalloutBlockquoteEnter(source, doc, blockIndex, blockId, plainOffset, plainText) {
|
|
233
|
+
const root = doc.blocks[blockIndex];
|
|
234
|
+
if (!root || root.type !== 'callout')
|
|
235
|
+
return { ok: false, error: 'Expected callout.' };
|
|
236
|
+
const result = calloutBlockquoteEnterAtPlain(root, blockId, plainOffset, plainText, source);
|
|
237
|
+
if (!result)
|
|
238
|
+
return { ok: false, error: 'Callout blockquote enter failed.' };
|
|
239
|
+
if (result.exitToParagraph) {
|
|
240
|
+
return buildCalloutExitTransaction(source, doc, blockIndex, result.root);
|
|
241
|
+
}
|
|
242
|
+
const built = calloutStructMutationTransaction(source, doc, blockIndex, blockId, () => result.root, `callout-quote-enter:${blockId}`, result.focusBlockId);
|
|
243
|
+
if (!built.ok)
|
|
244
|
+
return built;
|
|
245
|
+
return {
|
|
246
|
+
ok: true,
|
|
247
|
+
kind: 'transaction',
|
|
248
|
+
transaction: built.transaction,
|
|
249
|
+
focus: { mode: 'blockId', blockId: result.focusBlockId },
|
|
250
|
+
dirtyTopLevelIndex: blockIndex
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function buildCalloutChildEnter(source, doc, loc, blockId, plainOffset, plainText) {
|
|
254
|
+
switch (loc.block.type) {
|
|
255
|
+
case 'paragraph':
|
|
256
|
+
return buildCalloutParagraphEnter(source, doc, loc.topLevelIndex, blockId, plainOffset, plainText);
|
|
257
|
+
case 'listItem':
|
|
258
|
+
return buildCalloutListItemEnter(source, doc, loc.topLevelIndex, blockId, plainOffset, plainText);
|
|
259
|
+
case 'blockquote':
|
|
260
|
+
return buildCalloutBlockquoteEnter(source, doc, loc.topLevelIndex, blockId, plainOffset, plainText);
|
|
261
|
+
default:
|
|
262
|
+
return { ok: false, error: 'Enter not supported for this callout child type.' };
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** Build the outcome for {@link MarkdownEditor.enterAt} from block id and live plain snapshot. */
|
|
266
|
+
export function buildEnterCommand(source, doc, blockId, plainOffset, plainText) {
|
|
267
|
+
const loc = findBlockInDocument(doc, blockId);
|
|
268
|
+
if (!loc)
|
|
269
|
+
return { ok: false, error: 'Block not found.' };
|
|
270
|
+
const topBlock = doc.blocks[loc.topLevelIndex];
|
|
271
|
+
if (topBlock?.type === 'callout' && loc.parent !== null) {
|
|
272
|
+
return buildCalloutChildEnter(source, doc, loc, blockId, plainOffset, plainText);
|
|
273
|
+
}
|
|
274
|
+
switch (loc.block.type) {
|
|
275
|
+
case 'paragraph':
|
|
276
|
+
if (loc.parent !== null)
|
|
277
|
+
return { ok: false, error: 'Nested paragraph enter not supported.' };
|
|
278
|
+
return buildTopLevelBlockEnter(source, doc, loc.topLevelIndex, plainOffset, plainText, 'paragraph');
|
|
279
|
+
case 'heading':
|
|
280
|
+
return buildTopLevelBlockEnter(source, doc, loc.topLevelIndex, plainOffset, plainText, 'heading');
|
|
281
|
+
case 'listItem':
|
|
282
|
+
return buildListItemEnter(source, doc, blockId, plainOffset, plainText);
|
|
283
|
+
case 'blockquote':
|
|
284
|
+
return buildBlockquoteEnter(source, doc, blockId, plainOffset, plainText);
|
|
285
|
+
default:
|
|
286
|
+
return { ok: false, error: 'Enter not supported for this block type.' };
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type LinkRefDefinition } from '../plugins/links-images/parse-links-images';
|
|
2
|
+
/** Lines inside closed fenced code blocks (inclusive). */
|
|
3
|
+
export declare function fenceCoveredLineIndices(openClosePairs: {
|
|
4
|
+
openLine: number;
|
|
5
|
+
closeLine: number;
|
|
6
|
+
}[]): Set<number>;
|
|
7
|
+
/** `[label][ref]` where the reference cannot be resolved (non-blocking). */
|
|
8
|
+
export declare function collectUnresolvedReferenceLinkWarnings(source: string, codeFenceRanges?: {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
}[]): string[];
|
|
12
|
+
/** `` where the format suffix does not match grammar (non-blocking). */
|
|
13
|
+
export declare function collectMalformedImageSuffixWarnings(source: string, codeFenceRanges?: {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
}[]): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Non-blocking notices for extension syntax that is not modeled in the editor tree,
|
|
19
|
+
* plus unresolved reference links. Narrowed automatically for features handled by
|
|
20
|
+
* `parseMarkdownDocument` (tables, callouts, toggles, columns, `::toc`, task lists).
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectExtensionSyntaxWarnings(source: string, fencePairs: {
|
|
23
|
+
openLine: number;
|
|
24
|
+
closeLine: number;
|
|
25
|
+
}[], fenceCharRanges?: {
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
}[]): string[];
|
|
29
|
+
export type { LinkRefDefinition };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { collectDefinitionsAndExcluded, normalizeLinkLabel, parseBracketedContent, parseLinksImages } from '../plugins/links-images/parse-links-images';
|
|
2
|
+
import { afterBracketLabelContent, parseImageLabelLayout } from '../plugins/links-images/parse-image-layout';
|
|
3
|
+
import { splitLinesWithOffsets } from './line-utils';
|
|
4
|
+
/** Lines inside closed fenced code blocks (inclusive). */
|
|
5
|
+
export function fenceCoveredLineIndices(openClosePairs) {
|
|
6
|
+
const set = new Set();
|
|
7
|
+
for (const p of openClosePairs) {
|
|
8
|
+
for (let ln = p.openLine; ln <= p.closeLine; ln++)
|
|
9
|
+
set.add(ln);
|
|
10
|
+
}
|
|
11
|
+
return set;
|
|
12
|
+
}
|
|
13
|
+
function lineInsideFence(line, fenceLines) {
|
|
14
|
+
return fenceLines.has(line);
|
|
15
|
+
}
|
|
16
|
+
/** `[label][ref]` where the reference cannot be resolved (non-blocking). */
|
|
17
|
+
export function collectUnresolvedReferenceLinkWarnings(source, codeFenceRanges = []) {
|
|
18
|
+
const { defs, excluded } = collectDefinitionsAndExcluded(source);
|
|
19
|
+
const warns = [];
|
|
20
|
+
function skipOffset(i) {
|
|
21
|
+
if (excluded.some((r) => i >= r.start && i < r.end))
|
|
22
|
+
return true;
|
|
23
|
+
return codeFenceRanges.some((r) => i >= r.start && i < r.end);
|
|
24
|
+
}
|
|
25
|
+
let i = 0;
|
|
26
|
+
while (i < source.length) {
|
|
27
|
+
if (skipOffset(i)) {
|
|
28
|
+
i++;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (source[i] !== '[') {
|
|
32
|
+
i++;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const labelParsed = parseBracketedContent(source, i + 1);
|
|
36
|
+
if (!labelParsed) {
|
|
37
|
+
i++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const after = labelParsed.end;
|
|
41
|
+
let k = after;
|
|
42
|
+
while (k < source.length &&
|
|
43
|
+
(source[k] === ' ' || source[k] === '\t' || source[k] === '\n' || source[k] === '\r')) {
|
|
44
|
+
k++;
|
|
45
|
+
}
|
|
46
|
+
if (source[k] !== '[') {
|
|
47
|
+
i++;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const refParsed = parseBracketedContent(source, k + 1);
|
|
51
|
+
if (!refParsed) {
|
|
52
|
+
i++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const refKeyRaw = refParsed.content.trim();
|
|
56
|
+
const refKey = refKeyRaw
|
|
57
|
+
? normalizeLinkLabel(refKeyRaw)
|
|
58
|
+
: normalizeLinkLabel(labelParsed.content);
|
|
59
|
+
const def = defs.get(refKey);
|
|
60
|
+
if (!def) {
|
|
61
|
+
const line = source.slice(0, i).split('\n').length;
|
|
62
|
+
warns.push(`Unresolved reference link at line ${line}: [${labelParsed.content}][${refKeyRaw || ''}]`);
|
|
63
|
+
}
|
|
64
|
+
i = refParsed.end;
|
|
65
|
+
}
|
|
66
|
+
return warns;
|
|
67
|
+
}
|
|
68
|
+
function isInlineParenImage(source, start, _labelLength, end) {
|
|
69
|
+
void _labelLength;
|
|
70
|
+
const labelStart = start + 2;
|
|
71
|
+
const afterLabel = afterBracketLabelContent(source, labelStart);
|
|
72
|
+
if (afterLabel === null)
|
|
73
|
+
return false;
|
|
74
|
+
let k = afterLabel;
|
|
75
|
+
while (k < end && (source[k] === ' ' || source[k] === '\t' || source[k] === '\n' || source[k] === '\r')) {
|
|
76
|
+
k++;
|
|
77
|
+
}
|
|
78
|
+
return k < end && source[k] === '(';
|
|
79
|
+
}
|
|
80
|
+
/** `` where the format suffix does not match grammar (non-blocking). */
|
|
81
|
+
export function collectMalformedImageSuffixWarnings(source, codeFenceRanges = []) {
|
|
82
|
+
const warns = [];
|
|
83
|
+
function inFence(i) {
|
|
84
|
+
return codeFenceRanges.some((r) => i >= r.start && i < r.end);
|
|
85
|
+
}
|
|
86
|
+
for (const block of parseLinksImages(source)) {
|
|
87
|
+
if (block.kind !== 'image')
|
|
88
|
+
continue;
|
|
89
|
+
if (inFence(block.start))
|
|
90
|
+
continue;
|
|
91
|
+
if (!isInlineParenImage(source, block.start, block.label.length, block.end))
|
|
92
|
+
continue;
|
|
93
|
+
const layout = parseImageLabelLayout(block.label);
|
|
94
|
+
if (!layout.malformedSuffix)
|
|
95
|
+
continue;
|
|
96
|
+
const line = source.slice(0, block.start).split('\n').length;
|
|
97
|
+
warns.push(`Malformed image format suffix at line ${line}: `);
|
|
98
|
+
}
|
|
99
|
+
return warns;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Non-blocking notices for extension syntax that is not modeled in the editor tree,
|
|
103
|
+
* plus unresolved reference links. Narrowed automatically for features handled by
|
|
104
|
+
* `parseMarkdownDocument` (tables, callouts, toggles, columns, `::toc`, task lists).
|
|
105
|
+
*/
|
|
106
|
+
export function collectExtensionSyntaxWarnings(source, fencePairs, fenceCharRanges = []) {
|
|
107
|
+
const warns = [];
|
|
108
|
+
const fenceLines = fenceCoveredLineIndices(fencePairs);
|
|
109
|
+
const rows = splitLinesWithOffsets(source);
|
|
110
|
+
const syncedLineRe = /\{\{\s*block:/;
|
|
111
|
+
for (let li = 0; li < rows.length; li++) {
|
|
112
|
+
if (lineInsideFence(li, fenceLines))
|
|
113
|
+
continue;
|
|
114
|
+
const line = rows[li].line;
|
|
115
|
+
if (syncedLineRe.test(line)) {
|
|
116
|
+
warns.push(`Line ${li + 1}: synced block syntax (\`{{block:…}}\`) is recognized but not yet editable as a structured block.`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
warns.push(...collectUnresolvedReferenceLinkWarnings(source, fenceCharRanges));
|
|
120
|
+
warns.push(...collectMalformedImageSuffixWarnings(source, fenceCharRanges));
|
|
121
|
+
return warns;
|
|
122
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Deepest block whose source range contains `offset` (prefers later start on ties). */
|
|
2
|
+
export function findEditorBlockIdAtSourceOffset(blocks, offset) {
|
|
3
|
+
let bestId = null;
|
|
4
|
+
let bestStart = -1;
|
|
5
|
+
function walk(list) {
|
|
6
|
+
for (const block of list) {
|
|
7
|
+
if (block.sourceRange.synthetic || block.sourceRange.start < 0)
|
|
8
|
+
continue;
|
|
9
|
+
const { start, end } = block.sourceRange;
|
|
10
|
+
if (offset >= start && offset <= end && start >= bestStart) {
|
|
11
|
+
bestStart = start;
|
|
12
|
+
bestId = block.id;
|
|
13
|
+
}
|
|
14
|
+
if (block.children?.length)
|
|
15
|
+
walk(block.children);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
walk(blocks);
|
|
19
|
+
return bestId;
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Post-command caret target resolved by `MarkdownEditor.setFocusOutcome`. */
|
|
2
|
+
export type FocusOutcome = {
|
|
3
|
+
mode: 'blockId';
|
|
4
|
+
blockId: string;
|
|
5
|
+
plain?: {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
};
|
|
9
|
+
tableCell?: import('./types.js').TableCellAddress;
|
|
10
|
+
} | {
|
|
11
|
+
mode: 'siblingOffset';
|
|
12
|
+
anchorBlockId: string;
|
|
13
|
+
offset: number;
|
|
14
|
+
plain?: {
|
|
15
|
+
start: number;
|
|
16
|
+
end: number;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
mode: 'sourceOffset';
|
|
20
|
+
offset: number;
|
|
21
|
+
plain?: {
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { InlineDraftCommitBlockType } from './reparseOptions';
|
|
2
|
+
import type { EditorDocument } from './types';
|
|
3
|
+
export type IncrementalReparseResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
document: EditorDocument;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
reason: string;
|
|
9
|
+
};
|
|
10
|
+
/** True when `[rangeStart, rangeEnd)` intersects a link-reference definition line. */
|
|
11
|
+
export declare function editRangeTouchesLinkDefinitions(source: string, rangeStart: number, rangeEnd: number): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Incremental structural reparse for a single top-level block slice (phase 1).
|
|
14
|
+
* Falls back when validation fails — caller should run full `#reparse`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function tryIncrementalReparse(source: string, fileName: string | null, prevDoc: EditorDocument, blockIndex: number, expectedType: InlineDraftCommitBlockType): IncrementalReparseResult;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { collectDefinitionsAndExcluded } from '../plugins/links-images/parse-links-images';
|
|
2
|
+
import { applyInlineSecondPassToBlockIndices } from './inlineSecondPass';
|
|
3
|
+
import { parseMarkdownDocument } from './parseMarkdownDocument';
|
|
4
|
+
import { reconcileBlockIds } from './reconcileBlockIds';
|
|
5
|
+
function offsetToLine(source, offset) {
|
|
6
|
+
let line = 0;
|
|
7
|
+
const upto = Math.min(Math.max(0, offset), source.length);
|
|
8
|
+
for (let k = 0; k < upto; k++) {
|
|
9
|
+
if (source[k] === '\n')
|
|
10
|
+
line++;
|
|
11
|
+
}
|
|
12
|
+
return line;
|
|
13
|
+
}
|
|
14
|
+
function sourceRangeAtOffsets(source, start, end) {
|
|
15
|
+
const safeEnd = Math.max(start, end);
|
|
16
|
+
return {
|
|
17
|
+
start,
|
|
18
|
+
end: safeEnd,
|
|
19
|
+
startLine: offsetToLine(source, start),
|
|
20
|
+
endLine: offsetToLine(source, safeEnd > start ? safeEnd - 1 : start)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function shiftSourceRange(range, delta, source) {
|
|
24
|
+
if (range.synthetic || range.start < 0)
|
|
25
|
+
return range;
|
|
26
|
+
return sourceRangeAtOffsets(source, range.start + delta, range.end + delta);
|
|
27
|
+
}
|
|
28
|
+
function offsetParsedBlock(block, sliceOffset, fullSource) {
|
|
29
|
+
const sr = block.sourceRange;
|
|
30
|
+
const start = sr.start + sliceOffset;
|
|
31
|
+
const end = sr.end + sliceOffset;
|
|
32
|
+
return {
|
|
33
|
+
...block,
|
|
34
|
+
sourceRange: sourceRangeAtOffsets(fullSource, start, end)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** True when `[rangeStart, rangeEnd)` intersects a link-reference definition line. */
|
|
38
|
+
export function editRangeTouchesLinkDefinitions(source, rangeStart, rangeEnd) {
|
|
39
|
+
const { excluded } = collectDefinitionsAndExcluded(source);
|
|
40
|
+
return excluded.some((r) => r.start < rangeEnd && r.end > rangeStart);
|
|
41
|
+
}
|
|
42
|
+
function validateNextBlockFingerprint(prevSource, source, nextBlock, delta) {
|
|
43
|
+
if (nextBlock.sourceRange.synthetic || nextBlock.sourceRange.start < 0)
|
|
44
|
+
return true;
|
|
45
|
+
const oldStart = nextBlock.sourceRange.start;
|
|
46
|
+
const oldEnd = nextBlock.sourceRange.end;
|
|
47
|
+
const before = prevSource.slice(oldStart, oldEnd);
|
|
48
|
+
const after = source.slice(oldStart + delta, oldEnd + delta);
|
|
49
|
+
return before === after;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Incremental structural reparse for a single top-level block slice (phase 1).
|
|
53
|
+
* Falls back when validation fails — caller should run full `#reparse`.
|
|
54
|
+
*/
|
|
55
|
+
export function tryIncrementalReparse(source, fileName, prevDoc, blockIndex, expectedType) {
|
|
56
|
+
const prevBlocks = prevDoc.blocks;
|
|
57
|
+
const prevBlock = prevBlocks[blockIndex];
|
|
58
|
+
if (!prevBlock)
|
|
59
|
+
return { ok: false, reason: 'Invalid block index.' };
|
|
60
|
+
if (prevBlock.type !== expectedType) {
|
|
61
|
+
return { ok: false, reason: 'Block type mismatch.' };
|
|
62
|
+
}
|
|
63
|
+
if (prevBlock.sourceRange.synthetic || prevBlock.sourceRange.start < 0) {
|
|
64
|
+
return { ok: false, reason: 'Block is not incrementally reparseable.' };
|
|
65
|
+
}
|
|
66
|
+
const prevSource = prevDoc.source;
|
|
67
|
+
const oldStart = prevBlock.sourceRange.start;
|
|
68
|
+
const oldEnd = prevBlock.sourceRange.end;
|
|
69
|
+
const delta = source.length - prevSource.length;
|
|
70
|
+
const newEnd = oldEnd + delta;
|
|
71
|
+
if (editRangeTouchesLinkDefinitions(prevSource, oldStart, newEnd)) {
|
|
72
|
+
return { ok: false, reason: 'Edit touches link-reference definitions.' };
|
|
73
|
+
}
|
|
74
|
+
if (editRangeTouchesLinkDefinitions(source, oldStart, newEnd)) {
|
|
75
|
+
return { ok: false, reason: 'Edit touches link-reference definitions.' };
|
|
76
|
+
}
|
|
77
|
+
const slice = source.slice(oldStart, newEnd);
|
|
78
|
+
const sliceDoc = parseMarkdownDocument(slice, fileName);
|
|
79
|
+
const parsedBlocks = sliceDoc.blocks.filter((b) => !b.sourceRange.synthetic && b.sourceRange.start >= 0);
|
|
80
|
+
if (parsedBlocks.length !== 1 || parsedBlocks[0].type !== expectedType) {
|
|
81
|
+
return { ok: false, reason: 'Slice did not parse to a single expected block.' };
|
|
82
|
+
}
|
|
83
|
+
let parsedBlock = offsetParsedBlock(parsedBlocks[0], oldStart, source);
|
|
84
|
+
const [reconciled] = reconcileBlockIds([prevBlock], [parsedBlock]);
|
|
85
|
+
parsedBlock = reconciled ?? parsedBlock;
|
|
86
|
+
const outBlocks = [];
|
|
87
|
+
for (let i = 0; i < prevBlocks.length; i++) {
|
|
88
|
+
if (i === blockIndex) {
|
|
89
|
+
outBlocks.push(parsedBlock);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const prev = prevBlocks[i];
|
|
93
|
+
if (i < blockIndex) {
|
|
94
|
+
outBlocks.push(prev);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
outBlocks.push({
|
|
98
|
+
...prev,
|
|
99
|
+
sourceRange: shiftSourceRange(prev.sourceRange, delta, source)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (blockIndex + 1 < prevBlocks.length) {
|
|
103
|
+
const nextPrev = prevBlocks[blockIndex + 1];
|
|
104
|
+
if (!validateNextBlockFingerprint(prevSource, source, nextPrev, delta)) {
|
|
105
|
+
return { ok: false, reason: 'Next block source fingerprint mismatch.' };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
let document = { source, fileName, blocks: outBlocks };
|
|
109
|
+
document = applyInlineSecondPassToBlockIndices(document, [blockIndex]);
|
|
110
|
+
return { ok: true, document };
|
|
111
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { BlockPath, DocumentSelection, EditorBlock, EditorBlockType, EditorDocument, EditorHistorySnapshot, EditorOperation, EditorSelection, EditorTransaction, InlineCodeNode, InlineEmphasisNode, InlineNode, InlineStrongNode, InlineTextNode, PlainTextRange, SourceRange, SourceSliceRange } from './types';
|
|
2
|
+
export { clampSelection, normalizeSelectionRange, stableBlockId, syntheticRange } from './types';
|
|
3
|
+
export { applyEditorTransaction, deleteBlockTransaction, duplicateBlockTransaction, type TransactionBuildResult } from './editorTransactions';
|
|
4
|
+
export { applyBlockTreeDrop, blockTreeDropTransaction, canBlockTreeDrop, tabReparentBlockTransaction, type TreeDropPlacement } from './blockTreeDrop';
|
|
5
|
+
export { blockCanMoveSibling, blockTreeDepth, canNestUnder } from './blockTree';
|
|
6
|
+
export { applyListItemInlineWrapTransaction, applyQuoteParagraphInlineWrapTransaction, deleteListItemTransaction, deleteQuoteParagraphTransaction, duplicateListItemTransaction, duplicateQuoteParagraphTransaction, listItemTreeDropTransaction, listRegionStructMutation, moveListItemSiblingTransaction, moveQuoteParagraphSiblingTransaction, calloutBodyTreeDropTransaction, calloutDocumentStructMutation, deleteCalloutChildTransaction, duplicateCalloutChildTransaction, moveCalloutChildSiblingTransaction, quoteParagraphReorderTransaction, quoteStructMutationTransaction, siblingFocusIdForCalloutDelete, siblingFocusIdForListDelete, siblingFocusIdForQuoteDelete } from './nestedContainerTransactions';
|
|
7
|
+
export { findEditorBlockById, tryRemapDocumentSelectionBlockId } from './documentSelection';
|
|
8
|
+
export { documentSelectionFromSourceOffset } from './documentSelectionFromSource';
|
|
9
|
+
export type { FocusOutcome } from './focusOutcome';
|
|
10
|
+
export { findEditorBlockIdAtSourceOffset } from './findBlockAtSourceOffset';
|
|
11
|
+
export { blockIdentityFingerprint, reconcileBlockIds } from './reconcileBlockIds';
|
|
12
|
+
export { parseMarkdownDocument } from './parseMarkdownDocument';
|
|
13
|
+
export { EMPTY_PARAGRAPH_MARKER, EMPTY_PARAGRAPH_INSERTION, normalizeEmptySource, isDisplayEmptyParagraph, isSoleEmptyParagraphDocument, emptyParagraphBlockData } from './emptyParagraph';
|
|
14
|
+
export { applyInlineSecondPass, applyInlineSecondPassToBlockIndices } from './inlineSecondPass';
|
|
15
|
+
export { tryIncrementalReparse, editRangeTouchesLinkDefinitions, type IncrementalReparseResult } from './incrementalReparse';
|
|
16
|
+
export { mergeDraftInlineWithParser, draftInlineMergeFingerprint } from './inlineDraftMerge';
|
|
17
|
+
export { FULL_REPARSE, type ReparseOptions, type ReparseKind, type InlineDraftCommitBlockType } from './reparseOptions';
|
|
18
|
+
export { serializeEditorBlock, serializeMarkdownDocument, serializeMarkdownDocumentPreserving, serializeParagraphData } from './serializeMarkdownDocument';
|
|
19
|
+
export { serializeInlineNodes } from './serializeInlineNodes';
|
|
20
|
+
export type { InlineWrapKind } from './inlineEditCommands';
|
|
21
|
+
export { applyParagraphShortcut, applyStructuralMarkdownShortcut, isStructuralMarkdownShortcutLine, isStructuralMarkdownShortcutTrigger, markerOnlyListShortcutMarkdown, buildStructuralShortcutFocusOutcome, convertHeadingLevel, convertHeadingToParagraph, convertParagraphToHeading, deleteBlock, duplicateBlock, EDITOR_HISTORY_LIMIT, headingBodySourceRange, headingMarkdown, headingPlainOffsetToSourceOffset, buildEmptyParagraphInsertTransaction, insertEmptyParagraphRelative, mergeWithPreviousBlock, moveBlockDown, moveBlockToIndex, moveBlockUp, applyInlineWrap, paragraphBlockFromPlainText, paragraphBlockToPlainText, paragraphDisplayPlain, headingDisplayPlain, paragraphPlainOffsetToSourceOffset, replaceBlockMarkdownSlice, replaceSourceRange, splitBlockAtPlainOffset, swapAdjacentBlocks, updateBlockPlainText, type SourceEditResult, type SplitBlockAtPlainOffsetResult } from './blockEditCommands';
|
|
22
|
+
export { documentBlocksToRenderBlocks } from './documentToRenderBlocks';
|