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,19 @@
|
|
|
1
|
+
export { clampSelection, normalizeSelectionRange, stableBlockId, syntheticRange } from './types';
|
|
2
|
+
export { applyEditorTransaction, deleteBlockTransaction, duplicateBlockTransaction } from './editorTransactions';
|
|
3
|
+
export { applyBlockTreeDrop, blockTreeDropTransaction, canBlockTreeDrop, tabReparentBlockTransaction } from './blockTreeDrop';
|
|
4
|
+
export { blockCanMoveSibling, blockTreeDepth, canNestUnder } from './blockTree';
|
|
5
|
+
export { applyListItemInlineWrapTransaction, applyQuoteParagraphInlineWrapTransaction, deleteListItemTransaction, deleteQuoteParagraphTransaction, duplicateListItemTransaction, duplicateQuoteParagraphTransaction, listItemTreeDropTransaction, listRegionStructMutation, moveListItemSiblingTransaction, moveQuoteParagraphSiblingTransaction, calloutBodyTreeDropTransaction, calloutDocumentStructMutation, deleteCalloutChildTransaction, duplicateCalloutChildTransaction, moveCalloutChildSiblingTransaction, quoteParagraphReorderTransaction, quoteStructMutationTransaction, siblingFocusIdForCalloutDelete, siblingFocusIdForListDelete, siblingFocusIdForQuoteDelete } from './nestedContainerTransactions';
|
|
6
|
+
export { findEditorBlockById, tryRemapDocumentSelectionBlockId } from './documentSelection';
|
|
7
|
+
export { documentSelectionFromSourceOffset } from './documentSelectionFromSource';
|
|
8
|
+
export { findEditorBlockIdAtSourceOffset } from './findBlockAtSourceOffset';
|
|
9
|
+
export { blockIdentityFingerprint, reconcileBlockIds } from './reconcileBlockIds';
|
|
10
|
+
export { parseMarkdownDocument } from './parseMarkdownDocument';
|
|
11
|
+
export { EMPTY_PARAGRAPH_MARKER, EMPTY_PARAGRAPH_INSERTION, normalizeEmptySource, isDisplayEmptyParagraph, isSoleEmptyParagraphDocument, emptyParagraphBlockData } from './emptyParagraph';
|
|
12
|
+
export { applyInlineSecondPass, applyInlineSecondPassToBlockIndices } from './inlineSecondPass';
|
|
13
|
+
export { tryIncrementalReparse, editRangeTouchesLinkDefinitions } from './incrementalReparse';
|
|
14
|
+
export { mergeDraftInlineWithParser, draftInlineMergeFingerprint } from './inlineDraftMerge';
|
|
15
|
+
export { FULL_REPARSE } from './reparseOptions';
|
|
16
|
+
export { serializeEditorBlock, serializeMarkdownDocument, serializeMarkdownDocumentPreserving, serializeParagraphData } from './serializeMarkdownDocument';
|
|
17
|
+
export { serializeInlineNodes } from './serializeInlineNodes';
|
|
18
|
+
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 } from './blockEditCommands';
|
|
19
|
+
export { documentBlocksToRenderBlocks } from './documentToRenderBlocks';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SourceEditResult } from './blockEditCommands';
|
|
2
|
+
import type { CalloutBlock } from '../block-specs/callout/types';
|
|
3
|
+
import type { EditorBlock, EditorDocument, InlineNode } from './types';
|
|
4
|
+
/** Persist paragraph draft inlines to Markdown source. */
|
|
5
|
+
export declare function commitParagraphInlineDraft(source: string, doc: EditorDocument, blockIndex: number, inlines: InlineNode[], plainCaret: number): SourceEditResult;
|
|
6
|
+
/** Persist heading draft inlines to Markdown source. */
|
|
7
|
+
export declare function commitHeadingInlineDraft(source: string, doc: EditorDocument, blockIndex: number, inlines: InlineNode[], plainCaret: number): SourceEditResult;
|
|
8
|
+
/** Persist blockquote first-line body draft inlines on a nested quote node. */
|
|
9
|
+
export declare function commitBlockquoteBodyInlineDraft(source: string, topBlock: EditorBlock, quoteBlockId: string, inlines: InlineNode[]): SourceEditResult;
|
|
10
|
+
/** Persist nested paragraph draft inlines inside a blockquote subtree. */
|
|
11
|
+
export declare function commitBlockquoteParagraphInlineDraft(source: string, topBlock: EditorBlock, paragraphId: string, inlines: InlineNode[]): SourceEditResult;
|
|
12
|
+
/** Update callout opener metadata (`type`, `title`) on the root or a nested callout node. */
|
|
13
|
+
export declare function commitCalloutOpenerDraft(source: string, topBlock: EditorBlock, calloutId: string, data: CalloutBlock): SourceEditResult;
|
|
14
|
+
/** Persist nested paragraph draft inlines inside a callout body. */
|
|
15
|
+
export declare function commitCalloutParagraphInlineDraft(source: string, topBlock: EditorBlock, paragraphId: string, inlines: InlineNode[]): SourceEditResult;
|
|
16
|
+
/** Persist list item body draft inlines inside a callout body. */
|
|
17
|
+
export declare function commitCalloutListItemInlineDraft(source: string, topBlock: EditorBlock, itemId: string, inlines: InlineNode[]): SourceEditResult;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { headingMarkdown, headingPlainOffsetToSourceOffset } from '../block-specs/heading/edit';
|
|
2
|
+
import { paragraphBlockFromPlainText, paragraphPlainOffsetToSourceOffset } from '../block-specs/paragraph/edit';
|
|
3
|
+
import { replaceBlockSourceRange } from './blockEditCommands';
|
|
4
|
+
import { deepCloneBlock } from './blockTree';
|
|
5
|
+
import { cloneInlineNodeDeep } from './inlineEditCommands';
|
|
6
|
+
import { inlineNodesToPlainText } from './inlinePlain';
|
|
7
|
+
import { findQuoteBlockPath, nodeAtQuotePath } from './quoteEditCommands';
|
|
8
|
+
import { serializeEditorBlock } from './serializeMarkdownDocument';
|
|
9
|
+
import { serializeInlineNodes } from './serializeInlineNodes';
|
|
10
|
+
import { clampSelection } from './types';
|
|
11
|
+
function paragraphCommitResult(source, block, inlines, plainCaret) {
|
|
12
|
+
const p = block.data;
|
|
13
|
+
const replacement = serializeInlineNodes(inlines);
|
|
14
|
+
const newPlain = inlineNodesToPlainText(inlines);
|
|
15
|
+
const newSource = replaceBlockSourceRange(source, block.sourceRange.start, block.sourceRange.end, replacement);
|
|
16
|
+
const tmpBlock = {
|
|
17
|
+
type: 'paragraph',
|
|
18
|
+
id: 'tmp',
|
|
19
|
+
sourceRange: { start: 0, end: replacement.length, startLine: 0, endLine: 0 },
|
|
20
|
+
data: paragraphBlockFromPlainText(newPlain, p.startLineIndex),
|
|
21
|
+
inlines: inlines.map(cloneInlineNodeDeep)
|
|
22
|
+
};
|
|
23
|
+
const inner = paragraphPlainOffsetToSourceOffset(tmpBlock, plainCaret);
|
|
24
|
+
const anchor = block.sourceRange.start + inner;
|
|
25
|
+
return {
|
|
26
|
+
ok: true,
|
|
27
|
+
source: newSource,
|
|
28
|
+
selection: clampSelection({ anchor, focus: anchor }, newSource.length)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function headingCommitResult(source, block, inlines, plainCaret) {
|
|
32
|
+
const hb = block.data;
|
|
33
|
+
const bodyMd = serializeInlineNodes(inlines);
|
|
34
|
+
const replacement = headingMarkdown(hb.level, bodyMd);
|
|
35
|
+
const newPlain = inlineNodesToPlainText(inlines);
|
|
36
|
+
const newSource = replaceBlockSourceRange(source, block.sourceRange.start, block.sourceRange.end, replacement);
|
|
37
|
+
const tmpHeadingBlock = {
|
|
38
|
+
type: 'heading',
|
|
39
|
+
id: 'tmp',
|
|
40
|
+
sourceRange: { start: 0, end: replacement.length, startLine: 0, endLine: 0 },
|
|
41
|
+
data: { ...hb, text: newPlain },
|
|
42
|
+
inlines: inlines.map(cloneInlineNodeDeep)
|
|
43
|
+
};
|
|
44
|
+
const inner = headingPlainOffsetToSourceOffset(tmpHeadingBlock, replacement, Math.min(plainCaret, newPlain.length));
|
|
45
|
+
const anchor = block.sourceRange.start + inner;
|
|
46
|
+
return {
|
|
47
|
+
ok: true,
|
|
48
|
+
source: newSource,
|
|
49
|
+
selection: clampSelection({ anchor, focus: anchor }, newSource.length)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Persist paragraph draft inlines to Markdown source. */
|
|
53
|
+
export function commitParagraphInlineDraft(source, doc, blockIndex, inlines, plainCaret) {
|
|
54
|
+
const block = doc.blocks[blockIndex];
|
|
55
|
+
if (!block || block.type !== 'paragraph')
|
|
56
|
+
return { ok: false, error: 'Invalid paragraph block.' };
|
|
57
|
+
if (block.sourceRange.synthetic || block.sourceRange.start < 0) {
|
|
58
|
+
return { ok: false, error: 'Block is not editable.' };
|
|
59
|
+
}
|
|
60
|
+
return paragraphCommitResult(source, block, inlines, plainCaret);
|
|
61
|
+
}
|
|
62
|
+
/** Persist heading draft inlines to Markdown source. */
|
|
63
|
+
export function commitHeadingInlineDraft(source, doc, blockIndex, inlines, plainCaret) {
|
|
64
|
+
const block = doc.blocks[blockIndex];
|
|
65
|
+
if (!block || block.type !== 'heading')
|
|
66
|
+
return { ok: false, error: 'Invalid heading block.' };
|
|
67
|
+
if (block.sourceRange.synthetic || block.sourceRange.start < 0) {
|
|
68
|
+
return { ok: false, error: 'Block is not editable.' };
|
|
69
|
+
}
|
|
70
|
+
return headingCommitResult(source, block, inlines, plainCaret);
|
|
71
|
+
}
|
|
72
|
+
/** Persist blockquote first-line body draft inlines on a nested quote node. */
|
|
73
|
+
export function commitBlockquoteBodyInlineDraft(source, topBlock, quoteBlockId, inlines) {
|
|
74
|
+
if (topBlock.type !== 'blockquote')
|
|
75
|
+
return { ok: false, error: 'Invalid blockquote.' };
|
|
76
|
+
const draftRoot = deepCloneBlock(topBlock);
|
|
77
|
+
const path = findQuoteBlockPath(draftRoot, quoteBlockId);
|
|
78
|
+
if (path === null)
|
|
79
|
+
return { ok: false, error: 'Blockquote node not found.' };
|
|
80
|
+
const node = nodeAtQuotePath(draftRoot, path);
|
|
81
|
+
if (!node || node.type !== 'blockquote')
|
|
82
|
+
return { ok: false, error: 'Invalid blockquote node.' };
|
|
83
|
+
node.inlines = inlines.map(cloneInlineNodeDeep);
|
|
84
|
+
const replacement = serializeEditorBlock(draftRoot, source);
|
|
85
|
+
const newSource = replaceBlockSourceRange(source, topBlock.sourceRange.start, topBlock.sourceRange.end, replacement);
|
|
86
|
+
return {
|
|
87
|
+
ok: true,
|
|
88
|
+
source: newSource,
|
|
89
|
+
selection: clampSelection({ anchor: topBlock.sourceRange.start, focus: topBlock.sourceRange.start }, newSource.length)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Persist nested paragraph draft inlines inside a blockquote subtree. */
|
|
93
|
+
export function commitBlockquoteParagraphInlineDraft(source, topBlock, paragraphId, inlines) {
|
|
94
|
+
if (topBlock.type !== 'blockquote')
|
|
95
|
+
return { ok: false, error: 'Invalid blockquote.' };
|
|
96
|
+
const draftRoot = deepCloneBlock(topBlock);
|
|
97
|
+
function walk(node) {
|
|
98
|
+
if (node.id === paragraphId && node.type === 'paragraph') {
|
|
99
|
+
node.inlines = inlines.map(cloneInlineNodeDeep);
|
|
100
|
+
const newPlain = inlineNodesToPlainText(inlines);
|
|
101
|
+
node.data = paragraphBlockFromPlainText(newPlain, node.data.startLineIndex);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
for (const ch of node.children ?? []) {
|
|
105
|
+
if (walk(ch))
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (!walk(draftRoot))
|
|
111
|
+
return { ok: false, error: 'Blockquote paragraph not found.' };
|
|
112
|
+
const replacement = serializeEditorBlock(draftRoot, source);
|
|
113
|
+
const newSource = replaceBlockSourceRange(source, topBlock.sourceRange.start, topBlock.sourceRange.end, replacement);
|
|
114
|
+
return {
|
|
115
|
+
ok: true,
|
|
116
|
+
source: newSource,
|
|
117
|
+
selection: clampSelection({ anchor: topBlock.sourceRange.start, focus: topBlock.sourceRange.start }, newSource.length)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function commitCalloutSubtree(source, topBlock, mutate) {
|
|
121
|
+
if (topBlock.type !== 'callout')
|
|
122
|
+
return { ok: false, error: 'Invalid callout.' };
|
|
123
|
+
const draftRoot = deepCloneBlock(topBlock);
|
|
124
|
+
if (!mutate(draftRoot))
|
|
125
|
+
return { ok: false, error: 'Callout node not found.' };
|
|
126
|
+
const replacement = serializeEditorBlock(draftRoot, source);
|
|
127
|
+
const newSource = replaceBlockSourceRange(source, topBlock.sourceRange.start, topBlock.sourceRange.end, replacement);
|
|
128
|
+
return {
|
|
129
|
+
ok: true,
|
|
130
|
+
source: newSource,
|
|
131
|
+
selection: clampSelection({ anchor: topBlock.sourceRange.start, focus: topBlock.sourceRange.start }, newSource.length)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** Update callout opener metadata (`type`, `title`) on the root or a nested callout node. */
|
|
135
|
+
export function commitCalloutOpenerDraft(source, topBlock, calloutId, data) {
|
|
136
|
+
return commitCalloutSubtree(source, topBlock, (draft) => {
|
|
137
|
+
function walk(node) {
|
|
138
|
+
if (node.id === calloutId && node.type === 'callout') {
|
|
139
|
+
const prev = node.data;
|
|
140
|
+
node.data = { ...data, lineIndex: prev.lineIndex };
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
for (const ch of node.children ?? []) {
|
|
144
|
+
if (walk(ch))
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return walk(draft);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/** Persist nested paragraph draft inlines inside a callout body. */
|
|
153
|
+
export function commitCalloutParagraphInlineDraft(source, topBlock, paragraphId, inlines) {
|
|
154
|
+
return commitCalloutSubtree(source, topBlock, (draft) => {
|
|
155
|
+
function walk(node) {
|
|
156
|
+
if (node.id === paragraphId && node.type === 'paragraph') {
|
|
157
|
+
node.inlines = inlines.map(cloneInlineNodeDeep);
|
|
158
|
+
const newPlain = inlineNodesToPlainText(inlines);
|
|
159
|
+
node.data = paragraphBlockFromPlainText(newPlain, node.data.startLineIndex);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
for (const ch of node.children ?? []) {
|
|
163
|
+
if (walk(ch))
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
return walk(draft);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/** Persist list item body draft inlines inside a callout body. */
|
|
172
|
+
export function commitCalloutListItemInlineDraft(source, topBlock, itemId, inlines) {
|
|
173
|
+
return commitCalloutSubtree(source, topBlock, (draft) => {
|
|
174
|
+
function walk(node) {
|
|
175
|
+
if (node.id === itemId && node.type === 'listItem') {
|
|
176
|
+
node.inlines = inlines.map(cloneInlineNodeDeep);
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
for (const ch of node.children ?? []) {
|
|
180
|
+
if (walk(ch))
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
return walk(draft);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InlineNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* **Draft inline merge** — controlled wrap marks and atoms stay authoritative;
|
|
4
|
+
* parser fills plain-text gaps in the session draft.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mergeDraftInlineWithParser(draft: InlineNode[]): InlineNode[];
|
|
7
|
+
/** Stable fingerprint for merge scheduling — ignores volatile `sourceRange` fields. */
|
|
8
|
+
export declare function draftInlineMergeFingerprint(inlines: InlineNode[]): string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { buildRichInlinesForRange, createRichInlineContext } from './richInlines';
|
|
2
|
+
import { cloneInlineNodeDeep } from './inlineEditCommands';
|
|
3
|
+
function parsePlainGap(gapPlain) {
|
|
4
|
+
if (!gapPlain)
|
|
5
|
+
return [];
|
|
6
|
+
const ctx = createRichInlineContext(gapPlain);
|
|
7
|
+
return buildRichInlinesForRange(gapPlain, 0, gapPlain.length, ctx);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* **Draft inline merge** — controlled wrap marks and atoms stay authoritative;
|
|
11
|
+
* parser fills plain-text gaps in the session draft.
|
|
12
|
+
*/
|
|
13
|
+
export function mergeDraftInlineWithParser(draft) {
|
|
14
|
+
const out = [];
|
|
15
|
+
let gapPlain = '';
|
|
16
|
+
const flushGap = () => {
|
|
17
|
+
if (!gapPlain)
|
|
18
|
+
return;
|
|
19
|
+
out.push(...parsePlainGap(gapPlain));
|
|
20
|
+
gapPlain = '';
|
|
21
|
+
};
|
|
22
|
+
for (const node of draft) {
|
|
23
|
+
if (node.type === 'text') {
|
|
24
|
+
gapPlain += node.text;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
flushGap();
|
|
28
|
+
out.push(cloneInlineNodeDeep(node));
|
|
29
|
+
}
|
|
30
|
+
flushGap();
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/** Stable fingerprint for merge scheduling — ignores volatile `sourceRange` fields. */
|
|
34
|
+
export function draftInlineMergeFingerprint(inlines) {
|
|
35
|
+
const parts = [];
|
|
36
|
+
const walk = (nodes) => {
|
|
37
|
+
for (const n of nodes) {
|
|
38
|
+
if (n.type === 'text') {
|
|
39
|
+
parts.push(`t:${n.text}`);
|
|
40
|
+
}
|
|
41
|
+
else if (n.type === 'code') {
|
|
42
|
+
parts.push(`c:${n.text}`);
|
|
43
|
+
}
|
|
44
|
+
else if (n.type === 'link') {
|
|
45
|
+
parts.push(`l:${n.href}:${walkPlain(n.children)}`);
|
|
46
|
+
}
|
|
47
|
+
else if (n.type === 'image') {
|
|
48
|
+
parts.push(`i:${n.href ?? ''}`);
|
|
49
|
+
}
|
|
50
|
+
else if (n.type === 'autolink') {
|
|
51
|
+
parts.push(`a:${n.href}`);
|
|
52
|
+
}
|
|
53
|
+
else if (n.type === 'wikiLink') {
|
|
54
|
+
parts.push(`w:${n.target}:${n.label}`);
|
|
55
|
+
}
|
|
56
|
+
else if (n.type === 'mention') {
|
|
57
|
+
parts.push(`m:${n.kind}:${n.name}`);
|
|
58
|
+
}
|
|
59
|
+
else if (n.type === 'strong' || n.type === 'emphasis' || n.type === 'strikethrough') {
|
|
60
|
+
parts.push(`${n.type}:${walkPlain(n.children)}`);
|
|
61
|
+
}
|
|
62
|
+
else if (n.type === 'highlight') {
|
|
63
|
+
parts.push(`highlight:${n.color ?? ''}:${walkPlain(n.children)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const walkPlain = (nodes) => {
|
|
68
|
+
let s = '';
|
|
69
|
+
for (const n of nodes) {
|
|
70
|
+
if (n.type === 'text')
|
|
71
|
+
s += n.text;
|
|
72
|
+
else if ('children' in n && n.children)
|
|
73
|
+
s += walkPlain(n.children);
|
|
74
|
+
else if (n.type === 'code')
|
|
75
|
+
s += n.text;
|
|
76
|
+
}
|
|
77
|
+
return s;
|
|
78
|
+
};
|
|
79
|
+
walk(inlines);
|
|
80
|
+
return parts.join('|');
|
|
81
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { InlineNode, SourceRange } from './types';
|
|
2
|
+
export declare function syntheticInlineSourceRange(): SourceRange;
|
|
3
|
+
export declare function inlineTextNode(text: string): InlineNode;
|
|
4
|
+
export type InlineWrapKind = 'strong' | 'emphasis' | 'code' | 'strikethrough' | 'highlight' | 'link';
|
|
5
|
+
export declare function nodePlainLength(n: InlineNode): number;
|
|
6
|
+
export declare function inlineRangeFullyCoveredByKind(nodes: InlineNode[], start: number, end: number, kind: InlineWrapKind): boolean;
|
|
7
|
+
export declare function cloneInlineNodeDeep(n: InlineNode): InlineNode;
|
|
8
|
+
/** Split `nodes` into plain-offset prefix / suffix at `offset` (0-based into concatenated plain text). */
|
|
9
|
+
export declare function splitInlineNodesAtPlainOffset(nodes: InlineNode[], offset: number): {
|
|
10
|
+
left: InlineNode[];
|
|
11
|
+
right: InlineNode[];
|
|
12
|
+
};
|
|
13
|
+
export declare function wrapInlineSelection(nodes: InlineNode[], start: number, end: number, kind: InlineWrapKind, linkHref?: string): InlineNode[] | null;
|
|
14
|
+
/** Returns updated nodes when `newPlain` differs by a single insert/delete; otherwise `null`. */
|
|
15
|
+
export declare function mergePlainTypingIntoInlines(nodes: InlineNode[], newPlain: string): InlineNode[] | null;
|
|
16
|
+
export declare function isInlineAtom(n: InlineNode): boolean;
|
|
17
|
+
/** Clone block `inlines` for a session draft, or seed from display plain. */
|
|
18
|
+
export declare function draftInlinesFromBlock(inlines: InlineNode[] | undefined, displayPlain: string): InlineNode[];
|
|
19
|
+
/** Remove plain-text range `[start, end)` from inline AST. */
|
|
20
|
+
export declare function deletePlainRange(nodes: InlineNode[], start: number, end: number): InlineNode[];
|
|
21
|
+
export declare function deleteCharBefore(nodes: InlineNode[], pos: number): InlineNode[] | null;
|
|
22
|
+
export declare function deleteCharAfter(nodes: InlineNode[], pos: number): InlineNode[] | null;
|
|
23
|
+
/** Insert plain text at offset; optionally strip newlines (heading single-line). */
|
|
24
|
+
export declare function insertTextAtPlainOffset(nodes: InlineNode[], pos: number, text: string, options?: {
|
|
25
|
+
stripNewlines?: boolean;
|
|
26
|
+
}): InlineNode[];
|
|
27
|
+
/** Apply a controlled-input delta; falls back to plain flattening when merge fails. */
|
|
28
|
+
export declare function applyControlledPlainEdit(nodes: InlineNode[], oldPlain: string, newPlain: string): InlineNode[];
|