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,83 @@
|
|
|
1
|
+
import { afterLineTerminator } from '../../model/line-utils';
|
|
2
|
+
import { stableBlockId } from '../../model/types';
|
|
3
|
+
import { parseCalloutBodyBlocks } from './parseBody';
|
|
4
|
+
/** First line of an extended callout: `> [!type] Title`. */
|
|
5
|
+
const CALLOUT_OPENER = /^\s*>\s*\[!([a-zA-Z][a-zA-Z0-9_-]*)\]\s*(.*)$/;
|
|
6
|
+
/** Continuation line inside the same blockquote (not another callout opener). */
|
|
7
|
+
const BLANK_QUOTE_LINE = /^\s*>\s*$/;
|
|
8
|
+
const QUOTE_CONTINUATION = /^\s*>\s?(.*)$/;
|
|
9
|
+
export function parseCallouts(source) {
|
|
10
|
+
const lines = source.split(/\r?\n/);
|
|
11
|
+
const out = [];
|
|
12
|
+
for (let i = 0; i < lines.length; i++) {
|
|
13
|
+
const opener = lines[i].match(CALLOUT_OPENER);
|
|
14
|
+
if (!opener)
|
|
15
|
+
continue;
|
|
16
|
+
const type = opener[1];
|
|
17
|
+
const title = opener[2].trim();
|
|
18
|
+
let j = i + 1;
|
|
19
|
+
while (j < lines.length) {
|
|
20
|
+
const line = lines[j];
|
|
21
|
+
if (CALLOUT_OPENER.test(line))
|
|
22
|
+
break;
|
|
23
|
+
if (BLANK_QUOTE_LINE.test(line)) {
|
|
24
|
+
j++;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const cont = line.match(QUOTE_CONTINUATION);
|
|
28
|
+
if (!cont)
|
|
29
|
+
break;
|
|
30
|
+
j++;
|
|
31
|
+
}
|
|
32
|
+
out.push({ type, title, lineIndex: i });
|
|
33
|
+
i = j - 1;
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
export function tryParseCalloutAt(i, rows, source, fenceAtOpenLine) {
|
|
38
|
+
const row = rows[i];
|
|
39
|
+
if (!row || fenceAtOpenLine.has(i))
|
|
40
|
+
return null;
|
|
41
|
+
const opener = row.line.match(/^\s*>\s*\[!([^\]]+)\]\s*(.*)$/);
|
|
42
|
+
if (!opener)
|
|
43
|
+
return null;
|
|
44
|
+
const type = opener[1];
|
|
45
|
+
const title = (opener[2] ?? '').trim();
|
|
46
|
+
let j = i + 1;
|
|
47
|
+
while (j < rows.length) {
|
|
48
|
+
const line = rows[j].line;
|
|
49
|
+
if (/^\s*>\s*\[!([^\]]+)\]\s*(.*)$/.test(line))
|
|
50
|
+
break;
|
|
51
|
+
if (/^\s*>\s*$/.test(line)) {
|
|
52
|
+
j++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const cont = line.match(/^\s*>\s?(.*)$/);
|
|
56
|
+
if (!cont)
|
|
57
|
+
break;
|
|
58
|
+
j++;
|
|
59
|
+
}
|
|
60
|
+
const endLine = j - 1;
|
|
61
|
+
const sourceRange = {
|
|
62
|
+
start: row.start,
|
|
63
|
+
end: afterLineTerminator(source, rows[endLine]),
|
|
64
|
+
startLine: i,
|
|
65
|
+
endLine
|
|
66
|
+
};
|
|
67
|
+
const data = {
|
|
68
|
+
type,
|
|
69
|
+
title,
|
|
70
|
+
lineIndex: i
|
|
71
|
+
};
|
|
72
|
+
const children = j > i + 1 ? parseCalloutBodyBlocks(rows, i + 1, j, source, fenceAtOpenLine) : [];
|
|
73
|
+
return {
|
|
74
|
+
nextLine: j,
|
|
75
|
+
block: {
|
|
76
|
+
type: 'callout',
|
|
77
|
+
id: stableBlockId('callout', sourceRange),
|
|
78
|
+
sourceRange,
|
|
79
|
+
data,
|
|
80
|
+
children: children.length > 0 ? children : undefined
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type LineRow } from '../../model/line-utils';
|
|
2
|
+
import type { EditorBlock } from '../../model/types';
|
|
3
|
+
import type { FenceAtOpenLine } from './parse';
|
|
4
|
+
export declare function stripCalloutQuoteLine(line: string): string | null;
|
|
5
|
+
/** Parse quoted callout continuation lines into nested blocks. */
|
|
6
|
+
export declare function parseCalloutBodyBlocks(rows: LineRow[], start: number, end: number, source: string, fenceAtOpenLine: FenceAtOpenLine): EditorBlock[];
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { buildBlockquoteAtDepth, parseBlockquoteLine, parseBlockquoteLineInfo } from '../blockquote/parse';
|
|
2
|
+
import { buildListItemForest, parseListLine } from '../list/parse';
|
|
3
|
+
import { paragraphBlocksFromLines } from '../paragraph/parse';
|
|
4
|
+
import { afterLineTerminator } from '../../model/line-utils';
|
|
5
|
+
import { stableBlockId } from '../../model/types';
|
|
6
|
+
const FENCE_OPEN = /^(\s*)(`{3,})(.*)$/;
|
|
7
|
+
const INNER_CALLOUT_OPENER = /^\s*\[!([^\]]+)\]\s*(.*)$/;
|
|
8
|
+
export function stripCalloutQuoteLine(line) {
|
|
9
|
+
if (/^\s*>\s*$/.test(line))
|
|
10
|
+
return '';
|
|
11
|
+
const cont = line.match(/^\s*>\s?(.*)$/);
|
|
12
|
+
return cont ? (cont[1] ?? '') : null;
|
|
13
|
+
}
|
|
14
|
+
function tryParseFenceInCalloutAt(i, rows, end, source) {
|
|
15
|
+
const row = rows[i];
|
|
16
|
+
if (!row)
|
|
17
|
+
return null;
|
|
18
|
+
const stripped = stripCalloutQuoteLine(row.line);
|
|
19
|
+
if (stripped === null)
|
|
20
|
+
return null;
|
|
21
|
+
const open = stripped.match(FENCE_OPEN);
|
|
22
|
+
if (!open)
|
|
23
|
+
return null;
|
|
24
|
+
const fenceLen = open[2].length;
|
|
25
|
+
const langMatch = open[3] ?? '';
|
|
26
|
+
const lang = langMatch.trim() === '' ? null : (langMatch.trim().split(/\s+/)[0] ?? null);
|
|
27
|
+
const bodyLines = [];
|
|
28
|
+
let j = i + 1;
|
|
29
|
+
while (j < end) {
|
|
30
|
+
const inner = stripCalloutQuoteLine(rows[j].line);
|
|
31
|
+
if (inner === null)
|
|
32
|
+
break;
|
|
33
|
+
const close = inner.match(/^(`{3,})\s*$/);
|
|
34
|
+
if (close && close[1].length >= fenceLen)
|
|
35
|
+
break;
|
|
36
|
+
bodyLines.push(inner);
|
|
37
|
+
j++;
|
|
38
|
+
}
|
|
39
|
+
if (j >= end)
|
|
40
|
+
return null;
|
|
41
|
+
const closeRow = rows[j];
|
|
42
|
+
const sourceRange = {
|
|
43
|
+
start: row.start,
|
|
44
|
+
end: afterLineTerminator(source, closeRow),
|
|
45
|
+
startLine: i,
|
|
46
|
+
endLine: j
|
|
47
|
+
};
|
|
48
|
+
const data = {
|
|
49
|
+
kind: 'fenced',
|
|
50
|
+
language: lang,
|
|
51
|
+
code: bodyLines.join('\n'),
|
|
52
|
+
startLine: i
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
nextLine: j + 1,
|
|
56
|
+
block: {
|
|
57
|
+
type: 'codeFence',
|
|
58
|
+
id: stableBlockId('codeFence', sourceRange),
|
|
59
|
+
sourceRange,
|
|
60
|
+
data
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function tryParseToggleInCalloutAt(i, rows, end, source) {
|
|
65
|
+
const row = rows[i];
|
|
66
|
+
if (!row)
|
|
67
|
+
return null;
|
|
68
|
+
const stripped = stripCalloutQuoteLine(row.line);
|
|
69
|
+
if (stripped === null)
|
|
70
|
+
return null;
|
|
71
|
+
const openMatch = stripped.match(/^\s*\+\+\+\s+(.+)$/);
|
|
72
|
+
if (!openMatch)
|
|
73
|
+
return null;
|
|
74
|
+
const title = (openMatch[1] ?? '').trim();
|
|
75
|
+
const bodyLines = [];
|
|
76
|
+
let j = i + 1;
|
|
77
|
+
while (j < end) {
|
|
78
|
+
const inner = stripCalloutQuoteLine(rows[j].line);
|
|
79
|
+
if (inner === null)
|
|
80
|
+
break;
|
|
81
|
+
if (/^\s*\+\+\+\s*$/.test(inner)) {
|
|
82
|
+
const endLine = j;
|
|
83
|
+
const sourceRange = {
|
|
84
|
+
start: row.start,
|
|
85
|
+
end: afterLineTerminator(source, rows[endLine]),
|
|
86
|
+
startLine: i,
|
|
87
|
+
endLine
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
nextLine: j + 1,
|
|
91
|
+
block: {
|
|
92
|
+
type: 'toggle',
|
|
93
|
+
id: stableBlockId('toggle', sourceRange),
|
|
94
|
+
sourceRange,
|
|
95
|
+
data: {
|
|
96
|
+
title,
|
|
97
|
+
body: bodyLines.join('\n'),
|
|
98
|
+
startLineIndex: i
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
bodyLines.push(inner);
|
|
104
|
+
j++;
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
function tryParseInnerCalloutAt(i, rows, end, source, fenceAtOpenLine) {
|
|
109
|
+
const row = rows[i];
|
|
110
|
+
if (!row)
|
|
111
|
+
return null;
|
|
112
|
+
const stripped = stripCalloutQuoteLine(row.line);
|
|
113
|
+
if (stripped === null)
|
|
114
|
+
return null;
|
|
115
|
+
const opener = stripped.match(INNER_CALLOUT_OPENER);
|
|
116
|
+
if (!opener)
|
|
117
|
+
return null;
|
|
118
|
+
const type = opener[1];
|
|
119
|
+
const title = (opener[2] ?? '').trim();
|
|
120
|
+
let j = i + 1;
|
|
121
|
+
while (j < end) {
|
|
122
|
+
const line = rows[j].line;
|
|
123
|
+
if (/^\s*>\s*\[!([^\]]+)\]\s*(.*)$/.test(line))
|
|
124
|
+
break;
|
|
125
|
+
const inner = stripCalloutQuoteLine(line);
|
|
126
|
+
if (inner !== null && INNER_CALLOUT_OPENER.test(inner))
|
|
127
|
+
break;
|
|
128
|
+
if (/^\s*>\s*$/.test(line)) {
|
|
129
|
+
j++;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (stripCalloutQuoteLine(line) === null)
|
|
133
|
+
break;
|
|
134
|
+
j++;
|
|
135
|
+
}
|
|
136
|
+
const children = j > i + 1 ? parseCalloutBodyBlocks(rows, i + 1, j, source, fenceAtOpenLine) : undefined;
|
|
137
|
+
const endLine = j - 1;
|
|
138
|
+
const sourceRange = {
|
|
139
|
+
start: row.start,
|
|
140
|
+
end: afterLineTerminator(source, rows[endLine] ?? row),
|
|
141
|
+
startLine: i,
|
|
142
|
+
endLine
|
|
143
|
+
};
|
|
144
|
+
const data = { type, title, lineIndex: i };
|
|
145
|
+
return {
|
|
146
|
+
nextLine: j,
|
|
147
|
+
block: {
|
|
148
|
+
type: 'callout',
|
|
149
|
+
id: stableBlockId('callout', sourceRange),
|
|
150
|
+
sourceRange,
|
|
151
|
+
data,
|
|
152
|
+
children: children?.length ? children : undefined
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** Parse quoted callout continuation lines into nested blocks. */
|
|
157
|
+
export function parseCalloutBodyBlocks(rows, start, end, source, fenceAtOpenLine) {
|
|
158
|
+
const blocks = [];
|
|
159
|
+
let i = start;
|
|
160
|
+
while (i < end) {
|
|
161
|
+
const row = rows[i];
|
|
162
|
+
const stripped = stripCalloutQuoteLine(row.line);
|
|
163
|
+
if (stripped === null) {
|
|
164
|
+
i++;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (stripped.trim() === '') {
|
|
168
|
+
i++;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const fenceHit = tryParseFenceInCalloutAt(i, rows, end, source);
|
|
172
|
+
if (fenceHit) {
|
|
173
|
+
blocks.push(fenceHit.block);
|
|
174
|
+
i = fenceHit.nextLine;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const innerCallout = tryParseInnerCalloutAt(i, rows, end, source, fenceAtOpenLine);
|
|
178
|
+
if (innerCallout) {
|
|
179
|
+
blocks.push(innerCallout.block);
|
|
180
|
+
i = innerCallout.nextLine;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const toggleHit = tryParseToggleInCalloutAt(i, rows, end, source);
|
|
184
|
+
if (toggleHit) {
|
|
185
|
+
blocks.push(toggleHit.block);
|
|
186
|
+
i = toggleHit.nextLine;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const bqProbe = parseBlockquoteLine(row.line);
|
|
190
|
+
if (bqProbe && bqProbe.depth > 1) {
|
|
191
|
+
const bqStart = i;
|
|
192
|
+
const lineInfos = [];
|
|
193
|
+
while (i < end) {
|
|
194
|
+
const info = parseBlockquoteLineInfo(rows[i], i, source);
|
|
195
|
+
if (!info)
|
|
196
|
+
break;
|
|
197
|
+
lineInfos.push(info);
|
|
198
|
+
i++;
|
|
199
|
+
}
|
|
200
|
+
if (lineInfos.length > 0) {
|
|
201
|
+
const tree = buildBlockquoteAtDepth(lineInfos, 1, source);
|
|
202
|
+
const endLine = i - 1;
|
|
203
|
+
tree.sourceRange = {
|
|
204
|
+
start: rows[bqStart].start,
|
|
205
|
+
end: afterLineTerminator(source, rows[endLine]),
|
|
206
|
+
startLine: bqStart,
|
|
207
|
+
endLine
|
|
208
|
+
};
|
|
209
|
+
tree.id = stableBlockId('blockquote', tree.sourceRange);
|
|
210
|
+
blocks.push(tree);
|
|
211
|
+
}
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const listHead = parseListLine(stripped, i);
|
|
215
|
+
if (listHead) {
|
|
216
|
+
const chunk = [listHead];
|
|
217
|
+
let j = i + 1;
|
|
218
|
+
while (j < end) {
|
|
219
|
+
const inner = stripCalloutQuoteLine(rows[j].line);
|
|
220
|
+
if (inner === null || inner.trim() === '')
|
|
221
|
+
break;
|
|
222
|
+
const next = parseListLine(inner, j);
|
|
223
|
+
if (!next)
|
|
224
|
+
break;
|
|
225
|
+
chunk.push(next);
|
|
226
|
+
j++;
|
|
227
|
+
}
|
|
228
|
+
const items = buildListItemForest(chunk, source, rows);
|
|
229
|
+
for (const item of items) {
|
|
230
|
+
item.id = stableBlockId('listItem', item.sourceRange);
|
|
231
|
+
blocks.push(item);
|
|
232
|
+
}
|
|
233
|
+
i = j;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const pStart = i;
|
|
237
|
+
const buf = [];
|
|
238
|
+
const bufRows = [];
|
|
239
|
+
while (i < end) {
|
|
240
|
+
if (fenceAtOpenLine.has(i))
|
|
241
|
+
break;
|
|
242
|
+
const r = rows[i];
|
|
243
|
+
const inner = stripCalloutQuoteLine(r.line);
|
|
244
|
+
if (inner === null)
|
|
245
|
+
break;
|
|
246
|
+
if (inner.trim() === '')
|
|
247
|
+
break;
|
|
248
|
+
if (INNER_CALLOUT_OPENER.test(inner))
|
|
249
|
+
break;
|
|
250
|
+
if (/^\s*\+\+\+\s+/.test(inner))
|
|
251
|
+
break;
|
|
252
|
+
const bqInner = parseBlockquoteLine(r.line);
|
|
253
|
+
if (bqInner && bqInner.depth > 1)
|
|
254
|
+
break;
|
|
255
|
+
if (parseListLine(inner, i))
|
|
256
|
+
break;
|
|
257
|
+
buf.push(inner);
|
|
258
|
+
bufRows.push(r);
|
|
259
|
+
i++;
|
|
260
|
+
}
|
|
261
|
+
if (buf.length === 0) {
|
|
262
|
+
i++;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const paras = paragraphBlocksFromLines(buf, pStart);
|
|
266
|
+
let lineOffset = 0;
|
|
267
|
+
for (const para of paras) {
|
|
268
|
+
const numLines = para.lines.length;
|
|
269
|
+
const firstRow = bufRows[lineOffset];
|
|
270
|
+
const lastRow = bufRows[lineOffset + numLines - 1];
|
|
271
|
+
const startLine = pStart + lineOffset;
|
|
272
|
+
const endLine = pStart + lineOffset + numLines - 1;
|
|
273
|
+
const range = {
|
|
274
|
+
start: firstRow.start,
|
|
275
|
+
end: afterLineTerminator(source, lastRow),
|
|
276
|
+
startLine,
|
|
277
|
+
endLine
|
|
278
|
+
};
|
|
279
|
+
blocks.push({
|
|
280
|
+
type: 'paragraph',
|
|
281
|
+
id: stableBlockId('paragraph', range),
|
|
282
|
+
sourceRange: range,
|
|
283
|
+
data: para,
|
|
284
|
+
inlines: []
|
|
285
|
+
});
|
|
286
|
+
lineOffset += numLines;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return blocks;
|
|
290
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function calloutReconcileFingerprint(block, childFingerprint) {
|
|
2
|
+
if (block.type !== 'callout')
|
|
3
|
+
return '';
|
|
4
|
+
const d = block.data;
|
|
5
|
+
const fp = childFingerprint ?? ((c) => `${c.type}:${c.id}`);
|
|
6
|
+
const childPart = (block.children ?? []).map((c) => fp(c)).join('|');
|
|
7
|
+
return `callout:${d.type}:${d.title}:${childPart}`;
|
|
8
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
import type { CalloutBlock } from './types';
|
|
3
|
+
export declare function serializeCalloutOpener(d: CalloutBlock): string;
|
|
4
|
+
export declare function serializeCalloutData(d: CalloutBlock, children?: EditorBlock[]): string;
|
|
5
|
+
export declare function serializeCalloutBlock(block: EditorBlock): string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { serializeBlockquoteBlock } from '../blockquote';
|
|
2
|
+
import { serializeCodeFenceBlock } from '../codeFence';
|
|
3
|
+
import { serializeListRegion } from '../list';
|
|
4
|
+
import { serializeParagraphBlock } from '../paragraph';
|
|
5
|
+
import { serializeToggleBlock } from '../toggle';
|
|
6
|
+
function prefixQuotedLines(markdown) {
|
|
7
|
+
const lines = [];
|
|
8
|
+
for (const line of markdown.split('\n')) {
|
|
9
|
+
lines.push(line.length === 0 ? '>' : `> ${line}`);
|
|
10
|
+
}
|
|
11
|
+
return lines;
|
|
12
|
+
}
|
|
13
|
+
function serializeCalloutChild(block) {
|
|
14
|
+
switch (block.type) {
|
|
15
|
+
case 'paragraph':
|
|
16
|
+
return serializeParagraphBlock(block);
|
|
17
|
+
case 'blockquote':
|
|
18
|
+
return serializeBlockquoteBlock(block, serializeCalloutChild);
|
|
19
|
+
case 'codeFence':
|
|
20
|
+
return serializeCodeFenceBlock(block);
|
|
21
|
+
case 'toggle':
|
|
22
|
+
return serializeToggleBlock(block);
|
|
23
|
+
case 'callout':
|
|
24
|
+
return serializeCalloutBlock(block);
|
|
25
|
+
default:
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function serializeCalloutChildren(children) {
|
|
30
|
+
const lines = [];
|
|
31
|
+
let i = 0;
|
|
32
|
+
while (i < children.length) {
|
|
33
|
+
if (i > 0)
|
|
34
|
+
lines.push('>');
|
|
35
|
+
const child = children[i];
|
|
36
|
+
if (child.type === 'listItem') {
|
|
37
|
+
let j = i;
|
|
38
|
+
while (j < children.length && children[j]?.type === 'listItem')
|
|
39
|
+
j++;
|
|
40
|
+
lines.push(...prefixQuotedLines(serializeListRegion(children.slice(i, j))));
|
|
41
|
+
i = j;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
lines.push(...prefixQuotedLines(serializeCalloutChild(child)));
|
|
45
|
+
i++;
|
|
46
|
+
}
|
|
47
|
+
return lines;
|
|
48
|
+
}
|
|
49
|
+
export function serializeCalloutOpener(d) {
|
|
50
|
+
const base = `> [!${d.type}]`;
|
|
51
|
+
return d.title.trim().length > 0 ? `${base} ${d.title}` : base;
|
|
52
|
+
}
|
|
53
|
+
export function serializeCalloutData(d, children) {
|
|
54
|
+
const lines = [serializeCalloutOpener(d)];
|
|
55
|
+
if (children && children.length > 0) {
|
|
56
|
+
lines.push(...serializeCalloutChildren(children));
|
|
57
|
+
}
|
|
58
|
+
return lines.join('\n');
|
|
59
|
+
}
|
|
60
|
+
export function serializeCalloutBlock(block) {
|
|
61
|
+
if (block.type !== 'callout') {
|
|
62
|
+
throw new Error('serializeCalloutBlock expects a callout block');
|
|
63
|
+
}
|
|
64
|
+
return serializeCalloutData(block.data, block.children);
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import EditableCallout from '../blocks/EditableCallout.svelte';
|
|
2
|
+
import { calloutCommands } from './callout/commands';
|
|
3
|
+
import { parseCallouts, tryParseCalloutAt } from './callout/parse';
|
|
4
|
+
import { calloutReconcileFingerprint } from './callout/reconcile';
|
|
5
|
+
import { serializeCalloutBlock } from './callout/serialize';
|
|
6
|
+
import { calloutRenderer } from './callout/CalloutRenderer.svelte';
|
|
7
|
+
export const calloutSpec = {
|
|
8
|
+
type: 'callout',
|
|
9
|
+
id: 'callout',
|
|
10
|
+
render: calloutRenderer,
|
|
11
|
+
editComponent: EditableCallout,
|
|
12
|
+
parse: { parseCallouts, tryParseCalloutAt },
|
|
13
|
+
serialize: serializeCalloutBlock,
|
|
14
|
+
applyInlineSecondPass: (block, _source, _inside, _ctx) => block,
|
|
15
|
+
reconcileFingerprint: calloutReconcileFingerprint,
|
|
16
|
+
commands: calloutCommands,
|
|
17
|
+
toRenderBlock: (block) => ({
|
|
18
|
+
id: block.id,
|
|
19
|
+
pluginId: 'callout',
|
|
20
|
+
data: block,
|
|
21
|
+
render: calloutRenderer
|
|
22
|
+
})
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { CodeFencedData } from './types';
|
|
3
|
+
|
|
4
|
+
export { codeFenceRenderer };
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#snippet codeFenceRenderer(block: CodeFencedData)}
|
|
8
|
+
<div
|
|
9
|
+
class="mb-4 overflow-x-auto border-l-2 border-border-emphasis py-2 pl-4 font-mono text-sm text-txt-primary"
|
|
10
|
+
>
|
|
11
|
+
{#if block.language}
|
|
12
|
+
<p class="mb-2 text-xs font-medium tracking-wide text-txt-tertiary">
|
|
13
|
+
{block.language}
|
|
14
|
+
</p>
|
|
15
|
+
{/if}
|
|
16
|
+
<pre class="break-words whitespace-pre-wrap">{block.code}</pre>
|
|
17
|
+
</div>
|
|
18
|
+
{/snippet}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CodeFencedData } from './types';
|
|
2
|
+
declare const codeFenceRenderer: (block: CodeFencedData) => ReturnType<import("svelte").Snippet>;
|
|
3
|
+
export { codeFenceRenderer };
|
|
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 CodeFenceRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type CodeFenceRenderer = InstanceType<typeof CodeFenceRenderer>;
|
|
21
|
+
export default CodeFenceRenderer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const codeFenceCommands = [];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { codeFenceCommands } from './commands';
|
|
2
|
+
export { applyCodeFenceInlineSecondPass } from './inlineSecondPass';
|
|
3
|
+
export { codeFenceReconcileFingerprint } from './reconcile';
|
|
4
|
+
export { serializeCodeFenceBlock } from './serialize';
|
|
5
|
+
export type { CodeFencedData } from './types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RichInlineContext } from '../../model/richInlines';
|
|
2
|
+
import type { EditorBlock } from '../../model/types';
|
|
3
|
+
export declare function applyCodeFenceInlineSecondPass(block: EditorBlock, _source: string, _insideBlockquote: boolean, _ctx: RichInlineContext): EditorBlock;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function serializeCodeFenceBlock(block) {
|
|
2
|
+
if (block.type !== 'codeFence') {
|
|
3
|
+
throw new Error('serializeCodeFenceBlock expects a codeFence block');
|
|
4
|
+
}
|
|
5
|
+
const d = block.data;
|
|
6
|
+
const lang = d.language ?? '';
|
|
7
|
+
return `\`\`\`${lang}\n${d.code}\n\`\`\``;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import EditableCodeBlock from '../blocks/EditableCodeBlock.svelte';
|
|
2
|
+
import { codeFenceCommands } from './codeFence/commands';
|
|
3
|
+
import { applyCodeFenceInlineSecondPass } from './codeFence/inlineSecondPass';
|
|
4
|
+
import { codeFenceReconcileFingerprint } from './codeFence/reconcile';
|
|
5
|
+
import { serializeCodeFenceBlock } from './codeFence/serialize';
|
|
6
|
+
import { codeFenceRenderer } from './codeFence/CodeFenceRenderer.svelte';
|
|
7
|
+
export const codeFenceSpec = {
|
|
8
|
+
type: 'codeFence',
|
|
9
|
+
id: 'code',
|
|
10
|
+
render: codeFenceRenderer,
|
|
11
|
+
editComponent: EditableCodeBlock,
|
|
12
|
+
parse: {},
|
|
13
|
+
serialize: serializeCodeFenceBlock,
|
|
14
|
+
applyInlineSecondPass: applyCodeFenceInlineSecondPass,
|
|
15
|
+
reconcileFingerprint: codeFenceReconcileFingerprint,
|
|
16
|
+
commands: codeFenceCommands,
|
|
17
|
+
toRenderBlock: (block) => ({
|
|
18
|
+
id: block.id,
|
|
19
|
+
pluginId: 'code',
|
|
20
|
+
data: block.data,
|
|
21
|
+
render: codeFenceRenderer
|
|
22
|
+
})
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { ColumnsBlock } from './types';
|
|
3
|
+
|
|
4
|
+
export { columnsRenderer };
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#snippet columnsRenderer(block: ColumnsBlock)}
|
|
8
|
+
<div
|
|
9
|
+
class="mb-4 grid gap-6 text-txt-primary"
|
|
10
|
+
style={`grid-template-columns: repeat(${block.columns.length}, minmax(0, 1fr));`}
|
|
11
|
+
>
|
|
12
|
+
{#each block.columns as cell, index (index)}
|
|
13
|
+
<div class="min-w-0 text-sm leading-6 whitespace-pre-wrap text-txt-primary">
|
|
14
|
+
{cell}
|
|
15
|
+
</div>
|
|
16
|
+
{/each}
|
|
17
|
+
</div>
|
|
18
|
+
{/snippet}
|