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,23 @@
|
|
|
1
|
+
import { headingDisplayPlain } from '../block-specs/heading/edit';
|
|
2
|
+
import { paragraphDisplayPlain } from '../block-specs/paragraph/edit';
|
|
3
|
+
/** Map live DOM plain + caret into model display-plain coordinates for Enter. */
|
|
4
|
+
export function resolveEnterPlainSnapshot(block, plainText, plainOffset, kind) {
|
|
5
|
+
const display = kind === 'paragraph' && block.type === 'paragraph'
|
|
6
|
+
? paragraphDisplayPlain(block)
|
|
7
|
+
: kind === 'heading' && block.type === 'heading'
|
|
8
|
+
? headingDisplayPlain(block)
|
|
9
|
+
: plainText;
|
|
10
|
+
if (plainOffset >= plainText.length || plainOffset >= display.length) {
|
|
11
|
+
return { plain: display, offset: display.length };
|
|
12
|
+
}
|
|
13
|
+
if (block.inlines?.length && plainText !== display) {
|
|
14
|
+
return {
|
|
15
|
+
plain: display,
|
|
16
|
+
offset: Math.max(0, Math.min(plainOffset, display.length))
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
plain: plainText,
|
|
21
|
+
offset: Math.max(0, Math.min(plainOffset, plainText.length))
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type LinkRefDefinition } from '../plugins/links-images/parse-links-images';
|
|
2
|
+
import type { InlineNode } from './types';
|
|
3
|
+
type ExcludedRange = {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
};
|
|
7
|
+
export type RichInlineContext = {
|
|
8
|
+
source: string;
|
|
9
|
+
defs: Map<string, LinkRefDefinition>;
|
|
10
|
+
excluded: ExcludedRange[];
|
|
11
|
+
};
|
|
12
|
+
export declare function createRichInlineContext(source: string): RichInlineContext;
|
|
13
|
+
export declare function buildRichInlinesForRange(source: string, absStart: number, absEnd: number, ctx: RichInlineContext, options?: {
|
|
14
|
+
allowLinksAndWiki?: boolean;
|
|
15
|
+
}): InlineNode[];
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich inline parsing for Markdown bodies.
|
|
3
|
+
*
|
|
4
|
+
* Precedence inside a gap (outside inline code, highest wins on overlaps):
|
|
5
|
+
* inline code (`) → link / image → wiki link → autolink (`<http…>`) → mention →
|
|
6
|
+
* strikethrough (`~~`) → highlight (`==`) → emphasis (`*` / `**`).
|
|
7
|
+
*/
|
|
8
|
+
import { parseEmphasis } from '../plugins/emphasis/parse-emphasis';
|
|
9
|
+
import { collectDefinitionsAndExcluded, tryParseLinkImageAt } from '../plugins/links-images/parse-links-images';
|
|
10
|
+
import { parseImageLabelLayout, afterBracketLabelContent, sourceOffsetInBracketLabel } from '../plugins/links-images/parse-image-layout';
|
|
11
|
+
export function createRichInlineContext(source) {
|
|
12
|
+
const { defs, excluded } = collectDefinitionsAndExcluded(source);
|
|
13
|
+
return { source, defs, excluded };
|
|
14
|
+
}
|
|
15
|
+
function offsetToLine(source, offset) {
|
|
16
|
+
let line = 0;
|
|
17
|
+
const upto = Math.min(Math.max(0, offset), source.length);
|
|
18
|
+
for (let k = 0; k < upto; k++) {
|
|
19
|
+
if (source[k] === '\n')
|
|
20
|
+
line++;
|
|
21
|
+
}
|
|
22
|
+
return line;
|
|
23
|
+
}
|
|
24
|
+
function sourceRangeForOffsets(source, start, end) {
|
|
25
|
+
const safeEnd = Math.max(start, end);
|
|
26
|
+
return {
|
|
27
|
+
start,
|
|
28
|
+
end: safeEnd,
|
|
29
|
+
startLine: offsetToLine(source, start),
|
|
30
|
+
endLine: offsetToLine(source, safeEnd > start ? safeEnd - 1 : start)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function intersects(a, b, c, d) {
|
|
34
|
+
return a < d && b > c;
|
|
35
|
+
}
|
|
36
|
+
function findInlineCodeSpans(source, lo, hi) {
|
|
37
|
+
const out = [];
|
|
38
|
+
let i = lo;
|
|
39
|
+
while (i < hi) {
|
|
40
|
+
if (source[i] === '\\') {
|
|
41
|
+
i += 2;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (source[i] !== '`') {
|
|
45
|
+
i++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const startOffset = i;
|
|
49
|
+
i++;
|
|
50
|
+
let text = '';
|
|
51
|
+
let closed = false;
|
|
52
|
+
while (i < hi) {
|
|
53
|
+
if (source[i] === '\n' || source[i] === '\r')
|
|
54
|
+
break;
|
|
55
|
+
if (source[i] === '\\' && i + 1 < hi) {
|
|
56
|
+
text += source[i + 1];
|
|
57
|
+
i += 2;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (source[i] === '`') {
|
|
61
|
+
closed = true;
|
|
62
|
+
i++;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
text += source[i];
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
if (closed) {
|
|
69
|
+
out.push({ start: startOffset, end: i, text });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
i = startOffset + 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
function inExcluded(i, ctx) {
|
|
78
|
+
return ctx.excluded.some((r) => i >= r.start && i < r.end);
|
|
79
|
+
}
|
|
80
|
+
function isInlineParenDestination(source, afterLabelBracket, blockEnd) {
|
|
81
|
+
let k = afterLabelBracket;
|
|
82
|
+
while (k < blockEnd && (source[k] === ' ' || source[k] === '\t' || source[k] === '\n' || source[k] === '\r')) {
|
|
83
|
+
k++;
|
|
84
|
+
}
|
|
85
|
+
return k < blockEnd && source[k] === '(';
|
|
86
|
+
}
|
|
87
|
+
function collectLinkSpans(ctx, lo, hi) {
|
|
88
|
+
const out = [];
|
|
89
|
+
for (let i = lo; i < hi; i++) {
|
|
90
|
+
if (inExcluded(i, ctx))
|
|
91
|
+
continue;
|
|
92
|
+
const ch = ctx.source[i];
|
|
93
|
+
if (ch !== '[' && !(ch === '!' && ctx.source[i + 1] === '['))
|
|
94
|
+
continue;
|
|
95
|
+
const b = tryParseLinkImageAt(ctx.source, i, ctx.defs, ctx.excluded);
|
|
96
|
+
if (b && b.start >= lo && b.end <= hi) {
|
|
97
|
+
out.push(b);
|
|
98
|
+
i = b.end - 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
const WIKI_LINK = /\[\[([^[\]]+?)\]\]/g;
|
|
104
|
+
function collectWikiSpans(source, lo, hi) {
|
|
105
|
+
const slice = source.slice(lo, hi);
|
|
106
|
+
const out = [];
|
|
107
|
+
let m;
|
|
108
|
+
const re = new RegExp(WIKI_LINK.source, WIKI_LINK.flags);
|
|
109
|
+
while ((m = re.exec(slice)) !== null) {
|
|
110
|
+
const absStart = lo + (m.index ?? 0);
|
|
111
|
+
const absEnd = absStart + m[0].length;
|
|
112
|
+
const rawInner = m[1]?.trim() ?? '';
|
|
113
|
+
if (!rawInner)
|
|
114
|
+
continue;
|
|
115
|
+
const pipe = rawInner.indexOf('|');
|
|
116
|
+
let target;
|
|
117
|
+
let label;
|
|
118
|
+
if (pipe === -1) {
|
|
119
|
+
target = rawInner;
|
|
120
|
+
label = rawInner;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
target = rawInner.slice(0, pipe).trim();
|
|
124
|
+
label = rawInner.slice(pipe + 1).trim();
|
|
125
|
+
if (!target)
|
|
126
|
+
continue;
|
|
127
|
+
if (!label)
|
|
128
|
+
label = target;
|
|
129
|
+
}
|
|
130
|
+
if (target.toLowerCase() === 'toc')
|
|
131
|
+
continue;
|
|
132
|
+
out.push({
|
|
133
|
+
type: 'wikiLink',
|
|
134
|
+
target,
|
|
135
|
+
label,
|
|
136
|
+
sourceRange: sourceRangeForOffsets(source, absStart, absEnd)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
const ANGLE_AUTOLINK = /<((https?:\/\/[^>\s]+)|(mailto:[^>\s]+))>/gi;
|
|
142
|
+
function collectAutolinkSpans(source, lo, hi) {
|
|
143
|
+
const slice = source.slice(lo, hi);
|
|
144
|
+
const out = [];
|
|
145
|
+
let m;
|
|
146
|
+
const re = new RegExp(ANGLE_AUTOLINK.source, ANGLE_AUTOLINK.flags);
|
|
147
|
+
while ((m = re.exec(slice)) !== null) {
|
|
148
|
+
const absStart = lo + (m.index ?? 0);
|
|
149
|
+
const absEnd = absStart + m[0].length;
|
|
150
|
+
const href = m[1] ?? '';
|
|
151
|
+
out.push({ start: absStart, end: absEnd, href });
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
/** `@[Page]` page mentions — conservative. */
|
|
156
|
+
const MENTION_PAGE = /@\[([^\]\r\n]+)\]/g;
|
|
157
|
+
function collectPageMentions(source, lo, hi) {
|
|
158
|
+
const slice = source.slice(lo, hi);
|
|
159
|
+
const out = [];
|
|
160
|
+
let m;
|
|
161
|
+
const re = new RegExp(MENTION_PAGE.source, MENTION_PAGE.flags);
|
|
162
|
+
while ((m = re.exec(slice)) !== null) {
|
|
163
|
+
const absStart = lo + (m.index ?? 0);
|
|
164
|
+
const absEnd = absStart + m[0].length;
|
|
165
|
+
const name = (m[1] ?? '').trim();
|
|
166
|
+
if (!name)
|
|
167
|
+
continue;
|
|
168
|
+
out.push({
|
|
169
|
+
type: 'mention',
|
|
170
|
+
kind: 'page',
|
|
171
|
+
name,
|
|
172
|
+
sourceRange: sourceRangeForOffsets(source, absStart, absEnd)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
/** `@word` user mentions — not inside emails (no alphanumeric before `@`). */
|
|
178
|
+
const MENTION_USER = /(^|[^a-zA-Z0-9])@([a-zA-Z][a-zA-Z0-9_-]{0,63})/g;
|
|
179
|
+
function collectUserMentions(source, lo, hi) {
|
|
180
|
+
const slice = source.slice(lo, hi);
|
|
181
|
+
const out = [];
|
|
182
|
+
let m;
|
|
183
|
+
const re = new RegExp(MENTION_USER.source, MENTION_USER.flags);
|
|
184
|
+
while ((m = re.exec(slice)) !== null) {
|
|
185
|
+
const fullStartInSlice = m.index ?? 0;
|
|
186
|
+
const prefixLen = m[1]?.length ?? 0;
|
|
187
|
+
const absStart = lo + fullStartInSlice + prefixLen;
|
|
188
|
+
const absEnd = absStart + 1 + (m[2]?.length ?? 0);
|
|
189
|
+
const name = m[2] ?? '';
|
|
190
|
+
if (!name)
|
|
191
|
+
continue;
|
|
192
|
+
out.push({
|
|
193
|
+
type: 'mention',
|
|
194
|
+
kind: 'user',
|
|
195
|
+
name,
|
|
196
|
+
sourceRange: sourceRangeForOffsets(source, absStart, absEnd)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
function findDoubleDelimiterSpans(source, lo, hi, delimiter, outside) {
|
|
202
|
+
const out = [];
|
|
203
|
+
const open = delimiter + delimiter;
|
|
204
|
+
const n = open.length;
|
|
205
|
+
let i = lo;
|
|
206
|
+
while (i <= hi - n) {
|
|
207
|
+
if (source[i] === '\\') {
|
|
208
|
+
i += 2;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (source.slice(i, i + n) !== open) {
|
|
212
|
+
i++;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const start = i;
|
|
216
|
+
let j = i + n;
|
|
217
|
+
let closedAt = -1;
|
|
218
|
+
while (j <= hi - n) {
|
|
219
|
+
if (source[j] === '\\') {
|
|
220
|
+
j += 2;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (source.slice(j, j + n) === open) {
|
|
224
|
+
closedAt = j + n;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
j++;
|
|
228
|
+
}
|
|
229
|
+
if (closedAt < 0) {
|
|
230
|
+
i++;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const end = closedAt;
|
|
234
|
+
if (!outside.some((c) => intersects(start, end, c.start, c.end))) {
|
|
235
|
+
out.push({ start, end });
|
|
236
|
+
}
|
|
237
|
+
i = end;
|
|
238
|
+
}
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
function parseHighlightInner(text) {
|
|
242
|
+
const m = text.match(/^([a-zA-Z][a-zA-Z0-9_-]*):(.*)$/s);
|
|
243
|
+
if (m) {
|
|
244
|
+
return { color: m[1] ?? null, body: m[2] ?? '' };
|
|
245
|
+
}
|
|
246
|
+
return { color: null, body: text };
|
|
247
|
+
}
|
|
248
|
+
function emphasisOutsideCode(emph, code) {
|
|
249
|
+
return emph.filter((e) => !code.some((c) => intersects(e.startOffset, e.endOffset, c.start, c.end)));
|
|
250
|
+
}
|
|
251
|
+
function mergeTagged(parts) {
|
|
252
|
+
const sorted = [...parts].sort((a, b) => {
|
|
253
|
+
if (a.start !== b.start)
|
|
254
|
+
return a.start - b.start;
|
|
255
|
+
const lenA = a.end - a.start;
|
|
256
|
+
const lenB = b.end - b.start;
|
|
257
|
+
if (lenA !== lenB)
|
|
258
|
+
return lenB - lenA;
|
|
259
|
+
return b.pri - a.pri;
|
|
260
|
+
});
|
|
261
|
+
const picked = [];
|
|
262
|
+
for (const p of sorted) {
|
|
263
|
+
if (picked.some((q) => intersects(p.start, p.end, q.start, q.end)))
|
|
264
|
+
continue;
|
|
265
|
+
picked.push(p);
|
|
266
|
+
}
|
|
267
|
+
picked.sort((a, b) => a.start - b.start);
|
|
268
|
+
return picked;
|
|
269
|
+
}
|
|
270
|
+
export function buildRichInlinesForRange(source, absStart, absEnd, ctx, options = {}) {
|
|
271
|
+
const allowLinksAndWiki = options.allowLinksAndWiki !== false;
|
|
272
|
+
if (absEnd <= absStart)
|
|
273
|
+
return [];
|
|
274
|
+
const codeSpans = findInlineCodeSpans(source, absStart, absEnd);
|
|
275
|
+
const parts = [
|
|
276
|
+
...codeSpans.map((c) => ({
|
|
277
|
+
tag: 'code',
|
|
278
|
+
start: c.start,
|
|
279
|
+
end: c.end,
|
|
280
|
+
text: c.text,
|
|
281
|
+
pri: 1000
|
|
282
|
+
}))
|
|
283
|
+
];
|
|
284
|
+
if (allowLinksAndWiki) {
|
|
285
|
+
for (const block of collectLinkSpans(ctx, absStart, absEnd)) {
|
|
286
|
+
parts.push({ tag: 'link', start: block.start, end: block.end, block, pri: 700 });
|
|
287
|
+
}
|
|
288
|
+
for (const node of collectWikiSpans(source, absStart, absEnd)) {
|
|
289
|
+
const { start, end } = node.sourceRange;
|
|
290
|
+
parts.push({ tag: 'wiki', start, end, node, pri: 650 });
|
|
291
|
+
}
|
|
292
|
+
for (const a of collectAutolinkSpans(source, absStart, absEnd)) {
|
|
293
|
+
parts.push({ tag: 'auto', start: a.start, end: a.end, href: a.href, pri: 600 });
|
|
294
|
+
}
|
|
295
|
+
for (const node of collectPageMentions(source, absStart, absEnd)) {
|
|
296
|
+
const { start, end } = node.sourceRange;
|
|
297
|
+
parts.push({ tag: 'mention', start, end, node, pri: 550 });
|
|
298
|
+
}
|
|
299
|
+
for (const node of collectUserMentions(source, absStart, absEnd)) {
|
|
300
|
+
const { start, end } = node.sourceRange;
|
|
301
|
+
parts.push({ tag: 'mention', start, end, node, pri: 540 });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const strikeSpans = findDoubleDelimiterSpans(source, absStart, absEnd, '~', codeSpans);
|
|
305
|
+
for (const s of strikeSpans) {
|
|
306
|
+
parts.push({ tag: 'strike', start: s.start, end: s.end, pri: 400 });
|
|
307
|
+
}
|
|
308
|
+
const hiSpans = findDoubleDelimiterSpans(source, absStart, absEnd, '=', codeSpans);
|
|
309
|
+
for (const s of hiSpans) {
|
|
310
|
+
parts.push({ tag: 'hi', start: s.start, end: s.end, pri: 390 });
|
|
311
|
+
}
|
|
312
|
+
const slice = source.slice(absStart, absEnd);
|
|
313
|
+
const emphRaw = parseEmphasis(slice);
|
|
314
|
+
const emphSpans = emphasisOutsideCode(emphRaw.map((e) => ({
|
|
315
|
+
...e,
|
|
316
|
+
startOffset: e.startOffset + absStart,
|
|
317
|
+
endOffset: e.endOffset + absStart
|
|
318
|
+
})), codeSpans);
|
|
319
|
+
for (const e of emphSpans) {
|
|
320
|
+
parts.push({
|
|
321
|
+
tag: 'emph',
|
|
322
|
+
start: e.startOffset,
|
|
323
|
+
end: e.endOffset,
|
|
324
|
+
emphasisKind: e.kind,
|
|
325
|
+
text: e.text,
|
|
326
|
+
pri: e.kind === 'strong' ? 120 : 100
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
const merged = mergeTagged(parts);
|
|
330
|
+
const out = [];
|
|
331
|
+
let p = absStart;
|
|
332
|
+
for (const part of merged) {
|
|
333
|
+
if (part.end <= absStart || part.start >= absEnd)
|
|
334
|
+
continue;
|
|
335
|
+
const start = Math.max(part.start, absStart);
|
|
336
|
+
const end = Math.min(part.end, absEnd);
|
|
337
|
+
if (p < start) {
|
|
338
|
+
const t = source.slice(p, start);
|
|
339
|
+
if (t.length > 0) {
|
|
340
|
+
out.push({
|
|
341
|
+
type: 'text',
|
|
342
|
+
text: t,
|
|
343
|
+
sourceRange: sourceRangeForOffsets(source, p, start)
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (part.tag === 'code') {
|
|
348
|
+
out.push({
|
|
349
|
+
type: 'code',
|
|
350
|
+
text: part.text,
|
|
351
|
+
sourceRange: sourceRangeForOffsets(source, start, end)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
else if (part.tag === 'link') {
|
|
355
|
+
const b = part.block;
|
|
356
|
+
const labelStart = b.kind === 'image' ? b.start + 2 : b.start + 1;
|
|
357
|
+
const afterLabelBracket = afterBracketLabelContent(source, labelStart);
|
|
358
|
+
const innerEnd = afterLabelBracket === null ? labelStart + b.label.length : afterLabelBracket - 1;
|
|
359
|
+
let altEnd = innerEnd;
|
|
360
|
+
let displayWidth = null;
|
|
361
|
+
let floatAlign = null;
|
|
362
|
+
if (b.kind === 'image' &&
|
|
363
|
+
afterLabelBracket !== null &&
|
|
364
|
+
isInlineParenDestination(source, afterLabelBracket, b.end)) {
|
|
365
|
+
const layout = parseImageLabelLayout(b.label);
|
|
366
|
+
if (!layout.malformedSuffix && layout.suffixPipeIndex !== null) {
|
|
367
|
+
altEnd = sourceOffsetInBracketLabel(source, labelStart, layout.suffixPipeIndex);
|
|
368
|
+
displayWidth = layout.displayWidth;
|
|
369
|
+
floatAlign = layout.floatAlign;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
const labelNodes = buildRichInlinesForRange(source, labelStart, altEnd, ctx, {
|
|
373
|
+
allowLinksAndWiki: false
|
|
374
|
+
});
|
|
375
|
+
const outerRange = sourceRangeForOffsets(source, b.start, b.end);
|
|
376
|
+
if (b.kind === 'image') {
|
|
377
|
+
const node = {
|
|
378
|
+
type: 'image',
|
|
379
|
+
children: labelNodes,
|
|
380
|
+
href: b.href,
|
|
381
|
+
title: b.title ?? null,
|
|
382
|
+
displayWidth,
|
|
383
|
+
floatAlign,
|
|
384
|
+
sourceRange: outerRange
|
|
385
|
+
};
|
|
386
|
+
out.push(node);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
const node = {
|
|
390
|
+
type: 'link',
|
|
391
|
+
children: labelNodes,
|
|
392
|
+
href: b.href,
|
|
393
|
+
title: b.title ?? null,
|
|
394
|
+
sourceRange: outerRange
|
|
395
|
+
};
|
|
396
|
+
out.push(node);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
else if (part.tag === 'wiki') {
|
|
400
|
+
out.push(part.node);
|
|
401
|
+
}
|
|
402
|
+
else if (part.tag === 'auto') {
|
|
403
|
+
out.push({
|
|
404
|
+
type: 'autolink',
|
|
405
|
+
href: part.href,
|
|
406
|
+
sourceRange: sourceRangeForOffsets(source, start, end)
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
else if (part.tag === 'mention') {
|
|
410
|
+
out.push(part.node);
|
|
411
|
+
}
|
|
412
|
+
else if (part.tag === 'strike') {
|
|
413
|
+
const innerStart = start + 2;
|
|
414
|
+
const innerEnd = end - 2;
|
|
415
|
+
const innerNodes = buildRichInlinesForRange(source, innerStart, innerEnd, ctx, {
|
|
416
|
+
allowLinksAndWiki: false
|
|
417
|
+
});
|
|
418
|
+
out.push({
|
|
419
|
+
type: 'strikethrough',
|
|
420
|
+
children: innerNodes,
|
|
421
|
+
sourceRange: sourceRangeForOffsets(source, start, end)
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
else if (part.tag === 'hi') {
|
|
425
|
+
const innerStart = start + 2;
|
|
426
|
+
const innerEnd = end - 2;
|
|
427
|
+
const rawInner = source.slice(innerStart, innerEnd);
|
|
428
|
+
const { color, body } = parseHighlightInner(rawInner);
|
|
429
|
+
let bodyStart = innerStart;
|
|
430
|
+
const bodyEnd = innerEnd;
|
|
431
|
+
if (color !== null) {
|
|
432
|
+
const prefix = `${color}:`;
|
|
433
|
+
if (rawInner.startsWith(prefix)) {
|
|
434
|
+
bodyStart = innerStart + prefix.length;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const innerNodes = bodyStart < bodyEnd
|
|
438
|
+
? buildRichInlinesForRange(source, bodyStart, bodyEnd, ctx, {
|
|
439
|
+
allowLinksAndWiki: false
|
|
440
|
+
})
|
|
441
|
+
: [];
|
|
442
|
+
const node = {
|
|
443
|
+
type: 'highlight',
|
|
444
|
+
color,
|
|
445
|
+
children: innerNodes.length > 0
|
|
446
|
+
? innerNodes
|
|
447
|
+
: [
|
|
448
|
+
{
|
|
449
|
+
type: 'text',
|
|
450
|
+
text: body,
|
|
451
|
+
sourceRange: sourceRangeForOffsets(source, bodyStart, bodyEnd)
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
sourceRange: sourceRangeForOffsets(source, start, end)
|
|
455
|
+
};
|
|
456
|
+
out.push(node);
|
|
457
|
+
}
|
|
458
|
+
else if (part.tag === 'emph') {
|
|
459
|
+
const open = part.emphasisKind === 'strong' ? 2 : 1;
|
|
460
|
+
const innerStart = start + open;
|
|
461
|
+
const innerEnd = end - open;
|
|
462
|
+
const innerNodes = buildRichInlinesForRange(source, innerStart, innerEnd, ctx, {
|
|
463
|
+
allowLinksAndWiki: false
|
|
464
|
+
});
|
|
465
|
+
const outerRange = sourceRangeForOffsets(source, start, end);
|
|
466
|
+
if (part.emphasisKind === 'strong') {
|
|
467
|
+
out.push({
|
|
468
|
+
type: 'strong',
|
|
469
|
+
children: innerNodes,
|
|
470
|
+
sourceRange: outerRange
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
out.push({
|
|
475
|
+
type: 'emphasis',
|
|
476
|
+
children: innerNodes,
|
|
477
|
+
sourceRange: outerRange
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
p = end;
|
|
482
|
+
}
|
|
483
|
+
if (p < absEnd) {
|
|
484
|
+
const t = source.slice(p, absEnd);
|
|
485
|
+
if (t.length > 0) {
|
|
486
|
+
out.push({
|
|
487
|
+
type: 'text',
|
|
488
|
+
text: t,
|
|
489
|
+
sourceRange: sourceRangeForOffsets(source, p, absEnd)
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return out;
|
|
494
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { serializeImageLayoutSuffix } from '../plugins/links-images/parse-image-layout';
|
|
2
|
+
function escapeTitle(title) {
|
|
3
|
+
return title.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
4
|
+
}
|
|
5
|
+
function serializeInlineNode(node) {
|
|
6
|
+
switch (node.type) {
|
|
7
|
+
case 'text':
|
|
8
|
+
return node.text;
|
|
9
|
+
case 'code':
|
|
10
|
+
return '`' + node.text + '`';
|
|
11
|
+
case 'emphasis':
|
|
12
|
+
return '*' + node.children.map(serializeInlineNode).join('') + '*';
|
|
13
|
+
case 'strong':
|
|
14
|
+
return '**' + node.children.map(serializeInlineNode).join('') + '**';
|
|
15
|
+
case 'strikethrough':
|
|
16
|
+
return '~~' + node.children.map(serializeInlineNode).join('') + '~~';
|
|
17
|
+
case 'highlight': {
|
|
18
|
+
const inner = node.children.map(serializeInlineNode).join('');
|
|
19
|
+
return node.color ? `==${node.color}:${inner}==` : `==${inner}==`;
|
|
20
|
+
}
|
|
21
|
+
case 'autolink':
|
|
22
|
+
return `<${node.href}>`;
|
|
23
|
+
case 'wikiLink':
|
|
24
|
+
return node.label === node.target ? `[[${node.target}]]` : `[[${node.target}|${node.label}]]`;
|
|
25
|
+
case 'mention':
|
|
26
|
+
return node.kind === 'page' ? `@[${node.name}]` : `@${node.name}`;
|
|
27
|
+
case 'link': {
|
|
28
|
+
const label = node.children.map(serializeInlineNode).join('');
|
|
29
|
+
const title = node.title && node.title.length > 0 ? ` "${escapeTitle(node.title)}"` : '';
|
|
30
|
+
return node.href ? `[${label}](${node.href}${title})` : label;
|
|
31
|
+
}
|
|
32
|
+
case 'image': {
|
|
33
|
+
const alt = node.children.map(serializeInlineNode).join('');
|
|
34
|
+
const suffix = serializeImageLayoutSuffix(node.displayWidth, node.floatAlign);
|
|
35
|
+
const title = node.title && node.title.length > 0 ? ` "${escapeTitle(node.title)}"` : '';
|
|
36
|
+
return node.href ? `` : alt;
|
|
37
|
+
}
|
|
38
|
+
default:
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Emits Markdown inline spans for heading body / list items / serialized blocks. */
|
|
43
|
+
export function serializeInlineNodes(nodes) {
|
|
44
|
+
return nodes.map(serializeInlineNode).join('');
|
|
45
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EditorBlock, EditorDocument } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Canonical Markdown emitted when a block is dirty or unknown (no faithful slice).
|
|
4
|
+
*
|
|
5
|
+
* - **Paragraph**: soft breaks as ` \\n`, hard breaks as `\\n`; see {@link serializeParagraphData}.
|
|
6
|
+
* - **Headings**: `#` × level + space + body; inline nodes preferred over plain `data.text`.
|
|
7
|
+
* - **Lists**: unordered `-`; ordered `n.`; tasks `- [x]` / `n. [x]` with marker chars from list-item
|
|
8
|
+
* data when set; nested child blocks indented with four spaces per level.
|
|
9
|
+
* - **Blockquote**: every line prefixed with `> `, or bare `>` for blank inner lines.
|
|
10
|
+
* - **Tables**: `| a | b |` rows; delimiter cells `:---`, `:---:`, `---:`, or `---` per column alignment.
|
|
11
|
+
* - **Callouts**: `> [!type] title` then `> body` / `>` for blank body lines.
|
|
12
|
+
* - **Toggles**: `+++ title`, body, closing `+++`.
|
|
13
|
+
* - **Columns**: `||| column head`, column lines, closing `|||`.
|
|
14
|
+
* - **Horizontal rule**: `---`; **TOC**: `::toc`.
|
|
15
|
+
*/
|
|
16
|
+
export { serializeParagraphData } from '../block-specs/paragraph';
|
|
17
|
+
/** Serialize a single block to Markdown (no surrounding blank lines). Unknown types fall back to the original source slice when provided. */
|
|
18
|
+
export declare function serializeEditorBlock(block: EditorBlock, source?: string): string;
|
|
19
|
+
/** Serialize a contiguous slice of top-level blocks (list runs, paragraphs, etc.). */
|
|
20
|
+
export declare function serializeTopLevelBlockSpan(blocks: EditorBlock[], start: number, end: number, source?: string): string;
|
|
21
|
+
export declare function serializeMarkdownDocument(doc: EditorDocument): string;
|
|
22
|
+
/**
|
|
23
|
+
* Serialize the document while preserving author bytes for unchanged top-level blocks.
|
|
24
|
+
* Unchanged blocks emit original source slices; prefix, suffix, and inter-block gaps copy
|
|
25
|
+
* `doc.source` whenever adjacent blocks have concrete UTF-16 ranges (including when only one
|
|
26
|
+
* side is pristine). Synthetic blocks or missing ranges fall back to {@link DEFAULT_GAP_NON_PRISTINE}.
|
|
27
|
+
*
|
|
28
|
+
* **Formatting policy** for dirty / non-slice blocks: see file-level doc comment above.
|
|
29
|
+
*/
|
|
30
|
+
export declare function serializeMarkdownDocumentPreserving(doc: EditorDocument, dirtyTopLevelIds: ReadonlySet<string>): string;
|