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,15 @@
|
|
|
1
|
+
/** `---`, `***`, or `___` (3+ of one kind), optional leading/trailing whitespace only. */
|
|
2
|
+
const HR_LINE = /^\s*(?:-{3,}|\*{3,}|_{3,})\s*$/;
|
|
3
|
+
export function isHorizontalRuleLine(line) {
|
|
4
|
+
return HR_LINE.test(line);
|
|
5
|
+
}
|
|
6
|
+
export function parseHorizontalRules(source) {
|
|
7
|
+
const lines = source.split(/\r?\n/);
|
|
8
|
+
const out = [];
|
|
9
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10
|
+
if (HR_LINE.test(lines[i])) {
|
|
11
|
+
out.push({ lineIndex: i });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import EditableHorizontalRule from '../blocks/EditableHorizontalRule.svelte';
|
|
2
|
+
import { horizontalRuleCommands } from './horizontalRule/commands';
|
|
3
|
+
import { applyHorizontalRuleInlineSecondPass } from './horizontalRule/inlineSecondPass';
|
|
4
|
+
import { isHorizontalRuleLine, parseHorizontalRules } from './horizontalRule/parse';
|
|
5
|
+
import { horizontalRuleReconcileFingerprint } from './horizontalRule/reconcile';
|
|
6
|
+
import { serializeHorizontalRuleBlock } from './horizontalRule/serialize';
|
|
7
|
+
import { horizontalRuleRenderer } from './horizontalRule/HorizontalRuleRenderer.svelte';
|
|
8
|
+
export const horizontalRuleSpec = {
|
|
9
|
+
type: 'horizontalRule',
|
|
10
|
+
id: 'horizontal-rule',
|
|
11
|
+
render: horizontalRuleRenderer,
|
|
12
|
+
editComponent: EditableHorizontalRule,
|
|
13
|
+
parse: { isHorizontalRuleLine, parseHorizontalRules },
|
|
14
|
+
serialize: serializeHorizontalRuleBlock,
|
|
15
|
+
applyInlineSecondPass: applyHorizontalRuleInlineSecondPass,
|
|
16
|
+
reconcileFingerprint: horizontalRuleReconcileFingerprint,
|
|
17
|
+
commands: horizontalRuleCommands,
|
|
18
|
+
toRenderBlock: (block) => ({
|
|
19
|
+
id: block.id,
|
|
20
|
+
pluginId: 'horizontal-rule',
|
|
21
|
+
data: block.data,
|
|
22
|
+
render: horizontalRuleRenderer
|
|
23
|
+
})
|
|
24
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { StatusCheckbox } from 'phoundry-ui';
|
|
3
|
+
import type { EditorBlock, ListItemBlockData } from '../../model/types';
|
|
4
|
+
import { taskCheckboxStates } from '../../taskCheckboxStates.js';
|
|
5
|
+
import { inlineNodesSnippet } from '../../plugins/shared/InlineNodes.svelte';
|
|
6
|
+
|
|
7
|
+
const listClass = {
|
|
8
|
+
ul: 'list-outside pl-5 text-base text-txt-primary marker:text-txt-tertiary',
|
|
9
|
+
ol: 'list-outside pl-5 text-base text-txt-primary marker:text-txt-tertiary'
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
const itemRowClass = 'flex items-start gap-2 leading-relaxed';
|
|
13
|
+
|
|
14
|
+
function itemData(item: EditorBlock): ListItemBlockData {
|
|
15
|
+
return item.data as ListItemBlockData;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { listItemRenderer };
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
{#snippet taskCheckbox(data: ListItemBlockData)}
|
|
22
|
+
<div class="flex h-lh shrink-0 items-center">
|
|
23
|
+
<StatusCheckbox
|
|
24
|
+
activeKey={data.task!}
|
|
25
|
+
states={taskCheckboxStates}
|
|
26
|
+
fallbackChar={data.task === 'other' ? data.taskMarkerChar : undefined}
|
|
27
|
+
ariaLabelPrefix="Task"
|
|
28
|
+
disabled
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
{/snippet}
|
|
32
|
+
|
|
33
|
+
{#snippet listItemNode(item: EditorBlock)}
|
|
34
|
+
{@const data = itemData(item)}
|
|
35
|
+
<li>
|
|
36
|
+
<div class={itemRowClass}>
|
|
37
|
+
{#if data.task !== undefined}
|
|
38
|
+
{@render taskCheckbox(data)}
|
|
39
|
+
{/if}
|
|
40
|
+
<span class="min-w-0 flex-1 pt-0.5">
|
|
41
|
+
{#if item.inlines && item.inlines.length > 0}
|
|
42
|
+
{@render inlineNodesSnippet(item.inlines)}
|
|
43
|
+
{/if}
|
|
44
|
+
</span>
|
|
45
|
+
</div>
|
|
46
|
+
{#each item.children ?? [] as child (child.id)}
|
|
47
|
+
{#if child.type === 'listItem'}
|
|
48
|
+
<div class="pl-4">
|
|
49
|
+
<ul class={`${listClass.ul} list-disc`}>
|
|
50
|
+
{@render listItemNode(child)}
|
|
51
|
+
</ul>
|
|
52
|
+
</div>
|
|
53
|
+
{/if}
|
|
54
|
+
{/each}
|
|
55
|
+
</li>
|
|
56
|
+
{/snippet}
|
|
57
|
+
|
|
58
|
+
{#snippet listItemRenderer(block: EditorBlock)}
|
|
59
|
+
<div class="mb-4">
|
|
60
|
+
{#if (block.data as ListItemBlockData).ordered}
|
|
61
|
+
<ol class={`${listClass.ol} list-decimal`} start={(block.data as ListItemBlockData).ordinalValue}>
|
|
62
|
+
{@render listItemNode(block)}
|
|
63
|
+
</ol>
|
|
64
|
+
{:else}
|
|
65
|
+
<ul class={`${listClass.ul} list-disc`}>
|
|
66
|
+
{@render listItemNode(block)}
|
|
67
|
+
</ul>
|
|
68
|
+
{/if}
|
|
69
|
+
</div>
|
|
70
|
+
{/snippet}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
declare const listItemRenderer: (block: EditorBlock) => ReturnType<import("svelte").Snippet>;
|
|
3
|
+
export { listItemRenderer };
|
|
4
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
14
|
+
};
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
16
|
+
}
|
|
17
|
+
declare const ListRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type ListRenderer = InstanceType<typeof ListRenderer>;
|
|
21
|
+
export default ListRenderer;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const moveShortcut = { ariaKeyShortcuts: 'Alt+Shift+ArrowUp' };
|
|
2
|
+
const moveDownShortcut = { ariaKeyShortcuts: 'Alt+Shift+ArrowDown' };
|
|
3
|
+
function isListItemRow(ctx) {
|
|
4
|
+
return ctx.nestedRowBlockId !== undefined && ctx.nestedRowBlockType === 'listItem';
|
|
5
|
+
}
|
|
6
|
+
export const listCommands = [
|
|
7
|
+
{
|
|
8
|
+
id: 'duplicateListItem',
|
|
9
|
+
label: 'Duplicate',
|
|
10
|
+
group: 'structure',
|
|
11
|
+
surfaces: ['blockMenu'],
|
|
12
|
+
blockTypes: ['listItem'],
|
|
13
|
+
nestedRowOnly: true,
|
|
14
|
+
isEnabled: (ctx) => isListItemRow(ctx),
|
|
15
|
+
run: (ctx) => {
|
|
16
|
+
if (!ctx.nestedRowBlockId)
|
|
17
|
+
return;
|
|
18
|
+
ctx.editor.duplicateListItemAt(ctx.blockIndex, ctx.nestedRowBlockId);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'deleteListItem',
|
|
23
|
+
label: 'Delete',
|
|
24
|
+
group: 'structure',
|
|
25
|
+
surfaces: ['blockMenu'],
|
|
26
|
+
blockTypes: ['listItem'],
|
|
27
|
+
nestedRowOnly: true,
|
|
28
|
+
isEnabled: (ctx) => isListItemRow(ctx),
|
|
29
|
+
run: (ctx) => {
|
|
30
|
+
if (!ctx.nestedRowBlockId)
|
|
31
|
+
return;
|
|
32
|
+
ctx.editor.deleteListItemAt(ctx.blockIndex, ctx.nestedRowBlockId);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'moveListItemUp',
|
|
37
|
+
label: 'Move up',
|
|
38
|
+
group: 'structure',
|
|
39
|
+
surfaces: ['blockMenu'],
|
|
40
|
+
blockTypes: ['listItem'],
|
|
41
|
+
nestedRowOnly: true,
|
|
42
|
+
isEnabled: (ctx) => isListItemRow(ctx) && ctx.canMoveUp,
|
|
43
|
+
run: (ctx) => {
|
|
44
|
+
if (!ctx.nestedRowBlockId)
|
|
45
|
+
return;
|
|
46
|
+
ctx.editor.moveListItemSiblingAt(ctx.blockIndex, ctx.nestedRowBlockId, 'up');
|
|
47
|
+
},
|
|
48
|
+
shortcut: moveShortcut
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'moveListItemDown',
|
|
52
|
+
label: 'Move down',
|
|
53
|
+
group: 'structure',
|
|
54
|
+
surfaces: ['blockMenu'],
|
|
55
|
+
blockTypes: ['listItem'],
|
|
56
|
+
nestedRowOnly: true,
|
|
57
|
+
isEnabled: (ctx) => isListItemRow(ctx) && ctx.canMoveDown,
|
|
58
|
+
run: (ctx) => {
|
|
59
|
+
if (!ctx.nestedRowBlockId)
|
|
60
|
+
return;
|
|
61
|
+
ctx.editor.moveListItemSiblingAt(ctx.blockIndex, ctx.nestedRowBlockId, 'down');
|
|
62
|
+
},
|
|
63
|
+
shortcut: moveDownShortcut
|
|
64
|
+
}
|
|
65
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { listCommands } from './commands';
|
|
2
|
+
export { applyListItemInlineSecondPass } from './inlineSecondPass';
|
|
3
|
+
export { buildForest, buildListItemForest, buildListBlockTree, parseListLine, parseLists, taskCheckboxFromMarker } from './parse';
|
|
4
|
+
export { listItemReconcileFingerprint } from './reconcile';
|
|
5
|
+
export { serializeListItem, serializeListRegion } from './serialize';
|
|
6
|
+
export type { ListItemNode, ListsRegion, ListTree, ParsedListLine } from './types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { listCommands } from './commands';
|
|
2
|
+
export { applyListItemInlineSecondPass } from './inlineSecondPass';
|
|
3
|
+
export { buildForest, buildListItemForest, buildListBlockTree, parseListLine, parseLists, taskCheckboxFromMarker } from './parse';
|
|
4
|
+
export { listItemReconcileFingerprint } from './reconcile';
|
|
5
|
+
export { serializeListItem, serializeListRegion } from './serialize';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
import { type RichInlineContext } from '../../model/richInlines';
|
|
3
|
+
import type { LineRow } from '../../model/line-utils';
|
|
4
|
+
type AnnotateBlockFn = (block: EditorBlock, source: string, rows: LineRow[], ctx: RichInlineContext, insideBlockquote: boolean) => EditorBlock;
|
|
5
|
+
export declare function applyListItemInlineSecondPass(block: EditorBlock, source: string, rows: LineRow[], ctx: RichInlineContext, insideBlockquote: boolean, annotateBlock: AnnotateBlockFn): EditorBlock;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { buildRichInlinesForRange } from '../../model/richInlines';
|
|
2
|
+
function offsetToLine(source, offset) {
|
|
3
|
+
let line = 0;
|
|
4
|
+
const upto = Math.min(Math.max(0, offset), source.length);
|
|
5
|
+
for (let i = 0; i < upto; i++) {
|
|
6
|
+
if (source[i] === '\n')
|
|
7
|
+
line++;
|
|
8
|
+
}
|
|
9
|
+
return line;
|
|
10
|
+
}
|
|
11
|
+
function listItemTextRange(row, source) {
|
|
12
|
+
const line = row.line;
|
|
13
|
+
let i = 0;
|
|
14
|
+
while (i < line.length) {
|
|
15
|
+
const ch = line[i];
|
|
16
|
+
if (ch === ' ' || ch === '\t') {
|
|
17
|
+
i++;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const rest = line.slice(i);
|
|
24
|
+
const taskUm = rest.match(/^([-*+])([ \t]+)\[[^\]]+\]([ \t]+)(.*)$/);
|
|
25
|
+
const taskOm = rest.match(/^(\d+)\.([ \t]+)\[[^\]]+\]([ \t]+)(.*)$/);
|
|
26
|
+
const tm = taskUm ?? taskOm;
|
|
27
|
+
if (tm) {
|
|
28
|
+
const payload = tm[4] ?? '';
|
|
29
|
+
const markerLen = tm[0].length - payload.length;
|
|
30
|
+
const textStart = row.start + i + markerLen;
|
|
31
|
+
const text = payload.trimEnd();
|
|
32
|
+
const textEnd = textStart + text.length;
|
|
33
|
+
return {
|
|
34
|
+
start: textStart,
|
|
35
|
+
end: textEnd,
|
|
36
|
+
startLine: offsetToLine(source, textStart),
|
|
37
|
+
endLine: offsetToLine(source, Math.max(textStart, textEnd - 1))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const um = rest.match(/^([-*+])([ \t]+)(.*)$/);
|
|
41
|
+
const om = rest.match(/^(\d+)\.([ \t]+)(.*)$/);
|
|
42
|
+
const m = um ?? om;
|
|
43
|
+
if (!m) {
|
|
44
|
+
return {
|
|
45
|
+
start: row.start,
|
|
46
|
+
end: row.end,
|
|
47
|
+
startLine: offsetToLine(source, row.start),
|
|
48
|
+
endLine: offsetToLine(source, row.start)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const payload = m[3] ?? '';
|
|
52
|
+
const markerLen = m[0].length - payload.length;
|
|
53
|
+
const textStart = row.start + i + markerLen;
|
|
54
|
+
const text = payload.trimEnd();
|
|
55
|
+
const textEnd = textStart + text.length;
|
|
56
|
+
return {
|
|
57
|
+
start: textStart,
|
|
58
|
+
end: textEnd,
|
|
59
|
+
startLine: offsetToLine(source, textStart),
|
|
60
|
+
endLine: offsetToLine(source, Math.max(textStart, textEnd - 1))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function applyListItemInlineSecondPass(block, source, rows, ctx, insideBlockquote, annotateBlock) {
|
|
64
|
+
if (block.type !== 'listItem')
|
|
65
|
+
return block;
|
|
66
|
+
const row = rows[block.sourceRange.startLine];
|
|
67
|
+
const inlines = row
|
|
68
|
+
? (() => {
|
|
69
|
+
const tr = listItemTextRange(row, source);
|
|
70
|
+
return buildRichInlinesForRange(source, tr.start, tr.end, ctx);
|
|
71
|
+
})()
|
|
72
|
+
: [];
|
|
73
|
+
const out = { ...block, inlines };
|
|
74
|
+
if (block.children && block.children.length > 0) {
|
|
75
|
+
out.children = block.children.map((c) => annotateBlock(c, source, rows, ctx, insideBlockquote));
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type LineRow } from '../../model/line-utils';
|
|
2
|
+
import type { EditorBlock, TaskCheckboxState } from '../../model/types';
|
|
3
|
+
import type { ListTree, ListsRegion, ParsedListLine } from './types';
|
|
4
|
+
export declare function taskCheckboxFromMarker(ch: string): TaskCheckboxState;
|
|
5
|
+
export declare function parseListLine(line: string, lineIndex: number): ParsedListLine | null;
|
|
6
|
+
export declare function buildForest(lines: ParsedListLine[]): ListTree[];
|
|
7
|
+
export declare function parseLists(source: string): ListsRegion[];
|
|
8
|
+
/** Build flat `listItem` forest from a contiguous chunk of list lines (Notion-style nesting). */
|
|
9
|
+
export declare function buildListItemForest(chunk: ParsedListLine[], source: string, rows: LineRow[]): EditorBlock[];
|
|
10
|
+
/** @deprecated Use {@link buildListItemForest}. */
|
|
11
|
+
export declare function buildListBlockTree(chunk: ParsedListLine[], source: string, rows: LineRow[]): EditorBlock[];
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { afterLineTerminator } from '../../model/line-utils';
|
|
2
|
+
import { stableBlockId } from '../../model/types';
|
|
3
|
+
const UNORDERED = /^([-*+])([ \t]+)(.*)$/;
|
|
4
|
+
const ORDERED = /^(\d+)\.([ \t]+)(.*)$/;
|
|
5
|
+
const TASK_UNORDERED = /^([-*+])([ \t]+)\[([^\]]+)\]([ \t]+)(.*)$/;
|
|
6
|
+
const TASK_ORDERED = /^(\d+)\.([ \t]+)\[([^\]]+)\]([ \t]+)(.*)$/;
|
|
7
|
+
function tabAdvance(col) {
|
|
8
|
+
return col + (4 - (col % 4 || 4));
|
|
9
|
+
}
|
|
10
|
+
function leadingColumns(line) {
|
|
11
|
+
let col = 0;
|
|
12
|
+
let i = 0;
|
|
13
|
+
while (i < line.length) {
|
|
14
|
+
const ch = line[i];
|
|
15
|
+
if (ch === ' ') {
|
|
16
|
+
col++;
|
|
17
|
+
i++;
|
|
18
|
+
}
|
|
19
|
+
else if (ch === '\t') {
|
|
20
|
+
col = tabAdvance(col);
|
|
21
|
+
i++;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { columns: col, start: i };
|
|
28
|
+
}
|
|
29
|
+
export function taskCheckboxFromMarker(ch) {
|
|
30
|
+
if (ch === ' ' || ch === undefined)
|
|
31
|
+
return 'todo';
|
|
32
|
+
const u = ch.toLowerCase();
|
|
33
|
+
if (u === 'x')
|
|
34
|
+
return 'done';
|
|
35
|
+
if (ch === '/')
|
|
36
|
+
return 'in_progress';
|
|
37
|
+
if (ch === '>')
|
|
38
|
+
return 'deferred';
|
|
39
|
+
return 'other';
|
|
40
|
+
}
|
|
41
|
+
export function parseListLine(line, lineIndex) {
|
|
42
|
+
const { columns: indent, start } = leadingColumns(line);
|
|
43
|
+
const rest = line.slice(start);
|
|
44
|
+
let tm = rest.match(TASK_UNORDERED);
|
|
45
|
+
if (tm) {
|
|
46
|
+
return {
|
|
47
|
+
lineIndex,
|
|
48
|
+
indent,
|
|
49
|
+
ordered: false,
|
|
50
|
+
taskMarker: tm[3],
|
|
51
|
+
text: (tm[5] ?? '').trimEnd()
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
tm = rest.match(TASK_ORDERED);
|
|
55
|
+
if (tm) {
|
|
56
|
+
const orderValue = Number.parseInt(tm[1], 10);
|
|
57
|
+
if (!Number.isFinite(orderValue))
|
|
58
|
+
return null;
|
|
59
|
+
return {
|
|
60
|
+
lineIndex,
|
|
61
|
+
indent,
|
|
62
|
+
ordered: true,
|
|
63
|
+
orderValue,
|
|
64
|
+
taskMarker: tm[3],
|
|
65
|
+
text: (tm[5] ?? '').trimEnd()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
let m = rest.match(UNORDERED);
|
|
69
|
+
if (m) {
|
|
70
|
+
return {
|
|
71
|
+
lineIndex,
|
|
72
|
+
indent,
|
|
73
|
+
ordered: false,
|
|
74
|
+
text: m[3].trimEnd()
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
m = rest.match(ORDERED);
|
|
78
|
+
if (m) {
|
|
79
|
+
const orderValue = Number.parseInt(m[1], 10);
|
|
80
|
+
if (!Number.isFinite(orderValue))
|
|
81
|
+
return null;
|
|
82
|
+
return {
|
|
83
|
+
lineIndex,
|
|
84
|
+
indent,
|
|
85
|
+
ordered: true,
|
|
86
|
+
orderValue,
|
|
87
|
+
text: m[3].trimEnd()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function createList(ordered, orderValue) {
|
|
93
|
+
const start = ordered && orderValue !== undefined && orderValue !== 1 ? orderValue : undefined;
|
|
94
|
+
return { ordered, start, items: [] };
|
|
95
|
+
}
|
|
96
|
+
function appendItem(list, text) {
|
|
97
|
+
const node = { text, nested: [] };
|
|
98
|
+
list.items.push(node);
|
|
99
|
+
return node;
|
|
100
|
+
}
|
|
101
|
+
export function buildForest(lines) {
|
|
102
|
+
if (lines.length === 0)
|
|
103
|
+
return [];
|
|
104
|
+
const roots = [];
|
|
105
|
+
const stack = [];
|
|
106
|
+
const first = lines[0];
|
|
107
|
+
const rootList = createList(first.ordered, first.orderValue);
|
|
108
|
+
roots.push(rootList);
|
|
109
|
+
const firstItem = appendItem(rootList, first.text);
|
|
110
|
+
stack.push({ list: rootList, markerCol: first.indent, lastItem: firstItem });
|
|
111
|
+
for (let i = 1; i < lines.length; i++) {
|
|
112
|
+
const line = lines[i];
|
|
113
|
+
while (stack.length && line.indent < stack[stack.length - 1].markerCol) {
|
|
114
|
+
stack.pop();
|
|
115
|
+
}
|
|
116
|
+
if (stack.length === 0) {
|
|
117
|
+
const list = createList(line.ordered, line.orderValue);
|
|
118
|
+
roots.push(list);
|
|
119
|
+
const item = appendItem(list, line.text);
|
|
120
|
+
stack.push({ list, markerCol: line.indent, lastItem: item });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const top = stack[stack.length - 1];
|
|
124
|
+
if (line.indent > top.markerCol) {
|
|
125
|
+
const anchor = top.lastItem ?? top.list.items[top.list.items.length - 1] ?? null;
|
|
126
|
+
if (!anchor) {
|
|
127
|
+
const item = appendItem(top.list, line.text);
|
|
128
|
+
top.lastItem = item;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const nested = createList(line.ordered, line.orderValue);
|
|
132
|
+
anchor.nested.push(nested);
|
|
133
|
+
const item = appendItem(nested, line.text);
|
|
134
|
+
stack.push({ list: nested, markerCol: line.indent, lastItem: item });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (line.indent === top.markerCol && line.ordered === top.list.ordered) {
|
|
138
|
+
const item = appendItem(top.list, line.text);
|
|
139
|
+
top.lastItem = item;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
stack.pop();
|
|
143
|
+
const parent = stack[stack.length - 1];
|
|
144
|
+
const newList = createList(line.ordered, line.orderValue);
|
|
145
|
+
if (parent?.lastItem) {
|
|
146
|
+
parent.lastItem.nested.push(newList);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
roots.push(newList);
|
|
150
|
+
}
|
|
151
|
+
const item = appendItem(newList, line.text);
|
|
152
|
+
stack.push({ list: newList, markerCol: line.indent, lastItem: item });
|
|
153
|
+
}
|
|
154
|
+
return roots;
|
|
155
|
+
}
|
|
156
|
+
function isBlank(line) {
|
|
157
|
+
return line.trim() === '';
|
|
158
|
+
}
|
|
159
|
+
export function parseLists(source) {
|
|
160
|
+
const lines = source.split(/\r?\n/);
|
|
161
|
+
const regions = [];
|
|
162
|
+
let i = 0;
|
|
163
|
+
while (i < lines.length) {
|
|
164
|
+
if (isBlank(lines[i])) {
|
|
165
|
+
i++;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const parsed = parseListLine(lines[i], i);
|
|
169
|
+
if (!parsed) {
|
|
170
|
+
i++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const chunk = [parsed];
|
|
174
|
+
let j = i + 1;
|
|
175
|
+
while (j < lines.length) {
|
|
176
|
+
const raw = lines[j];
|
|
177
|
+
if (isBlank(raw))
|
|
178
|
+
break;
|
|
179
|
+
const next = parseListLine(raw, j);
|
|
180
|
+
if (!next)
|
|
181
|
+
break;
|
|
182
|
+
chunk.push(next);
|
|
183
|
+
j++;
|
|
184
|
+
}
|
|
185
|
+
regions.push({
|
|
186
|
+
startLine: i,
|
|
187
|
+
endLine: j - 1,
|
|
188
|
+
roots: buildForest(chunk)
|
|
189
|
+
});
|
|
190
|
+
i = j;
|
|
191
|
+
}
|
|
192
|
+
return regions;
|
|
193
|
+
}
|
|
194
|
+
function expandItemSubtreeRanges(block) {
|
|
195
|
+
let maxEnd = block.sourceRange.end;
|
|
196
|
+
let maxLine = block.sourceRange.endLine;
|
|
197
|
+
if (block.children) {
|
|
198
|
+
for (const child of block.children) {
|
|
199
|
+
const r = expandItemSubtreeRanges(child);
|
|
200
|
+
if (r.end > maxEnd) {
|
|
201
|
+
maxEnd = r.end;
|
|
202
|
+
maxLine = r.endLine;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return { end: maxEnd, endLine: maxLine };
|
|
207
|
+
}
|
|
208
|
+
function makeListItemBlock(line, source, rows) {
|
|
209
|
+
const task = line.taskMarker !== undefined ? taskCheckboxFromMarker(line.taskMarker) : undefined;
|
|
210
|
+
const data = {
|
|
211
|
+
ordered: line.ordered,
|
|
212
|
+
...(line.orderValue !== undefined ? { ordinalValue: line.orderValue } : {}),
|
|
213
|
+
indentColumns: line.indent,
|
|
214
|
+
...(task !== undefined
|
|
215
|
+
? {
|
|
216
|
+
task,
|
|
217
|
+
...(task === 'other' && line.taskMarker !== undefined
|
|
218
|
+
? { taskMarkerChar: line.taskMarker }
|
|
219
|
+
: {})
|
|
220
|
+
}
|
|
221
|
+
: {})
|
|
222
|
+
};
|
|
223
|
+
const range = rangeForRow(source, rows[line.lineIndex], line.lineIndex);
|
|
224
|
+
return {
|
|
225
|
+
type: 'listItem',
|
|
226
|
+
id: stableBlockId('listItem', range),
|
|
227
|
+
sourceRange: range,
|
|
228
|
+
data,
|
|
229
|
+
children: []
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function rangeForRow(source, row, lineIndex) {
|
|
233
|
+
return {
|
|
234
|
+
start: row.start,
|
|
235
|
+
end: afterLineTerminator(source, row),
|
|
236
|
+
startLine: lineIndex,
|
|
237
|
+
endLine: lineIndex
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/** Build flat `listItem` forest from a contiguous chunk of list lines (Notion-style nesting). */
|
|
241
|
+
export function buildListItemForest(chunk, source, rows) {
|
|
242
|
+
if (chunk.length === 0)
|
|
243
|
+
return [];
|
|
244
|
+
const roots = [];
|
|
245
|
+
const stack = [];
|
|
246
|
+
const pushItem = (line, items) => {
|
|
247
|
+
const item = makeListItemBlock(line, source, rows);
|
|
248
|
+
items.push(item);
|
|
249
|
+
return item;
|
|
250
|
+
};
|
|
251
|
+
const first = chunk[0];
|
|
252
|
+
const firstItem = pushItem(first, roots);
|
|
253
|
+
stack.push({ items: roots, markerCol: first.indent, ordered: first.ordered, lastItem: firstItem });
|
|
254
|
+
for (let i = 1; i < chunk.length; i++) {
|
|
255
|
+
const line = chunk[i];
|
|
256
|
+
while (stack.length && line.indent < stack[stack.length - 1].markerCol) {
|
|
257
|
+
stack.pop();
|
|
258
|
+
}
|
|
259
|
+
if (stack.length === 0) {
|
|
260
|
+
const item = pushItem(line, roots);
|
|
261
|
+
stack.push({ items: roots, markerCol: line.indent, ordered: line.ordered, lastItem: item });
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const top = stack[stack.length - 1];
|
|
265
|
+
if (line.indent > top.markerCol) {
|
|
266
|
+
const anchor = top.lastItem;
|
|
267
|
+
if (!anchor) {
|
|
268
|
+
const item = pushItem(line, top.items);
|
|
269
|
+
top.lastItem = item;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (!anchor.children)
|
|
273
|
+
anchor.children = [];
|
|
274
|
+
const item = pushItem(line, anchor.children);
|
|
275
|
+
stack.push({
|
|
276
|
+
items: anchor.children,
|
|
277
|
+
markerCol: line.indent,
|
|
278
|
+
ordered: line.ordered,
|
|
279
|
+
lastItem: item
|
|
280
|
+
});
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (line.indent === top.markerCol && line.ordered === top.ordered) {
|
|
284
|
+
const item = pushItem(line, top.items);
|
|
285
|
+
top.lastItem = item;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
stack.pop();
|
|
289
|
+
const parentFrame = stack[stack.length - 1];
|
|
290
|
+
let targetItems;
|
|
291
|
+
if (parentFrame?.lastItem && line.indent > parentFrame.markerCol) {
|
|
292
|
+
if (!parentFrame.lastItem.children)
|
|
293
|
+
parentFrame.lastItem.children = [];
|
|
294
|
+
targetItems = parentFrame.lastItem.children;
|
|
295
|
+
}
|
|
296
|
+
else if (parentFrame) {
|
|
297
|
+
targetItems = parentFrame.items;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
targetItems = roots;
|
|
301
|
+
}
|
|
302
|
+
const item = pushItem(line, targetItems);
|
|
303
|
+
stack.push({ items: targetItems, markerCol: line.indent, ordered: line.ordered, lastItem: item });
|
|
304
|
+
}
|
|
305
|
+
for (const root of roots)
|
|
306
|
+
expandItemSubtreeRanges(root);
|
|
307
|
+
return roots;
|
|
308
|
+
}
|
|
309
|
+
/** @deprecated Use {@link buildListItemForest}. */
|
|
310
|
+
export function buildListBlockTree(chunk, source, rows) {
|
|
311
|
+
return buildListItemForest(chunk, source, rows);
|
|
312
|
+
}
|