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,28 @@
|
|
|
1
|
+
export type ImageFloatAlign = 'left' | 'center' | 'right';
|
|
2
|
+
export type ImageLayoutFields = {
|
|
3
|
+
displayWidth: number | 'full' | null;
|
|
4
|
+
floatAlign: ImageFloatAlign | null;
|
|
5
|
+
};
|
|
6
|
+
export type ParsedImageLabel = ImageLayoutFields & {
|
|
7
|
+
/** Alt text after suffix removal and outer trim. */
|
|
8
|
+
alt: string;
|
|
9
|
+
/** Index of `|` starting a valid format suffix in the raw label, or null. */
|
|
10
|
+
suffixPipeIndex: number | null;
|
|
11
|
+
/** True when a suffix-like tail after `|` was present but did not match grammar. */
|
|
12
|
+
malformedSuffix: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Split inline image bracket label into alt text and layout fields. */
|
|
15
|
+
export declare function parseImageLabelLayout(label: string): ParsedImageLabel;
|
|
16
|
+
/** Canonical `|suffix` for serialize from model fields. */
|
|
17
|
+
export declare function serializeImageLayoutSuffix(displayWidth: number | 'full' | null | undefined, floatAlign: ImageFloatAlign | null | undefined): string;
|
|
18
|
+
/** Map an index in the unescaped bracket label to a source offset inside `[…]`. */
|
|
19
|
+
export declare function sourceOffsetInBracketLabel(source: string, labelStart: number, unescapedIndex: number): number;
|
|
20
|
+
/** Exclusive source offset immediately after the closing `]` of a bracket label. */
|
|
21
|
+
export declare function afterBracketLabelContent(source: string, labelStart: number): number | null;
|
|
22
|
+
export type ImageLayoutCss = {
|
|
23
|
+
wrapperClass: string;
|
|
24
|
+
imgClass: string;
|
|
25
|
+
imgStyle: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
/** Block-on-own-line layout classes for suffixed images (v1). */
|
|
28
|
+
export declare function imageLayoutCss(displayWidth: number | 'full' | null | undefined, floatAlign: ImageFloatAlign | null | undefined): ImageLayoutCss;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { parseBracketedContent } from './parse-links-images';
|
|
2
|
+
const WIDTH = '([1-9]\\d*)';
|
|
3
|
+
const SUFFIX_RULES = [
|
|
4
|
+
{
|
|
5
|
+
re: new RegExp(`^\\|-1$`),
|
|
6
|
+
apply: () => ({ displayWidth: 'full', floatAlign: null })
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
re: new RegExp(`^\\|:${WIDTH}:$`),
|
|
10
|
+
apply: (m) => ({ displayWidth: Number(m[1]), floatAlign: 'center' })
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
re: new RegExp(`^\\|:${WIDTH}$`),
|
|
14
|
+
apply: (m) => ({ displayWidth: Number(m[1]), floatAlign: 'left' })
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
re: new RegExp(`^\\|${WIDTH}:$`),
|
|
18
|
+
apply: (m) => ({ displayWidth: Number(m[1]), floatAlign: 'right' })
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
re: new RegExp(`^\\|${WIDTH}$`),
|
|
22
|
+
apply: (m) => ({ displayWidth: Number(m[1]), floatAlign: null })
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
/** Heuristic: tail after last `|` looks like a failed format suffix attempt. */
|
|
26
|
+
function looksLikeMalformedSuffixTail(tail) {
|
|
27
|
+
const t = tail.trim();
|
|
28
|
+
if (!t)
|
|
29
|
+
return false;
|
|
30
|
+
if (/^-1$/.test(t))
|
|
31
|
+
return true;
|
|
32
|
+
if (/^:?-?\d+:?$/u.test(t))
|
|
33
|
+
return true;
|
|
34
|
+
if (/^\d/u.test(t))
|
|
35
|
+
return true;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
function trySuffixAt(label, pipeIndex) {
|
|
39
|
+
const suffix = label.slice(pipeIndex);
|
|
40
|
+
for (const rule of SUFFIX_RULES) {
|
|
41
|
+
const m = suffix.match(rule.re);
|
|
42
|
+
if (m)
|
|
43
|
+
return rule.apply(m);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/** Split inline image bracket label into alt text and layout fields. */
|
|
48
|
+
export function parseImageLabelLayout(label) {
|
|
49
|
+
const lastPipe = label.lastIndexOf('|');
|
|
50
|
+
if (lastPipe === -1) {
|
|
51
|
+
return {
|
|
52
|
+
alt: label.trim(),
|
|
53
|
+
displayWidth: null,
|
|
54
|
+
floatAlign: null,
|
|
55
|
+
suffixPipeIndex: null,
|
|
56
|
+
malformedSuffix: false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
for (let pipeIndex = lastPipe; pipeIndex >= 0; pipeIndex = label.lastIndexOf('|', pipeIndex - 1)) {
|
|
60
|
+
const layout = trySuffixAt(label, pipeIndex);
|
|
61
|
+
if (layout) {
|
|
62
|
+
return {
|
|
63
|
+
alt: label.slice(0, pipeIndex).trim(),
|
|
64
|
+
...layout,
|
|
65
|
+
suffixPipeIndex: pipeIndex,
|
|
66
|
+
malformedSuffix: false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const malformedSuffix = looksLikeMalformedSuffixTail(label.slice(lastPipe + 1));
|
|
71
|
+
return {
|
|
72
|
+
alt: label.trim(),
|
|
73
|
+
displayWidth: null,
|
|
74
|
+
floatAlign: null,
|
|
75
|
+
suffixPipeIndex: null,
|
|
76
|
+
malformedSuffix
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Canonical `|suffix` for serialize from model fields. */
|
|
80
|
+
export function serializeImageLayoutSuffix(displayWidth, floatAlign) {
|
|
81
|
+
if (displayWidth === 'full')
|
|
82
|
+
return '|-1';
|
|
83
|
+
if (displayWidth == null || displayWidth <= 0)
|
|
84
|
+
return '';
|
|
85
|
+
if (floatAlign === 'left')
|
|
86
|
+
return `|:${displayWidth}`;
|
|
87
|
+
if (floatAlign === 'right')
|
|
88
|
+
return `|${displayWidth}:`;
|
|
89
|
+
if (floatAlign === 'center')
|
|
90
|
+
return `|:${displayWidth}:`;
|
|
91
|
+
return `|${displayWidth}`;
|
|
92
|
+
}
|
|
93
|
+
/** Map an index in the unescaped bracket label to a source offset inside `[…]`. */
|
|
94
|
+
export function sourceOffsetInBracketLabel(source, labelStart, unescapedIndex) {
|
|
95
|
+
let u = 0;
|
|
96
|
+
let i = labelStart;
|
|
97
|
+
while (u < unescapedIndex && i < source.length) {
|
|
98
|
+
if (source[i] === '\\' && i + 1 < source.length) {
|
|
99
|
+
i += 2;
|
|
100
|
+
u++;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (source[i] === ']')
|
|
104
|
+
break;
|
|
105
|
+
i++;
|
|
106
|
+
u++;
|
|
107
|
+
}
|
|
108
|
+
return i;
|
|
109
|
+
}
|
|
110
|
+
/** Exclusive source offset immediately after the closing `]` of a bracket label. */
|
|
111
|
+
export function afterBracketLabelContent(source, labelStart) {
|
|
112
|
+
const parsed = parseBracketedContent(source, labelStart);
|
|
113
|
+
return parsed?.end ?? null;
|
|
114
|
+
}
|
|
115
|
+
/** Block-on-own-line layout classes for suffixed images (v1). */
|
|
116
|
+
export function imageLayoutCss(displayWidth, floatAlign) {
|
|
117
|
+
const hasLayout = displayWidth != null;
|
|
118
|
+
if (!hasLayout) {
|
|
119
|
+
return {
|
|
120
|
+
wrapperClass: 'inline-block max-w-full align-middle',
|
|
121
|
+
imgClass: 'max-h-48 max-w-full rounded-xs object-contain',
|
|
122
|
+
imgStyle: undefined
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const wrapperClass = 'block max-w-full';
|
|
126
|
+
let widthStyle;
|
|
127
|
+
if (displayWidth === 'full') {
|
|
128
|
+
widthStyle = 'width:100%';
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
widthStyle = `width:${displayWidth}px`;
|
|
132
|
+
}
|
|
133
|
+
let marginStyle = '';
|
|
134
|
+
if (displayWidth !== 'full' && floatAlign === 'left')
|
|
135
|
+
marginStyle = 'margin-right:auto';
|
|
136
|
+
else if (displayWidth !== 'full' && floatAlign === 'right')
|
|
137
|
+
marginStyle = 'margin-left:auto';
|
|
138
|
+
else if (displayWidth !== 'full' && floatAlign === 'center') {
|
|
139
|
+
marginStyle = 'margin-left:auto;margin-right:auto';
|
|
140
|
+
}
|
|
141
|
+
const imgStyle = [widthStyle, marginStyle].filter(Boolean).join(';') || undefined;
|
|
142
|
+
return {
|
|
143
|
+
wrapperClass,
|
|
144
|
+
imgClass: 'max-w-full rounded-xs object-contain',
|
|
145
|
+
imgStyle
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LinkImageBlock } from './types';
|
|
2
|
+
export type LinkRefDefinition = {
|
|
3
|
+
url: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
};
|
|
6
|
+
/** Minimal reference label normalization (trim, lowercase ASCII, collapse whitespace). */
|
|
7
|
+
export declare function normalizeLinkLabel(label: string): string;
|
|
8
|
+
/** Allow relative paths, fragments, http(s), and mailto; block obvious dangerous schemes. */
|
|
9
|
+
export declare function safeHref(href: string): string | null;
|
|
10
|
+
type ExcludedRange = {
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function collectDefinitionsAndExcluded(source: string): {
|
|
15
|
+
defs: Map<string, LinkRefDefinition>;
|
|
16
|
+
excluded: ExcludedRange[];
|
|
17
|
+
};
|
|
18
|
+
/** Parse bracketed inline content until unescaped `]`; `start` is index of first char inside brackets. */
|
|
19
|
+
export declare function parseBracketedContent(s: string, start: number): {
|
|
20
|
+
content: string;
|
|
21
|
+
end: number;
|
|
22
|
+
} | null;
|
|
23
|
+
export declare function tryParseLinkImageAt(s: string, i: number, defs: Map<string, LinkRefDefinition>, excluded: ExcludedRange[]): LinkImageBlock | null;
|
|
24
|
+
export declare function parseLinksImages(source: string): LinkImageBlock[];
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/** Minimal reference label normalization (trim, lowercase ASCII, collapse whitespace). */
|
|
2
|
+
export function normalizeLinkLabel(label) {
|
|
3
|
+
return label.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
4
|
+
}
|
|
5
|
+
/** Allow relative paths, fragments, http(s), and mailto; block obvious dangerous schemes. */
|
|
6
|
+
export function safeHref(href) {
|
|
7
|
+
const t = href.trim();
|
|
8
|
+
if (!t)
|
|
9
|
+
return null;
|
|
10
|
+
const lower = t.toLowerCase();
|
|
11
|
+
if (lower.startsWith('javascript:') ||
|
|
12
|
+
lower.startsWith('data:') ||
|
|
13
|
+
lower.startsWith('vbscript:')) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (t.startsWith('//'))
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
if (!/^[a-zA-Z][a-zA-Z0-9+.-]*:/u.test(t)) {
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
const u = new URL(t);
|
|
23
|
+
if (u.protocol === 'http:' || u.protocol === 'https:' || u.protocol === 'mailto:') {
|
|
24
|
+
return t;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return !/^[a-zA-Z][a-zA-Z0-9+.-]*:/u.test(t) ? t : null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const LINK_DEF_LINE = /^(\s{0,3})\[([^\]\r\n]+)\]:\s*(?:<([^>\s]+)>|(\S+))(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/;
|
|
33
|
+
export function collectDefinitionsAndExcluded(source) {
|
|
34
|
+
const defs = new Map();
|
|
35
|
+
const excluded = [];
|
|
36
|
+
let pos = 0;
|
|
37
|
+
while (pos < source.length) {
|
|
38
|
+
const nl = source.indexOf('\n', pos);
|
|
39
|
+
const rawEnd = nl === -1 ? source.length : nl;
|
|
40
|
+
const line = source.slice(pos, rawEnd).replace(/\r$/, '');
|
|
41
|
+
const lineStart = pos;
|
|
42
|
+
const lineEnd = nl === -1 ? source.length : nl + 1;
|
|
43
|
+
const m = line.match(LINK_DEF_LINE);
|
|
44
|
+
if (m) {
|
|
45
|
+
const label = normalizeLinkLabel(m[2]);
|
|
46
|
+
const url = (m[3] ?? m[4] ?? '').trim();
|
|
47
|
+
const titleRaw = m[5] ?? m[6] ?? m[7];
|
|
48
|
+
const title = titleRaw !== undefined ? titleRaw.trim() : undefined;
|
|
49
|
+
if (label && url) {
|
|
50
|
+
defs.set(label, title ? { url, title } : { url });
|
|
51
|
+
}
|
|
52
|
+
excluded.push({ start: lineStart, end: lineEnd });
|
|
53
|
+
}
|
|
54
|
+
pos = lineEnd;
|
|
55
|
+
}
|
|
56
|
+
return { defs, excluded };
|
|
57
|
+
}
|
|
58
|
+
function inExcluded(i, excluded) {
|
|
59
|
+
return excluded.some((r) => i >= r.start && i < r.end);
|
|
60
|
+
}
|
|
61
|
+
/** Parse bracketed inline content until unescaped `]`; `start` is index of first char inside brackets. */
|
|
62
|
+
export function parseBracketedContent(s, start) {
|
|
63
|
+
let i = start;
|
|
64
|
+
let out = '';
|
|
65
|
+
while (i < s.length) {
|
|
66
|
+
const c = s[i];
|
|
67
|
+
if (c === '\\' && i + 1 < s.length) {
|
|
68
|
+
out += s[i + 1];
|
|
69
|
+
i += 2;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (c === ']') {
|
|
73
|
+
return { content: out, end: i + 1 };
|
|
74
|
+
}
|
|
75
|
+
out += c;
|
|
76
|
+
i++;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function skipAsciiWhitespace(s, i) {
|
|
81
|
+
let j = i;
|
|
82
|
+
while (j < s.length && (s[j] === ' ' || s[j] === '\t' || s[j] === '\n' || s[j] === '\r')) {
|
|
83
|
+
j++;
|
|
84
|
+
}
|
|
85
|
+
return j;
|
|
86
|
+
}
|
|
87
|
+
function parseInlineDestination(s, openParen) {
|
|
88
|
+
let i = openParen + 1;
|
|
89
|
+
const n = s.length;
|
|
90
|
+
i = skipAsciiWhitespace(s, i);
|
|
91
|
+
if (i >= n)
|
|
92
|
+
return null;
|
|
93
|
+
let href = '';
|
|
94
|
+
if (s[i] === '<') {
|
|
95
|
+
i++;
|
|
96
|
+
while (i < n && s[i] !== '>') {
|
|
97
|
+
href += s[i];
|
|
98
|
+
i++;
|
|
99
|
+
}
|
|
100
|
+
if (i >= n || s[i] !== '>')
|
|
101
|
+
return null;
|
|
102
|
+
i++;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
while (i < n && !/\s/.test(s[i]) && s[i] !== ')') {
|
|
106
|
+
href += s[i];
|
|
107
|
+
i++;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
href = href.trim();
|
|
111
|
+
i = skipAsciiWhitespace(s, i);
|
|
112
|
+
let title;
|
|
113
|
+
if (i < n && (s[i] === '"' || s[i] === "'")) {
|
|
114
|
+
const q = s[i];
|
|
115
|
+
i++;
|
|
116
|
+
let t = '';
|
|
117
|
+
while (i < n && s[i] !== q) {
|
|
118
|
+
if (s[i] === '\\' && i + 1 < n) {
|
|
119
|
+
t += s[i + 1];
|
|
120
|
+
i += 2;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
t += s[i];
|
|
124
|
+
i++;
|
|
125
|
+
}
|
|
126
|
+
if (i >= n || s[i] !== q)
|
|
127
|
+
return null;
|
|
128
|
+
i++;
|
|
129
|
+
title = t;
|
|
130
|
+
}
|
|
131
|
+
else if (i < n && s[i] === '(') {
|
|
132
|
+
i++;
|
|
133
|
+
let t = '';
|
|
134
|
+
let depth = 1;
|
|
135
|
+
while (i < n && depth > 0) {
|
|
136
|
+
const c = s[i];
|
|
137
|
+
if (c === '(')
|
|
138
|
+
depth++;
|
|
139
|
+
else if (c === ')')
|
|
140
|
+
depth--;
|
|
141
|
+
if (depth > 0)
|
|
142
|
+
t += c;
|
|
143
|
+
i++;
|
|
144
|
+
}
|
|
145
|
+
title = t;
|
|
146
|
+
}
|
|
147
|
+
i = skipAsciiWhitespace(s, i);
|
|
148
|
+
if (i >= n || s[i] !== ')')
|
|
149
|
+
return null;
|
|
150
|
+
return { href, title, end: i + 1 };
|
|
151
|
+
}
|
|
152
|
+
export function tryParseLinkImageAt(s, i, defs, excluded) {
|
|
153
|
+
if (inExcluded(i, excluded))
|
|
154
|
+
return null;
|
|
155
|
+
const image = s[i] === '!' && s[i + 1] === '[';
|
|
156
|
+
const bracketOpen = image ? i + 1 : i;
|
|
157
|
+
if (s[bracketOpen] !== '[')
|
|
158
|
+
return null;
|
|
159
|
+
const labelStart = bracketOpen + 1;
|
|
160
|
+
const labelParsed = parseBracketedContent(s, labelStart);
|
|
161
|
+
if (!labelParsed)
|
|
162
|
+
return null;
|
|
163
|
+
const { content: label, end: afterFirstBracket } = labelParsed;
|
|
164
|
+
const spanStart = image ? i : bracketOpen;
|
|
165
|
+
if (label.includes('\n') || label.includes('\r'))
|
|
166
|
+
return null;
|
|
167
|
+
const k = skipAsciiWhitespace(s, afterFirstBracket);
|
|
168
|
+
if (s[k] === '(') {
|
|
169
|
+
const dest = parseInlineDestination(s, k);
|
|
170
|
+
if (!dest)
|
|
171
|
+
return null;
|
|
172
|
+
const hrefRaw = safeHref(dest.href);
|
|
173
|
+
return {
|
|
174
|
+
kind: image ? 'image' : 'link',
|
|
175
|
+
label,
|
|
176
|
+
href: hrefRaw,
|
|
177
|
+
title: dest.title ?? null,
|
|
178
|
+
start: spanStart,
|
|
179
|
+
end: dest.end
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (s[k] === '[') {
|
|
183
|
+
const second = parseBracketedContent(s, k + 1);
|
|
184
|
+
if (!second)
|
|
185
|
+
return null;
|
|
186
|
+
const refKeyRaw = second.content.trim();
|
|
187
|
+
const refKey = refKeyRaw ? normalizeLinkLabel(refKeyRaw) : normalizeLinkLabel(label);
|
|
188
|
+
const def = defs.get(refKey);
|
|
189
|
+
if (!def)
|
|
190
|
+
return null;
|
|
191
|
+
const hrefRaw = safeHref(def.url);
|
|
192
|
+
return {
|
|
193
|
+
kind: image ? 'image' : 'link',
|
|
194
|
+
label,
|
|
195
|
+
href: hrefRaw,
|
|
196
|
+
title: def.title ?? null,
|
|
197
|
+
start: spanStart,
|
|
198
|
+
end: second.end
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const shortcutKey = normalizeLinkLabel(label);
|
|
202
|
+
const def = defs.get(shortcutKey);
|
|
203
|
+
if (!def)
|
|
204
|
+
return null;
|
|
205
|
+
const hrefRaw = safeHref(def.url);
|
|
206
|
+
return {
|
|
207
|
+
kind: image ? 'image' : 'link',
|
|
208
|
+
label,
|
|
209
|
+
href: hrefRaw,
|
|
210
|
+
title: def.title ?? null,
|
|
211
|
+
start: spanStart,
|
|
212
|
+
end: afterFirstBracket
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
export function parseLinksImages(source) {
|
|
216
|
+
const { defs, excluded } = collectDefinitionsAndExcluded(source);
|
|
217
|
+
const out = [];
|
|
218
|
+
let i = 0;
|
|
219
|
+
while (i < source.length) {
|
|
220
|
+
if (inExcluded(i, excluded)) {
|
|
221
|
+
i++;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (source[i] === '[' || (source[i] === '!' && source[i + 1] === '[')) {
|
|
225
|
+
const block = tryParseLinkImageAt(source, i, defs, excluded);
|
|
226
|
+
if (block) {
|
|
227
|
+
out.push(block);
|
|
228
|
+
i = block.end;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
i++;
|
|
233
|
+
}
|
|
234
|
+
out.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
235
|
+
return out;
|
|
236
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a relative asset URL against a base for DOM loading (e.g. Tauri `asset://` dirs).
|
|
3
|
+
* Markdown source keeps relative paths; preview uses the resolved absolute URL.
|
|
4
|
+
*/
|
|
5
|
+
export function resolveAssetUrlForDom(src, base) {
|
|
6
|
+
const t = src.trim();
|
|
7
|
+
if (!t)
|
|
8
|
+
return t;
|
|
9
|
+
const b = base.trim();
|
|
10
|
+
if (!b)
|
|
11
|
+
return t;
|
|
12
|
+
if (/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(t))
|
|
13
|
+
return t;
|
|
14
|
+
try {
|
|
15
|
+
const baseForUrl = b.endsWith('/') ? b : `${b}/`;
|
|
16
|
+
return new URL(t, baseForUrl).href;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type LinkImageBlock = {
|
|
2
|
+
kind: 'link' | 'image';
|
|
3
|
+
/** Link text or image alt (unescaped). */
|
|
4
|
+
label: string;
|
|
5
|
+
href: string | null;
|
|
6
|
+
title?: string | null;
|
|
7
|
+
/** Inclusive start offset in source. */
|
|
8
|
+
start: number;
|
|
9
|
+
/** Exclusive end offset in source. */
|
|
10
|
+
end: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { MentionBlock } from './types';
|
|
3
|
+
|
|
4
|
+
export { mentionRenderer };
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#snippet mentionRenderer(block: MentionBlock)}
|
|
8
|
+
<p class="mb-4 text-sm text-option-cyan/95">
|
|
9
|
+
<span class="font-medium text-option-cyan">Mention</span>
|
|
10
|
+
{#if block.kind === 'page'}
|
|
11
|
+
<span class="text-txt-secondary"> page </span>
|
|
12
|
+
<code class="font-mono text-txt-primary">{block.pageTitle}</code>
|
|
13
|
+
{:else}
|
|
14
|
+
<span class="text-txt-secondary"> @</span>
|
|
15
|
+
<code class="font-mono text-txt-primary">{block.name}</code>
|
|
16
|
+
{/if}
|
|
17
|
+
</p>
|
|
18
|
+
{/snippet}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MentionBlock } from './types';
|
|
2
|
+
declare const mentionRenderer: (block: MentionBlock) => ReturnType<import("svelte").Snippet>;
|
|
3
|
+
export { mentionRenderer };
|
|
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 MentionRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type MentionRenderer = InstanceType<typeof MentionRenderer>;
|
|
21
|
+
export default MentionRenderer;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Avoid matching the `@` inside `user@host`. */
|
|
2
|
+
function atIsMentionPrefix(source, index) {
|
|
3
|
+
if (index === 0)
|
|
4
|
+
return true;
|
|
5
|
+
const prev = source[index - 1];
|
|
6
|
+
return !/[A-Za-z0-9_]/.test(prev);
|
|
7
|
+
}
|
|
8
|
+
const NAME_TAIL = /^[A-Za-z0-9_]+/;
|
|
9
|
+
export function parseMentions(source) {
|
|
10
|
+
const out = [];
|
|
11
|
+
let i = 0;
|
|
12
|
+
while (i < source.length) {
|
|
13
|
+
if (source[i] !== '@') {
|
|
14
|
+
i++;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (!atIsMentionPrefix(source, i)) {
|
|
18
|
+
i++;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (source[i + 1] === '[') {
|
|
22
|
+
const close = source.indexOf(']', i + 2);
|
|
23
|
+
if (close === -1) {
|
|
24
|
+
i++;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const pageTitle = source.slice(i + 2, close).trim();
|
|
28
|
+
if (pageTitle.length > 0) {
|
|
29
|
+
out.push({
|
|
30
|
+
kind: 'page',
|
|
31
|
+
pageTitle,
|
|
32
|
+
raw: source.slice(i, close + 1),
|
|
33
|
+
startIndex: i
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
i = close + 1;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const tail = source.slice(i + 1).match(NAME_TAIL);
|
|
40
|
+
if (!tail) {
|
|
41
|
+
i++;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const name = tail[0];
|
|
45
|
+
out.push({
|
|
46
|
+
kind: 'user',
|
|
47
|
+
name,
|
|
48
|
+
raw: `@${name}`,
|
|
49
|
+
startIndex: i
|
|
50
|
+
});
|
|
51
|
+
i += 1 + name.length;
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type MentionBlock = {
|
|
2
|
+
kind: 'page';
|
|
3
|
+
/** Inner title between `@[` and `]`. */
|
|
4
|
+
pageTitle: string;
|
|
5
|
+
/** Full slice including `@`, `[`, `]`. */
|
|
6
|
+
raw: string;
|
|
7
|
+
startIndex: number;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'user';
|
|
10
|
+
name: string;
|
|
11
|
+
/** Full slice including `@`. */
|
|
12
|
+
raw: string;
|
|
13
|
+
startIndex: number;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export { rawTextRenderer };
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import type { RawTextBlock } from './types';
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#snippet rawTextRenderer(block: RawTextBlock)}
|
|
10
|
+
<section class="mb-4 text-txt-primary">
|
|
11
|
+
{#if block.fileName}
|
|
12
|
+
<p class="mb-2 text-xs font-medium tracking-wide text-txt-tertiary uppercase">
|
|
13
|
+
{block.fileName}
|
|
14
|
+
</p>
|
|
15
|
+
{/if}
|
|
16
|
+
|
|
17
|
+
<pre class="font-mono text-sm leading-6 break-words whitespace-pre-wrap">{block.text}</pre>
|
|
18
|
+
</section>
|
|
19
|
+
{/snippet}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { rawTextRenderer };
|
|
2
|
+
import type { RawTextBlock } from './types';
|
|
3
|
+
declare const rawTextRenderer: (block: RawTextBlock) => ReturnType<import("svelte").Snippet>;
|
|
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 RawTextRenderer: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type RawTextRenderer = InstanceType<typeof RawTextRenderer>;
|
|
21
|
+
export default RawTextRenderer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|