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,196 @@
|
|
|
1
|
+
import { clearDraft, draftKeyForFileFingerprint, draftKeyUntitled, fileFingerprint, loadDraftForFileWithLegacy } from '../editor/draftPersistence.js';
|
|
2
|
+
export function createDemoDocumentSession() {
|
|
3
|
+
return {
|
|
4
|
+
fingerprint: null,
|
|
5
|
+
origin: 'new',
|
|
6
|
+
persistenceKind: 'none',
|
|
7
|
+
lastMarkedSavedAt: null,
|
|
8
|
+
lastExportedAt: null,
|
|
9
|
+
pendingFileDraft: null,
|
|
10
|
+
fileConflictDismissed: false,
|
|
11
|
+
diskSourceAtConflictDecision: null
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function demoDraftStorageKey(session) {
|
|
15
|
+
return session.fingerprint
|
|
16
|
+
? draftKeyForFileFingerprint(session.fingerprint)
|
|
17
|
+
: draftKeyUntitled();
|
|
18
|
+
}
|
|
19
|
+
export function shouldDeferDraftAutosave(session, currentSource) {
|
|
20
|
+
if (session.pendingFileDraft)
|
|
21
|
+
return true;
|
|
22
|
+
return (session.fileConflictDismissed &&
|
|
23
|
+
session.diskSourceAtConflictDecision !== null &&
|
|
24
|
+
currentSource === session.diskSourceAtConflictDecision);
|
|
25
|
+
}
|
|
26
|
+
export function fileFromInput(input) {
|
|
27
|
+
if (input instanceof File)
|
|
28
|
+
return input;
|
|
29
|
+
if (input instanceof HTMLInputElement)
|
|
30
|
+
return input.files?.item(0) ?? null;
|
|
31
|
+
const target = input instanceof Event ? input.currentTarget : null;
|
|
32
|
+
if (target instanceof HTMLInputElement)
|
|
33
|
+
return target.files?.item(0) ?? null;
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
export async function loadMarkdownFile(file) {
|
|
37
|
+
try {
|
|
38
|
+
const source = await file.text();
|
|
39
|
+
const fingerprint = fileFingerprint(file);
|
|
40
|
+
const draft = loadDraftForFileWithLegacy(fingerprint, file.name);
|
|
41
|
+
const pendingDraft = draft && draft.source !== source ? draft : null;
|
|
42
|
+
return {
|
|
43
|
+
ok: true,
|
|
44
|
+
source,
|
|
45
|
+
fileName: file.name,
|
|
46
|
+
fingerprint,
|
|
47
|
+
pendingDraft
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
ok: false,
|
|
53
|
+
error: error instanceof Error ? error.message : 'Unable to load markdown file.'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function loadMarkdownFileFromInput(input) {
|
|
58
|
+
const file = fileFromInput(input);
|
|
59
|
+
if (!file)
|
|
60
|
+
return { ok: false, error: 'Choose a markdown file to load.' };
|
|
61
|
+
return loadMarkdownFile(file);
|
|
62
|
+
}
|
|
63
|
+
export function applyLoadedFileToEditor(editor, result, session) {
|
|
64
|
+
editor.setSource(result.source, {
|
|
65
|
+
fileName: result.fileName,
|
|
66
|
+
resetHistory: true,
|
|
67
|
+
syncBaseline: true
|
|
68
|
+
});
|
|
69
|
+
session.fingerprint = result.fingerprint;
|
|
70
|
+
session.origin = 'loaded_from_file';
|
|
71
|
+
session.pendingFileDraft = result.pendingDraft;
|
|
72
|
+
session.fileConflictDismissed = false;
|
|
73
|
+
session.diskSourceAtConflictDecision = null;
|
|
74
|
+
}
|
|
75
|
+
export function restoreLocalDraft(editor, session, source) {
|
|
76
|
+
editor.setSource(source, {
|
|
77
|
+
fileName: null,
|
|
78
|
+
resetHistory: true,
|
|
79
|
+
syncBaseline: false
|
|
80
|
+
});
|
|
81
|
+
session.fingerprint = null;
|
|
82
|
+
session.origin = 'draft_restored';
|
|
83
|
+
session.pendingFileDraft = null;
|
|
84
|
+
session.fileConflictDismissed = false;
|
|
85
|
+
session.diskSourceAtConflictDecision = null;
|
|
86
|
+
}
|
|
87
|
+
export function discardLocalDraftSnapshot(session) {
|
|
88
|
+
clearDraft(demoDraftStorageKey(session));
|
|
89
|
+
}
|
|
90
|
+
export function restorePendingFileDraft(editor, session) {
|
|
91
|
+
const draft = session.pendingFileDraft;
|
|
92
|
+
if (!draft?.source)
|
|
93
|
+
return;
|
|
94
|
+
session.pendingFileDraft = null;
|
|
95
|
+
session.fileConflictDismissed = false;
|
|
96
|
+
session.diskSourceAtConflictDecision = null;
|
|
97
|
+
editor.setSource(draft.source, {
|
|
98
|
+
resetHistory: true,
|
|
99
|
+
syncBaseline: false
|
|
100
|
+
});
|
|
101
|
+
session.origin = 'draft_restored';
|
|
102
|
+
}
|
|
103
|
+
export function discardPendingFileDraft(session) {
|
|
104
|
+
if (!session.pendingFileDraft)
|
|
105
|
+
return;
|
|
106
|
+
clearDraft(demoDraftStorageKey(session));
|
|
107
|
+
session.pendingFileDraft = null;
|
|
108
|
+
session.fileConflictDismissed = false;
|
|
109
|
+
session.diskSourceAtConflictDecision = null;
|
|
110
|
+
}
|
|
111
|
+
export function dismissPendingFileDraftConflict(editor, session) {
|
|
112
|
+
if (!session.pendingFileDraft)
|
|
113
|
+
return;
|
|
114
|
+
session.pendingFileDraft = null;
|
|
115
|
+
session.fileConflictDismissed = true;
|
|
116
|
+
session.diskSourceAtConflictDecision = editor.source;
|
|
117
|
+
}
|
|
118
|
+
export function downloadMarkdownFile(editor, session, fileName) {
|
|
119
|
+
const blob = new Blob([editor.source], { type: 'text/markdown;charset=utf-8' });
|
|
120
|
+
const url = URL.createObjectURL(blob);
|
|
121
|
+
const a = document.createElement('a');
|
|
122
|
+
const fn = fileName ?? editor.fileName;
|
|
123
|
+
a.download =
|
|
124
|
+
fn && /\.(md|markdown)$/i.test(fn)
|
|
125
|
+
? fn
|
|
126
|
+
: `${(fn && fn.replace(/\.[^/.]+$/, '')) || 'document'}.md`;
|
|
127
|
+
a.href = url;
|
|
128
|
+
a.click();
|
|
129
|
+
URL.revokeObjectURL(url);
|
|
130
|
+
editor.markSaved();
|
|
131
|
+
session.persistenceKind = 'exported';
|
|
132
|
+
session.lastExportedAt = Date.now();
|
|
133
|
+
clearDraft(demoDraftStorageKey(session));
|
|
134
|
+
}
|
|
135
|
+
export function markDocumentSaved(editor, session) {
|
|
136
|
+
editor.markSaved();
|
|
137
|
+
session.persistenceKind = 'marked_saved';
|
|
138
|
+
session.lastMarkedSavedAt = Date.now();
|
|
139
|
+
}
|
|
140
|
+
/** Controlled demo: mark session saved without a {@link MarkdownEditor} instance. */
|
|
141
|
+
export function markDemoSessionSaved(session) {
|
|
142
|
+
session.persistenceKind = 'marked_saved';
|
|
143
|
+
session.lastMarkedSavedAt = Date.now();
|
|
144
|
+
}
|
|
145
|
+
/** Controlled demo: restore local draft — returns source to assign to `value`. */
|
|
146
|
+
export function restoreLocalDraftControlled(session, source) {
|
|
147
|
+
session.fingerprint = null;
|
|
148
|
+
session.origin = 'draft_restored';
|
|
149
|
+
session.pendingFileDraft = null;
|
|
150
|
+
session.fileConflictDismissed = false;
|
|
151
|
+
session.diskSourceAtConflictDecision = null;
|
|
152
|
+
return source;
|
|
153
|
+
}
|
|
154
|
+
/** Controlled demo: apply pending file draft — returns draft source or null. */
|
|
155
|
+
export function restorePendingFileDraftControlled(session) {
|
|
156
|
+
const draft = session.pendingFileDraft;
|
|
157
|
+
if (!draft?.source)
|
|
158
|
+
return null;
|
|
159
|
+
session.pendingFileDraft = null;
|
|
160
|
+
session.fileConflictDismissed = false;
|
|
161
|
+
session.diskSourceAtConflictDecision = null;
|
|
162
|
+
session.origin = 'draft_restored';
|
|
163
|
+
return draft.source;
|
|
164
|
+
}
|
|
165
|
+
export function dismissPendingFileDraftConflictControlled(session, currentSource) {
|
|
166
|
+
if (!session.pendingFileDraft)
|
|
167
|
+
return;
|
|
168
|
+
session.pendingFileDraft = null;
|
|
169
|
+
session.fileConflictDismissed = true;
|
|
170
|
+
session.diskSourceAtConflictDecision = currentSource;
|
|
171
|
+
}
|
|
172
|
+
/** Controlled demo: download source string as .md file. */
|
|
173
|
+
export function downloadMarkdownSource(source, session, fileName) {
|
|
174
|
+
const blob = new Blob([source], { type: 'text/markdown;charset=utf-8' });
|
|
175
|
+
const url = URL.createObjectURL(blob);
|
|
176
|
+
const a = document.createElement('a');
|
|
177
|
+
const fn = fileName;
|
|
178
|
+
a.download =
|
|
179
|
+
fn && /\.(md|markdown)$/i.test(fn)
|
|
180
|
+
? fn
|
|
181
|
+
: `${(fn && fn.replace(/\.[^/.]+$/, '')) || 'document'}.md`;
|
|
182
|
+
a.href = url;
|
|
183
|
+
a.click();
|
|
184
|
+
URL.revokeObjectURL(url);
|
|
185
|
+
session.persistenceKind = 'exported';
|
|
186
|
+
session.lastExportedAt = Date.now();
|
|
187
|
+
clearDraft(demoDraftStorageKey(session));
|
|
188
|
+
}
|
|
189
|
+
export function applyLoadedFileControlled(result, session) {
|
|
190
|
+
session.fingerprint = result.fingerprint;
|
|
191
|
+
session.origin = 'loaded_from_file';
|
|
192
|
+
session.pendingFileDraft = result.pendingDraft;
|
|
193
|
+
session.fileConflictDismissed = false;
|
|
194
|
+
session.diskSourceAtConflictDecision = null;
|
|
195
|
+
return { source: result.source, fileName: result.fileName };
|
|
196
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { applyLoadedFileControlled, applyLoadedFileToEditor, createDemoDocumentSession, demoDraftStorageKey, discardLocalDraftSnapshot, discardPendingFileDraft, dismissPendingFileDraftConflict, dismissPendingFileDraftConflictControlled, downloadMarkdownFile, downloadMarkdownSource, fileFromInput, loadMarkdownFile, loadMarkdownFileFromInput, markDemoSessionSaved, markDocumentSaved, restoreLocalDraft, restoreLocalDraftControlled, restorePendingFileDraft, restorePendingFileDraftControlled, shouldDeferDraftAutosave, type DemoDocumentSession, type DemoPersistenceKind, type DemoSessionOrigin, type LoadMarkdownFileResult, type LoadMDFileInput } from './documentLifecycle.js';
|
|
2
|
+
export { clearDraft, draftKeyForFileFingerprint, draftKeyUntitled, draftStorageKey, fileFingerprint, legacyDraftKeyForFileName, loadDraft, loadDraftForFileWithLegacy, saveDraft, type SaveDraftMeta, type StoredDraft } from '../editor/draftPersistence.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { applyLoadedFileControlled, applyLoadedFileToEditor, createDemoDocumentSession, demoDraftStorageKey, discardLocalDraftSnapshot, discardPendingFileDraft, dismissPendingFileDraftConflict, dismissPendingFileDraftConflictControlled, downloadMarkdownFile, downloadMarkdownSource, fileFromInput, loadMarkdownFile, loadMarkdownFileFromInput, markDemoSessionSaved, markDocumentSaved, restoreLocalDraft, restoreLocalDraftControlled, restorePendingFileDraft, restorePendingFileDraftControlled, shouldDeferDraftAutosave } from './documentLifecycle.js';
|
|
2
|
+
export { clearDraft, draftKeyForFileFingerprint, draftKeyUntitled, draftStorageKey, fileFingerprint, legacyDraftKeyForFileName, loadDraft, loadDraftForFileWithLegacy, saveDraft } from '../editor/draftPersistence.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { dndTree, DndTreeGhost, DndTreeIndicator } from 'phoundry-ui';
|
|
3
|
+
import type { Attachment } from 'svelte/attachments';
|
|
4
|
+
import BlockSpecMissing from './block-specs/BlockSpecMissing.svelte';
|
|
5
|
+
import BlockRow from './BlockRow.svelte';
|
|
6
|
+
import type { MarkdownEditor } from './MarkdownEditor.svelte';
|
|
7
|
+
import { getBlockSpec } from './block-specs/registry';
|
|
8
|
+
import { canBlockTreeDrop } from './model/blockTreeDrop';
|
|
9
|
+
import { listRegionBounds } from './model/blockTree';
|
|
10
|
+
import type { EditorBlock } from './model/types';
|
|
11
|
+
|
|
12
|
+
let { editor }: { editor: MarkdownEditor } = $props();
|
|
13
|
+
|
|
14
|
+
const blocks = $derived(editor.document.blocks);
|
|
15
|
+
|
|
16
|
+
/** px-1 (4) + grip (24) + mr-1 (4) + gap-1 (4) — content column start past block grip. */
|
|
17
|
+
const BLOCK_GRIP_CONTENT_INSET = 44;
|
|
18
|
+
|
|
19
|
+
type ListRegionSegment = {
|
|
20
|
+
kind: 'listRegion';
|
|
21
|
+
regionStart: number;
|
|
22
|
+
items: { blockIndex: number; block: EditorBlock }[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type BlockSegment = {
|
|
26
|
+
kind: 'block';
|
|
27
|
+
blockIndex: number;
|
|
28
|
+
block: EditorBlock;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type EditorSegment = ListRegionSegment | BlockSegment;
|
|
32
|
+
|
|
33
|
+
const segments = $derived.by((): EditorSegment[] => {
|
|
34
|
+
const out: EditorSegment[] = [];
|
|
35
|
+
let i = 0;
|
|
36
|
+
while (i < blocks.length) {
|
|
37
|
+
const block = blocks[i]!;
|
|
38
|
+
if (block.type === 'listItem') {
|
|
39
|
+
const { start, end } = listRegionBounds(blocks, i);
|
|
40
|
+
const items: { blockIndex: number; block: EditorBlock }[] = [];
|
|
41
|
+
for (let j = start; j < end; j++) {
|
|
42
|
+
items.push({ blockIndex: j, block: blocks[j]! });
|
|
43
|
+
}
|
|
44
|
+
out.push({ kind: 'listRegion', regionStart: start, items });
|
|
45
|
+
i = end;
|
|
46
|
+
} else {
|
|
47
|
+
out.push({ kind: 'block', blockIndex: i, block });
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const documentTreeAttach: Attachment = (element) => {
|
|
55
|
+
const inner = dndTree({
|
|
56
|
+
id: 'md-editor-document-tree',
|
|
57
|
+
contentInsetLeft: BLOCK_GRIP_CONTENT_INSET,
|
|
58
|
+
nestIndent: 16,
|
|
59
|
+
canDrop(result) {
|
|
60
|
+
if (editor.readonly) return false;
|
|
61
|
+
return canBlockTreeDrop(
|
|
62
|
+
editor.document.blocks,
|
|
63
|
+
result.draggedId,
|
|
64
|
+
result.targetId,
|
|
65
|
+
result.placement
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
onDrop(result) {
|
|
69
|
+
editor.blockTreeDropAt(result.draggedId, result.targetId, result.placement);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return inner(element);
|
|
73
|
+
};
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<div class="flex flex-col gap-2" {@attach documentTreeAttach}>
|
|
77
|
+
{#each segments as segment (segment.kind === 'listRegion' ? `list-${segment.regionStart}` : segment.block.id)}
|
|
78
|
+
{#if segment.kind === 'listRegion'}
|
|
79
|
+
<div>
|
|
80
|
+
{#each segment.items as { block, blockIndex } (block.id)}
|
|
81
|
+
{@const spec = getBlockSpec('listItem')}
|
|
82
|
+
{#if spec}
|
|
83
|
+
<spec.editComponent {editor} {blockIndex} {block} />
|
|
84
|
+
{:else}
|
|
85
|
+
<BlockSpecMissing blockType="listItem" />
|
|
86
|
+
{/if}
|
|
87
|
+
{/each}
|
|
88
|
+
</div>
|
|
89
|
+
{:else}
|
|
90
|
+
{@const block = segment.block}
|
|
91
|
+
{@const blockIndex = segment.blockIndex}
|
|
92
|
+
<BlockRow
|
|
93
|
+
{editor}
|
|
94
|
+
{blockIndex}
|
|
95
|
+
blockId={block.id}
|
|
96
|
+
blockType={block.type}
|
|
97
|
+
blockSynthetic={block.sourceRange.synthetic === true}
|
|
98
|
+
canMoveUp={blockIndex > 0}
|
|
99
|
+
canMoveDown={blockIndex < blocks.length - 1}
|
|
100
|
+
>
|
|
101
|
+
{@const spec = getBlockSpec(block.type)}
|
|
102
|
+
{#if spec}
|
|
103
|
+
<spec.editComponent {editor} {blockIndex} {block} />
|
|
104
|
+
{:else}
|
|
105
|
+
<BlockSpecMissing blockType={block.type} />
|
|
106
|
+
{/if}
|
|
107
|
+
</BlockRow>
|
|
108
|
+
{/if}
|
|
109
|
+
{/each}
|
|
110
|
+
</div>
|
|
111
|
+
<DndTreeGhost />
|
|
112
|
+
<DndTreeIndicator />
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MarkdownEditor } from './MarkdownEditor.svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
editor: MarkdownEditor;
|
|
4
|
+
};
|
|
5
|
+
declare const BlockEditor: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type BlockEditor = ReturnType<typeof BlockEditor>;
|
|
7
|
+
export default BlockEditor;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import NestedRowChrome from './NestedRowChrome.svelte';
|
|
4
|
+
import type { MarkdownEditor } from './MarkdownEditor.svelte';
|
|
5
|
+
import { blockCanMoveSibling, blockTreeDepth } from './model/blockTree';
|
|
6
|
+
import type { EditorBlockType } from './model/types';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
editor,
|
|
10
|
+
blockIndex,
|
|
11
|
+
blockId,
|
|
12
|
+
blockType,
|
|
13
|
+
blockSynthetic,
|
|
14
|
+
canMoveUp,
|
|
15
|
+
canMoveDown,
|
|
16
|
+
moveUpCommandId,
|
|
17
|
+
moveDownCommandId,
|
|
18
|
+
nestedRowBlockId,
|
|
19
|
+
nestedRowBlockType,
|
|
20
|
+
children
|
|
21
|
+
}: {
|
|
22
|
+
editor: MarkdownEditor;
|
|
23
|
+
blockIndex: number;
|
|
24
|
+
blockId: string;
|
|
25
|
+
blockType: EditorBlockType;
|
|
26
|
+
blockSynthetic: boolean;
|
|
27
|
+
canMoveUp?: boolean;
|
|
28
|
+
canMoveDown?: boolean;
|
|
29
|
+
moveUpCommandId?: string;
|
|
30
|
+
moveDownCommandId?: string;
|
|
31
|
+
nestedRowBlockId?: string;
|
|
32
|
+
nestedRowBlockType?: EditorBlockType;
|
|
33
|
+
children: Snippet;
|
|
34
|
+
} = $props();
|
|
35
|
+
|
|
36
|
+
const treeDepth = $derived(blockTreeDepth(editor.document.blocks, blockId));
|
|
37
|
+
|
|
38
|
+
const resolvedCanMoveUp = $derived(
|
|
39
|
+
canMoveUp ?? blockCanMoveSibling(editor.document.blocks, blockId, 'up')
|
|
40
|
+
);
|
|
41
|
+
const resolvedCanMoveDown = $derived(
|
|
42
|
+
canMoveDown ?? blockCanMoveSibling(editor.document.blocks, blockId, 'down')
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const commandCtx = $derived({
|
|
46
|
+
editor,
|
|
47
|
+
blockIndex,
|
|
48
|
+
blockId,
|
|
49
|
+
blockType,
|
|
50
|
+
blockSynthetic,
|
|
51
|
+
canMoveUp: resolvedCanMoveUp,
|
|
52
|
+
canMoveDown: resolvedCanMoveDown,
|
|
53
|
+
nestedRowBlockId,
|
|
54
|
+
nestedRowBlockType
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div>
|
|
59
|
+
<NestedRowChrome
|
|
60
|
+
{commandCtx}
|
|
61
|
+
rowId={blockId}
|
|
62
|
+
{treeDepth}
|
|
63
|
+
gripDisabled={blockSynthetic}
|
|
64
|
+
toolbarAriaLabel="Block controls"
|
|
65
|
+
gripAriaLabel="Block actions"
|
|
66
|
+
menuAriaLabel="Block actions"
|
|
67
|
+
moveUpCommandId={moveUpCommandId ??
|
|
68
|
+
(nestedRowBlockId !== undefined ? 'moveListItemUp' : 'moveBlockUp')}
|
|
69
|
+
moveDownCommandId={moveDownCommandId ??
|
|
70
|
+
(nestedRowBlockId !== undefined ? 'moveListItemDown' : 'moveBlockDown')}
|
|
71
|
+
canMoveUp={resolvedCanMoveUp}
|
|
72
|
+
canMoveDown={resolvedCanMoveDown}
|
|
73
|
+
>
|
|
74
|
+
{@render children()}
|
|
75
|
+
</NestedRowChrome>
|
|
76
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { MarkdownEditor } from './MarkdownEditor.svelte';
|
|
3
|
+
import type { EditorBlockType } from './model/types';
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
editor: MarkdownEditor;
|
|
6
|
+
blockIndex: number;
|
|
7
|
+
blockId: string;
|
|
8
|
+
blockType: EditorBlockType;
|
|
9
|
+
blockSynthetic: boolean;
|
|
10
|
+
canMoveUp?: boolean;
|
|
11
|
+
canMoveDown?: boolean;
|
|
12
|
+
moveUpCommandId?: string;
|
|
13
|
+
moveDownCommandId?: string;
|
|
14
|
+
nestedRowBlockId?: string;
|
|
15
|
+
nestedRowBlockType?: EditorBlockType;
|
|
16
|
+
children: Snippet;
|
|
17
|
+
};
|
|
18
|
+
declare const BlockRow: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
19
|
+
type BlockRow = ReturnType<typeof BlockRow>;
|
|
20
|
+
export default BlockRow;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@deprecated Use {@link PhormatEditor} for embeddable controlled editing.
|
|
3
|
+
State-object shell for advanced use: pass an existing {@link MarkdownEditor} instance.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { Button, CheckboxToggle, EmptyState } from 'phoundry-ui';
|
|
7
|
+
import BlockEditor from './BlockEditor.svelte';
|
|
8
|
+
import RawMarkdownPanel from './RawMarkdownPanel.svelte';
|
|
9
|
+
import InlineChromeCoordinator from './inlineChrome/InlineChromeCoordinator.svelte';
|
|
10
|
+
import type { MarkdownEditor } from './MarkdownEditor.svelte';
|
|
11
|
+
|
|
12
|
+
let { editor }: { editor: MarkdownEditor } = $props();
|
|
13
|
+
|
|
14
|
+
let editorRoot = $state.raw<HTMLElement | null>(null);
|
|
15
|
+
let showRawMarkdown = $state(false);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<section class="text-txt-primary">
|
|
19
|
+
<div
|
|
20
|
+
class="mb-4 flex shrink-0 flex-wrap items-center justify-between gap-4 border-b border-border-muted pb-4"
|
|
21
|
+
>
|
|
22
|
+
<div>
|
|
23
|
+
<p class="text-sm text-txt-secondary">
|
|
24
|
+
{editor.fileName ?? 'No file name.'}
|
|
25
|
+
</p>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
29
|
+
<CheckboxToggle
|
|
30
|
+
checked={showRawMarkdown}
|
|
31
|
+
onchange={() => (showRawMarkdown = !showRawMarkdown)}
|
|
32
|
+
label="Raw markdown"
|
|
33
|
+
size="sm"
|
|
34
|
+
data-testid="toggle-raw-markdown"
|
|
35
|
+
/>
|
|
36
|
+
<Button
|
|
37
|
+
variant="secondary"
|
|
38
|
+
size="sm"
|
|
39
|
+
icon="carbon:undo"
|
|
40
|
+
disabled={!editor.canUndo}
|
|
41
|
+
aria-label="Undo last edit"
|
|
42
|
+
onclick={() => editor.undo()}
|
|
43
|
+
>
|
|
44
|
+
Undo
|
|
45
|
+
</Button>
|
|
46
|
+
<Button
|
|
47
|
+
variant="secondary"
|
|
48
|
+
size="sm"
|
|
49
|
+
icon="carbon:redo"
|
|
50
|
+
disabled={!editor.canRedo}
|
|
51
|
+
aria-label="Redo previously undone edit"
|
|
52
|
+
onclick={() => editor.redo()}
|
|
53
|
+
>
|
|
54
|
+
Redo
|
|
55
|
+
</Button>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
{#if editor.document.parseWarnings?.length}
|
|
60
|
+
<div
|
|
61
|
+
class="mb-4 rounded-lg border border-semantic-warning/50 bg-semantic-warning/10 px-3 py-2"
|
|
62
|
+
role="status"
|
|
63
|
+
>
|
|
64
|
+
<p class="text-sm font-medium text-txt-primary">Parse notes</p>
|
|
65
|
+
<ul class="mt-1 list-inside list-disc text-sm text-txt-secondary">
|
|
66
|
+
{#each editor.document.parseWarnings as w (w)}
|
|
67
|
+
<li>{w}</li>
|
|
68
|
+
{/each}
|
|
69
|
+
</ul>
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
72
|
+
|
|
73
|
+
{#if editor.error}
|
|
74
|
+
<p
|
|
75
|
+
class="mb-4 rounded-lg border border-semantic-error/50 bg-semantic-error/10 px-3 py-2 text-sm text-semantic-error"
|
|
76
|
+
role="alert"
|
|
77
|
+
>
|
|
78
|
+
{editor.error}
|
|
79
|
+
</p>
|
|
80
|
+
{/if}
|
|
81
|
+
|
|
82
|
+
{#if editor.blocks.length}
|
|
83
|
+
<div class={showRawMarkdown ? 'grid grid-cols-2 gap-4' : undefined}>
|
|
84
|
+
<article bind:this={editorRoot} class="relative">
|
|
85
|
+
<BlockEditor {editor} />
|
|
86
|
+
{#if editorRoot}
|
|
87
|
+
<InlineChromeCoordinator {editor} root={editorRoot} />
|
|
88
|
+
{/if}
|
|
89
|
+
</article>
|
|
90
|
+
{#if showRawMarkdown}
|
|
91
|
+
<RawMarkdownPanel source={editor.source} />
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
{:else}
|
|
95
|
+
<EmptyState
|
|
96
|
+
icon="carbon:document-blank"
|
|
97
|
+
title="No markdown loaded yet."
|
|
98
|
+
description="Set source on the editor instance to start editing."
|
|
99
|
+
size="sm"
|
|
100
|
+
class="rounded-lg border border-dashed border-border-default/60"
|
|
101
|
+
/>
|
|
102
|
+
{/if}
|
|
103
|
+
</section>
|