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,188 @@
|
|
|
1
|
+
import { afterLineTerminator } from '../../model/line-utils';
|
|
2
|
+
import { paragraphBlocksFromLines } from '../paragraph/parse';
|
|
3
|
+
import { stableBlockId } from '../../model/types';
|
|
4
|
+
/** Optional leading whitespace, then one or more `>` each optionally followed by spaces/tabs. */
|
|
5
|
+
const BLOCKQUOTE_PREFIX = /^\s*((?:>\s*)+)(.*)$/;
|
|
6
|
+
/** `> ` markers prefix; captures leading whitespace, marker run, trailing payload. */
|
|
7
|
+
const BLOCKQUOTE_LINE = /^(\s*)((?:>\s*)+)(.*)$/;
|
|
8
|
+
export function parseBlockquoteLine(line) {
|
|
9
|
+
const match = line.match(BLOCKQUOTE_PREFIX);
|
|
10
|
+
if (!match)
|
|
11
|
+
return null;
|
|
12
|
+
const markers = match[1];
|
|
13
|
+
const depth = (markers.match(/>/g) ?? []).length;
|
|
14
|
+
let text = match[2];
|
|
15
|
+
if (text.startsWith(' '))
|
|
16
|
+
text = text.slice(1);
|
|
17
|
+
return { depth, text };
|
|
18
|
+
}
|
|
19
|
+
export function parseBlockquoteLineInfo(row, lineIndex, source) {
|
|
20
|
+
const m = row.line.match(BLOCKQUOTE_LINE);
|
|
21
|
+
if (!m)
|
|
22
|
+
return null;
|
|
23
|
+
const markers = m[2] ?? '';
|
|
24
|
+
const tail = m[3] ?? '';
|
|
25
|
+
const depth = (markers.match(/>/g) ?? []).length;
|
|
26
|
+
return {
|
|
27
|
+
depth,
|
|
28
|
+
contentText: tail.startsWith(' ') ? tail.slice(1) : tail,
|
|
29
|
+
rowStart: row.start,
|
|
30
|
+
rowEnd: afterLineTerminator(source, row),
|
|
31
|
+
lineIndex
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** `>` marker depth for a content-bearing blockquote from its source opener line. */
|
|
35
|
+
export function quoteDepthFromBlock(block, source) {
|
|
36
|
+
if (!source || block.sourceRange.startLine < 0)
|
|
37
|
+
return 0;
|
|
38
|
+
const line = source.split(/\r?\n/)[block.sourceRange.startLine] ?? '';
|
|
39
|
+
return parseBlockquoteLine(line)?.depth ?? 0;
|
|
40
|
+
}
|
|
41
|
+
/** True when `child` is a deeper nested quote (`>>`), not a same-depth continuation. */
|
|
42
|
+
export function isNestedQuoteChild(parent, child, source) {
|
|
43
|
+
if (parent.type !== 'blockquote' || child.type !== 'blockquote')
|
|
44
|
+
return false;
|
|
45
|
+
const parentDepth = quoteDepthFromBlock(parent, source);
|
|
46
|
+
const childDepth = quoteDepthFromBlock(child, source);
|
|
47
|
+
return parentDepth > 0 && childDepth > parentDepth;
|
|
48
|
+
}
|
|
49
|
+
function makeContentBlockquote(para, paraLines) {
|
|
50
|
+
const first = paraLines[0];
|
|
51
|
+
const last = paraLines[paraLines.length - 1];
|
|
52
|
+
const range = {
|
|
53
|
+
start: first.rowStart,
|
|
54
|
+
end: last.rowEnd,
|
|
55
|
+
startLine: first.lineIndex,
|
|
56
|
+
endLine: last.lineIndex
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
type: 'blockquote',
|
|
60
|
+
id: stableBlockId('blockquote', range),
|
|
61
|
+
sourceRange: range,
|
|
62
|
+
data: {},
|
|
63
|
+
children: [],
|
|
64
|
+
inlines: []
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function appendParagraphChildrenFromRun(children, paras, paraLines, startParaIndex) {
|
|
68
|
+
let lineOffset = 0;
|
|
69
|
+
for (let pi = 0; pi < startParaIndex; pi++) {
|
|
70
|
+
lineOffset += paras[pi].lines.length;
|
|
71
|
+
}
|
|
72
|
+
for (let pi = startParaIndex; pi < paras.length; pi++) {
|
|
73
|
+
const para = paras[pi];
|
|
74
|
+
const plines = paraLines.slice(lineOffset, lineOffset + para.lines.length);
|
|
75
|
+
children.push(makeContentBlockquote(para, plines));
|
|
76
|
+
lineOffset += para.lines.length;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Build content-bearing `blockquote` subtree from one nesting level. */
|
|
80
|
+
export function buildBlockquoteAtDepth(lines, depth, source) {
|
|
81
|
+
const children = [];
|
|
82
|
+
let root = null;
|
|
83
|
+
let i = 0;
|
|
84
|
+
while (i < lines.length) {
|
|
85
|
+
const cur = lines[i];
|
|
86
|
+
if (cur.depth > depth) {
|
|
87
|
+
let j = i;
|
|
88
|
+
while (j < lines.length && lines[j].depth > depth)
|
|
89
|
+
j++;
|
|
90
|
+
children.push(buildBlockquoteAtDepth(lines.slice(i, j), depth + 1, source));
|
|
91
|
+
i = j;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (cur.depth < depth)
|
|
95
|
+
break;
|
|
96
|
+
if (cur.contentText.trim() === '') {
|
|
97
|
+
i++;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let j = i;
|
|
101
|
+
while (j < lines.length && lines[j].depth === depth && lines[j].contentText.trim() !== '') {
|
|
102
|
+
j++;
|
|
103
|
+
}
|
|
104
|
+
const paraLines = lines.slice(i, j);
|
|
105
|
+
const contentLines = paraLines.map((l) => l.contentText);
|
|
106
|
+
const paras = paragraphBlocksFromLines(contentLines, paraLines[0].lineIndex);
|
|
107
|
+
if (!root) {
|
|
108
|
+
root = makeContentBlockquote(paras[0], paraLines.slice(0, paras[0].lines.length));
|
|
109
|
+
appendParagraphChildrenFromRun(children, paras, paraLines, 1);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
appendParagraphChildrenFromRun(children, paras, paraLines, 0);
|
|
113
|
+
}
|
|
114
|
+
i = j;
|
|
115
|
+
}
|
|
116
|
+
if (!root) {
|
|
117
|
+
const first = lines[0];
|
|
118
|
+
const last = lines[lines.length - 1];
|
|
119
|
+
const range = {
|
|
120
|
+
start: first.rowStart,
|
|
121
|
+
end: last.rowEnd,
|
|
122
|
+
startLine: first.lineIndex,
|
|
123
|
+
endLine: last.lineIndex
|
|
124
|
+
};
|
|
125
|
+
root = {
|
|
126
|
+
type: 'blockquote',
|
|
127
|
+
id: stableBlockId('blockquote', range),
|
|
128
|
+
sourceRange: range,
|
|
129
|
+
data: {},
|
|
130
|
+
children: [],
|
|
131
|
+
inlines: []
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
root.children = children.length > 0 ? children : undefined;
|
|
135
|
+
return root;
|
|
136
|
+
}
|
|
137
|
+
function appendText(children, text) {
|
|
138
|
+
const last = children[children.length - 1];
|
|
139
|
+
if (last?.kind === 'text') {
|
|
140
|
+
last.text += '\n' + text;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
children.push({ kind: 'text', text });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function buildLegacyTree(lines) {
|
|
147
|
+
const root = [];
|
|
148
|
+
const stack = [root];
|
|
149
|
+
for (const { depth, text } of lines) {
|
|
150
|
+
while (stack.length > depth) {
|
|
151
|
+
stack.pop();
|
|
152
|
+
}
|
|
153
|
+
while (stack.length < depth) {
|
|
154
|
+
const nested = { kind: 'quote', children: [] };
|
|
155
|
+
stack[stack.length - 1].push(nested);
|
|
156
|
+
stack.push(nested.children);
|
|
157
|
+
}
|
|
158
|
+
appendText(stack[stack.length - 1], text);
|
|
159
|
+
}
|
|
160
|
+
return root;
|
|
161
|
+
}
|
|
162
|
+
/** Legacy region parser retained for tooling; canonical upload parse uses `buildBlockquoteAtDepth`. */
|
|
163
|
+
export function parseBlockquotes(source) {
|
|
164
|
+
const lines = source.split(/\r?\n/);
|
|
165
|
+
const out = [];
|
|
166
|
+
let i = 0;
|
|
167
|
+
while (i < lines.length) {
|
|
168
|
+
const firstParsed = parseBlockquoteLine(lines[i]);
|
|
169
|
+
if (!firstParsed) {
|
|
170
|
+
i++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const start = i;
|
|
174
|
+
const regionLines = [];
|
|
175
|
+
while (i < lines.length) {
|
|
176
|
+
const line = lines[i];
|
|
177
|
+
const parsed = parseBlockquoteLine(line);
|
|
178
|
+
if (!parsed)
|
|
179
|
+
break;
|
|
180
|
+
regionLines.push(parsed);
|
|
181
|
+
i++;
|
|
182
|
+
}
|
|
183
|
+
if (regionLines.length > 0) {
|
|
184
|
+
out.push({ lineIndex: start, children: buildLegacyTree(regionLines) });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function blockquoteReconcileFingerprint(block, childFingerprint) {
|
|
2
|
+
if (block.type !== 'blockquote')
|
|
3
|
+
return '';
|
|
4
|
+
if (block.inlines?.length) {
|
|
5
|
+
return childFingerprint({ ...block, type: 'paragraph' });
|
|
6
|
+
}
|
|
7
|
+
const first = block.children?.[0];
|
|
8
|
+
return first ? childFingerprint(first) : '';
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
declare function indentLines(text: string, prefix: string): string;
|
|
3
|
+
/** Blockquote-prefix every line; blank lines collapse to bare `>` (not `> `). */
|
|
4
|
+
declare function blockquotePrefix(text: string): string;
|
|
5
|
+
export declare function serializeBlockquoteBlock(block: EditorBlock, serializeChild: (block: EditorBlock) => string, source?: string): string;
|
|
6
|
+
export { indentLines, blockquotePrefix };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { serializeInlineNodes } from '../../model/serializeInlineNodes';
|
|
2
|
+
import { parseBlockquoteLine, quoteDepthFromBlock } from './parse';
|
|
3
|
+
function indentLines(text, prefix) {
|
|
4
|
+
return text
|
|
5
|
+
.split('\n')
|
|
6
|
+
.map((l) => prefix + l)
|
|
7
|
+
.join('\n');
|
|
8
|
+
}
|
|
9
|
+
/** Blockquote-prefix every line; blank lines collapse to bare `>` (not `> `). */
|
|
10
|
+
function blockquotePrefix(text) {
|
|
11
|
+
return text
|
|
12
|
+
.split('\n')
|
|
13
|
+
.map((l) => (l.length === 0 ? '>' : `> ${l}`))
|
|
14
|
+
.join('\n');
|
|
15
|
+
}
|
|
16
|
+
function blockquoteBodyFromSource(block, source) {
|
|
17
|
+
if (block.inlines?.length)
|
|
18
|
+
return serializeInlineNodes(block.inlines);
|
|
19
|
+
if (!source || block.sourceRange.start < 0 || block.sourceRange.synthetic)
|
|
20
|
+
return '';
|
|
21
|
+
const slice = source.slice(block.sourceRange.start, block.sourceRange.end);
|
|
22
|
+
const firstLine = slice.split('\n')[0] ?? '';
|
|
23
|
+
const m = firstLine.match(/^\s*(?:>\s*)+(.*)$/);
|
|
24
|
+
return (m ? m[1] : firstLine).trimEnd();
|
|
25
|
+
}
|
|
26
|
+
export function serializeBlockquoteBlock(block, serializeChild, source) {
|
|
27
|
+
if (block.type !== 'blockquote') {
|
|
28
|
+
throw new Error('serializeBlockquoteBlock expects a blockquote block');
|
|
29
|
+
}
|
|
30
|
+
const parts = [];
|
|
31
|
+
const body = blockquoteBodyFromSource(block, source);
|
|
32
|
+
if (body.length > 0)
|
|
33
|
+
parts.push(body);
|
|
34
|
+
const parentDepth = quoteDepthFromBlock(block, source);
|
|
35
|
+
for (const child of block.children ?? []) {
|
|
36
|
+
if (child.type === 'blockquote' && parentDepth > 0) {
|
|
37
|
+
const childDepth = quoteDepthFromBlock(child, source);
|
|
38
|
+
if (childDepth === parentDepth) {
|
|
39
|
+
const childBody = blockquoteBodyFromSource(child, source);
|
|
40
|
+
if (childBody.length > 0)
|
|
41
|
+
parts.push(childBody);
|
|
42
|
+
for (const sub of child.children ?? []) {
|
|
43
|
+
parts.push('');
|
|
44
|
+
parts.push(serializeChild(sub));
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
parts.push('');
|
|
50
|
+
parts.push(serializeChild(child));
|
|
51
|
+
}
|
|
52
|
+
const inner = parts.join('\n');
|
|
53
|
+
return blockquotePrefix(inner);
|
|
54
|
+
}
|
|
55
|
+
export { indentLines, blockquotePrefix };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type BlockquoteLineInfo = {
|
|
2
|
+
depth: number;
|
|
3
|
+
contentText: string;
|
|
4
|
+
rowStart: number;
|
|
5
|
+
rowEnd: number;
|
|
6
|
+
lineIndex: number;
|
|
7
|
+
};
|
|
8
|
+
export type BlockquoteText = {
|
|
9
|
+
kind: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
};
|
|
12
|
+
export type BlockquoteQuote = {
|
|
13
|
+
kind: 'quote';
|
|
14
|
+
children: BlockquoteChild[];
|
|
15
|
+
};
|
|
16
|
+
export type BlockquoteChild = BlockquoteText | BlockquoteQuote;
|
|
17
|
+
export type BlockquoteBlock = {
|
|
18
|
+
lineIndex: number;
|
|
19
|
+
children: BlockquoteChild[];
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import EditableBlockquote from '../blocks/EditableBlockquote.svelte';
|
|
2
|
+
import { listItemReconcileFingerprint } from './list/reconcile';
|
|
3
|
+
import { paragraphReconcileFingerprint } from './paragraph/reconcile';
|
|
4
|
+
import { blockquoteCommands } from './blockquote/commands';
|
|
5
|
+
import { blockquoteRenderer } from './blockquote/BlockquoteRenderer.svelte';
|
|
6
|
+
import { serializeEditorBlock } from '../model/serializeMarkdownDocument';
|
|
7
|
+
import { buildBlockquoteAtDepth, parseBlockquoteLine, parseBlockquoteLineInfo } from './blockquote/parse';
|
|
8
|
+
import { blockquoteReconcileFingerprint } from './blockquote/reconcile';
|
|
9
|
+
import { serializeBlockquoteBlock } from './blockquote/serialize';
|
|
10
|
+
function blockquoteChildFingerprint(block) {
|
|
11
|
+
if (block.type === 'listItem')
|
|
12
|
+
return listItemReconcileFingerprint(block);
|
|
13
|
+
if (block.type === 'paragraph')
|
|
14
|
+
return paragraphReconcileFingerprint(block);
|
|
15
|
+
if (block.type === 'blockquote') {
|
|
16
|
+
return blockquoteReconcileFingerprint(block, blockquoteChildFingerprint);
|
|
17
|
+
}
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
export const blockquoteSpec = {
|
|
21
|
+
type: 'blockquote',
|
|
22
|
+
id: 'blockquotes',
|
|
23
|
+
render: blockquoteRenderer,
|
|
24
|
+
editComponent: EditableBlockquote,
|
|
25
|
+
parse: { parseBlockquoteLine, parseBlockquoteLineInfo, buildBlockquoteAtDepth },
|
|
26
|
+
serialize: (block, source) => serializeBlockquoteBlock(block, (child) => serializeEditorBlock(child, source), source),
|
|
27
|
+
applyInlineSecondPass: (block) => block,
|
|
28
|
+
reconcileFingerprint: (block) => blockquoteReconcileFingerprint(block, blockquoteChildFingerprint),
|
|
29
|
+
commands: blockquoteCommands,
|
|
30
|
+
toRenderBlock: (block) => ({
|
|
31
|
+
id: block.id,
|
|
32
|
+
pluginId: 'blockquotes',
|
|
33
|
+
data: block,
|
|
34
|
+
render: blockquoteRenderer
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
export { blockquoteReconcileFingerprint };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { getBlockSpec } from '../../block-specs/registry';
|
|
3
|
+
import type { EditorBlock } from '../../model/types';
|
|
4
|
+
import { calloutAccentFor } from './icons';
|
|
5
|
+
import type { CalloutBlock } from './types';
|
|
6
|
+
import CalloutTypeIcon from './CalloutTypeIcon.svelte';
|
|
7
|
+
|
|
8
|
+
export { calloutRenderer };
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#snippet calloutChildBody(child: EditorBlock)}
|
|
12
|
+
{@const spec = getBlockSpec(child.type)}
|
|
13
|
+
{#if spec}
|
|
14
|
+
{@render spec.render(child)}
|
|
15
|
+
{:else}
|
|
16
|
+
<p class="text-sm text-txt-tertiary">Unsupported block in callout: {child.type}</p>
|
|
17
|
+
{/if}
|
|
18
|
+
{/snippet}
|
|
19
|
+
|
|
20
|
+
{#snippet calloutRenderer(block: EditorBlock)}
|
|
21
|
+
{@const data = block.data as CalloutBlock}
|
|
22
|
+
{@const accent = calloutAccentFor(data.type)}
|
|
23
|
+
<aside class="mb-4 border-l-4 py-1 pl-4 {accent.bar}">
|
|
24
|
+
<div class="mb-2 flex items-start gap-2">
|
|
25
|
+
<CalloutTypeIcon type={data.type} class="mt-0.5 h-5 w-5 shrink-0 {accent.title}" />
|
|
26
|
+
{#if data.title}
|
|
27
|
+
<h3 class="min-w-0 flex-1 text-base font-semibold {accent.title}">{data.title}</h3>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
{#if block.children && block.children.length > 0}
|
|
31
|
+
<div class="callout-body space-y-1 text-sm leading-relaxed text-txt-secondary">
|
|
32
|
+
{#each block.children as child (child.id)}
|
|
33
|
+
{@render calloutChildBody(child)}
|
|
34
|
+
{/each}
|
|
35
|
+
</div>
|
|
36
|
+
{/if}
|
|
37
|
+
</aside>
|
|
38
|
+
{/snippet}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EditorBlock } from '../../model/types';
|
|
2
|
+
declare const calloutRenderer: (block: EditorBlock) => ReturnType<import("svelte").Snippet>;
|
|
3
|
+
export { calloutRenderer };
|
|
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 CalloutRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type CalloutRenderer = InstanceType<typeof CalloutRenderer>;
|
|
21
|
+
export default CalloutRenderer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '@iconify/svelte'
|
|
3
|
+
import { calloutIconFor } from './icons';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
type,
|
|
7
|
+
class: className = ''
|
|
8
|
+
}: {
|
|
9
|
+
type: string;
|
|
10
|
+
class?: string;
|
|
11
|
+
} = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Icon icon={calloutIconFor(type)} class={className} aria-hidden="true" />
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const moveShortcut = { ariaKeyShortcuts: 'Alt+Shift+ArrowUp' };
|
|
2
|
+
const moveDownShortcut = { ariaKeyShortcuts: 'Alt+Shift+ArrowDown' };
|
|
3
|
+
function isCalloutBodyRow(ctx) {
|
|
4
|
+
return ctx.nestedRowBlockId !== undefined && ctx.blockType === 'callout';
|
|
5
|
+
}
|
|
6
|
+
export const calloutCommands = [
|
|
7
|
+
{
|
|
8
|
+
id: 'duplicateCalloutChild',
|
|
9
|
+
label: 'Duplicate',
|
|
10
|
+
group: 'structure',
|
|
11
|
+
surfaces: ['blockMenu'],
|
|
12
|
+
blockTypes: ['callout'],
|
|
13
|
+
nestedRowOnly: true,
|
|
14
|
+
isEnabled: (ctx) => isCalloutBodyRow(ctx),
|
|
15
|
+
run: (ctx) => {
|
|
16
|
+
if (!ctx.nestedRowBlockId)
|
|
17
|
+
return;
|
|
18
|
+
ctx.editor.duplicateCalloutChildAt(ctx.blockIndex, ctx.nestedRowBlockId);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'deleteCalloutChild',
|
|
23
|
+
label: 'Delete',
|
|
24
|
+
group: 'structure',
|
|
25
|
+
surfaces: ['blockMenu'],
|
|
26
|
+
blockTypes: ['callout'],
|
|
27
|
+
nestedRowOnly: true,
|
|
28
|
+
isEnabled: (ctx) => isCalloutBodyRow(ctx),
|
|
29
|
+
run: (ctx) => {
|
|
30
|
+
if (!ctx.nestedRowBlockId)
|
|
31
|
+
return;
|
|
32
|
+
ctx.editor.deleteCalloutChildAt(ctx.blockIndex, ctx.nestedRowBlockId);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'moveCalloutChildUp',
|
|
37
|
+
label: 'Move up',
|
|
38
|
+
group: 'structure',
|
|
39
|
+
surfaces: ['blockMenu'],
|
|
40
|
+
blockTypes: ['callout'],
|
|
41
|
+
nestedRowOnly: true,
|
|
42
|
+
isEnabled: (ctx) => isCalloutBodyRow(ctx) && ctx.canMoveUp,
|
|
43
|
+
run: (ctx) => {
|
|
44
|
+
if (!ctx.nestedRowBlockId)
|
|
45
|
+
return;
|
|
46
|
+
ctx.editor.moveCalloutChildSiblingAt(ctx.blockIndex, ctx.nestedRowBlockId, 'up');
|
|
47
|
+
},
|
|
48
|
+
shortcut: moveShortcut
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'moveCalloutChildDown',
|
|
52
|
+
label: 'Move down',
|
|
53
|
+
group: 'structure',
|
|
54
|
+
surfaces: ['blockMenu'],
|
|
55
|
+
blockTypes: ['callout'],
|
|
56
|
+
nestedRowOnly: true,
|
|
57
|
+
isEnabled: (ctx) => isCalloutBodyRow(ctx) && ctx.canMoveDown,
|
|
58
|
+
run: (ctx) => {
|
|
59
|
+
if (!ctx.nestedRowBlockId)
|
|
60
|
+
return;
|
|
61
|
+
ctx.editor.moveCalloutChildSiblingAt(ctx.blockIndex, ctx.nestedRowBlockId, 'down');
|
|
62
|
+
},
|
|
63
|
+
shortcut: moveDownShortcut
|
|
64
|
+
}
|
|
65
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Curated callout variants shown in the type popover. */
|
|
2
|
+
export declare const CURATED_CALLOUT_TYPES: readonly ["note", "tip", "important", "warning", "caution", "success", "error"];
|
|
3
|
+
export type CuratedCalloutType = (typeof CURATED_CALLOUT_TYPES)[number];
|
|
4
|
+
export declare function normalizeCalloutType(type: string): string;
|
|
5
|
+
export declare function calloutIconFor(type: string): string;
|
|
6
|
+
export declare function calloutAccentFor(type: string): {
|
|
7
|
+
bar: string;
|
|
8
|
+
title: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function calloutTypeLabel(type: CuratedCalloutType): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Curated callout variants shown in the type popover. */
|
|
2
|
+
export const CURATED_CALLOUT_TYPES = [
|
|
3
|
+
'note',
|
|
4
|
+
'tip',
|
|
5
|
+
'important',
|
|
6
|
+
'warning',
|
|
7
|
+
'caution',
|
|
8
|
+
'success',
|
|
9
|
+
'error'
|
|
10
|
+
];
|
|
11
|
+
const TYPE_ICONS = {
|
|
12
|
+
note: 'carbon:information',
|
|
13
|
+
tip: 'carbon:idea',
|
|
14
|
+
important: 'carbon:star-filled',
|
|
15
|
+
warning: 'carbon:warning-alt',
|
|
16
|
+
caution: 'carbon:warning',
|
|
17
|
+
success: 'carbon:checkmark-filled',
|
|
18
|
+
error: 'carbon:error'
|
|
19
|
+
};
|
|
20
|
+
const TYPE_ALIASES = {
|
|
21
|
+
info: 'note',
|
|
22
|
+
danger: 'error'
|
|
23
|
+
};
|
|
24
|
+
const TYPE_ACCENTS = {
|
|
25
|
+
note: { bar: 'border-l-option-blue', title: 'text-option-blue' },
|
|
26
|
+
tip: { bar: 'border-l-semantic-success', title: 'text-semantic-success' },
|
|
27
|
+
important: { bar: 'border-l-option-purple', title: 'text-option-purple' },
|
|
28
|
+
warning: { bar: 'border-l-semantic-warning', title: 'text-semantic-warning' },
|
|
29
|
+
caution: { bar: 'border-l-semantic-warning', title: 'text-semantic-warning' },
|
|
30
|
+
success: { bar: 'border-l-semantic-success', title: 'text-semantic-success' },
|
|
31
|
+
error: { bar: 'border-l-semantic-error', title: 'text-semantic-error' }
|
|
32
|
+
};
|
|
33
|
+
const FALLBACK_ACCENT = { bar: 'border-l-border-emphasis', title: 'text-txt-primary' };
|
|
34
|
+
export function normalizeCalloutType(type) {
|
|
35
|
+
const key = type.toLowerCase();
|
|
36
|
+
return TYPE_ALIASES[key] ?? key;
|
|
37
|
+
}
|
|
38
|
+
export function calloutIconFor(type) {
|
|
39
|
+
const key = normalizeCalloutType(type);
|
|
40
|
+
if (key in TYPE_ICONS)
|
|
41
|
+
return TYPE_ICONS[key];
|
|
42
|
+
return 'carbon:help';
|
|
43
|
+
}
|
|
44
|
+
export function calloutAccentFor(type) {
|
|
45
|
+
const key = normalizeCalloutType(type);
|
|
46
|
+
if (key in TYPE_ACCENTS)
|
|
47
|
+
return TYPE_ACCENTS[key];
|
|
48
|
+
return FALLBACK_ACCENT;
|
|
49
|
+
}
|
|
50
|
+
export function calloutTypeLabel(type) {
|
|
51
|
+
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { calloutCommands } from './commands';
|
|
2
|
+
export { applyCalloutInlineSecondPass } from './inlineSecondPass';
|
|
3
|
+
export { parseCallouts, tryParseCalloutAt } from './parse';
|
|
4
|
+
export { parseCalloutBodyBlocks, stripCalloutQuoteLine } from './parseBody';
|
|
5
|
+
export { CURATED_CALLOUT_TYPES, calloutAccentFor, calloutIconFor, normalizeCalloutType } from './icons';
|
|
6
|
+
export type { FenceAtOpenLine } from './parse';
|
|
7
|
+
export { calloutReconcileFingerprint } from './reconcile';
|
|
8
|
+
export { serializeCalloutBlock, serializeCalloutData } from './serialize';
|
|
9
|
+
export type { CalloutBlock } from './types';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { calloutCommands } from './commands';
|
|
2
|
+
export { applyCalloutInlineSecondPass } from './inlineSecondPass';
|
|
3
|
+
export { parseCallouts, tryParseCalloutAt } from './parse';
|
|
4
|
+
export { parseCalloutBodyBlocks, stripCalloutQuoteLine } from './parseBody';
|
|
5
|
+
export { CURATED_CALLOUT_TYPES, calloutAccentFor, calloutIconFor, normalizeCalloutType } from './icons';
|
|
6
|
+
export { calloutReconcileFingerprint } from './reconcile';
|
|
7
|
+
export { serializeCalloutBlock, serializeCalloutData } from './serialize';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RichInlineContext } from '../../model/richInlines';
|
|
2
|
+
import type { EditorBlock } from '../../model/types';
|
|
3
|
+
import type { LineRow } from '../../model/line-utils';
|
|
4
|
+
type AnnotateBlockFn = (block: EditorBlock, source: string, rows: LineRow[], ctx: RichInlineContext, insideBlockquote: boolean) => EditorBlock;
|
|
5
|
+
export declare function applyCalloutInlineSecondPass(block: EditorBlock, source: string, rows: LineRow[], ctx: RichInlineContext, annotateBlock: AnnotateBlockFn): EditorBlock;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function applyCalloutInlineSecondPass(block, source, rows, ctx, annotateBlock) {
|
|
2
|
+
if (block.type !== 'callout')
|
|
3
|
+
return block;
|
|
4
|
+
const out = { ...block };
|
|
5
|
+
if (block.children && block.children.length > 0) {
|
|
6
|
+
out.children = block.children.map((c) => annotateBlock(c, source, rows, ctx, true));
|
|
7
|
+
}
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type LineRow } from '../../model/line-utils';
|
|
2
|
+
import type { EditorBlock } from '../../model/types';
|
|
3
|
+
import type { CalloutBlock } from './types';
|
|
4
|
+
export declare function parseCallouts(source: string): CalloutBlock[];
|
|
5
|
+
export type FenceAtOpenLine = ReadonlyMap<number, unknown>;
|
|
6
|
+
export declare function tryParseCalloutAt(i: number, rows: LineRow[], source: string, fenceAtOpenLine: FenceAtOpenLine): {
|
|
7
|
+
nextLine: number;
|
|
8
|
+
block: EditorBlock;
|
|
9
|
+
} | null;
|