edytor 2.0.0 → 4.0.0
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 +19 -4
- package/dist/block/block.svelte.js +2 -4
- package/dist/clipboard/htmlFlow.d.ts +20 -7
- package/dist/clipboard/htmlFlow.js +23 -15
- package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
- package/dist/clipboard/serializeClipboardFragment.js +6 -4
- package/dist/clipboard/textBlocks.d.ts +8 -0
- package/dist/clipboard/textBlocks.js +6 -2
- package/dist/cloudflare/DocumentRoom.d.ts +13 -9
- package/dist/cloudflare/DocumentRoom.js +10 -6
- package/dist/cloudflare/room/admission.js +3 -3
- package/dist/cloudflare/room/context.d.ts +28 -27
- package/dist/cloudflare/room/context.js +2 -2
- package/dist/cloudflare/room/purge.d.ts +6 -3
- package/dist/cloudflare/room/purge.js +44 -19
- package/dist/cloudflare/room/updates.d.ts +3 -4
- package/dist/cloudflare/room/updates.js +6 -8
- package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
- package/dist/cloudflare/routeDocumentSocket.js +53 -0
- package/dist/collaboration/comments/client.d.ts +1 -1
- package/dist/collaboration/comments/client.js +1 -1
- package/dist/collaboration/remoteSelection.js +3 -3
- package/dist/components/Edytor.svelte +2 -10
- package/dist/components/Edytor.svelte.d.ts +1 -3
- package/dist/crdt/admission.d.ts +5 -10
- package/dist/crdt/admission.js +5 -11
- package/dist/crdt/attribution/attribution.d.ts +31 -12
- package/dist/crdt/attribution/attribution.js +56 -18
- package/dist/crdt/attribution/block.d.ts +3 -3
- package/dist/crdt/attribution/block.js +7 -8
- package/dist/crdt/attribution/index.d.ts +1 -1
- package/dist/crdt/attribution/index.js +1 -1
- package/dist/crdt/data.d.ts +62 -31
- package/dist/crdt/data.js +211 -103
- package/dist/crdt/doc/delete.d.ts +1 -1
- package/dist/crdt/doc/delete.js +13 -30
- package/dist/crdt/doc/funnel.d.ts +7 -6
- package/dist/crdt/doc/funnel.js +39 -33
- package/dist/crdt/doc/gate.d.ts +3 -20
- package/dist/crdt/doc/gate.js +2 -41
- package/dist/crdt/doc/history.d.ts +25 -9
- package/dist/crdt/doc/history.js +152 -42
- package/dist/crdt/doc/layout.js +11 -22
- package/dist/crdt/doc/meta.js +12 -17
- package/dist/crdt/doc/moves.d.ts +1 -1
- package/dist/crdt/doc/moves.js +52 -32
- package/dist/crdt/doc/reads.js +2 -2
- package/dist/crdt/doc/seed.js +2 -2
- package/dist/crdt/doc/split-merge.js +12 -15
- package/dist/crdt/doc/steps.d.ts +25 -13
- package/dist/crdt/doc/steps.js +52 -122
- package/dist/crdt/doc/types.d.ts +21 -9
- package/dist/crdt/document.d.ts +21 -19
- package/dist/crdt/document.js +26 -23
- package/dist/crdt/edytor-doc.d.ts +66 -68
- package/dist/crdt/edytor-doc.js +21 -20
- package/dist/crdt/engine-api.d.ts +33 -1
- package/dist/crdt/engine.d.ts +0 -1
- package/dist/crdt/engine.js +1 -4
- package/dist/crdt/flow.d.ts +1 -1
- package/dist/crdt/flow.js +25 -27
- package/dist/crdt/index.d.ts +29 -28
- package/dist/crdt/index.js +3 -3
- package/dist/crdt/placement/display.d.ts +5 -30
- package/dist/crdt/placement/display.js +39 -144
- package/dist/crdt/placement/keys.d.ts +58 -0
- package/dist/crdt/placement/keys.js +90 -0
- package/dist/crdt/placement/model.d.ts +119 -118
- package/dist/crdt/placement/model.js +242 -142
- package/dist/crdt/placement/resolve.d.ts +123 -35
- package/dist/crdt/placement/resolve.js +187 -153
- package/dist/crdt/placement/slots.d.ts +134 -0
- package/dist/crdt/placement/slots.js +152 -0
- package/dist/crdt/protocol.d.ts +2 -2
- package/dist/crdt/protocol.js +2 -2
- package/dist/crdt/providers/index.d.ts +1 -1
- package/dist/crdt/providers/room.d.ts +26 -11
- package/dist/crdt/providers/room.js +77 -27
- package/dist/crdt/providers/websocket.d.ts +1 -1
- package/dist/crdt/providers/websocket.js +33 -32
- package/dist/crdt/purge.d.ts +17 -8
- package/dist/crdt/purge.js +236 -126
- package/dist/crdt/restore.d.ts +2 -2
- package/dist/crdt/restore.js +18 -34
- package/dist/crdt/schema.d.ts +22 -21
- package/dist/crdt/schema.js +29 -23
- package/dist/crdt/semantics.js +3 -1
- package/dist/crdt/storage.d.ts +1 -1
- package/dist/crdt/storage.js +1 -1
- package/dist/crdt/structs.d.ts +15 -15
- package/dist/crdt/structs.js +8 -22
- package/dist/crdt/text/index/cache.js +4 -0
- package/dist/crdt/text/index/claims.js +12 -0
- package/dist/crdt/text/index/fold.d.ts +2 -3
- package/dist/crdt/text/index/fold.js +194 -44
- package/dist/crdt/text/index/layout.js +5 -8
- package/dist/crdt/text/index/placement.d.ts +26 -18
- package/dist/crdt/text/index/placement.js +404 -138
- package/dist/crdt/text/index/records.d.ts +3 -3
- package/dist/crdt/text/index/records.js +24 -31
- package/dist/crdt/text/index/shared.d.ts +11 -3
- package/dist/crdt/text/index/shared.js +12 -3
- package/dist/crdt/text/index/state.d.ts +21 -17
- package/dist/crdt/text/index/state.js +15 -17
- package/dist/crdt/text/index/streams.d.ts +10 -5
- package/dist/crdt/text/index/streams.js +78 -27
- package/dist/crdt/text/items.d.ts +10 -3
- package/dist/crdt/text/items.js +7 -0
- package/dist/crdt/text/model.d.ts +77 -62
- package/dist/crdt/text/model.js +84 -169
- package/dist/crdt/text/ranges.d.ts +1 -1
- package/dist/crdt/text/ranges.js +3 -3
- package/dist/crdt/text/rows.d.ts +13 -7
- package/dist/crdt/text/rows.js +24 -7
- package/dist/crdt/text/runs.d.ts +17 -12
- package/dist/crdt/text/runs.js +24 -7
- package/dist/crdt/text/streams.d.ts +26 -13
- package/dist/crdt/text/streams.js +41 -14
- package/dist/crdt/vendor/yjs/UPSTREAM.md +568 -21
- package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +194 -10
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
- package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
- package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
- package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
- package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
- package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +43 -7
- package/dist/crdt/vendor/yjs/global.d.ts +2 -0
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
- package/dist/crdt/vendor/yjs/src/structs/Item.js +610 -51
- package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
- package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
- package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
- package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
- package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
- package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
- package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
- package/dist/crdt/vendor/yjs/src/ynode.js +177 -12
- package/dist/dnd/autoScroll.d.ts +15 -7
- package/dist/dnd/autoScroll.js +10 -15
- package/dist/dnd/dropIndicator.js +2 -5
- package/dist/dnd/external.d.ts +6 -0
- package/dist/dnd/external.js +17 -0
- package/dist/dnd/geometry.d.ts +2 -0
- package/dist/dnd/geometry.js +3 -4
- package/dist/dnd/placement.d.ts +1 -1
- package/dist/dnd/pragmatic.d.ts +3 -1
- package/dist/dnd/pragmatic.js +12 -2
- package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.d.ts +1 -1
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
- package/dist/edytor.svelte.d.ts +2 -5
- package/dist/edytor.svelte.js +21 -32
- package/dist/events/beforeInputCommands.js +2 -2
- package/dist/events/onBeforeInput.js +1 -1
- package/dist/events/onDrop.d.ts +0 -6
- package/dist/events/onDrop.js +10 -23
- package/dist/events/onInput.d.ts +0 -12
- package/dist/events/onInput.js +1 -67
- package/dist/events/onPageHide.d.ts +3 -0
- package/dist/events/onPageHide.js +16 -0
- package/dist/export/forms.d.ts +627 -0
- package/dist/export/forms.js +749 -0
- package/dist/export/index.d.ts +170 -0
- package/dist/export/index.js +161 -0
- package/dist/export/markdown.d.ts +41 -0
- package/dist/export/markdown.js +585 -0
- package/dist/export/markdownWriter.d.ts +9 -0
- package/dist/export/markdownWriter.js +133 -0
- package/dist/export/mdx.d.ts +15 -0
- package/dist/export/mdx.js +33 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/kinds.js +1 -1
- package/dist/plugins/anchored.svelte.d.ts +21 -25
- package/dist/plugins/anchored.svelte.js +23 -39
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
- package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
- package/dist/plugins/blockHandles/dragPreview.js +33 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
- package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
- package/dist/plugins/chrome.d.ts +27 -5
- package/dist/plugins/chrome.js +24 -9
- package/dist/plugins/code/CodePlugin.svelte +12 -9
- package/dist/plugins/code/header.svelte.js +7 -11
- package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
- package/dist/plugins/code/languageMenu.svelte.js +13 -20
- package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
- package/dist/plugins/columns/resize.svelte.d.ts +2 -3
- package/dist/plugins/columns/resize.svelte.js +2 -5
- package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
- package/dist/plugins/comments/CommentsController.svelte.js +20 -0
- package/dist/plugins/equation/EquationPlugin.svelte +12 -22
- package/dist/plugins/equation/equation.svelte.d.ts +7 -15
- package/dist/plugins/equation/equation.svelte.js +13 -50
- package/dist/plugins/equation/tex.d.ts +17 -0
- package/dist/plugins/equation/tex.js +42 -0
- package/dist/plugins/fileDrop.d.ts +38 -23
- package/dist/plugins/fileDrop.js +82 -76
- package/dist/plugins/find/FindController.svelte.d.ts +5 -0
- package/dist/plugins/find/FindController.svelte.js +14 -14
- package/dist/plugins/find/findPlugin.js +1 -15
- package/dist/plugins/image/ImageChrome.svelte +8 -2
- package/dist/plugins/image/ImagePlugin.svelte +15 -52
- package/dist/plugins/image/controls.svelte.js +16 -2
- package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
- package/dist/plugins/image/toolbar.svelte.js +21 -31
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/list.svelte.d.ts +9 -0
- package/dist/plugins/list.svelte.js +18 -0
- package/dist/plugins/marquee/marqueePlugin.js +0 -4
- package/dist/plugins/media/AudioPlugin.svelte +1 -1
- package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
- package/dist/plugins/media/EmbedPlugin.svelte +5 -90
- package/dist/plugins/media/EmptySlot.svelte +36 -20
- package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
- package/dist/plugins/media/FilePlugin.svelte +1 -19
- package/dist/plugins/media/MediaEmpty.svelte +2 -55
- package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
- package/dist/plugins/media/SourceBlock.svelte +142 -52
- package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
- package/dist/plugins/media/VideoPlugin.svelte +1 -1
- package/dist/plugins/media/empty.svelte.js +2 -7
- package/dist/plugins/media/media.d.ts +2 -63
- package/dist/plugins/media/media.js +1 -194
- package/dist/plugins/media/sources.d.ts +60 -0
- package/dist/plugins/media/sources.js +165 -0
- package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
- package/dist/plugins/media/urlPaste.svelte.js +12 -21
- package/dist/plugins/mention/MentionPlugin.svelte +8 -35
- package/dist/plugins/page/PagePlugin.svelte +2 -9
- package/dist/plugins/page/page.js +1 -1
- package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
- package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
- package/dist/plugins/richtext/body.js +1 -1
- package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
- package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
- package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
- package/dist/plugins/richtext/richTextOperations.js +3 -49
- package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
- package/dist/plugins/table/TableChrome.svelte +2 -3
- package/dist/plugins/table/TablePlugin.svelte +20 -54
- package/dist/plugins/table/chrome.svelte.d.ts +5 -2
- package/dist/plugins/table/chrome.svelte.js +30 -54
- package/dist/plugins/table/table.js +3 -3
- package/dist/plugins/toc/TocPlugin.svelte +2 -4
- package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
- package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
- package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
- package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
- package/dist/plugins/triggers/place.js +1 -2
- package/dist/plugins/triggers/triggers.d.ts +6 -1
- package/dist/plugins/triggers/triggers.js +12 -13
- package/dist/plugins/uploads.svelte.d.ts +5 -2
- package/dist/plugins/uploads.svelte.js +25 -15
- package/dist/plugins.d.ts +26 -0
- package/dist/plugins.js +0 -24
- package/dist/selection/replaceSelection.js +2 -2
- package/dist/selection/selection.svelte.d.ts +4 -10
- package/dist/selection/selection.svelte.js +7 -11
- package/dist/session/bindings.js +1 -1
- package/dist/session/commands.d.ts +7 -11
- package/dist/session/commands.js +13 -19
- package/dist/session/inputRules.js +1 -1
- package/dist/session/navigation.js +1 -1
- package/dist/session/suggestions.svelte.d.ts +0 -11
- package/dist/session/suggestions.svelte.js +15 -3
- package/dist/session/uploads.d.ts +8 -8
- package/dist/surface/lines.js +1 -3
- package/dist/surface/observer.svelte.d.ts +17 -1
- package/dist/surface/observer.svelte.js +74 -19
- package/dist/surface/overlay.d.ts +0 -14
- package/dist/surface/overlay.js +0 -25
- package/dist/surface/projector.svelte.d.ts +15 -3
- package/dist/surface/projector.svelte.js +60 -9
- package/dist/text/text.svelte.js +3 -13
- package/dist/utils/sanitize.d.ts +38 -0
- package/dist/utils/sanitize.js +82 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +5 -0
- package/package.json +19 -2
- package/dist/crdt/placement/rank.d.ts +0 -87
- package/dist/crdt/placement/rank.js +0 -332
- package/dist/crdt/placement/source.d.ts +0 -43
- package/dist/crdt/placement/source.js +0 -66
- package/dist/crdt/text/delete-index.d.ts +0 -129
- package/dist/crdt/text/delete-index.js +0 -365
- package/dist/crdt/text/deletes.d.ts +0 -76
- package/dist/crdt/text/deletes.js +0 -362
- package/dist/crdt/text/index/anchored.d.ts +0 -17
- package/dist/crdt/text/index/anchored.js +0 -197
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
- package/dist/plugins/code/LanguageMenu.svelte +0 -25
- package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
- package/dist/plugins/equation/EquationEditor.svelte +0 -27
- package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
- package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
- package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
- package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
- package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { isTextPart } from '../block/contentRange.js';
|
|
2
|
+
import { contentOf } from '../clipboard/serializeClipboardFragment.js';
|
|
3
|
+
/** Characters markdown reads as syntax inside a line: escaped in exported text. */
|
|
4
|
+
const MD_SPECIAL = /[\\`*_[\]~<]/g;
|
|
5
|
+
/** A line start markdown reads as a block (a heading, a list item, a quote, a rule): escaped. */
|
|
6
|
+
const MD_LINE_START = /^(\s*)(#{1,6}(?=\s|$)|[-+](?=\s)|\d+(?=[.)]\s)|>|=+\s*$|-{3,}\s*$)/;
|
|
7
|
+
/** Text as markdown: its syntax characters escaped, a soft break a hard break (`\` + newline). */
|
|
8
|
+
const escapeMarkdown = (text) => text.replace(MD_SPECIAL, (c) => `\\${c}`).replace(/\n/g, '\\\n');
|
|
9
|
+
/** The delimiters a mark's value exports as, or none. */
|
|
10
|
+
const delimitersOf = (mark, value) => typeof mark.markdown === 'function' ? mark.markdown(value) : mark.markdown;
|
|
11
|
+
/** A code span's fence: one backtick more than the longest run inside it. */
|
|
12
|
+
const codeFence = (text) => '`'.repeat(Math.max(0, ...[...text.matchAll(/`+/g)].map((m) => m[0].length)) + 1);
|
|
13
|
+
/**
|
|
14
|
+
* Rich text as inline markdown. Marks open in their registration order
|
|
15
|
+
* reversed (the first registered innermost, as HTML wraps them), a mark
|
|
16
|
+
* spanning several runs opens once (`**a *b***`), a mark without a
|
|
17
|
+
* `markdown` form is left out, and a delimiter never sits on a space
|
|
18
|
+
* (`** x**` is no emphasis): the spaces move outside it.
|
|
19
|
+
*/
|
|
20
|
+
const inlineMarkdown = (content = [], kinds) => {
|
|
21
|
+
// A code span holds no markup: it opens last, innermost.
|
|
22
|
+
const order = [...kinds.marks.keys()]
|
|
23
|
+
.reverse()
|
|
24
|
+
.sort((a, b) => Number(a === 'code') - Number(b === 'code'));
|
|
25
|
+
/** The open marks, outermost first: name, value key and closing delimiter. */
|
|
26
|
+
const open = [];
|
|
27
|
+
let out = '';
|
|
28
|
+
const closeTo = (depth) => {
|
|
29
|
+
// A delimiter closes after the text's last non-space: trailing spaces move out.
|
|
30
|
+
const spaces = /[ \t]*$/.exec(out)[0];
|
|
31
|
+
out = out.slice(0, out.length - spaces.length);
|
|
32
|
+
while (open.length > depth)
|
|
33
|
+
out += open.pop().close;
|
|
34
|
+
out += spaces;
|
|
35
|
+
};
|
|
36
|
+
for (const part of content) {
|
|
37
|
+
if (!isTextPart(part)) {
|
|
38
|
+
closeTo(0);
|
|
39
|
+
const atom = kinds.inlineBlocks.get(part.type);
|
|
40
|
+
out += atom?.markdown?.(part.data) ?? escapeMarkdown(atom?.plain?.(part.data) ?? '');
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const wanted = order
|
|
44
|
+
.map((name) => {
|
|
45
|
+
const mark = kinds.marks.get(name);
|
|
46
|
+
const value = part.marks?.[name];
|
|
47
|
+
const delimiters = value ? delimitersOf(mark, value) : undefined;
|
|
48
|
+
return delimiters && { name, key: JSON.stringify(value), delimiters };
|
|
49
|
+
})
|
|
50
|
+
.filter((m) => !!m);
|
|
51
|
+
// Keep the open marks this run still has, in order; close from the first it lacks.
|
|
52
|
+
let keep = 0;
|
|
53
|
+
while (keep < open.length &&
|
|
54
|
+
wanted.some((m) => m.name === open[keep].name && m.key === open[keep].key))
|
|
55
|
+
keep++;
|
|
56
|
+
// A mark opening inside an open code span would be literal: the span closes first.
|
|
57
|
+
const opening = wanted.some((m) => !open.slice(0, keep).some((o) => o.name === m.name));
|
|
58
|
+
const span = open.findIndex((m) => m.name === 'code');
|
|
59
|
+
if (opening && span !== -1 && span < keep)
|
|
60
|
+
keep = span;
|
|
61
|
+
closeTo(keep);
|
|
62
|
+
const code = wanted.some((m) => m.name === 'code');
|
|
63
|
+
const raw = part.text;
|
|
64
|
+
const lead = /^[ \t]*/.exec(raw)[0];
|
|
65
|
+
const body = raw.slice(lead.length);
|
|
66
|
+
out += lead;
|
|
67
|
+
if (!body)
|
|
68
|
+
continue;
|
|
69
|
+
for (const mark of wanted)
|
|
70
|
+
if (!open.some((m) => m.name === mark.name)) {
|
|
71
|
+
const [start, end] = mark.delimiters;
|
|
72
|
+
const fence = mark.name === 'code' ? codeFence(body) : '';
|
|
73
|
+
const pad = fence && /^`|`$/.test(body) ? ' ' : '';
|
|
74
|
+
out += fence ? fence + pad : start;
|
|
75
|
+
open.push({ name: mark.name, key: mark.key, close: fence ? pad + fence : end });
|
|
76
|
+
}
|
|
77
|
+
out += code ? body : escapeMarkdown(body);
|
|
78
|
+
}
|
|
79
|
+
closeTo(0);
|
|
80
|
+
return out;
|
|
81
|
+
};
|
|
82
|
+
/** Every line of `text` prefixed with `prefix` (an empty line with its trimmed form). */
|
|
83
|
+
const indent = (text, prefix) => text
|
|
84
|
+
.split('\n')
|
|
85
|
+
.map((line) => (line ? prefix + line : prefix.trimEnd()))
|
|
86
|
+
.join('\n');
|
|
87
|
+
/** A list item's markdown (`- `, `1. `, `- [ ] `): its block's first line starts one. */
|
|
88
|
+
const LIST_LINE = /^(?:[-*+]|\d+[.)])\s/;
|
|
89
|
+
/**
|
|
90
|
+
* Sibling blocks as markdown: a blank line between blocks, a single
|
|
91
|
+
* newline between items of one list (a tight list).
|
|
92
|
+
*/
|
|
93
|
+
const siblingsMarkdown = (blocks, kinds) => {
|
|
94
|
+
let out = '';
|
|
95
|
+
let previous = null;
|
|
96
|
+
let run = 0;
|
|
97
|
+
let type = null;
|
|
98
|
+
for (const block of blocks) {
|
|
99
|
+
run = block.type === type ? run + 1 : 1;
|
|
100
|
+
type = block.type;
|
|
101
|
+
const md = blockMarkdown(block, kinds, run);
|
|
102
|
+
if (!md)
|
|
103
|
+
continue;
|
|
104
|
+
if (previous !== null)
|
|
105
|
+
out += LIST_LINE.test(previous) && LIST_LINE.test(md) ? '\n' : '\n\n';
|
|
106
|
+
out += md;
|
|
107
|
+
previous = md;
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
};
|
|
111
|
+
/** A block and its subtree as markdown, by its kind's form. */
|
|
112
|
+
const blockMarkdown = (block, kinds, index) => {
|
|
113
|
+
const kind = kinds.blocks.get(block.type);
|
|
114
|
+
const content = inlineMarkdown(block.content, kinds);
|
|
115
|
+
const children = siblingsMarkdown(block.children ?? [], kinds);
|
|
116
|
+
if (kind?.markdown) {
|
|
117
|
+
const context = {
|
|
118
|
+
index,
|
|
119
|
+
indent,
|
|
120
|
+
inline: (parts) => inlineMarkdown(parts, kinds)
|
|
121
|
+
};
|
|
122
|
+
return kind.markdown(block, content, children, context);
|
|
123
|
+
}
|
|
124
|
+
if (kind?.plain) {
|
|
125
|
+
const plain = kind.plain(block, contentOf(block.content, kinds, false), '');
|
|
126
|
+
return [plain && escapeMarkdown(plain), children].filter(Boolean).join('\n\n');
|
|
127
|
+
}
|
|
128
|
+
// A paragraph: its text, a leading block marker escaped (`\# not a heading`).
|
|
129
|
+
const text = content.replace(MD_LINE_START, (_, space, marker) => /^\d/.test(marker) ? `${space}${marker}\\` : `${space}\\${marker}`);
|
|
130
|
+
return [text, children].filter(Boolean).join('\n\n');
|
|
131
|
+
};
|
|
132
|
+
/** Blocks as markdown (`toMarkdown`), by each kind's, mark's and atom's `markdown` form. */
|
|
133
|
+
export const blocksToMarkdown = (blocks, kinds) => siblingsMarkdown(blocks, kinds);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MDX-lite tags as markdown (`toMarkdown`): a block written as
|
|
3
|
+
* `<Name a="x" n={1} on={true} />`, the tag `fromMarkdown` reads back.
|
|
4
|
+
*/
|
|
5
|
+
import type { SerializableContent } from '../utils/json.js';
|
|
6
|
+
/**
|
|
7
|
+
* A component tag, for a kind's `markdown` form: `mdxComponent('Endpoint',
|
|
8
|
+
* block.data, content, children)`. Each data value that has a literal is an
|
|
9
|
+
* attribute (a string `"x"`, a number `{1}`, a boolean `{true}`); others
|
|
10
|
+
* (objects, arrays, `null`, a string holding a newline or both quotes) are
|
|
11
|
+
* left out. No text and no children: a self-closing tag. Text only: the
|
|
12
|
+
* text inside the tag on one line. Children: the tag on its own lines, the
|
|
13
|
+
* text first (a paragraph), then the children.
|
|
14
|
+
*/
|
|
15
|
+
export declare const mdxComponent: (name: string, data?: Record<string, SerializableContent> | undefined, content?: string, children?: string) => string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const ATTRIBUTE = /^[A-Za-z_][\w:-]*$/;
|
|
2
|
+
/** A data value as an attribute, or `null` when MDX-lite has no literal for it. */
|
|
3
|
+
const attribute = (name, value) => {
|
|
4
|
+
if (!ATTRIBUTE.test(name))
|
|
5
|
+
return null;
|
|
6
|
+
if (typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value)))
|
|
7
|
+
return `${name}={${value}}`;
|
|
8
|
+
if (typeof value !== 'string' || /\n/.test(value))
|
|
9
|
+
return null;
|
|
10
|
+
if (!value.includes('"'))
|
|
11
|
+
return `${name}="${value}"`;
|
|
12
|
+
return value.includes("'") ? null : `${name}='${value}'`;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A component tag, for a kind's `markdown` form: `mdxComponent('Endpoint',
|
|
16
|
+
* block.data, content, children)`. Each data value that has a literal is an
|
|
17
|
+
* attribute (a string `"x"`, a number `{1}`, a boolean `{true}`); others
|
|
18
|
+
* (objects, arrays, `null`, a string holding a newline or both quotes) are
|
|
19
|
+
* left out. No text and no children: a self-closing tag. Text only: the
|
|
20
|
+
* text inside the tag on one line. Children: the tag on its own lines, the
|
|
21
|
+
* text first (a paragraph), then the children.
|
|
22
|
+
*/
|
|
23
|
+
export const mdxComponent = (name, data = {}, content = '', children = '') => {
|
|
24
|
+
const attributes = Object.entries(data)
|
|
25
|
+
.map(([key, value]) => attribute(key, value))
|
|
26
|
+
.filter((part) => part !== null);
|
|
27
|
+
const open = `<${[name, ...attributes].join(' ')}`;
|
|
28
|
+
if (!content && !children)
|
|
29
|
+
return `${open} />`;
|
|
30
|
+
if (!children)
|
|
31
|
+
return `${open}>${content}</${name}>`;
|
|
32
|
+
return `${open}>\n${[content, children].filter(Boolean).join('\n\n')}\n</${name}>`;
|
|
33
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -35,17 +35,17 @@ export { InlineBlock } from './block/inlineBlock.svelte.js';
|
|
|
35
35
|
export { Text } from './text/text.svelte.js';
|
|
36
36
|
export type { BlockMoveDirection, BlockMovePosition, BlockMoveRequest } from './session/moves.js';
|
|
37
37
|
export type { HotKey, HotKeyCombination } from './session/keymap.js';
|
|
38
|
-
export type { Plugin, KindPreset, KindMenuAction, EditorCommand, BlockDefinition, MarkDefinition, InlineBlockDefinition, BlockSnippetPayload, MarkSnippetPayload, InlineBlockSnippetPayload, Placeholder, PlaceholderView, ChangePayload, Commands, AfterOperationPayload, Prevent, InputRule, InputRuleContext, Trigger, TriggerContext, TextRuleContext } from './plugins.js';
|
|
38
|
+
export type { Plugin, KindPreset, KindMenuAction, EditorCommand, BlockDefinition, MarkdownContext, MarkDefinition, InlineBlockDefinition, BlockSnippetPayload, MarkSnippetPayload, InlineBlockSnippetPayload, Placeholder, PlaceholderView, ChangePayload, Commands, AfterOperationPayload, Prevent, InputRule, InputRuleContext, Trigger, TriggerContext, TextRuleContext } from './plugins.js';
|
|
39
39
|
export type { Caret } from './selection/selection.svelte.js';
|
|
40
40
|
export { PreventionError, isPrevention } from './utils.js';
|
|
41
41
|
export type { CommandResult } from './session/commands.js';
|
|
42
42
|
export { convertToKind, turnCommands, wrapBlocks, wrappable, type KindRow } from './kinds.js';
|
|
43
43
|
export { textToBlocks, type TextToBlocksOptions } from './clipboard/textBlocks.js';
|
|
44
44
|
export type { Suggestion, Suggestions, SuggestionAt, SuggestionContent, SuggestionOptions, SuggestionRange, SuggestionStatus, SuggestionsAt, ResolvedAt } from './session/suggestions.svelte.js';
|
|
45
|
-
export { createRichTextPlugin, richTextOperations, richTextPlaceholder, CALLOUT_ICONS, createCalloutIconsPlugin, type CalloutIconPicker, type CalloutIconsOptions, type RichTextPluginOptions, type TodoCheckboxPayload, type CalloutIconPayload, type EmptyBodyPayload, createArrowMovePlugin, createCodePlugin, CODE_LANGUAGES, loadCodeLanguage, type CodeLanguage, type CodePluginOptions, type CodeHeader, type LanguageMenu, type LanguageMenuItem, type LanguageRow, createMarkdownShortcutsPlugin, createMentionPlugin, type MentionItem, type MentionData, type MentionPluginOptions, createPageLinkPlugin, type PageLinkItem, type PageLinkData, type PageLinkPluginOptions, type TriggerMenuController, withRulesAndTriggers, BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT, type BlockActivation, type BlockAddition, createBlockHandlesPlugin, type BlockHandlesOptions, type BlockHandleSnippetPayload, type BlockHandleController, createSlashMenuPlugin, type SlashMenuOptions, type SlashMenuController, createToolbarPlugin, type ToolbarOptions, type ToolbarController, createBlockMenuPlugin, type BlockMenuOptions, type BlockMenuController, type BlockMenuAction, type BlockMenuColor, createSuggestionsPlugin, createSuggestionBarPlugin, type SuggestionBarOptions, type SuggestionBarPayload, createImagePlugin, type ImagePluginOptions, safeImageSrc, storableImageSrc, MAX_INLINE_IMAGE_BYTES, createColumnsPlugin, type ColumnsPluginOptions, createEmbedPlugin, EMBED_PROVIDERS, EMBED_SANDBOX, EMBED_ALLOW, embedSourceOf, type EmbedProvider, type EmbedPluginOptions, type EmbedFallbackPayload, createBookmarkPlugin, type BookmarkPluginOptions, type BookmarkPreview, type BookmarkCardPayload, createFilePlugin, type FilePluginOptions, type FileRowPayload, createVideoPlugin, type VideoPluginOptions, createAudioPlugin, type AudioPluginOptions, safeWebUrl, safeMediaSrc, type MediaKind, createMediaEmptyPlugin, type MediaEmptyOptions, createImageToolbarPlugin, type ImageToolbar, type ImageToolbarOptions, type MediaEmptyController, type MediaEmptyFailure, type UrlPasteController, type UrlPasteOffer, type UrlPasteOption, type ImageControls, type ImageBox, type MenuItemPayload, createFindPlugin, findController, findMatches, type FindPluginOptions, type FindController, type ReplaceMatches, type FindMatch, type FindOptions, createMarqueePlugin, type MarqueePluginOptions, type MarqueeBoxPayload, createCommentsPlugin, commentsController, type CommentsPluginOptions, type CommentCardPayload, type CommentsController, type CommentDraft, type CommentNotice, type CommentUser, type PlacedThread, createPagePlugin, type PagePluginOptions, type PageBlockLinkPayload, createTocPlugin, type TocPluginOptions, type TocHeadingLevel, type TocEntryPayload, type TocEmptyPayload, createTablePlugin, type TablePluginOptions, insertTableRow, deleteTableRows, insertTableColumn, deleteTableColumn, moveTableColumn, moveTableRows, fillTableCell, type TableChrome, type TableMenu, type TableMenuRow, type TableMenuItem, type TableGripPayload, type TableAddPayload, tableBlock, type TableBlockOptions, createEquationPlugin, KATEX_CDN, KATEX_VERSION, type EquationPluginOptions, type EquationData, type EquationEditor, type EquationErrorPayload, type EquationPlaceholderPayload, type EquationTarget, type KatexLike, type KatexLoader } from './plugins/index.js';
|
|
45
|
+
export { createRichTextPlugin, richTextOperations, richTextPlaceholder, CALLOUT_ICONS, createCalloutIconsPlugin, type CalloutIconPicker, type CalloutIconsOptions, type RichTextPluginOptions, type TodoCheckboxPayload, type CalloutIconPayload, type EmptyBodyPayload, createArrowMovePlugin, createCodePlugin, CODE_LANGUAGES, loadCodeLanguage, type CodeLanguage, type CodePluginOptions, type CodeHeader, type LanguageMenu, type LanguageMenuItem, type LanguageRow, createMarkdownShortcutsPlugin, createMentionPlugin, type MentionItem, type MentionData, type MentionPluginOptions, createPageLinkPlugin, type PageLinkItem, type PageLinkData, type PageLinkPluginOptions, type TriggerMenuController, withRulesAndTriggers, BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT, type BlockActivation, type BlockAddition, createBlockHandlesPlugin, type BlockHandlesOptions, type BlockHandleSnippetPayload, type BlockHandleController, createSlashMenuPlugin, type SlashMenuOptions, type SlashMenuController, createToolbarPlugin, type ToolbarOptions, type ToolbarController, createBlockMenuPlugin, type BlockMenuOptions, type BlockMenuController, type BlockMenuAction, type BlockMenuColor, createSuggestionsPlugin, createSuggestionBarPlugin, type SuggestionBarOptions, type SuggestionBarPayload, createImagePlugin, type ImagePluginOptions, safeImageSrc, storableImageSrc, MAX_INLINE_IMAGE_BYTES, createColumnsPlugin, type ColumnsPluginOptions, createEmbedPlugin, EMBED_PROVIDERS, EMBED_SANDBOX, EMBED_ALLOW, embedSourceOf, type EmbedProvider, type EmbedPluginOptions, type EmbedFallbackPayload, createBookmarkPlugin, type BookmarkPluginOptions, type BookmarkPreview, type BookmarkCardPayload, createFilePlugin, type FilePluginOptions, type FileRowPayload, createVideoPlugin, type VideoPluginOptions, createAudioPlugin, type AudioPluginOptions, safeWebUrl, safeMediaSrc, type MediaKind, createMediaEmptyPlugin, type MediaEmptyOptions, createImageToolbarPlugin, type ImageToolbar, type ImageToolbarOptions, type MediaEmptyController, type MediaEmptyFailure, type UrlPasteController, type UrlPasteOffer, type UrlPasteOption, type ImageControls, type ImageBox, type ChromeAnchor, type MenuItemPayload, createFindPlugin, findController, findMatches, type FindPluginOptions, type FindController, type ReplaceMatches, type FindMatch, type FindOptions, createMarqueePlugin, type MarqueePluginOptions, type MarqueeBoxPayload, createCommentsPlugin, commentsController, type CommentsPluginOptions, type CommentCardPayload, type CommentsController, type CommentDraft, type CommentNotice, type CommentUser, type PlacedThread, createPagePlugin, type PagePluginOptions, type PageBlockLinkPayload, createTocPlugin, type TocPluginOptions, type TocHeadingLevel, type TocEntryPayload, type TocEmptyPayload, createTablePlugin, type TablePluginOptions, insertTableRow, deleteTableRows, insertTableColumn, deleteTableColumn, moveTableColumn, moveTableRows, fillTableCell, type TableChrome, type TableMenu, type TableMenuRow, type TableMenuItem, type TableGripPayload, type TableAddPayload, tableBlock, type TableBlockOptions, createEquationPlugin, KATEX_CDN, KATEX_VERSION, type EquationPluginOptions, type EquationData, type EquationEditor, type EquationErrorPayload, type EquationPlaceholderPayload, type EquationTarget, type KatexLike, type KatexLoader } from './plugins/index.js';
|
|
46
46
|
export { BLOCK_COLORS, setBlockColor, type BlockColorField } from './block/colors.js';
|
|
47
47
|
export { englishLabels, type Labels, type PartialLabels } from './labels.js';
|
|
48
|
-
export { EdytorDocument, createDocument, loadDocument, attachDocument, defaultSemantics, semanticsOf, mergeSemantics, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, SchemaMismatchError, UndecodableUpdateError,
|
|
48
|
+
export { EdytorDocument, createDocument, loadDocument, attachDocument, defaultSemantics, semanticsOf, mergeSemantics, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, SchemaMismatchError, UndecodableUpdateError, SyncRefusedError, type CreateDocumentOptions, type LoadDocumentOptions, type DocumentActor, type DocumentReadiness, type KindSemantics, type JSONDoc, type JSONBlock, type JSONText, type JSONInlineBlock, type OpResult, type Plan, type Prepared, type DocChange } from './crdt/index.js';
|
|
49
49
|
export { createIndexeddbSync, createWebsocketSync, clearDocument, prefetch, lastUpdated, documentSnapshot, DEFAULT_PRESENCE_THROTTLE, type EdytorSync, type EdytorSyncPayload, type IndexeddbSyncOptions, type WebsocketSync, type WebsocketSyncOptions, type PresenceOptions, type PresenceShare } from './collaboration/index.js';
|
|
50
50
|
export { createCommentsClient, createMemoryCommentsClient, CommentRequestError, commentAnchors, type CommentDocument, type CommentFeed, type CommentResult, type CommentsClient, type CommentsClientOptions, type MemoryCommentsClient, type MemoryCommentsClientOptions, type CommentChange, type CommentRequest, type CommentRun, type CommentSnapshot, type CommentThread, type ThreadComment } from './collaboration/comments/index.js';
|
|
51
51
|
export { VersionHistory, createHistoryClient, HistoryRequestError, versionDiff, type HistoryClient, type HistoryClientOptions, type HistoryRestoreResult, type HistoryUndoResult, type HistoryVersion, type VersionHistoryStatus, type VersionHistoryOptions, type VersionChange, type VersionDiff } from './collaboration/history/index.js';
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ export { englishLabels } from './labels.js';
|
|
|
44
44
|
// The application names of `edytor/crdt/edytor`: a Svelte app builds,
|
|
45
45
|
// loads and catches its documents from here. The facade's full vocabulary
|
|
46
46
|
// stays on that entry.
|
|
47
|
-
export { EdytorDocument, createDocument, loadDocument, attachDocument, defaultSemantics, semanticsOf, mergeSemantics, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, SchemaMismatchError, UndecodableUpdateError,
|
|
47
|
+
export { EdytorDocument, createDocument, loadDocument, attachDocument, defaultSemantics, semanticsOf, mergeSemantics, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, SchemaMismatchError, UndecodableUpdateError, SyncRefusedError } from './crdt/index.js';
|
|
48
48
|
// ── Sync and presence ──────────────────────────────────────────────────
|
|
49
49
|
export { createIndexeddbSync, createWebsocketSync, clearDocument, prefetch, lastUpdated, documentSnapshot, DEFAULT_PRESENCE_THROTTLE } from './collaboration/index.js';
|
|
50
50
|
// ── Comment threads ────────────────────────────────────────────────────
|
package/dist/kinds.js
CHANGED
|
@@ -209,7 +209,7 @@ export const convertToKind = (edytor, block, row, caret = row.replaces) => {
|
|
|
209
209
|
let line = kind.children?.length ? at?.children[0] : at;
|
|
210
210
|
while (line && !line.rendersContent && !line.definition.void && line.children[0])
|
|
211
211
|
line = line.children[0];
|
|
212
|
-
edytor.dispatcher.
|
|
212
|
+
edytor.dispatcher.caretIn(line?.firstText, 0);
|
|
213
213
|
}
|
|
214
214
|
return true;
|
|
215
215
|
};
|
|
@@ -1,47 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A panel the
|
|
3
|
-
*
|
|
4
|
-
* equation): the
|
|
5
|
-
* one rule that closes the panel without
|
|
6
|
-
* a press or a focus outside the panel
|
|
7
|
-
* readonly.
|
|
2
|
+
* A panel the app draws by an element of the page (the code language list
|
|
3
|
+
* by its button, the callout icon picker by its icon, the equation editor
|
|
4
|
+
* by its equation): that element as the panel's `anchor`, which the app's
|
|
5
|
+
* markup places itself by, and the one rule that closes the panel without
|
|
6
|
+
* moving the keys: its anchor gone, a press or a focus outside the panel
|
|
7
|
+
* and its anchor, the view turning readonly.
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { Snippet } from 'svelte';
|
|
10
10
|
import type { Edytor } from '../edytor.svelte.js';
|
|
11
|
-
import { type LayerBox } from '../surface/overlay.js';
|
|
12
11
|
export declare class Anchored {
|
|
13
12
|
#private;
|
|
14
13
|
private edytor;
|
|
15
14
|
/** The overlay host's name: its element is `[data-<name>]`. */
|
|
16
15
|
private name;
|
|
17
|
-
/** The element the panel stands
|
|
18
|
-
private
|
|
16
|
+
/** The element the panel stands by: `null` when it left the page, `undefined` while closed. */
|
|
17
|
+
private element;
|
|
19
18
|
/** Close the panel, the keys where they are. */
|
|
20
19
|
private dismiss;
|
|
21
|
-
/** The anchor's box in the overlay's frame while the panel is open, else `null` (reactive). */
|
|
22
|
-
box: LayerBox | null;
|
|
23
20
|
constructor(edytor: Edytor,
|
|
24
21
|
/** The overlay host's name: its element is `[data-<name>]`. */
|
|
25
22
|
name: string,
|
|
26
|
-
/** The element the panel stands
|
|
27
|
-
|
|
23
|
+
/** The element the panel stands by: `null` when it left the page, `undefined` while closed. */
|
|
24
|
+
element: () => Element | null | undefined,
|
|
28
25
|
/** Close the panel, the keys where they are. */
|
|
29
26
|
dismiss: () => void);
|
|
30
|
-
/** Where the panel stands:
|
|
31
|
-
|
|
32
|
-
left: number;
|
|
33
|
-
top: number;
|
|
34
|
-
} | null;
|
|
27
|
+
/** Where the panel stands: its element's box, read on every call (`ChromeAnchor`). */
|
|
28
|
+
readonly anchor: import("./chrome.js").ChromeAnchor;
|
|
35
29
|
/**
|
|
36
30
|
* Focus left a field of the panel (its `focusout`): for somewhere outside
|
|
37
|
-
* the panel and its
|
|
38
|
-
* to the background), it stays.
|
|
31
|
+
* the panel and its element, it closes; with no new focus (the window
|
|
32
|
+
* went to the background), it stays.
|
|
39
33
|
*/
|
|
40
34
|
blurred: (event: FocusEvent) => void;
|
|
41
35
|
/**
|
|
42
|
-
* Mount the
|
|
43
|
-
*
|
|
44
|
-
*
|
|
36
|
+
* Mount the app's `snippet` with `payload` in the overlay at `zIndex`
|
|
37
|
+
* (above the block handles, 5, by default) while `shown` holds, with a
|
|
38
|
+
* press listener (capture) on `node`'s document, the anchor-gone rule
|
|
39
|
+
* (on the overlay's frames) and the readonly rule. Answers the teardown,
|
|
40
|
+
* which closes it.
|
|
45
41
|
*/
|
|
46
|
-
mount: <
|
|
42
|
+
mount: <T>(node: HTMLElement, snippet: Snippet<[T]>, payload: T, shown: () => unknown, zIndex?: number) => () => void;
|
|
47
43
|
}
|
|
@@ -1,71 +1,55 @@
|
|
|
1
1
|
import { onPress } from '../events/onFocus.js';
|
|
2
|
-
import {
|
|
2
|
+
import { mountChrome, virtualAnchor } from './chrome.js';
|
|
3
3
|
export class Anchored {
|
|
4
4
|
edytor;
|
|
5
5
|
name;
|
|
6
|
-
|
|
6
|
+
element;
|
|
7
7
|
dismiss;
|
|
8
|
-
/** The anchor's box in the overlay's frame while the panel is open, else `null` (reactive). */
|
|
9
|
-
box = $state.raw(null);
|
|
10
8
|
constructor(edytor,
|
|
11
9
|
/** The overlay host's name: its element is `[data-<name>]`. */
|
|
12
10
|
name,
|
|
13
|
-
/** The element the panel stands
|
|
14
|
-
|
|
11
|
+
/** The element the panel stands by: `null` when it left the page, `undefined` while closed. */
|
|
12
|
+
element,
|
|
15
13
|
/** Close the panel, the keys where they are. */
|
|
16
14
|
dismiss) {
|
|
17
15
|
this.edytor = edytor;
|
|
18
16
|
this.name = name;
|
|
19
|
-
this.
|
|
17
|
+
this.element = element;
|
|
20
18
|
this.dismiss = dismiss;
|
|
21
19
|
}
|
|
22
|
-
/** Where the panel stands:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return box && { left: box.x + (center ? box.width / 2 : 0), top: box.y + box.height + gap };
|
|
26
|
-
};
|
|
27
|
-
/** `at` is outside the panel's host and its anchor: the panel closes. */
|
|
20
|
+
/** Where the panel stands: its element's box, read on every call (`ChromeAnchor`). */
|
|
21
|
+
anchor = virtualAnchor(() => this.element()?.getBoundingClientRect(), () => this.element());
|
|
22
|
+
/** `at` is outside the panel's host and its element: the panel closes. */
|
|
28
23
|
#outside = (at, host) => {
|
|
29
24
|
if (!(at instanceof Node))
|
|
30
25
|
return;
|
|
31
|
-
if (!host?.contains(at) && !this.
|
|
26
|
+
if (!host?.contains(at) && !this.element()?.contains(at))
|
|
32
27
|
this.dismiss();
|
|
33
28
|
};
|
|
34
29
|
/**
|
|
35
30
|
* Focus left a field of the panel (its `focusout`): for somewhere outside
|
|
36
|
-
* the panel and its
|
|
37
|
-
* to the background), it stays.
|
|
31
|
+
* the panel and its element, it closes; with no new focus (the window
|
|
32
|
+
* went to the background), it stays.
|
|
38
33
|
*/
|
|
39
34
|
blurred = (event) => this.#outside(event.relatedTarget, event.currentTarget?.closest(`[data-${this.name}]`));
|
|
40
35
|
/**
|
|
41
|
-
* Mount the
|
|
42
|
-
*
|
|
43
|
-
*
|
|
36
|
+
* Mount the app's `snippet` with `payload` in the overlay at `zIndex`
|
|
37
|
+
* (above the block handles, 5, by default) while `shown` holds, with a
|
|
38
|
+
* press listener (capture) on `node`'s document, the anchor-gone rule
|
|
39
|
+
* (on the overlay's frames) and the readonly rule. Answers the teardown,
|
|
40
|
+
* which closes it.
|
|
44
41
|
*/
|
|
45
|
-
mount = (node,
|
|
42
|
+
mount = (node, snippet, payload, shown, zIndex = 7) => {
|
|
46
43
|
const { edytor } = this;
|
|
47
|
-
const offPress = onPress(edytor, node.ownerDocument, (event) => this.
|
|
44
|
+
const offPress = onPress(edytor, node.ownerDocument, (event) => this.element() !== undefined &&
|
|
48
45
|
this.#outside(event.target, event.target?.closest?.(`[data-${this.name}]`)), true);
|
|
49
|
-
const unmount = edytor
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (anchor === null)
|
|
55
|
-
return this.dismiss();
|
|
56
|
-
if (!sameValues(box, this.box))
|
|
57
|
-
this.box = box;
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
const offLock = $effect.root(() => {
|
|
61
|
-
$effect(() => {
|
|
62
|
-
if (edytor.readonly)
|
|
63
|
-
this.dismiss();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
46
|
+
const unmount = mountChrome(edytor, snippet, payload, shown, {
|
|
47
|
+
name: this.name,
|
|
48
|
+
zIndex,
|
|
49
|
+
measure: () => (this.element() === null ? this.dismiss : undefined)
|
|
50
|
+
}, this.dismiss);
|
|
66
51
|
return () => {
|
|
67
52
|
offPress();
|
|
68
|
-
offLock();
|
|
69
53
|
unmount();
|
|
70
54
|
this.dismiss();
|
|
71
55
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { untrack } from 'svelte';
|
|
2
2
|
import { autoScrollFor } from '../../dnd/autoScroll.js';
|
|
3
3
|
import { blockSelection, noSelection, project } from '../../session/selection.js';
|
|
4
|
-
import {
|
|
4
|
+
import { dropTargetForElements, elementScrollers } from '../../dnd/pragmatic.js';
|
|
5
5
|
import { getSelectionBlocks, holdsBlocks, movable, outermost, selectMoved, shownText } from '../../selection/replaceSelection.js';
|
|
6
6
|
import { takeKeys } from '../../events/onFocus.js';
|
|
7
|
-
import { EDYTOR_BLOCK_DRAG_MIME } from '../../events/onDrop.js';
|
|
8
7
|
import { kindLabel } from '../../kinds.js';
|
|
9
8
|
import { siblingSlot } from '../../session/handles.js';
|
|
10
|
-
import {
|
|
9
|
+
import { dragSource, ghost } from './dragPreview.js';
|
|
11
10
|
import { DropIndicator } from '../../dnd/dropIndicator.js';
|
|
12
11
|
import { DropResolver, SLOP_X, SLOP_Y } from '../../dnd/placement.js';
|
|
13
12
|
import { getOwnRowBottom, ownRow } from '../../dnd/geometry.js';
|
|
@@ -226,7 +225,7 @@ export class BlockHandleController {
|
|
|
226
225
|
edytor.move({ blocks: [target], target: block, position: 'right' });
|
|
227
226
|
// The caret is the model's: the projector shows it once the block mounts.
|
|
228
227
|
if (target?.firstText)
|
|
229
|
-
dispatcher.
|
|
228
|
+
dispatcher.caretIn(target.firstText, 0);
|
|
230
229
|
if (!target || !then)
|
|
231
230
|
return;
|
|
232
231
|
const [added, before] = [facade.version, dispatcher.last];
|
|
@@ -283,21 +282,20 @@ export class BlockHandleController {
|
|
|
283
282
|
const text = grip && shownText(grip, 'first');
|
|
284
283
|
// A block with no text (a divider): no selection, as before the grip.
|
|
285
284
|
if (text)
|
|
286
|
-
this.edytor.dispatcher.
|
|
285
|
+
this.edytor.dispatcher.caretIn(text, 0);
|
|
287
286
|
else
|
|
288
287
|
selection.select(noSelection);
|
|
289
288
|
}
|
|
290
289
|
registerHandle(element, block) {
|
|
291
290
|
if (!this.options.draggable)
|
|
292
291
|
return () => { };
|
|
293
|
-
return
|
|
294
|
-
element,
|
|
292
|
+
return dragSource(element, {
|
|
295
293
|
canDrag: () => !this.edytor.readonly && block.movable,
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
data: () => ({ owner: this.owner, blockId: block.id }),
|
|
295
|
+
id: () => block.id,
|
|
298
296
|
// The moved blocks are known, and drop targets exist, from the start of
|
|
299
297
|
// our drag (before any target is looked up).
|
|
300
|
-
|
|
298
|
+
begin: (pointer, setImage) => {
|
|
301
299
|
this.dragging = block.id;
|
|
302
300
|
this.handle = element.closest('[data-edytor-block-handle-host]') ?? element;
|
|
303
301
|
const group = (this.group = this.dragBlocks(block));
|
|
@@ -305,36 +303,30 @@ export class BlockHandleController {
|
|
|
305
303
|
// removed with the drag library's container once the drag starts.
|
|
306
304
|
const root = this.edytor.node;
|
|
307
305
|
const nodes = group.flatMap((moved) => (moved.node ? [moved.node] : []));
|
|
308
|
-
|
|
309
|
-
const preview = dragPreview(root, nodes, location.current.input);
|
|
310
|
-
setCustomNativeDragPreview({
|
|
311
|
-
nativeSetDragImage,
|
|
312
|
-
getOffset: preview.offset,
|
|
313
|
-
render: ({ container }) => container.append(preview.element)
|
|
314
|
-
});
|
|
315
|
-
}
|
|
306
|
+
ghost(setImage, root, nodes, pointer);
|
|
316
307
|
for (const [node, target] of this.targets)
|
|
317
308
|
this.#registerDropTarget(node, target);
|
|
318
309
|
this.#registerDropTarget(element.ownerDocument.body, null);
|
|
319
310
|
this.scrolling?.();
|
|
320
|
-
this.scrolling = root
|
|
311
|
+
this.scrolling = root
|
|
312
|
+
? autoScrollFor(root, elementScrollers((data) => data.owner === this.owner))
|
|
313
|
+
: null;
|
|
321
314
|
this.indicator.begin(element.ownerDocument);
|
|
322
315
|
},
|
|
323
316
|
// The moved blocks show selected while they move (a text range becomes their
|
|
324
317
|
// block selection); the drop's undo step restores the selection held before.
|
|
325
|
-
|
|
318
|
+
start: () => {
|
|
326
319
|
const { selectedBlocks, value } = this.edytor.selection;
|
|
327
320
|
if (holdsBlocks(selectedBlocks, this.group))
|
|
328
321
|
return;
|
|
329
322
|
this.held = value;
|
|
330
323
|
this.select(block);
|
|
331
324
|
},
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (location.current.dropTargets.length)
|
|
325
|
+
// Kept the shown placement and the targets until the target has
|
|
326
|
+
// committed its move. A drop on one of ours gives the keys to the
|
|
327
|
+
// editor (Notion: Mod+Z right after a drag), whatever it selected.
|
|
328
|
+
end: (dropped) => {
|
|
329
|
+
if (dropped)
|
|
338
330
|
takeKeys(this.edytor);
|
|
339
331
|
this.indicator.end();
|
|
340
332
|
this.scrolling?.();
|
|
@@ -346,7 +338,7 @@ export class BlockHandleController {
|
|
|
346
338
|
this.handle = null;
|
|
347
339
|
this.group = [];
|
|
348
340
|
this.held = null;
|
|
349
|
-
}
|
|
341
|
+
}
|
|
350
342
|
});
|
|
351
343
|
}
|
|
352
344
|
/** A candidate drop target; registered at once when our drag is in progress. */
|
|
@@ -390,14 +382,14 @@ export class BlockHandleController {
|
|
|
390
382
|
const dragSource = this.#getDragSource(source.data);
|
|
391
383
|
if (!dragSource)
|
|
392
384
|
return false;
|
|
385
|
+
const drag = this.#drag(dragSource);
|
|
393
386
|
if (!target)
|
|
394
|
-
return Boolean(this.drop.margin(
|
|
387
|
+
return Boolean(this.drop.margin(drag, input));
|
|
395
388
|
if (this.drop.inHandleColumn(input.clientX))
|
|
396
389
|
return false;
|
|
397
|
-
const row = this.drop.rowAt(
|
|
398
|
-
const { before, after } = this.drop.zones(
|
|
399
|
-
return
|
|
400
|
-
Boolean(this.drop.beside(this.#drag(dragSource), row, input)));
|
|
390
|
+
const row = this.drop.rowAt(drag, target, node, input);
|
|
391
|
+
const { before, after } = this.drop.zones(drag, row, input);
|
|
392
|
+
return [...before, ...after].some(drag.fits) || Boolean(this.drop.beside(drag, row, input));
|
|
401
393
|
},
|
|
402
394
|
// The row at the pointer and the half of its own row (not its subtree's)
|
|
403
395
|
// the pointer is in: held while the target is sticky (the drag library
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Notion's drag ghost: a copy of the dragged blocks, rendered as they look in
|
|
3
|
-
* the editor, scaled down, that follows the pointer (the browser adds its own
|
|
4
|
-
* drag-image translucency). Cloned once when the drag starts and mounted by
|
|
5
|
-
* the drag library for the frame the browser takes its picture
|
|
6
|
-
* (`setCustomNativeDragPreview`), then removed with it.
|
|
7
|
-
*/
|
|
8
1
|
export type DragPreview = {
|
|
9
2
|
/** The ghost, `[data-edytor-drag-preview]`, to mount in the drag library's container. */
|
|
10
3
|
element: HTMLElement;
|
|
@@ -33,3 +26,29 @@ export declare const dragPreview: (root: HTMLElement, nodes: HTMLElement[], poin
|
|
|
33
26
|
clientX: number;
|
|
34
27
|
clientY: number;
|
|
35
28
|
}, columns?: number[]) => DragPreview;
|
|
29
|
+
type Pointer = {
|
|
30
|
+
clientX: number;
|
|
31
|
+
clientY: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* One of the editor's own drags from `element` (a block's handle, a table's
|
|
35
|
+
* grip): `canDrag` asks whether it may start, `data` is what its targets
|
|
36
|
+
* read, `id` the block another view sees it carry (no view takes it as a
|
|
37
|
+
* foreign drop); `begin` runs as it starts (the ghost and the targets),
|
|
38
|
+
* `start` once it has, and `end` after the drop target's own drop (the drag
|
|
39
|
+
* library tells the source first).
|
|
40
|
+
*/
|
|
41
|
+
export declare const dragSource: (element: HTMLElement, { canDrag, data, id, begin, start, end }: {
|
|
42
|
+
canDrag: () => boolean;
|
|
43
|
+
data: () => Record<string | symbol, unknown>;
|
|
44
|
+
id: () => string;
|
|
45
|
+
begin: (pointer: Pointer, setImage: DataTransfer["setDragImage"] | null) => void;
|
|
46
|
+
start?: () => void;
|
|
47
|
+
end: (dropped: boolean) => void;
|
|
48
|
+
}) => import("../../dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types").CleanupFn;
|
|
49
|
+
/**
|
|
50
|
+
* The drag's ghost (`dragPreview` of `nodes` under `root`), mounted for the
|
|
51
|
+
* browser's picture of it, when the drag has an image to set.
|
|
52
|
+
*/
|
|
53
|
+
export declare const ghost: (setImage: DataTransfer["setDragImage"] | null, root: HTMLElement | null | undefined, nodes: HTMLElement[], pointer: Pointer, columns?: number[]) => void;
|
|
54
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { draggable, setCustomNativeDragPreview } from '../../dnd/pragmatic.js';
|
|
2
|
+
import { EDYTOR_BLOCK_DRAG_MIME } from '../../events/onDrop.js';
|
|
1
3
|
/**
|
|
2
4
|
* Notion's drag ghost: a copy of the dragged blocks, rendered as they look in
|
|
3
5
|
* the editor, scaled down, that follows the pointer (the browser adds its own
|
|
@@ -227,3 +229,34 @@ export const dragPreview = (root, nodes, pointer, columns) => {
|
|
|
227
229
|
};
|
|
228
230
|
return { element, offset };
|
|
229
231
|
};
|
|
232
|
+
/**
|
|
233
|
+
* One of the editor's own drags from `element` (a block's handle, a table's
|
|
234
|
+
* grip): `canDrag` asks whether it may start, `data` is what its targets
|
|
235
|
+
* read, `id` the block another view sees it carry (no view takes it as a
|
|
236
|
+
* foreign drop); `begin` runs as it starts (the ghost and the targets),
|
|
237
|
+
* `start` once it has, and `end` after the drop target's own drop (the drag
|
|
238
|
+
* library tells the source first).
|
|
239
|
+
*/
|
|
240
|
+
export const dragSource = (element, { canDrag, data, id, begin, start, end }) => draggable({
|
|
241
|
+
element,
|
|
242
|
+
canDrag,
|
|
243
|
+
getInitialData: data,
|
|
244
|
+
getInitialDataForExternal: () => ({ [EDYTOR_BLOCK_DRAG_MIME]: id() }),
|
|
245
|
+
onGenerateDragPreview: ({ nativeSetDragImage, location }) => begin(location.current.input, nativeSetDragImage),
|
|
246
|
+
onDragStart: start,
|
|
247
|
+
onDrop: ({ location }) => queueMicrotask(() => end(location.current.dropTargets.length > 0))
|
|
248
|
+
});
|
|
249
|
+
/**
|
|
250
|
+
* The drag's ghost (`dragPreview` of `nodes` under `root`), mounted for the
|
|
251
|
+
* browser's picture of it, when the drag has an image to set.
|
|
252
|
+
*/
|
|
253
|
+
export const ghost = (setImage, root, nodes, pointer, columns) => {
|
|
254
|
+
if (!setImage || !root || !nodes.length)
|
|
255
|
+
return;
|
|
256
|
+
const preview = dragPreview(root, nodes, pointer, columns);
|
|
257
|
+
setCustomNativeDragPreview({
|
|
258
|
+
nativeSetDragImage: setImage,
|
|
259
|
+
getOffset: preview.offset,
|
|
260
|
+
render: ({ container }) => container.append(preview.element)
|
|
261
|
+
});
|
|
262
|
+
};
|
|
@@ -69,6 +69,11 @@ export declare class BlockMenuController {
|
|
|
69
69
|
* after). Delete and Turn into act on their `members`, its items too.
|
|
70
70
|
*/
|
|
71
71
|
blocks: Block[];
|
|
72
|
+
/**
|
|
73
|
+
* Where the menu stands: the handle that opened it (a `ChromeAnchor`:
|
|
74
|
+
* your `menu` places itself beside it, its flyout beside the menu);
|
|
75
|
+
* `null` while closed.
|
|
76
|
+
*/
|
|
72
77
|
anchor: HTMLElement | null;
|
|
73
78
|
query: string;
|
|
74
79
|
/** The keyboard's row. */
|