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,38 @@
|
|
|
1
|
+
/** Split into lines with start/end indices in the original string (handles `\r`, `\r\n`, `\n`). */
|
|
2
|
+
export function splitLinesWithOffsets(source) {
|
|
3
|
+
const rows = [];
|
|
4
|
+
let start = 0;
|
|
5
|
+
for (let i = 0; i < source.length;) {
|
|
6
|
+
const ch = source[i];
|
|
7
|
+
if (ch === '\r' || ch === '\n') {
|
|
8
|
+
rows.push({ line: source.slice(start, i), start, end: i });
|
|
9
|
+
i++;
|
|
10
|
+
if (ch === '\r' && source[i] === '\n')
|
|
11
|
+
i++;
|
|
12
|
+
start = i;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
rows.push({ line: source.slice(start, source.length), start, end: source.length });
|
|
19
|
+
return rows;
|
|
20
|
+
}
|
|
21
|
+
/** Line and character totals for editor chrome; uses the same line split as the parser. */
|
|
22
|
+
export function sourceLineAndCharacterCount(source) {
|
|
23
|
+
return {
|
|
24
|
+
lineCount: splitLinesWithOffsets(source).length,
|
|
25
|
+
characterCount: source.length
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Index just after the line's trailing `\r` / `\n` (or `source.length`). */
|
|
29
|
+
export function afterLineTerminator(source, row) {
|
|
30
|
+
if (row.end >= source.length)
|
|
31
|
+
return source.length;
|
|
32
|
+
let p = row.end;
|
|
33
|
+
if (source[p] === '\r')
|
|
34
|
+
p++;
|
|
35
|
+
if (p < source.length && source[p] === '\n')
|
|
36
|
+
p++;
|
|
37
|
+
return p;
|
|
38
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type TreePath } from './blockTree';
|
|
2
|
+
import type { EditorBlock, TaskCheckboxState } from './types';
|
|
3
|
+
export type ListPath = TreePath;
|
|
4
|
+
export type ResolvedListItem = {
|
|
5
|
+
parent: EditorBlock | null;
|
|
6
|
+
siblings: EditorBlock[];
|
|
7
|
+
itemIndex: number;
|
|
8
|
+
item: EditorBlock;
|
|
9
|
+
};
|
|
10
|
+
export declare function deepCloneListRoot(block: EditorBlock): EditorBlock;
|
|
11
|
+
export declare function listItemDisplayPlain(item: EditorBlock, source: string): string;
|
|
12
|
+
/** @deprecated Use {@link listItemDisplayPlain} — same plain text the edit surface shows. */
|
|
13
|
+
export declare function listItemBodyPlain(item: EditorBlock, source: string): string;
|
|
14
|
+
export declare function setListItemBodyPlain(item: EditorBlock, plain: string): void;
|
|
15
|
+
export declare function resolveListItem(blocks: EditorBlock[], path: ListPath): ResolvedListItem | null;
|
|
16
|
+
/** @deprecated Pass document blocks; {@link resolveListItem} replaces container-root resolution. */
|
|
17
|
+
export declare function resolveListItemFromRoot(rootList: EditorBlock, path: ListPath): ResolvedListItem | null;
|
|
18
|
+
export declare function findListItemPath(blocks: EditorBlock[], itemId: string): ListPath | null;
|
|
19
|
+
/** Increase nesting: item becomes last child of previous sibling listItem. */
|
|
20
|
+
export declare function listIndentItem(blocks: EditorBlock[], itemId: string): EditorBlock[] | null;
|
|
21
|
+
/** Move item one level up (insert after parent among its siblings). */
|
|
22
|
+
export declare function listOutdentItem(blocks: EditorBlock[], itemId: string): EditorBlock[] | null;
|
|
23
|
+
/** @deprecated Use {@link listSetTaskState} with **StatusCheckbox** cycle/snap. */
|
|
24
|
+
export declare function listToggleTask(blocks: EditorBlock[], itemId: string): EditorBlock[] | null;
|
|
25
|
+
export declare function listSetTaskState(blocks: EditorBlock[], itemId: string, task: TaskCheckboxState): EditorBlock[] | null;
|
|
26
|
+
export type ListItemTaskBodyShortcutTrigger = 'space' | 'enter' | 'blur';
|
|
27
|
+
/** Plain `[ ]` / `[x]` / … typed in a non-task **listItem** body (not the `-` leader). */
|
|
28
|
+
export declare function isListItemTaskBodyShortcutPlain(plain: string): boolean;
|
|
29
|
+
export declare function isListItemTaskBodyShortcutTrigger(plain: string, trigger: ListItemTaskBodyShortcutTrigger): boolean;
|
|
30
|
+
/** Promote a non-task **listItem** when the body plain is a reserved task bracket prefix only. */
|
|
31
|
+
export declare function listPromoteToTaskFromBodyShortcut(blocks: EditorBlock[], itemId: string, bodyPlain: string): EditorBlock[] | null;
|
|
32
|
+
export type ListMergeWithPreviousResult = {
|
|
33
|
+
blocks: EditorBlock[];
|
|
34
|
+
focusBlockId: string;
|
|
35
|
+
joinPlainOffset: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function listMergeWithPrevious(blocks: EditorBlock[], itemId: string, source: string): ListMergeWithPreviousResult | null;
|
|
38
|
+
export declare function isEmptyListItemBody(item: EditorBlock, source: string, livePlain?: string): boolean;
|
|
39
|
+
export declare function listDemoteEmptyItemAt(blocks: EditorBlock[], itemId: string): EditorBlock[] | null;
|
|
40
|
+
export declare function listSplitItemAtPlain(blocks: EditorBlock[], itemId: string, offset: number, plainText: string, source: string): EditorBlock[] | null;
|
|
41
|
+
export type ListEnterResult = {
|
|
42
|
+
blocks: EditorBlock[];
|
|
43
|
+
focusBlockId: string;
|
|
44
|
+
demoteToParagraph?: false;
|
|
45
|
+
};
|
|
46
|
+
export type ListDemotionResult = {
|
|
47
|
+
blocks: EditorBlock[];
|
|
48
|
+
demoteToParagraph: true;
|
|
49
|
+
focusBlockId: string;
|
|
50
|
+
};
|
|
51
|
+
export declare function listEnterAtPlain(blocks: EditorBlock[], itemId: string, offset: number, plainText: string, _source: string): ListEnterResult | ListDemotionResult | null;
|
|
52
|
+
export declare function listMoveSibling(blocks: EditorBlock[], itemId: string, direction: 'up' | 'down'): EditorBlock[] | null;
|
|
53
|
+
export declare function listDeleteItem(blocks: EditorBlock[], itemId: string): EditorBlock[] | null;
|
|
54
|
+
export declare function listDuplicateItem(blocks: EditorBlock[], itemId: string): EditorBlock[] | null;
|
|
55
|
+
export declare function listItemCanMoveSibling(blocks: EditorBlock[], itemId: string, direction: 'up' | 'down'): boolean;
|
|
56
|
+
export declare function siblingFocusIdForListDelete(blocks: EditorBlock[], itemId: string): string | undefined;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { taskCheckboxFromMarker } from '../block-specs/list/parse';
|
|
2
|
+
import { paragraphBlockFromPlainText } from '../block-specs/paragraph/edit';
|
|
3
|
+
import { deepCloneBlock, deepCloneBlocks, findBlockLocation, normalizeListOrdinalsForest } from './blockTree';
|
|
4
|
+
import { nestUnderPreviousSibling, promoteOneLevel } from './blockTreeMutations';
|
|
5
|
+
import { inlineTextNode } from './inlineEditCommands';
|
|
6
|
+
import { inlineNodesToPlainText } from './inlinePlain';
|
|
7
|
+
function syntheticRange() {
|
|
8
|
+
return { start: -1, end: -1, startLine: -1, endLine: -1, synthetic: true };
|
|
9
|
+
}
|
|
10
|
+
export function deepCloneListRoot(block) {
|
|
11
|
+
return deepCloneBlock(block);
|
|
12
|
+
}
|
|
13
|
+
export function listItemDisplayPlain(item, source) {
|
|
14
|
+
if (item.inlines?.length)
|
|
15
|
+
return inlineNodesToPlainText(item.inlines);
|
|
16
|
+
if (item.sourceRange.start >= 0 && !item.sourceRange.synthetic) {
|
|
17
|
+
const slice = source.slice(item.sourceRange.start, item.sourceRange.end);
|
|
18
|
+
const firstLine = slice.split('\n')[0] ?? '';
|
|
19
|
+
const taskUm = firstLine.match(/^\s*[-*+][ \t]+\[[^\]]+\][ \t]+(.*)$/);
|
|
20
|
+
const taskOm = firstLine.match(/^\s*\d+\.[ \t]+\[[^\]]+\][ \t]+(.*)$/);
|
|
21
|
+
const tm = taskUm ?? taskOm;
|
|
22
|
+
if (tm)
|
|
23
|
+
return (tm[1] ?? '').trimEnd();
|
|
24
|
+
const um = firstLine.match(/^\s*[-*+][ \t]+(.*)$/);
|
|
25
|
+
const om = firstLine.match(/^\s*\d+\.[ \t]+(.*)$/);
|
|
26
|
+
const m = um ?? om;
|
|
27
|
+
return (m ? m[1] : firstLine).trimEnd();
|
|
28
|
+
}
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
/** @deprecated Use {@link listItemDisplayPlain} — same plain text the edit surface shows. */
|
|
32
|
+
export function listItemBodyPlain(item, source) {
|
|
33
|
+
return listItemDisplayPlain(item, source);
|
|
34
|
+
}
|
|
35
|
+
export function setListItemBodyPlain(item, plain) {
|
|
36
|
+
item.inlines = plain.length > 0 ? [inlineTextNode(plain)] : [];
|
|
37
|
+
}
|
|
38
|
+
export function resolveListItem(blocks, path) {
|
|
39
|
+
if (path.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
let siblings = blocks;
|
|
42
|
+
let parent = null;
|
|
43
|
+
for (let pi = 0; pi < path.length - 1; pi++) {
|
|
44
|
+
const node = siblings[path[pi]];
|
|
45
|
+
if (!node)
|
|
46
|
+
return null;
|
|
47
|
+
parent = node;
|
|
48
|
+
siblings = node.children ?? [];
|
|
49
|
+
}
|
|
50
|
+
const itemIndex = path[path.length - 1];
|
|
51
|
+
const item = siblings[itemIndex];
|
|
52
|
+
if (!item || item.type !== 'listItem')
|
|
53
|
+
return null;
|
|
54
|
+
return { parent, siblings, itemIndex, item };
|
|
55
|
+
}
|
|
56
|
+
/** @deprecated Pass document blocks; {@link resolveListItem} replaces container-root resolution. */
|
|
57
|
+
export function resolveListItemFromRoot(rootList, path) {
|
|
58
|
+
if (rootList.type !== 'listItem')
|
|
59
|
+
return resolveListItem([rootList], path);
|
|
60
|
+
return resolveListItem([rootList], path);
|
|
61
|
+
}
|
|
62
|
+
export function findListItemPath(blocks, itemId) {
|
|
63
|
+
const loc = findBlockLocation(blocks, itemId);
|
|
64
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
65
|
+
return null;
|
|
66
|
+
return loc.path;
|
|
67
|
+
}
|
|
68
|
+
function extractListItem(siblings, index) {
|
|
69
|
+
const [removed] = siblings.splice(index, 1);
|
|
70
|
+
return removed ?? null;
|
|
71
|
+
}
|
|
72
|
+
/** Increase nesting: item becomes last child of previous sibling listItem. */
|
|
73
|
+
export function listIndentItem(blocks, itemId) {
|
|
74
|
+
return nestUnderPreviousSibling(blocks, itemId, (parent, child) => parent.type === 'listItem' && child.type === 'listItem');
|
|
75
|
+
}
|
|
76
|
+
/** Move item one level up (insert after parent among its siblings). */
|
|
77
|
+
export function listOutdentItem(blocks, itemId) {
|
|
78
|
+
const loc = findBlockLocation(blocks, itemId);
|
|
79
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
80
|
+
return null;
|
|
81
|
+
return promoteOneLevel(blocks, itemId);
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use {@link listSetTaskState} with **StatusCheckbox** cycle/snap. */
|
|
84
|
+
export function listToggleTask(blocks, itemId) {
|
|
85
|
+
const loc = findBlockLocation(blocks, itemId);
|
|
86
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
87
|
+
return null;
|
|
88
|
+
const d = loc.block.data;
|
|
89
|
+
if (d.task === undefined)
|
|
90
|
+
return null;
|
|
91
|
+
const next = d.task === 'done' ? 'todo' : 'done';
|
|
92
|
+
return listSetTaskState(blocks, itemId, next);
|
|
93
|
+
}
|
|
94
|
+
export function listSetTaskState(blocks, itemId, task) {
|
|
95
|
+
const clone = deepCloneBlocks(blocks);
|
|
96
|
+
const loc = findBlockLocation(clone, itemId);
|
|
97
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
98
|
+
return null;
|
|
99
|
+
const d = loc.block.data;
|
|
100
|
+
if (d.task === undefined)
|
|
101
|
+
return null;
|
|
102
|
+
loc.block.data = { ...d, task };
|
|
103
|
+
if (task !== 'other') {
|
|
104
|
+
delete loc.block.data.taskMarkerChar;
|
|
105
|
+
}
|
|
106
|
+
return clone;
|
|
107
|
+
}
|
|
108
|
+
const LIST_ITEM_TASK_BODY_MARKER_ONLY = /^\[([ xX/>])\]$/;
|
|
109
|
+
const LIST_ITEM_TASK_BODY_COMPLETE = /^\[([ xX/>])\]\s+$/;
|
|
110
|
+
/** Plain `[ ]` / `[x]` / … typed in a non-task **listItem** body (not the `-` leader). */
|
|
111
|
+
export function isListItemTaskBodyShortcutPlain(plain) {
|
|
112
|
+
return LIST_ITEM_TASK_BODY_MARKER_ONLY.test(plain) || LIST_ITEM_TASK_BODY_COMPLETE.test(plain);
|
|
113
|
+
}
|
|
114
|
+
export function isListItemTaskBodyShortcutTrigger(plain, trigger) {
|
|
115
|
+
if (trigger === 'blur')
|
|
116
|
+
return LIST_ITEM_TASK_BODY_COMPLETE.test(plain);
|
|
117
|
+
return LIST_ITEM_TASK_BODY_MARKER_ONLY.test(plain);
|
|
118
|
+
}
|
|
119
|
+
/** Promote a non-task **listItem** when the body plain is a reserved task bracket prefix only. */
|
|
120
|
+
export function listPromoteToTaskFromBodyShortcut(blocks, itemId, bodyPlain) {
|
|
121
|
+
const marker = bodyPlain.match(LIST_ITEM_TASK_BODY_MARKER_ONLY)?.[1];
|
|
122
|
+
if (marker === undefined)
|
|
123
|
+
return null;
|
|
124
|
+
const task = taskCheckboxFromMarker(marker);
|
|
125
|
+
if (task === 'other')
|
|
126
|
+
return null;
|
|
127
|
+
const clone = deepCloneBlocks(blocks);
|
|
128
|
+
const loc = findBlockLocation(clone, itemId);
|
|
129
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
130
|
+
return null;
|
|
131
|
+
const d = loc.block.data;
|
|
132
|
+
if (d.task !== undefined)
|
|
133
|
+
return null;
|
|
134
|
+
loc.block.data = { ...d, task };
|
|
135
|
+
setListItemBodyPlain(loc.block, '');
|
|
136
|
+
return clone;
|
|
137
|
+
}
|
|
138
|
+
export function listMergeWithPrevious(blocks, itemId, source) {
|
|
139
|
+
const clone = deepCloneBlocks(blocks);
|
|
140
|
+
const loc = findBlockLocation(clone, itemId);
|
|
141
|
+
if (!loc || loc.index === 0 || loc.block.type !== 'listItem')
|
|
142
|
+
return null;
|
|
143
|
+
const prev = loc.siblings[loc.index - 1];
|
|
144
|
+
if (!prev || prev.type !== 'listItem')
|
|
145
|
+
return null;
|
|
146
|
+
const joinPlainOffset = listItemDisplayPlain(prev, source).replace(/[ \t]+$/, '').length;
|
|
147
|
+
const a = listItemBodyPlain(prev, source);
|
|
148
|
+
const b = listItemBodyPlain(loc.block, source);
|
|
149
|
+
setListItemBodyPlain(prev, a + b);
|
|
150
|
+
const childrenToReparent = loc.block.children ?? [];
|
|
151
|
+
if (childrenToReparent.length > 0) {
|
|
152
|
+
if (!prev.children)
|
|
153
|
+
prev.children = [];
|
|
154
|
+
prev.children.push(...childrenToReparent);
|
|
155
|
+
}
|
|
156
|
+
loc.siblings.splice(loc.index, 1);
|
|
157
|
+
normalizeListOrdinalsForest(clone);
|
|
158
|
+
return { blocks: clone, focusBlockId: prev.id, joinPlainOffset };
|
|
159
|
+
}
|
|
160
|
+
export function isEmptyListItemBody(item, source, livePlain) {
|
|
161
|
+
const plain = livePlain ?? listItemDisplayPlain(item, source);
|
|
162
|
+
return plain.trim().length === 0;
|
|
163
|
+
}
|
|
164
|
+
export function listDemoteEmptyItemAt(blocks, itemId) {
|
|
165
|
+
const result = listEnterAtPlain(blocks, itemId, 0, '', '');
|
|
166
|
+
if (!result || !('demoteToParagraph' in result) || !result.demoteToParagraph)
|
|
167
|
+
return null;
|
|
168
|
+
return result.blocks;
|
|
169
|
+
}
|
|
170
|
+
export function listSplitItemAtPlain(blocks, itemId, offset, plainText, source) {
|
|
171
|
+
const result = listEnterAtPlain(blocks, itemId, offset, plainText, source);
|
|
172
|
+
return result && !('demoteToParagraph' in result && result.demoteToParagraph) ? result.blocks : null;
|
|
173
|
+
}
|
|
174
|
+
function listItemToParagraph(item) {
|
|
175
|
+
const lineIndex = item.sourceRange.startLine >= 0 ? item.sourceRange.startLine : 0;
|
|
176
|
+
// Empty paragraphs need one source byte; otherwise serializing the demotion
|
|
177
|
+
// deletes the list line instead of materializing an editable paragraph.
|
|
178
|
+
const emptyParagraphPlain = ' ';
|
|
179
|
+
return {
|
|
180
|
+
type: 'paragraph',
|
|
181
|
+
id: item.id,
|
|
182
|
+
sourceRange: { ...item.sourceRange },
|
|
183
|
+
data: paragraphBlockFromPlainText(emptyParagraphPlain, lineIndex),
|
|
184
|
+
inlines: [],
|
|
185
|
+
children: item.children?.map(deepCloneBlock)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function makeEmptyListItemLike(item) {
|
|
189
|
+
const d = item.data;
|
|
190
|
+
const data = d.task !== undefined
|
|
191
|
+
? { ...d, task: 'todo', taskMarkerChar: undefined }
|
|
192
|
+
: { ...d };
|
|
193
|
+
return {
|
|
194
|
+
type: 'listItem',
|
|
195
|
+
id: crypto.randomUUID(),
|
|
196
|
+
sourceRange: syntheticRange(),
|
|
197
|
+
data,
|
|
198
|
+
children: [],
|
|
199
|
+
inlines: []
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export function listEnterAtPlain(blocks, itemId, offset, plainText, _source) {
|
|
203
|
+
const clone = deepCloneBlocks(blocks);
|
|
204
|
+
const loc = findBlockLocation(clone, itemId);
|
|
205
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
206
|
+
return null;
|
|
207
|
+
const body = plainText;
|
|
208
|
+
if (body.trim().length === 0) {
|
|
209
|
+
const focusBlockId = loc.block.id;
|
|
210
|
+
loc.siblings[loc.index] = listItemToParagraph(loc.block);
|
|
211
|
+
normalizeListOrdinalsForest(clone);
|
|
212
|
+
return { blocks: clone, demoteToParagraph: true, focusBlockId };
|
|
213
|
+
}
|
|
214
|
+
if (offset <= 0) {
|
|
215
|
+
const newItem = makeEmptyListItemLike(loc.block);
|
|
216
|
+
loc.siblings.splice(loc.index, 0, newItem);
|
|
217
|
+
normalizeListOrdinalsForest(clone);
|
|
218
|
+
return { blocks: clone, focusBlockId: newItem.id };
|
|
219
|
+
}
|
|
220
|
+
if (offset >= body.length) {
|
|
221
|
+
const newItem = makeEmptyListItemLike(loc.block);
|
|
222
|
+
loc.siblings.splice(loc.index + 1, 0, newItem);
|
|
223
|
+
normalizeListOrdinalsForest(clone);
|
|
224
|
+
return { blocks: clone, focusBlockId: newItem.id };
|
|
225
|
+
}
|
|
226
|
+
const left = body.slice(0, offset);
|
|
227
|
+
const right = body.slice(offset);
|
|
228
|
+
setListItemBodyPlain(loc.block, left);
|
|
229
|
+
const newItem = makeEmptyListItemLike(loc.block);
|
|
230
|
+
setListItemBodyPlain(newItem, right);
|
|
231
|
+
loc.siblings.splice(loc.index + 1, 0, newItem);
|
|
232
|
+
normalizeListOrdinalsForest(clone);
|
|
233
|
+
return { blocks: clone, focusBlockId: newItem.id };
|
|
234
|
+
}
|
|
235
|
+
export function listMoveSibling(blocks, itemId, direction) {
|
|
236
|
+
const clone = deepCloneBlocks(blocks);
|
|
237
|
+
const loc = findBlockLocation(clone, itemId);
|
|
238
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
239
|
+
return null;
|
|
240
|
+
const newIdx = direction === 'up' ? loc.index - 1 : loc.index + 1;
|
|
241
|
+
if (newIdx < 0 || newIdx >= loc.siblings.length)
|
|
242
|
+
return null;
|
|
243
|
+
const [removed] = loc.siblings.splice(loc.index, 1);
|
|
244
|
+
if (!removed)
|
|
245
|
+
return null;
|
|
246
|
+
loc.siblings.splice(newIdx, 0, removed);
|
|
247
|
+
normalizeListOrdinalsForest(clone);
|
|
248
|
+
return clone;
|
|
249
|
+
}
|
|
250
|
+
export function listDeleteItem(blocks, itemId) {
|
|
251
|
+
const clone = deepCloneBlocks(blocks);
|
|
252
|
+
const loc = findBlockLocation(clone, itemId);
|
|
253
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
254
|
+
return null;
|
|
255
|
+
const removed = extractListItem(loc.siblings, loc.index);
|
|
256
|
+
if (!removed)
|
|
257
|
+
return null;
|
|
258
|
+
normalizeListOrdinalsForest(clone);
|
|
259
|
+
return clone;
|
|
260
|
+
}
|
|
261
|
+
function cloneListItemSubtree(item) {
|
|
262
|
+
const copy = deepCloneBlock(item);
|
|
263
|
+
copy.id = crypto.randomUUID();
|
|
264
|
+
function reId(node) {
|
|
265
|
+
node.id = crypto.randomUUID();
|
|
266
|
+
for (const ch of node.children ?? [])
|
|
267
|
+
reId(ch);
|
|
268
|
+
}
|
|
269
|
+
reId(copy);
|
|
270
|
+
return copy;
|
|
271
|
+
}
|
|
272
|
+
export function listDuplicateItem(blocks, itemId) {
|
|
273
|
+
const clone = deepCloneBlocks(blocks);
|
|
274
|
+
const loc = findBlockLocation(clone, itemId);
|
|
275
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
276
|
+
return null;
|
|
277
|
+
const dup = cloneListItemSubtree(loc.block);
|
|
278
|
+
loc.siblings.splice(loc.index + 1, 0, dup);
|
|
279
|
+
normalizeListOrdinalsForest(clone);
|
|
280
|
+
return clone;
|
|
281
|
+
}
|
|
282
|
+
export function listItemCanMoveSibling(blocks, itemId, direction) {
|
|
283
|
+
const loc = findBlockLocation(blocks, itemId);
|
|
284
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
285
|
+
return false;
|
|
286
|
+
const newIdx = direction === 'up' ? loc.index - 1 : loc.index + 1;
|
|
287
|
+
return newIdx >= 0 && newIdx < loc.siblings.length;
|
|
288
|
+
}
|
|
289
|
+
export function siblingFocusIdForListDelete(blocks, itemId) {
|
|
290
|
+
const loc = findBlockLocation(blocks, itemId);
|
|
291
|
+
if (!loc || loc.block.type !== 'listItem')
|
|
292
|
+
return undefined;
|
|
293
|
+
const { siblings, index } = loc;
|
|
294
|
+
if (index > 0)
|
|
295
|
+
return siblings[index - 1]?.id;
|
|
296
|
+
if (index + 1 < siblings.length)
|
|
297
|
+
return siblings[index + 1]?.id;
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type InlineWrapKind } from './inlineEditCommands';
|
|
2
|
+
import type { EditorBlock, EditorDocument } from './types';
|
|
3
|
+
import type { TransactionBuildResult } from './editorTransactions';
|
|
4
|
+
import { type TreeDropPlacement } from './blockTreeDrop';
|
|
5
|
+
import { siblingFocusIdForListDelete } from './listEditCommands';
|
|
6
|
+
import { siblingFocusIdForCalloutDelete } from './calloutEditCommands';
|
|
7
|
+
import { type QuotePath } from './quoteEditCommands';
|
|
8
|
+
export type { TreeDropPlacement } from './blockTreeDrop';
|
|
9
|
+
export { applyBlockTreeDrop, blockTreeDropTransaction, canBlockTreeDrop } from './blockTreeDrop';
|
|
10
|
+
export { isDescendantBlock, nestUnderPreviousSibling, nestUnderTarget, promoteOneLevel, removeBlockFromTree } from './blockTreeMutations';
|
|
11
|
+
export declare function listRegionStructMutation(source: string, doc: EditorDocument, itemId: string, mutate: (blocks: EditorBlock[]) => EditorBlock[] | null, txId: string, caretBlockId?: string): TransactionBuildResult;
|
|
12
|
+
export declare function moveListItemSiblingTransaction(source: string, doc: EditorDocument, _itemIndex: number, itemId: string, direction: 'up' | 'down'): TransactionBuildResult;
|
|
13
|
+
export declare function listItemTreeDropTransaction(source: string, doc: EditorDocument, _blockIndex: number, draggedId: string, targetId: string, placement: TreeDropPlacement): TransactionBuildResult;
|
|
14
|
+
export declare function deleteListItemTransaction(source: string, doc: EditorDocument, _blockIndex: number, itemId: string, focusAfterId?: string): TransactionBuildResult;
|
|
15
|
+
export declare function duplicateListItemTransaction(source: string, doc: EditorDocument, _blockIndex: number, itemId: string): TransactionBuildResult;
|
|
16
|
+
export { siblingFocusIdForListDelete };
|
|
17
|
+
export declare function moveQuoteBlockSiblingTransaction(source: string, doc: EditorDocument, blockIndex: number, quoteBlockId: string, direction: 'up' | 'down'): TransactionBuildResult;
|
|
18
|
+
export declare function deleteQuoteBlockTransaction(source: string, doc: EditorDocument, blockIndex: number, quoteBlockId: string, focusAfterId?: string): TransactionBuildResult;
|
|
19
|
+
export declare function duplicateQuoteBlockTransaction(source: string, doc: EditorDocument, blockIndex: number, quoteBlockId: string): TransactionBuildResult;
|
|
20
|
+
export declare function applyListItemInlineWrapTransaction(source: string, doc: EditorDocument, _blockIndex: number, itemId: string, plainStart: number, plainEnd: number, kind: InlineWrapKind, linkHref?: string): TransactionBuildResult;
|
|
21
|
+
export declare function applyQuoteBlockInlineWrapTransaction(source: string, doc: EditorDocument, blockIndex: number, quoteBlockId: string, plainStart: number, plainEnd: number, kind: InlineWrapKind, linkHref?: string): TransactionBuildResult;
|
|
22
|
+
export declare function quoteStructMutationTransaction(source: string, doc: EditorDocument, blockIndex: number, quoteBlockId: string, mutate: (root: EditorBlock) => EditorBlock | null, txId: string, caretBlockId?: string): TransactionBuildResult;
|
|
23
|
+
export declare const moveQuoteParagraphSiblingTransaction: typeof moveQuoteBlockSiblingTransaction;
|
|
24
|
+
export declare const deleteQuoteParagraphTransaction: typeof deleteQuoteBlockTransaction;
|
|
25
|
+
export declare const duplicateQuoteParagraphTransaction: typeof duplicateQuoteBlockTransaction;
|
|
26
|
+
export declare const applyQuoteParagraphInlineWrapTransaction: typeof applyQuoteBlockInlineWrapTransaction;
|
|
27
|
+
export declare function siblingFocusIdForQuoteDelete(block: EditorBlock, quoteBlockId: string): string | undefined;
|
|
28
|
+
export declare function quoteParagraphReorderTransaction(source: string, doc: EditorDocument, blockIndex: number, quotePath: QuotePath, fromIndex: number, toIndex: number, paragraphId: string): TransactionBuildResult;
|
|
29
|
+
export declare function calloutStructMutationTransaction(source: string, doc: EditorDocument, blockIndex: number, childBlockId: string, mutate: (root: EditorBlock) => EditorBlock | null, txId: string, caretBlockId?: string): TransactionBuildResult;
|
|
30
|
+
export declare function calloutExitTransaction(source: string, doc: EditorDocument, blockIndex: number, rootAfterExit: EditorBlock): TransactionBuildResult;
|
|
31
|
+
export declare function moveCalloutChildSiblingTransaction(source: string, doc: EditorDocument, blockIndex: number, childId: string, direction: 'up' | 'down'): TransactionBuildResult;
|
|
32
|
+
export declare function deleteCalloutChildTransaction(source: string, doc: EditorDocument, blockIndex: number, childId: string, focusAfterId?: string): TransactionBuildResult;
|
|
33
|
+
export declare function duplicateCalloutChildTransaction(source: string, doc: EditorDocument, blockIndex: number, childId: string): TransactionBuildResult;
|
|
34
|
+
export declare function calloutBodyTreeDropTransaction(source: string, doc: EditorDocument, _blockIndex: number, draggedId: string, targetId: string, placement: TreeDropPlacement): TransactionBuildResult;
|
|
35
|
+
export declare function calloutDocumentStructMutation(source: string, doc: EditorDocument, calloutBlockIndex: number, anchorBlockId: string, mutate: (blocks: EditorBlock[]) => EditorBlock[] | null, txId: string, caretBlockId?: string): TransactionBuildResult;
|
|
36
|
+
export { siblingFocusIdForCalloutDelete };
|