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,4 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
export declare function serializeListItem(item: EditorBlock, source?: string): string;
|
|
3
|
+
/** Serialize a contiguous run of top-level {@link EditorBlock.type} `listItem` blocks. */
|
|
4
|
+
export declare function serializeListRegion(items: EditorBlock[], source?: string): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { serializeEditorBlock } from '../../model/serializeMarkdownDocument';
|
|
2
|
+
import { serializeInlineNodes } from '../../model/serializeInlineNodes';
|
|
3
|
+
function indentLines(text, prefix) {
|
|
4
|
+
return text
|
|
5
|
+
.split('\n')
|
|
6
|
+
.map((l) => prefix + l)
|
|
7
|
+
.join('\n');
|
|
8
|
+
}
|
|
9
|
+
/** Recover list item body from the original line slice when `inlines` are absent. */
|
|
10
|
+
function listItemBodyFromSource(item, source) {
|
|
11
|
+
if (!source)
|
|
12
|
+
return '';
|
|
13
|
+
if (item.sourceRange.start < 0 || item.sourceRange.synthetic)
|
|
14
|
+
return '';
|
|
15
|
+
const slice = source.slice(item.sourceRange.start, item.sourceRange.end);
|
|
16
|
+
const firstLine = slice.split('\n')[0] ?? '';
|
|
17
|
+
const taskUm = firstLine.match(/^\s*[-*+][ \t]+\[[^\]]+\][ \t]+(.*)$/);
|
|
18
|
+
const taskOm = firstLine.match(/^\s*\d+\.[ \t]+\[[^\]]+\][ \t]+(.*)$/);
|
|
19
|
+
const tm = taskUm ?? taskOm;
|
|
20
|
+
if (tm)
|
|
21
|
+
return (tm[1] ?? '').trimEnd();
|
|
22
|
+
const um = firstLine.match(/^\s*[-*+][ \t]+(.*)$/);
|
|
23
|
+
const om = firstLine.match(/^\s*\d+\.[ \t]+(.*)$/);
|
|
24
|
+
const m = um ?? om;
|
|
25
|
+
return (m ? m[1] : firstLine).trimEnd();
|
|
26
|
+
}
|
|
27
|
+
function serializeListItemChild(child, source) {
|
|
28
|
+
if (child.type === 'listItem')
|
|
29
|
+
return serializeListItem(child, source);
|
|
30
|
+
return serializeEditorBlock(child, source);
|
|
31
|
+
}
|
|
32
|
+
export function serializeListItem(item, source) {
|
|
33
|
+
const data = item.data;
|
|
34
|
+
const body = item.inlines && item.inlines.length > 0
|
|
35
|
+
? serializeInlineNodes(item.inlines)
|
|
36
|
+
: listItemBodyFromSource(item, source);
|
|
37
|
+
let leader;
|
|
38
|
+
if (data.task !== undefined) {
|
|
39
|
+
const inner = data.taskMarkerChar ??
|
|
40
|
+
(data.task === 'todo'
|
|
41
|
+
? ' '
|
|
42
|
+
: data.task === 'done'
|
|
43
|
+
? 'x'
|
|
44
|
+
: data.task === 'in_progress'
|
|
45
|
+
? '/'
|
|
46
|
+
: data.task === 'deferred'
|
|
47
|
+
? '>'
|
|
48
|
+
: '?');
|
|
49
|
+
const box = `[${inner}]`;
|
|
50
|
+
leader = data.ordered ? `${data.ordinalValue ?? 1}. ${box}` : `- ${box}`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
leader = data.ordered ? `${data.ordinalValue ?? 1}.` : '-';
|
|
54
|
+
}
|
|
55
|
+
const head = body.length > 0
|
|
56
|
+
? `${leader} ${body}`
|
|
57
|
+
: `${leader}${/\s$/.test(leader) ? '' : ' '}`;
|
|
58
|
+
if (!item.children || item.children.length === 0)
|
|
59
|
+
return head;
|
|
60
|
+
const lines = [head];
|
|
61
|
+
for (const child of item.children) {
|
|
62
|
+
const childMd = serializeListItemChild(child, source);
|
|
63
|
+
lines.push(indentLines(childMd, ' '));
|
|
64
|
+
}
|
|
65
|
+
return lines.join('\n');
|
|
66
|
+
}
|
|
67
|
+
/** Serialize a contiguous run of top-level {@link EditorBlock.type} `listItem` blocks. */
|
|
68
|
+
export function serializeListRegion(items, source) {
|
|
69
|
+
const segments = [];
|
|
70
|
+
let i = 0;
|
|
71
|
+
while (i < items.length) {
|
|
72
|
+
const ordered = items[i].data.ordered;
|
|
73
|
+
const run = [];
|
|
74
|
+
while (i < items.length &&
|
|
75
|
+
items[i].type === 'listItem' &&
|
|
76
|
+
items[i].data.ordered === ordered) {
|
|
77
|
+
run.push(items[i]);
|
|
78
|
+
i++;
|
|
79
|
+
}
|
|
80
|
+
segments.push(run.map((it) => serializeListItem(it, source)).join('\n'));
|
|
81
|
+
}
|
|
82
|
+
return segments.join('\n');
|
|
83
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ParsedListLine = {
|
|
2
|
+
lineIndex: number;
|
|
3
|
+
indent: number;
|
|
4
|
+
ordered: boolean;
|
|
5
|
+
orderValue?: number;
|
|
6
|
+
text: string;
|
|
7
|
+
/** Single-character checkbox marker when this is a task item. */
|
|
8
|
+
taskMarker?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ListTree = {
|
|
11
|
+
ordered: boolean;
|
|
12
|
+
/** For `<ol start="…">` when the first marker is not `1`. */
|
|
13
|
+
start?: number;
|
|
14
|
+
items: ListItemNode[];
|
|
15
|
+
};
|
|
16
|
+
export type ListItemNode = {
|
|
17
|
+
text: string;
|
|
18
|
+
/** Sibling nested lists under this item (e.g. `ul` then `ol` at the same indent). */
|
|
19
|
+
nested: ListTree[];
|
|
20
|
+
};
|
|
21
|
+
export type ListsRegion = {
|
|
22
|
+
startLine: number;
|
|
23
|
+
endLine: number;
|
|
24
|
+
/** One or more top-level lists (e.g. `ul` then `ol` at column 0). */
|
|
25
|
+
roots: ListTree[];
|
|
26
|
+
itemLineIndices?: number[];
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import EditableList from '../blocks/EditableList.svelte';
|
|
2
|
+
import { listCommands } from './list/commands';
|
|
3
|
+
import { listItemRenderer } from './list/ListRenderer.svelte';
|
|
4
|
+
import { buildListItemForest, parseListLine, taskCheckboxFromMarker } from './list/parse';
|
|
5
|
+
import { listItemReconcileFingerprint } from './list/reconcile';
|
|
6
|
+
import { serializeListItem } from './list/serialize';
|
|
7
|
+
export const listSpec = {
|
|
8
|
+
type: 'listItem',
|
|
9
|
+
id: 'lists',
|
|
10
|
+
render: listItemRenderer,
|
|
11
|
+
editComponent: EditableList,
|
|
12
|
+
parse: { parseListLine, taskCheckboxFromMarker, buildListItemForest },
|
|
13
|
+
serialize: serializeListItem,
|
|
14
|
+
applyInlineSecondPass: (block) => block,
|
|
15
|
+
reconcileFingerprint: listItemReconcileFingerprint,
|
|
16
|
+
commands: listCommands,
|
|
17
|
+
toRenderBlock: (block) => ({
|
|
18
|
+
id: block.id,
|
|
19
|
+
pluginId: 'lists',
|
|
20
|
+
data: block,
|
|
21
|
+
render: listItemRenderer
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
export { listItemReconcileFingerprint };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { EditorBlock } from '../../model/types';
|
|
3
|
+
import { inlineNodesSnippet } from '../../plugins/shared/InlineNodes.svelte';
|
|
4
|
+
import type { ParagraphBlock } from './types';
|
|
5
|
+
|
|
6
|
+
export { paragraphRenderer };
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#snippet paragraphRenderer(block: EditorBlock)}
|
|
10
|
+
{@const para = block.data as ParagraphBlock}
|
|
11
|
+
<p class="mb-4 leading-relaxed whitespace-pre-wrap text-txt-secondary">
|
|
12
|
+
{#if block.inlines && block.inlines.length > 0}
|
|
13
|
+
{@render inlineNodesSnippet(block.inlines)}
|
|
14
|
+
{:else}
|
|
15
|
+
{#each para.lines as line, i (i)}
|
|
16
|
+
{line.text}{#if line.softBreakAfter}
|
|
17
|
+
<br />
|
|
18
|
+
{:else if i < para.lines.length - 1}<span class="select-none"> </span>{/if}
|
|
19
|
+
{/each}
|
|
20
|
+
{/if}
|
|
21
|
+
</p>
|
|
22
|
+
{/snippet}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
declare const paragraphRenderer: (block: EditorBlock) => ReturnType<import("svelte").Snippet>;
|
|
3
|
+
export { paragraphRenderer };
|
|
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 ParagraphRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type ParagraphRenderer = InstanceType<typeof ParagraphRenderer>;
|
|
21
|
+
export default ParagraphRenderer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function paragraphHeadingLevels() {
|
|
2
|
+
return [1, 2, 3];
|
|
3
|
+
}
|
|
4
|
+
export const paragraphCommands = [
|
|
5
|
+
...paragraphHeadingLevels().map((level) => ({
|
|
6
|
+
id: `convertParagraphToHeading${level}`,
|
|
7
|
+
label: `Heading ${level}`,
|
|
8
|
+
group: 'turnInto',
|
|
9
|
+
surfaces: ['slash', 'blockMenu'],
|
|
10
|
+
blockTypes: ['paragraph'],
|
|
11
|
+
slashKinds: ['paragraph'],
|
|
12
|
+
isEnabled: () => true,
|
|
13
|
+
run: (ctx) => {
|
|
14
|
+
ctx.editor.convertParagraphToHeadingAt(ctx.blockIndex, level);
|
|
15
|
+
}
|
|
16
|
+
})),
|
|
17
|
+
{
|
|
18
|
+
id: 'bulletList',
|
|
19
|
+
label: 'Bullet list',
|
|
20
|
+
group: 'turnInto',
|
|
21
|
+
surfaces: ['slash', 'blockMenu'],
|
|
22
|
+
blockTypes: ['paragraph'],
|
|
23
|
+
slashKinds: ['paragraph'],
|
|
24
|
+
isEnabled: () => true,
|
|
25
|
+
run: (ctx) => {
|
|
26
|
+
ctx.editor.convertParagraphToBulletListAt(ctx.blockIndex);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'turnIntoTableFromParagraph',
|
|
31
|
+
label: 'Table',
|
|
32
|
+
group: 'turnInto',
|
|
33
|
+
surfaces: ['slash', 'blockMenu'],
|
|
34
|
+
blockTypes: ['paragraph'],
|
|
35
|
+
slashKinds: ['paragraph'],
|
|
36
|
+
isEnabled: () => true,
|
|
37
|
+
run: (ctx) => {
|
|
38
|
+
ctx.editor.convertBlockToTableAt(ctx.blockIndex);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
import type { ParagraphBlock } from './types';
|
|
3
|
+
/** Plain-text editing buffer for a paragraph block (matches `linesToParagraphSegments` round-trip). */
|
|
4
|
+
export declare function paragraphBlockToPlainText(p: ParagraphBlock): string;
|
|
5
|
+
export declare function paragraphBlockFromPlainText(text: string, startLineIndex: number): ParagraphBlock;
|
|
6
|
+
/** Join two paragraph blocks into one; marks the boundary with a soft break so load-time split stays one block. */
|
|
7
|
+
export declare function mergeParagraphBlockData(a: ParagraphBlock, b: ParagraphBlock): ParagraphBlock;
|
|
8
|
+
/** Plain text shown in the paragraph editor (prefers inline AST over `lines`). */
|
|
9
|
+
export declare function paragraphDisplayPlain(block: EditorBlock): string;
|
|
10
|
+
export declare function paragraphPlainOffsetToSourceOffset(block: EditorBlock, plainOffset: number): number;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { inlineNodesToPlainText } from '../../model/inlinePlain';
|
|
2
|
+
import { linesToParagraphSegments } from './parse';
|
|
3
|
+
/** Plain-text editing buffer for a paragraph block (matches `linesToParagraphSegments` round-trip). */
|
|
4
|
+
export function paragraphBlockToPlainText(p) {
|
|
5
|
+
if (p.lines.length === 1 && p.lines[0]?.text === ' ')
|
|
6
|
+
return '';
|
|
7
|
+
const parts = [];
|
|
8
|
+
for (let i = 0; i < p.lines.length; i++) {
|
|
9
|
+
const line = p.lines[i];
|
|
10
|
+
parts.push(line.text);
|
|
11
|
+
if (i < p.lines.length - 1) {
|
|
12
|
+
parts.push(line.softBreakAfter ? ' \n' : '\n');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return parts.join('');
|
|
16
|
+
}
|
|
17
|
+
export function paragraphBlockFromPlainText(text, startLineIndex) {
|
|
18
|
+
const rawLines = text.split('\n');
|
|
19
|
+
return { startLineIndex, lines: linesToParagraphSegments(rawLines) };
|
|
20
|
+
}
|
|
21
|
+
/** Join two paragraph blocks into one; marks the boundary with a soft break so load-time split stays one block. */
|
|
22
|
+
export function mergeParagraphBlockData(a, b) {
|
|
23
|
+
const leftLines = a.lines.map((line) => ({ ...line }));
|
|
24
|
+
if (leftLines.length > 0 && b.lines.length > 0) {
|
|
25
|
+
const last = leftLines[leftLines.length - 1];
|
|
26
|
+
leftLines[leftLines.length - 1] = { ...last, softBreakAfter: true };
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
startLineIndex: a.startLineIndex,
|
|
30
|
+
lines: [...leftLines, ...b.lines.map((line) => ({ ...line }))]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Plain text shown in the paragraph editor (prefers inline AST over `lines`). */
|
|
34
|
+
export function paragraphDisplayPlain(block) {
|
|
35
|
+
if (block.type !== 'paragraph')
|
|
36
|
+
return '';
|
|
37
|
+
const plain = block.inlines?.length
|
|
38
|
+
? inlineNodesToPlainText(block.inlines)
|
|
39
|
+
: paragraphBlockToPlainText(block.data);
|
|
40
|
+
// Demoted empty list items materialize as a lone source space — show empty in the editor.
|
|
41
|
+
return plain === ' ' ? '' : plain;
|
|
42
|
+
}
|
|
43
|
+
export function paragraphPlainOffsetToSourceOffset(block, plainOffset) {
|
|
44
|
+
if (block.type !== 'paragraph')
|
|
45
|
+
return block.sourceRange.start;
|
|
46
|
+
const p = block.data;
|
|
47
|
+
let mdPos = block.sourceRange.start;
|
|
48
|
+
let plainAcc = 0;
|
|
49
|
+
for (let i = 0; i < p.lines.length; i++) {
|
|
50
|
+
const line = p.lines[i];
|
|
51
|
+
const t = line.text;
|
|
52
|
+
const remaining = plainOffset - plainAcc;
|
|
53
|
+
if (remaining <= t.length) {
|
|
54
|
+
return mdPos + remaining;
|
|
55
|
+
}
|
|
56
|
+
plainAcc += t.length;
|
|
57
|
+
mdPos += t.length;
|
|
58
|
+
if (i < p.lines.length - 1) {
|
|
59
|
+
const sepPlain = line.softBreakAfter ? 3 : 1;
|
|
60
|
+
const sepMd = line.softBreakAfter ? 3 : 1;
|
|
61
|
+
if (plainOffset <= plainAcc + sepPlain) {
|
|
62
|
+
return mdPos + Math.min(sepMd, Math.max(0, plainOffset - plainAcc));
|
|
63
|
+
}
|
|
64
|
+
plainAcc += sepPlain;
|
|
65
|
+
mdPos += sepMd;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return block.sourceRange.end;
|
|
69
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { paragraphCommands } from './commands';
|
|
2
|
+
export { mergeParagraphBlockData, paragraphBlockFromPlainText, paragraphBlockToPlainText, paragraphDisplayPlain, paragraphPlainOffsetToSourceOffset } from './edit';
|
|
3
|
+
export { applyParagraphInlineSecondPass } from './inlineSecondPass';
|
|
4
|
+
export { linesToParagraphSegments, paragraphBlocksFromLines, parseParagraphs } from './parse';
|
|
5
|
+
export { paragraphReconcileFingerprint } from './reconcile';
|
|
6
|
+
export { serializeParagraphBlock, serializeParagraphData } from './serialize';
|
|
7
|
+
export type { ParagraphBlock, ParagraphLine } from './types';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { paragraphCommands } from './commands';
|
|
2
|
+
export { mergeParagraphBlockData, paragraphBlockFromPlainText, paragraphBlockToPlainText, paragraphDisplayPlain, paragraphPlainOffsetToSourceOffset } from './edit';
|
|
3
|
+
export { applyParagraphInlineSecondPass } from './inlineSecondPass';
|
|
4
|
+
export { linesToParagraphSegments, paragraphBlocksFromLines, parseParagraphs } from './parse';
|
|
5
|
+
export { paragraphReconcileFingerprint } from './reconcile';
|
|
6
|
+
export { serializeParagraphBlock, serializeParagraphData } from './serialize';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
import { type RichInlineContext } from '../../model/richInlines';
|
|
3
|
+
export declare function applyParagraphInlineSecondPass(block: EditorBlock, source: string, insideBlockquote: boolean, ctx: RichInlineContext): EditorBlock;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { buildRichInlinesForRange, createRichInlineContext } from '../../model/richInlines';
|
|
2
|
+
import { withSyntheticRanges } from '../../model/syntheticInlineRanges';
|
|
3
|
+
import { paragraphBlockToPlainText } from './edit';
|
|
4
|
+
function paragraphInlineEnd(source, start, end) {
|
|
5
|
+
if (end <= start)
|
|
6
|
+
return end;
|
|
7
|
+
if (source[end - 1] !== '\n')
|
|
8
|
+
return end;
|
|
9
|
+
return end - (end - 2 >= start && source[end - 2] === '\r' ? 2 : 1);
|
|
10
|
+
}
|
|
11
|
+
export function applyParagraphInlineSecondPass(block, source, insideBlockquote, ctx) {
|
|
12
|
+
if (block.type !== 'paragraph')
|
|
13
|
+
return block;
|
|
14
|
+
if (insideBlockquote) {
|
|
15
|
+
const text = paragraphBlockToPlainText(block.data);
|
|
16
|
+
const innerCtx = createRichInlineContext(text);
|
|
17
|
+
const inlines = withSyntheticRanges(buildRichInlinesForRange(text, 0, text.length, innerCtx));
|
|
18
|
+
return { ...block, inlines };
|
|
19
|
+
}
|
|
20
|
+
const { start, end } = block.sourceRange;
|
|
21
|
+
return {
|
|
22
|
+
...block,
|
|
23
|
+
inlines: buildRichInlinesForRange(source, start, paragraphInlineEnd(source, start, end), ctx)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ParagraphBlock, ParagraphLine } from './types';
|
|
2
|
+
/** Exported for block editing: split raw lines into paragraph segments (soft breaks via trailing two spaces). */
|
|
3
|
+
export declare function linesToParagraphSegments(lines: string[]): ParagraphLine[];
|
|
4
|
+
/**
|
|
5
|
+
* Split consecutive non-blank source lines into paragraph blocks (hybrid load rule):
|
|
6
|
+
* one line per block unless the line ends with a soft break (` `), which merges with the next line.
|
|
7
|
+
*/
|
|
8
|
+
export declare function paragraphBlocksFromLines(lines: string[], startLineIndex: number): ParagraphBlock[];
|
|
9
|
+
export declare function parseParagraphs(source: string): ParagraphBlock[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Exported for block editing: split raw lines into paragraph segments (soft breaks via trailing two spaces). */
|
|
2
|
+
export function linesToParagraphSegments(lines) {
|
|
3
|
+
const out = [];
|
|
4
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5
|
+
const line = lines[i];
|
|
6
|
+
const isLast = i === lines.length - 1;
|
|
7
|
+
if (isLast) {
|
|
8
|
+
out.push({ text: line, softBreakAfter: false });
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const softBreakMatch = line.match(/^(.*?)( {2,})$/);
|
|
12
|
+
if (softBreakMatch) {
|
|
13
|
+
out.push({ text: softBreakMatch[1], softBreakAfter: true });
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
out.push({ text: line, softBreakAfter: false });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Split consecutive non-blank source lines into paragraph blocks (hybrid load rule):
|
|
23
|
+
* one line per block unless the line ends with a soft break (` `), which merges with the next line.
|
|
24
|
+
*/
|
|
25
|
+
export function paragraphBlocksFromLines(lines, startLineIndex) {
|
|
26
|
+
if (lines.length === 0)
|
|
27
|
+
return [];
|
|
28
|
+
const segments = linesToParagraphSegments(lines);
|
|
29
|
+
const out = [];
|
|
30
|
+
let buffer = [];
|
|
31
|
+
let blockStartLineIndex = startLineIndex;
|
|
32
|
+
for (let i = 0; i < segments.length; i++) {
|
|
33
|
+
const seg = segments[i];
|
|
34
|
+
if (buffer.length === 0) {
|
|
35
|
+
blockStartLineIndex = startLineIndex + i;
|
|
36
|
+
}
|
|
37
|
+
buffer.push(seg);
|
|
38
|
+
if (!seg.softBreakAfter) {
|
|
39
|
+
out.push({ startLineIndex: blockStartLineIndex, lines: buffer });
|
|
40
|
+
buffer = [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (buffer.length > 0) {
|
|
44
|
+
out.push({ startLineIndex: blockStartLineIndex, lines: buffer });
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
export function parseParagraphs(source) {
|
|
49
|
+
const lines = source.split(/\r?\n/);
|
|
50
|
+
const out = [];
|
|
51
|
+
let buffer = [];
|
|
52
|
+
let startLineIndex = 0;
|
|
53
|
+
function flush() {
|
|
54
|
+
if (buffer.length === 0)
|
|
55
|
+
return;
|
|
56
|
+
out.push({
|
|
57
|
+
startLineIndex,
|
|
58
|
+
lines: linesToParagraphSegments(buffer)
|
|
59
|
+
});
|
|
60
|
+
buffer = [];
|
|
61
|
+
}
|
|
62
|
+
for (let i = 0; i < lines.length; i++) {
|
|
63
|
+
const line = lines[i];
|
|
64
|
+
const isBlank = /^\s*$/.test(line);
|
|
65
|
+
if (isBlank) {
|
|
66
|
+
flush();
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (buffer.length === 0) {
|
|
70
|
+
startLineIndex = i;
|
|
71
|
+
}
|
|
72
|
+
buffer.push(line);
|
|
73
|
+
}
|
|
74
|
+
flush();
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { inlineNodesToPlainText } from '../../model/inlinePlain';
|
|
2
|
+
import { paragraphBlockToPlainText } from './edit';
|
|
3
|
+
export function paragraphReconcileFingerprint(block) {
|
|
4
|
+
if (block.type !== 'paragraph')
|
|
5
|
+
return '';
|
|
6
|
+
if (block.inlines?.length)
|
|
7
|
+
return inlineNodesToPlainText(block.inlines);
|
|
8
|
+
return paragraphBlockToPlainText(block.data);
|
|
9
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
import type { ParagraphBlock } from './types';
|
|
3
|
+
export declare function serializeParagraphData(p: ParagraphBlock): string;
|
|
4
|
+
export declare function serializeParagraphBlock(block: EditorBlock, source?: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { serializeEditorBlock } from '../../model/serializeMarkdownDocument';
|
|
2
|
+
import { serializeInlineNodes } from '../../model/serializeInlineNodes';
|
|
3
|
+
function indentLines(text, prefix) {
|
|
4
|
+
return text
|
|
5
|
+
.split('\n')
|
|
6
|
+
.map((l) => prefix + l)
|
|
7
|
+
.join('\n');
|
|
8
|
+
}
|
|
9
|
+
export function serializeParagraphData(p) {
|
|
10
|
+
const parts = [];
|
|
11
|
+
for (let i = 0; i < p.lines.length; i++) {
|
|
12
|
+
const line = p.lines[i];
|
|
13
|
+
parts.push(line.text);
|
|
14
|
+
if (i < p.lines.length - 1) {
|
|
15
|
+
parts.push(line.softBreakAfter ? ' \n' : '\n');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const joined = parts.join('');
|
|
19
|
+
return joined.length === 0 ? ' ' : joined;
|
|
20
|
+
}
|
|
21
|
+
export function serializeParagraphBlock(block, source) {
|
|
22
|
+
if (block.type !== 'paragraph') {
|
|
23
|
+
throw new Error('serializeParagraphBlock expects a paragraph block');
|
|
24
|
+
}
|
|
25
|
+
let head;
|
|
26
|
+
if (block.inlines && block.inlines.length > 0) {
|
|
27
|
+
head = serializeInlineNodes(block.inlines);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
head = serializeParagraphData(block.data);
|
|
31
|
+
}
|
|
32
|
+
if (!block.children?.length)
|
|
33
|
+
return head;
|
|
34
|
+
const lines = [head];
|
|
35
|
+
for (const child of block.children) {
|
|
36
|
+
lines.push(indentLines(serializeEditorBlock(child, source), ' '));
|
|
37
|
+
}
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ParagraphLine = {
|
|
2
|
+
text: string;
|
|
3
|
+
/** True when this line ended with two-or-more spaces before the following line in the same paragraph (Markdown soft break). */
|
|
4
|
+
softBreakAfter: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type ParagraphBlock = {
|
|
7
|
+
/** 0-based index of the first source line in this paragraph. */
|
|
8
|
+
startLineIndex: number;
|
|
9
|
+
lines: ParagraphLine[];
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import EditableParagraph from '../blocks/EditableParagraph.svelte';
|
|
2
|
+
import { paragraphRenderer } from './paragraph/ParagraphRenderer.svelte';
|
|
3
|
+
import { paragraphCommands } from './paragraph/commands';
|
|
4
|
+
import { applyParagraphInlineSecondPass } from './paragraph/inlineSecondPass';
|
|
5
|
+
import { linesToParagraphSegments, parseParagraphs } from './paragraph/parse';
|
|
6
|
+
import { paragraphReconcileFingerprint } from './paragraph/reconcile';
|
|
7
|
+
import { serializeParagraphBlock } from './paragraph/serialize';
|
|
8
|
+
export const paragraphSpec = {
|
|
9
|
+
type: 'paragraph',
|
|
10
|
+
id: 'paragraphs',
|
|
11
|
+
render: paragraphRenderer,
|
|
12
|
+
editComponent: EditableParagraph,
|
|
13
|
+
parse: { linesToParagraphSegments, parseParagraphs },
|
|
14
|
+
serialize: serializeParagraphBlock,
|
|
15
|
+
applyInlineSecondPass: applyParagraphInlineSecondPass,
|
|
16
|
+
reconcileFingerprint: paragraphReconcileFingerprint,
|
|
17
|
+
commands: paragraphCommands,
|
|
18
|
+
toRenderBlock: (block) => ({
|
|
19
|
+
id: block.id,
|
|
20
|
+
pluginId: 'paragraphs',
|
|
21
|
+
data: block,
|
|
22
|
+
render: paragraphRenderer
|
|
23
|
+
})
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorBlockType } from '../model/types';
|
|
2
|
+
import type { BlockSpec } from './types';
|
|
3
|
+
export declare function getBlockSpec(type: EditorBlockType): BlockSpec | undefined;
|
|
4
|
+
export declare function registeredBlockSpecs(): BlockSpec[];
|
|
5
|
+
/** Render-adapter metadata derived from registered BlockSpecs (replaces foundationRenderAdapters). */
|
|
6
|
+
export declare function registeredRenderAdapters(): {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
export type { BlockSpec, BlockEditProps } from './types';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { blockquoteSpec } from './blockquoteSpec';
|
|
2
|
+
import { calloutSpec } from './calloutSpec';
|
|
3
|
+
import { codeFenceSpec } from './codeFenceSpec';
|
|
4
|
+
import { columnsSpec } from './columnsSpec';
|
|
5
|
+
import { headingSpec } from './headingSpec';
|
|
6
|
+
import { horizontalRuleSpec } from './horizontalRuleSpec';
|
|
7
|
+
import { listSpec } from './listSpec';
|
|
8
|
+
import { paragraphSpec } from './paragraphSpec';
|
|
9
|
+
import { tableSpec } from './tableSpec';
|
|
10
|
+
import { tocSpec } from './tocSpec';
|
|
11
|
+
import { toggleSpec } from './toggleSpec';
|
|
12
|
+
const specsByType = new Map([
|
|
13
|
+
[paragraphSpec.type, paragraphSpec],
|
|
14
|
+
[headingSpec.type, headingSpec],
|
|
15
|
+
[listSpec.type, listSpec],
|
|
16
|
+
[blockquoteSpec.type, blockquoteSpec],
|
|
17
|
+
[tableSpec.type, tableSpec],
|
|
18
|
+
[codeFenceSpec.type, codeFenceSpec],
|
|
19
|
+
[horizontalRuleSpec.type, horizontalRuleSpec],
|
|
20
|
+
[calloutSpec.type, calloutSpec],
|
|
21
|
+
[toggleSpec.type, toggleSpec],
|
|
22
|
+
[columnsSpec.type, columnsSpec],
|
|
23
|
+
[tocSpec.type, tocSpec]
|
|
24
|
+
]);
|
|
25
|
+
export function getBlockSpec(type) {
|
|
26
|
+
return specsByType.get(type);
|
|
27
|
+
}
|
|
28
|
+
export function registeredBlockSpecs() {
|
|
29
|
+
return [...specsByType.values()];
|
|
30
|
+
}
|
|
31
|
+
/** Render-adapter metadata derived from registered BlockSpecs (replaces foundationRenderAdapters). */
|
|
32
|
+
export function registeredRenderAdapters() {
|
|
33
|
+
return registeredBlockSpecs().map((spec) => ({ id: spec.id, name: spec.type }));
|
|
34
|
+
}
|