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
package/dist/edytor.svelte.js
CHANGED
|
@@ -6,8 +6,9 @@ import { onCut } from './events/onCut.js';
|
|
|
6
6
|
import { isControlEvent, isKindControl } from './events/nativeInteractiveControl.js';
|
|
7
7
|
import { onInput } from './events/onInput.js';
|
|
8
8
|
import { onPaste } from './events/onPaste.js';
|
|
9
|
-
import {
|
|
9
|
+
import { onTextDragEnd, onTextDragStart, preventUnsupportedDrop } from './events/onDrop.js';
|
|
10
10
|
import { attachFocus, selectionIsInside, takeKeys } from './events/onFocus.js';
|
|
11
|
+
import { attachPageHide } from './events/onPageHide.js';
|
|
11
12
|
import { insertLineBreak, runIntent } from './events/beforeInputCommands.js';
|
|
12
13
|
import { textPointAt } from './selection/selection.utils.js';
|
|
13
14
|
import { Attempts } from './session/attempt.js';
|
|
@@ -29,7 +30,7 @@ import Announcer from './components/Announcer.svelte';
|
|
|
29
30
|
import RemoteSelections from './collaboration/RemoteSelections.svelte';
|
|
30
31
|
import Ranges from './components/Ranges.svelte';
|
|
31
32
|
import { Handles } from './session/handles.js';
|
|
32
|
-
import { id } from './utils.js';
|
|
33
|
+
import { cleanups, id } from './utils.js';
|
|
33
34
|
import { Y } from './crdt/engine.js';
|
|
34
35
|
import { markName } from './crdt/text/marks.js';
|
|
35
36
|
import { callEach } from './crdt/protocols/observable.js';
|
|
@@ -193,11 +194,10 @@ export class Edytor {
|
|
|
193
194
|
// CRDT (v14) — the document is the composition owner: it holds the ONE
|
|
194
195
|
// engine doc, the shared facade (only structural read/write surface),
|
|
195
196
|
// the default local history and the shared awareness. Injected
|
|
196
|
-
// documents are borrowed; a view with no `document` option
|
|
197
|
-
// owns one (built around `doc`/`awareness` when those are injected).
|
|
197
|
+
// documents are borrowed; a view with no `document` option owns a fresh one.
|
|
198
198
|
document;
|
|
199
|
-
/**
|
|
200
|
-
|
|
199
|
+
/** `true` when this view created its document — `destroy()` then releases it. */
|
|
200
|
+
#owned = false;
|
|
201
201
|
get doc() {
|
|
202
202
|
return this.document.doc;
|
|
203
203
|
}
|
|
@@ -297,7 +297,7 @@ export class Edytor {
|
|
|
297
297
|
this.dispatcher.record({ operation: command, status: this.history.replay(command) });
|
|
298
298
|
};
|
|
299
299
|
constructor(options) {
|
|
300
|
-
const { readonly, hotkeys, plugins, document,
|
|
300
|
+
const { readonly, hotkeys, plugins, document, actor, requireHydration, presence, sync, value, onSelectionChange, labels, onChange, onDocChange, allowNesting } = options;
|
|
301
301
|
for (const name of DOCUMENT_WRITES)
|
|
302
302
|
Object.defineProperty(this, name, {
|
|
303
303
|
value: (...args) => this.dispatcher.operate(name, args)
|
|
@@ -306,21 +306,14 @@ export class Edytor {
|
|
|
306
306
|
this.labels = labels;
|
|
307
307
|
this.allowNesting = allowNesting === true;
|
|
308
308
|
if (document !== undefined) {
|
|
309
|
-
if (DEV &&
|
|
310
|
-
(
|
|
311
|
-
awareness !== undefined ||
|
|
312
|
-
actor !== undefined ||
|
|
313
|
-
requireHydration !== undefined)) {
|
|
314
|
-
throw new Error('EdytorOptions: `document` cannot be combined with `doc`/`awareness`/`actor`/`requireHydration` — ' +
|
|
315
|
-
'the document owns them (compose them via attachDocument first).');
|
|
309
|
+
if (DEV && (actor !== undefined || requireHydration !== undefined)) {
|
|
310
|
+
throw new Error('EdytorOptions: `document` cannot be combined with `actor`/`requireHydration`: set them on the document.');
|
|
316
311
|
}
|
|
317
312
|
this.document = document;
|
|
318
313
|
}
|
|
319
314
|
else {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
this.document = attachDocument(doc ?? new Y.Doc(), { awareness, actor, requireHydration });
|
|
323
|
-
this.ownsDocument = true;
|
|
315
|
+
this.document = attachDocument(new Y.Doc(), { actor, requireHydration });
|
|
316
|
+
this.#owned = true;
|
|
324
317
|
}
|
|
325
318
|
this.readonly = readonly || false;
|
|
326
319
|
this.onChange = onChange;
|
|
@@ -388,7 +381,7 @@ export class Edytor {
|
|
|
388
381
|
// decision; every other view binds on the one readiness event
|
|
389
382
|
// (`<Edytor>` decides an injected document at mount, once the
|
|
390
383
|
// providers of its sibling views attached).
|
|
391
|
-
if (this
|
|
384
|
+
if (this.#owned && !sync) {
|
|
392
385
|
this.sync(value || { children: [] });
|
|
393
386
|
}
|
|
394
387
|
else {
|
|
@@ -409,7 +402,7 @@ export class Edytor {
|
|
|
409
402
|
// document-lifetime additive declarations, and an injected
|
|
410
403
|
// document's are left for the views that legitimately share it.
|
|
411
404
|
this.document.untrackOrigin(this.transaction);
|
|
412
|
-
if (this
|
|
405
|
+
if (this.#owned) {
|
|
413
406
|
this.document.destroy();
|
|
414
407
|
}
|
|
415
408
|
throw error;
|
|
@@ -611,9 +604,7 @@ export class Edytor {
|
|
|
611
604
|
// A failed async handler (a command's hook or write) surfaces
|
|
612
605
|
// through the platform's error reporting; the DOM ignores
|
|
613
606
|
// the listener's promise.
|
|
614
|
-
void Promise.resolve(result)
|
|
615
|
-
.finally(clear)
|
|
616
|
-
.catch((error) => typeof reportError === 'function' ? reportError(error) : console.error(error));
|
|
607
|
+
void Promise.resolve(result).finally(clear).catch(reportError);
|
|
617
608
|
}
|
|
618
609
|
else {
|
|
619
610
|
clear();
|
|
@@ -804,7 +795,9 @@ export class Edytor {
|
|
|
804
795
|
keydown(event);
|
|
805
796
|
}),
|
|
806
797
|
// Pointer and focus ownership, and the focus-time caret restore.
|
|
807
|
-
...attachFocus(this, node),
|
|
798
|
+
...attachFocus(this, node),
|
|
799
|
+
// The page leaving for good ends the session's history.
|
|
800
|
+
attachPageHide(this), on(node, 'mousedown', this.selection.pointer.preventTripleClick), on(node, 'click', this.selection.pointer.tripleClick),
|
|
808
801
|
// Settle queued mutation repairs before the native menu opens —
|
|
809
802
|
// spellcheck suggestions are computed against the DOM at this
|
|
810
803
|
// moment (PM flushes its DOM observer on contextmenu for the
|
|
@@ -812,7 +805,7 @@ export class Edytor {
|
|
|
812
805
|
on(node, 'contextmenu', () => void this.surface.flush()), on(node, 'beforeinput', this.#withUserInput(this.onBeforeInput)),
|
|
813
806
|
// An `input` records what the browser did; it says nothing new about
|
|
814
807
|
// where the user wants the selection (a display still to land wins).
|
|
815
|
-
on(node, 'input', this.#withUserInput(this.onInput, { bumpSerial: false })), on(node, 'copy', this.onCopy), on(node, 'cut', this.#withUserInput(this.onCut)), on(node, 'paste', this.#withUserInput(this.onPaste)), on(node, 'dragstart', (event) => onTextDragStart(this, event)), on(node, 'dragend', () => onTextDragEnd(this)), on(node, 'dragover', (event) => preventUnsupportedDrop(event, this)), on(node, '
|
|
808
|
+
on(node, 'input', this.#withUserInput(this.onInput, { bumpSerial: false })), on(node, 'copy', this.onCopy), on(node, 'cut', this.#withUserInput(this.onCut)), on(node, 'paste', this.#withUserInput(this.onPaste)), on(node, 'dragstart', (event) => onTextDragStart(this, event)), on(node, 'dragend', () => onTextDragEnd(this)), on(node, 'dragover', (event) => preventUnsupportedDrop(event, this)), on(node, 'drop', this.#withUserInput((event) => preventUnsupportedDrop(event, this))), on(node, 'compositionstart', this.onCompositionStart), on(node, 'compositionend', this.onCompositionEnd), detachSurface);
|
|
816
809
|
// Chrome lives in the overlay, outside the host: remote carets, then the plugins'.
|
|
817
810
|
const detachOverlay = this.overlay.attach(node);
|
|
818
811
|
const presence = mount(RemoteSelections, {
|
|
@@ -830,11 +823,7 @@ export class Edytor {
|
|
|
830
823
|
props: { announcer: this.announcer }
|
|
831
824
|
});
|
|
832
825
|
this.off.push(() => unmount(presence), () => unmount(ranges), () => unmount(live), detachOverlay);
|
|
833
|
-
this.
|
|
834
|
-
const action = plugin.onEdytorAttached?.({ node });
|
|
835
|
-
if (typeof action === 'function')
|
|
836
|
-
this.off.push(action);
|
|
837
|
-
});
|
|
826
|
+
this.off.push(...cleanups(this.plugins, (plugin) => plugin.onEdytorAttached?.({ node })));
|
|
838
827
|
return {
|
|
839
828
|
destroy: () => {
|
|
840
829
|
if (selectionIsInside(node))
|
|
@@ -864,7 +853,7 @@ export class Edytor {
|
|
|
864
853
|
* discarded.
|
|
865
854
|
*
|
|
866
855
|
* Releases every listener the editor holds on potentially-SHARED objects
|
|
867
|
-
* — an injected
|
|
856
|
+
* — an injected document outlives a single editor, so an
|
|
868
857
|
* undestroyed mount leaks a facade `update` listener and the undo
|
|
869
858
|
* manager's doc observers forever.
|
|
870
859
|
*
|
|
@@ -908,7 +897,7 @@ export class Edytor {
|
|
|
908
897
|
// awareness, doc) belong to the document — released exactly once,
|
|
909
898
|
// and only when THIS view created it. A borrowed document keeps
|
|
910
899
|
// serving its sibling views and headless consumers.
|
|
911
|
-
if (this
|
|
900
|
+
if (this.#owned) {
|
|
912
901
|
this.document.destroy();
|
|
913
902
|
}
|
|
914
903
|
};
|
|
@@ -209,14 +209,14 @@ const splitKeepingChildren = (edytor, [id, offset, born, tail], child) => {
|
|
|
209
209
|
return REFUSED;
|
|
210
210
|
if (!child)
|
|
211
211
|
return facade.compose({ ...split, writes: [step] });
|
|
212
|
-
// The
|
|
212
|
+
// The document's answer on placing the kind as a first child.
|
|
213
213
|
const slot = facade.prepare.insertBlocks({ parent: id, index: 0 }, [
|
|
214
214
|
{ id: born, type: tail?.type ?? facade.defaultChild(id) }
|
|
215
215
|
]);
|
|
216
216
|
const first = 'writes' in slot ? slot.writes[0] : undefined;
|
|
217
217
|
if (first?.op !== 'insertBlocks')
|
|
218
218
|
return REFUSED;
|
|
219
|
-
const placed = { ...step, parent: id,
|
|
219
|
+
const placed = { ...step, parent: id, index: 0 };
|
|
220
220
|
return facade.compose({ ...split, writes: [placed] });
|
|
221
221
|
};
|
|
222
222
|
/**
|
|
@@ -7,7 +7,7 @@ import { isAndroidChromeBrowser } from './events.utils.js';
|
|
|
7
7
|
import { isNativeInteractiveControl, isNativeInteractiveEvent, ownsEvent } from './nativeInteractiveControl.js';
|
|
8
8
|
import { runBeforeInputCommand } from './beforeInputCommands.js';
|
|
9
9
|
import { deleteInText } from './beforeInputDeleteCommands.js';
|
|
10
|
-
import { readDomText } from '
|
|
10
|
+
import { readDomText } from '../surface/observer.svelte.js';
|
|
11
11
|
/** The Android no-op-Backspace and model-owned drift deadlines (named, counted browser rules). */
|
|
12
12
|
const NATIVE_INPUT_REPAIR_WINDOW_MS = 150;
|
|
13
13
|
const dirOf = (inputType) => INTENTS[inputType]?.dir;
|
package/dist/events/onDrop.d.ts
CHANGED
|
@@ -31,9 +31,3 @@ export declare const onTextDragEnd: (edytor: Edytor) => undefined;
|
|
|
31
31
|
* which is the control's (`isControlDrop`).
|
|
32
32
|
*/
|
|
33
33
|
export declare const preventUnsupportedDrop: (event: DragEvent, edytor: Edytor) => void | Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* A drag leaving the host (to the page around it, or out of the window):
|
|
36
|
-
* a file drag's indicator goes. Moving between the host's own elements is
|
|
37
|
-
* no leave.
|
|
38
|
-
*/
|
|
39
|
-
export declare const onDragLeave: (edytor: Edytor, event: DragEvent) => void;
|
package/dist/events/onDrop.js
CHANGED
|
@@ -13,8 +13,9 @@ import { viewUploads } from '../session/uploads.js';
|
|
|
13
13
|
* `Files` is intentionally accepted (so the browser never opens a dropped
|
|
14
14
|
* file in place of the page): with the view's uploads (a media plugin given
|
|
15
15
|
* an `upload`), file drops route through the plugin `onPaste` hook with the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* placement the uploads' drop target resolved (`ViewUploads.drop`, Pragmatic's
|
|
17
|
+
* external adapter: a block per file the kinds take there; unclaimed files
|
|
18
|
+
* insert nothing); without them a drop carrying
|
|
18
19
|
* files is ignored, its effect `none`.
|
|
19
20
|
*/
|
|
20
21
|
const ACCEPTED_FOREIGN_DROP_TYPES = ['Files', 'text/html', 'text/plain', 'text/uri-list'];
|
|
@@ -188,21 +189,19 @@ export const preventUnsupportedDrop = (event, edytor) => {
|
|
|
188
189
|
if (isAcceptedForeignDrop(root, event.dataTransfer)) {
|
|
189
190
|
event.preventDefault();
|
|
190
191
|
event.stopPropagation();
|
|
191
|
-
//
|
|
192
|
-
// read-only view or one without uploads
|
|
193
|
-
// browser must not open the file
|
|
194
|
-
const shown = drop && !ownsEvent(root, event) && drop.over(event);
|
|
192
|
+
// Where files land shows from the uploads' drop target (Pragmatic's
|
|
193
|
+
// external adapter); a read-only view or one without uploads takes no
|
|
194
|
+
// file drop, and the browser must not open the file.
|
|
195
195
|
if (event.dataTransfer)
|
|
196
196
|
event.dataTransfer.dropEffect = files && (edytor.readonly || !drop) ? 'none' : 'copy';
|
|
197
|
-
if (drop && !shown)
|
|
198
|
-
drop.end();
|
|
199
197
|
}
|
|
200
198
|
return;
|
|
201
199
|
}
|
|
202
200
|
const accepted = isAcceptedForeignDrop(root, event.dataTransfer);
|
|
203
|
-
// Where the files land: the
|
|
204
|
-
|
|
205
|
-
drop?.
|
|
201
|
+
// Where the files land: the placement the uploads' drop target resolved at
|
|
202
|
+
// the drop point (its window listener captures, so it ran first).
|
|
203
|
+
const placed = drop?.take() ?? null;
|
|
204
|
+
const at = accepted && !ownsEvent(root, event) ? placed : null;
|
|
206
205
|
if (accepted && isControlDrop(root, event))
|
|
207
206
|
return;
|
|
208
207
|
event.preventDefault();
|
|
@@ -219,15 +218,3 @@ export const preventUnsupportedDrop = (event, edytor) => {
|
|
|
219
218
|
if (!edytor.isComposing)
|
|
220
219
|
return insertFromDrop(edytor, root, event, at);
|
|
221
220
|
};
|
|
222
|
-
/**
|
|
223
|
-
* A drag leaving the host (to the page around it, or out of the window):
|
|
224
|
-
* a file drag's indicator goes. Moving between the host's own elements is
|
|
225
|
-
* no leave.
|
|
226
|
-
*/
|
|
227
|
-
export const onDragLeave = (edytor, event) => {
|
|
228
|
-
const root = event.currentTarget;
|
|
229
|
-
const to = event.relatedTarget;
|
|
230
|
-
if (to instanceof Node && root.contains(to))
|
|
231
|
-
return;
|
|
232
|
-
viewUploads(edytor)?.drop.end();
|
|
233
|
-
};
|
package/dist/events/onInput.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import type { Edytor } from '../edytor.svelte.js';
|
|
2
|
-
import type { Text } from '../text/text.svelte.js';
|
|
3
|
-
/**
|
|
4
|
-
* What the browser shows for `text`: its element's text nodes in order (WebKit's
|
|
5
|
-
* converted-space wrappers read as plain spaces), the empty filler and the
|
|
6
|
-
* trailing-newline marker stripped.
|
|
7
|
-
*/
|
|
8
|
-
export declare const readDomText: (text: Text) => string;
|
|
9
|
-
export declare const getCollapsedDomTextSelection: (edytor: Edytor) => {
|
|
10
|
-
text: Text;
|
|
11
|
-
offset: number;
|
|
12
|
-
} | null;
|
|
13
|
-
export declare const handleNativeLineBreakTextValue: (edytor: Edytor, text: Text, value: string) => Promise<boolean>;
|
|
14
2
|
/**
|
|
15
3
|
* An `input` event. Browser-made text is never adopted here: the mutation
|
|
16
4
|
* queue is the only adopter (a native line break there runs as its
|
package/dist/events/onInput.js
CHANGED
|
@@ -1,76 +1,10 @@
|
|
|
1
|
-
import { diffText } from '../utils/diffText.js';
|
|
2
|
-
import { getDomSelectionSnapshot } from '../selection/domSelection.js';
|
|
3
|
-
import { domOffsetIn } from '../selection/selection.utils.js';
|
|
4
1
|
import { isControlEvent } from './nativeInteractiveControl.js';
|
|
5
|
-
import { runOccurrence } from './onBeforeInput.js';
|
|
6
2
|
import { attemptOf, kindOf } from '../session/attempt.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* What the browser shows for `text`: its element's text nodes in order (WebKit's
|
|
10
|
-
* converted-space wrappers read as plain spaces), the empty filler and the
|
|
11
|
-
* trailing-newline marker stripped.
|
|
12
|
-
*/
|
|
13
|
-
export const readDomText = (text) => {
|
|
14
|
-
let value = '';
|
|
15
|
-
const node = text.node;
|
|
16
|
-
if (node) {
|
|
17
|
-
const walker = (node.ownerDocument ?? document).createTreeWalker(node, NodeFilter.SHOW_TEXT);
|
|
18
|
-
while (walker.nextNode()) {
|
|
19
|
-
const leaf = walker.currentNode;
|
|
20
|
-
value += leaf.parentElement?.closest('span.Apple-converted-space')
|
|
21
|
-
? leaf.data.replaceAll('\u00A0', ' ')
|
|
22
|
-
: leaf.data;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// An empty text's filler shares its node with what the browser typed, on either side.
|
|
26
|
-
if (text.isEmpty)
|
|
27
|
-
return value.replaceAll(ZERO_WIDTH_SPACE, '');
|
|
28
|
-
if (text.endsWithNewline && value.endsWith(ZERO_WIDTH_SPACE)) {
|
|
29
|
-
value = value.slice(0, -ZERO_WIDTH_SPACE.length);
|
|
30
|
-
}
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
export const getCollapsedDomTextSelection = (edytor) => {
|
|
34
|
-
const selection = getDomSelectionSnapshot(edytor.node);
|
|
35
|
-
if (!selection?.anchorNode || !selection.isCollapsed) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
if (!edytor.node?.contains(selection.anchorNode)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const text = edytor.selection.getTextOfNode(selection.anchorNode);
|
|
42
|
-
if (!text?.node) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
// No model rule here: the DOM caret is read BEFORE the reconcile writes
|
|
46
|
-
// the model, so a native insertion legitimately sits past `text.length`
|
|
47
|
-
// (`selectText` clamps the final write).
|
|
48
|
-
return { text, offset: domOffsetIn(text, selection.anchorNode, selection.anchorOffset) };
|
|
49
|
-
};
|
|
3
|
+
import { getCollapsedDomTextSelection } from '../surface/observer.svelte.js';
|
|
50
4
|
const getInputType = (event) => {
|
|
51
5
|
const inputType = event.inputType;
|
|
52
6
|
return typeof inputType === 'string' ? inputType : '';
|
|
53
7
|
};
|
|
54
|
-
const getNativeLineBreakInsertionIndexFromValue = (text, value) => {
|
|
55
|
-
const change = diffText(text.stringContent, value);
|
|
56
|
-
return change && !change.remove && /^[\r\n]+$/.test(change.insert) ? change.at : null;
|
|
57
|
-
};
|
|
58
|
-
export const handleNativeLineBreakTextValue = async (edytor, text, value) => {
|
|
59
|
-
if (!text.isInDocument)
|
|
60
|
-
return false;
|
|
61
|
-
const insertionIndex = getNativeLineBreakInsertionIndexFromValue(text, value);
|
|
62
|
-
if (insertionIndex === null) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
// The native line break is the key's occurrence: its intent, run by the model.
|
|
66
|
-
const inputType = edytor.attempts.confirm()?.inputType === 'insertLineBreak' || value.includes('\n')
|
|
67
|
-
? 'insertLineBreak'
|
|
68
|
-
: 'insertParagraph';
|
|
69
|
-
text.refreshFromModel();
|
|
70
|
-
edytor.selection.selectText(text, insertionIndex);
|
|
71
|
-
await runOccurrence(edytor, { inputType, cancelable: false });
|
|
72
|
-
return true;
|
|
73
|
-
};
|
|
74
8
|
/**
|
|
75
9
|
* An `input` no attempt expected (its engine sent no `beforeinput`): the
|
|
76
10
|
* browser changed the text under its caret — a browser-owned attempt of its own.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page leaves for good (installed by `Edytor.attach`): a `pagehide` the
|
|
3
|
+
* back/forward cache keeps nothing of. The view tells its document the
|
|
4
|
+
* session's history ended (`document.endHistory()`, `hist.release.end`): the
|
|
5
|
+
* history's rule releases what the session deleted. A page the cache keeps
|
|
6
|
+
* may come back with its history, and a lost connection fires nothing here:
|
|
7
|
+
* both keep it.
|
|
8
|
+
*
|
|
9
|
+
* The page's lifecycle is the sync layer's (`onPageLeave`, which the
|
|
10
|
+
* providers leave by too): the view subscribes to its `write` phase, run
|
|
11
|
+
* before the providers' teardown whatever order they subscribed in, so the
|
|
12
|
+
* release goes out on a socket or store that is still open.
|
|
13
|
+
*/
|
|
14
|
+
import { onPageLeave } from '../crdt/providers/room.js';
|
|
15
|
+
/** End the view's session when its page leaves for good; answers the teardown. */
|
|
16
|
+
export const attachPageHide = (edytor) => onPageLeave(() => edytor.document.endHistory(), 'write');
|