edytor 0.0.11 → 0.1.0-next.16
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 +77 -197
- package/dist/block/block.svelte.d.ts +156 -69
- package/dist/block/block.svelte.js +324 -355
- package/dist/block/block.utils.d.ts +191 -24
- package/dist/block/block.utils.js +327 -460
- package/dist/block/contentRange.d.ts +4 -0
- package/dist/block/contentRange.js +20 -0
- package/dist/block/inlineBlock.svelte.d.ts +26 -19
- package/dist/block/inlineBlock.svelte.js +91 -39
- package/dist/clipboard/clipboard.d.ts +4 -0
- package/dist/clipboard/clipboard.js +4 -0
- package/dist/clipboard/createClipboardFragment.d.ts +3 -0
- package/dist/clipboard/createClipboardFragment.js +103 -0
- package/dist/clipboard/fragmentData.d.ts +6 -0
- package/dist/clipboard/fragmentData.js +74 -0
- package/dist/clipboard/htmlFlow.d.ts +22 -0
- package/dist/clipboard/htmlFlow.js +167 -0
- package/dist/clipboard/insertClipboardFragment.d.ts +18 -0
- package/dist/clipboard/insertClipboardFragment.js +48 -0
- package/dist/clipboard/serializeClipboardFragment.d.ts +7 -0
- package/dist/clipboard/serializeClipboardFragment.js +53 -0
- package/dist/clipboard/textBlocks.d.ts +23 -0
- package/dist/clipboard/textBlocks.js +103 -0
- package/dist/clipboard/types.d.ts +20 -0
- package/dist/clipboard/types.js +2 -0
- package/dist/cloudflare/DocumentRoom.d.ts +586 -0
- package/dist/cloudflare/DocumentRoom.js +1706 -0
- package/dist/cloudflare/index.d.ts +8 -0
- package/dist/cloudflare/index.js +8 -0
- package/dist/cloudflare/routeDocumentSocket.d.ts +33 -0
- package/dist/cloudflare/routeDocumentSocket.js +51 -0
- package/dist/collaboration/RemoteSelections.svelte +94 -0
- package/dist/collaboration/RemoteSelections.svelte.d.ts +7 -0
- package/dist/collaboration/awarenessSelection.d.ts +127 -0
- package/dist/collaboration/awarenessSelection.js +199 -0
- package/dist/collaboration/documentSync.d.ts +20 -0
- package/dist/collaboration/documentSync.js +13 -0
- package/dist/collaboration/index.d.ts +3 -0
- package/dist/collaboration/index.js +3 -0
- package/dist/collaboration/providers.d.ts +13 -0
- package/dist/collaboration/providers.js +21 -0
- package/dist/collaboration/remoteSelection.d.ts +21 -0
- package/dist/collaboration/remoteSelection.js +159 -0
- package/dist/components/Block.svelte +223 -15
- package/dist/components/Block.svelte.d.ts +4 -2
- package/dist/components/Content.svelte +128 -32
- package/dist/components/Content.svelte.d.ts +6 -2
- package/dist/components/Edytor.svelte +308 -110
- package/dist/components/Edytor.svelte.d.ts +64 -20
- package/dist/components/InlineBlock.svelte +38 -7
- package/dist/components/InlineBlock.svelte.d.ts +5 -2
- package/dist/components/Mark.svelte +29 -13
- package/dist/components/Mark.svelte.d.ts +4 -4
- package/dist/components/Suggestion.svelte +48 -0
- package/dist/components/Suggestion.svelte.d.ts +7 -0
- package/dist/components/SuggestionRanges.svelte +58 -0
- package/dist/components/SuggestionRanges.svelte.d.ts +7 -0
- package/dist/components/Text.svelte +107 -14
- package/dist/components/Text.svelte.d.ts +8 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -2
- package/dist/crdt/admission.d.ts +141 -0
- package/dist/crdt/admission.js +147 -0
- package/dist/crdt/anchors.d.ts +47 -0
- package/dist/crdt/anchors.js +42 -0
- package/dist/crdt/attribution/attribution.d.ts +169 -0
- package/dist/crdt/attribution/attribution.js +136 -0
- package/dist/crdt/attribution/block.d.ts +200 -0
- package/dist/crdt/attribution/block.js +327 -0
- package/dist/crdt/attribution/index.d.ts +9 -0
- package/dist/crdt/attribution/index.js +9 -0
- package/dist/crdt/data.d.ts +81 -0
- package/dist/crdt/data.js +383 -0
- package/dist/crdt/document.d.ts +590 -0
- package/dist/crdt/document.js +1160 -0
- package/dist/crdt/edytor-doc.d.ts +752 -0
- package/dist/crdt/edytor-doc.js +2382 -0
- package/dist/crdt/engine-api.d.ts +153 -0
- package/dist/crdt/engine.d.ts +37 -0
- package/dist/crdt/engine.js +50 -0
- package/dist/crdt/flow.d.ts +104 -0
- package/dist/crdt/flow.js +229 -0
- package/dist/crdt/index.d.ts +630 -0
- package/dist/crdt/index.js +168 -0
- package/dist/crdt/migration/legacy-schema.d.ts +61 -0
- package/dist/crdt/migration/legacy-schema.js +149 -0
- package/dist/crdt/migration/migrate.d.ts +67 -0
- package/dist/crdt/migration/migrate.js +219 -0
- package/dist/crdt/nodes.d.ts +120 -0
- package/dist/crdt/nodes.js +56 -0
- package/dist/crdt/placement/model.d.ts +383 -0
- package/dist/crdt/placement/model.js +811 -0
- package/dist/crdt/placement/rank.d.ts +57 -0
- package/dist/crdt/placement/rank.js +209 -0
- package/dist/crdt/protocols/auth.d.ts +28 -0
- package/dist/crdt/protocols/auth.js +43 -0
- package/dist/crdt/protocols/awareness.d.ts +87 -0
- package/dist/crdt/protocols/awareness.js +271 -0
- package/dist/crdt/protocols/envelope.d.ts +75 -0
- package/dist/crdt/protocols/envelope.js +89 -0
- package/dist/crdt/protocols/observable.d.ts +19 -0
- package/dist/crdt/protocols/observable.js +26 -0
- package/dist/crdt/protocols/sync.d.ts +82 -0
- package/dist/crdt/protocols/sync.js +288 -0
- package/dist/crdt/providers/container.d.ts +23 -0
- package/dist/crdt/providers/container.js +64 -0
- package/dist/crdt/providers/index.d.ts +282 -0
- package/dist/crdt/providers/index.js +118 -0
- package/dist/crdt/providers/indexeddb.d.ts +196 -0
- package/dist/crdt/providers/indexeddb.js +332 -0
- package/dist/crdt/providers/room.d.ts +193 -0
- package/dist/crdt/providers/room.js +444 -0
- package/dist/crdt/providers/websocket.d.ts +223 -0
- package/dist/crdt/providers/websocket.js +601 -0
- package/dist/crdt/rand.d.ts +22 -0
- package/dist/crdt/rand.js +22 -0
- package/dist/crdt/rangeDelete.d.ts +85 -0
- package/dist/crdt/rangeDelete.js +126 -0
- package/dist/crdt/schema.d.ts +96 -0
- package/dist/crdt/schema.js +79 -0
- package/dist/crdt/semantics.d.ts +81 -0
- package/dist/crdt/semantics.js +57 -0
- package/dist/crdt/structs.d.ts +106 -0
- package/dist/crdt/structs.js +119 -0
- package/dist/crdt/text/deletes.d.ts +23 -0
- package/dist/crdt/text/deletes.js +608 -0
- package/dist/crdt/text/model.d.ts +280 -0
- package/dist/crdt/text/model.js +554 -0
- package/dist/crdt/text/runs.d.ts +212 -0
- package/dist/crdt/text/runs.js +1142 -0
- package/dist/crdt/vendor/yjs/API-NOTES.md +59 -0
- package/dist/crdt/vendor/yjs/LICENSE +23 -0
- package/dist/crdt/vendor/yjs/UPSTREAM.md +653 -0
- package/dist/crdt/vendor/yjs/dts/global.d.ts +52 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +25 -0
- package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +38 -0
- package/dist/crdt/vendor/yjs/dts/structs/GC.d.ts +25 -0
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +748 -0
- package/dist/crdt/vendor/yjs/dts/structs/Skip.d.ts +30 -0
- package/dist/crdt/vendor/yjs/dts/utils/BlockSet.d.ts +34 -0
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +198 -0
- package/dist/crdt/vendor/yjs/dts/utils/EventHandler.d.ts +17 -0
- package/dist/crdt/vendor/yjs/dts/utils/ID.d.ts +20 -0
- package/dist/crdt/vendor/yjs/dts/utils/RangeCursor.d.ts +198 -0
- package/dist/crdt/vendor/yjs/dts/utils/RelativePosition.d.ts +80 -0
- package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +61 -0
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +129 -0
- package/dist/crdt/vendor/yjs/dts/utils/UndoManager.d.ts +205 -0
- package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +170 -0
- package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +164 -0
- package/dist/crdt/vendor/yjs/dts/utils/YEvent.d.ts +93 -0
- package/dist/crdt/vendor/yjs/dts/utils/content-helper.d.ts +1 -0
- package/dist/crdt/vendor/yjs/dts/utils/encoding-helpers.d.ts +5 -0
- package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +26 -0
- package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +407 -0
- package/dist/crdt/vendor/yjs/dts/utils/isParentOf.d.ts +1 -0
- package/dist/crdt/vendor/yjs/dts/utils/meta.d.ts +25 -0
- package/dist/crdt/vendor/yjs/dts/utils/renderer-helpers.d.ts +98 -0
- package/dist/crdt/vendor/yjs/dts/utils/schemas.d.ts +2 -0
- package/dist/crdt/vendor/yjs/dts/utils/transaction-helpers.d.ts +15 -0
- package/dist/crdt/vendor/yjs/dts/utils/updates.d.ts +70 -0
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +655 -0
- package/dist/crdt/vendor/yjs/global.d.ts +52 -0
- package/dist/crdt/vendor/yjs/src/index.js +64 -0
- package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +64 -0
- package/dist/crdt/vendor/yjs/src/structs/GC.js +75 -0
- package/dist/crdt/vendor/yjs/src/structs/Item.js +1538 -0
- package/dist/crdt/vendor/yjs/src/structs/Skip.js +72 -0
- package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +291 -0
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +255 -0
- package/dist/crdt/vendor/yjs/src/utils/EventHandler.js +75 -0
- package/dist/crdt/vendor/yjs/src/utils/ID.js +59 -0
- package/dist/crdt/vendor/yjs/src/utils/RangeCursor.js +407 -0
- package/dist/crdt/vendor/yjs/src/utils/RelativePosition.js +301 -0
- package/dist/crdt/vendor/yjs/src/utils/StructStore.js +134 -0
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +458 -0
- package/dist/crdt/vendor/yjs/src/utils/UndoManager.js +554 -0
- package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +284 -0
- package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +323 -0
- package/dist/crdt/vendor/yjs/src/utils/YEvent.js +158 -0
- package/dist/crdt/vendor/yjs/src/utils/content-helper.js +0 -0
- package/dist/crdt/vendor/yjs/src/utils/encoding-helpers.js +110 -0
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +662 -0
- package/dist/crdt/vendor/yjs/src/utils/ids.js +1504 -0
- package/dist/crdt/vendor/yjs/src/utils/isParentOf.js +19 -0
- package/dist/crdt/vendor/yjs/src/utils/meta.js +74 -0
- package/dist/crdt/vendor/yjs/src/utils/renderer-helpers.js +186 -0
- package/dist/crdt/vendor/yjs/src/utils/schemas.js +3 -0
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +391 -0
- package/dist/crdt/vendor/yjs/src/utils/updates.js +264 -0
- package/dist/crdt/vendor/yjs/src/ynode.js +2897 -0
- package/dist/dnd/pragmatic.d.ts +22 -0
- package/dist/dnd/pragmatic.js +26 -0
- package/dist/edytor.svelte.d.ts +323 -54
- package/dist/edytor.svelte.js +771 -197
- package/dist/edytor.utils.d.ts +49 -2
- package/dist/edytor.utils.js +65 -76
- package/dist/events/beforeInputCommands.d.ts +21 -0
- package/dist/events/beforeInputCommands.js +328 -0
- package/dist/events/beforeInputDeleteCommands.d.ts +3 -0
- package/dist/events/beforeInputDeleteCommands.js +245 -0
- package/dist/events/dataTransferPayload.d.ts +6 -0
- package/dist/events/dataTransferPayload.js +9 -0
- package/dist/events/domTextOffset.d.ts +12 -0
- package/dist/events/domTextOffset.js +52 -0
- package/dist/events/events.utils.d.ts +3 -0
- package/dist/events/events.utils.js +13 -0
- package/dist/events/nativeInteractiveControl.d.ts +31 -0
- package/dist/events/nativeInteractiveControl.js +98 -0
- package/dist/events/onBeforeInput.d.ts +10 -1
- package/dist/events/onBeforeInput.js +449 -330
- package/dist/events/onCopy.d.ts +7 -0
- package/dist/events/onCopy.js +30 -0
- package/dist/events/onCut.d.ts +8 -0
- package/dist/events/onCut.js +13 -0
- package/dist/events/onDrop.d.ts +16 -0
- package/dist/events/onDrop.js +158 -0
- package/dist/events/onFocus.d.ts +4 -0
- package/dist/events/onFocus.js +166 -0
- package/dist/events/onInput.d.ts +20 -0
- package/dist/events/onInput.js +249 -0
- package/dist/events/onKeyDown.js +191 -11
- package/dist/events/onPaste.d.ts +3 -0
- package/dist/events/onPaste.js +108 -0
- package/dist/events/wordBoundary.d.ts +2 -0
- package/dist/events/wordBoundary.js +58 -0
- package/dist/index.d.ts +38 -1
- package/dist/index.js +36 -1
- package/dist/kinds.d.ts +100 -0
- package/dist/kinds.js +198 -0
- package/dist/plugins/arrowMove/arrowMove.d.ts +1 -1
- package/dist/plugins/arrowMove/arrowMove.js +30 -65
- package/dist/plugins/blockHandles/BlockHandle.svelte +152 -0
- package/dist/plugins/blockHandles/BlockHandle.svelte.d.ts +12 -0
- package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +208 -0
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +823 -0
- package/dist/plugins/blockHandles/BlockHandles.svelte +151 -0
- package/dist/plugins/blockHandles/BlockHandles.svelte.d.ts +20 -0
- package/dist/plugins/blockHandles/autoScroll.d.ts +8 -0
- package/dist/plugins/blockHandles/autoScroll.js +25 -0
- package/dist/plugins/blockHandles/blockHandlesPlugin.d.ts +37 -0
- package/dist/plugins/blockHandles/blockHandlesPlugin.js +100 -0
- package/dist/plugins/blockHandles/dragPreview.d.ts +33 -0
- package/dist/plugins/blockHandles/dragPreview.js +228 -0
- package/dist/plugins/blockMenu/BlockMenu.svelte +301 -0
- package/dist/plugins/blockMenu/BlockMenu.svelte.d.ts +9 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +102 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.js +245 -0
- package/dist/plugins/blockMenu/blockMenuPlugin.d.ts +11 -0
- package/dist/plugins/blockMenu/blockMenuPlugin.js +89 -0
- package/dist/plugins/code/CodePlugin.svelte +210 -163
- package/dist/plugins/code/CodePlugin.svelte.d.ts +1 -3
- package/dist/plugins/code/code.css +92 -0
- package/dist/plugins/icons.d.ts +2 -0
- package/dist/plugins/icons.js +31 -0
- package/dist/plugins/image/ImageEmpty.svelte +69 -0
- package/dist/plugins/image/ImageEmpty.svelte.d.ts +8 -0
- package/dist/plugins/image/ImagePlugin.svelte +74 -12
- package/dist/plugins/image/ImagePlugin.svelte.d.ts +15 -0
- package/dist/plugins/image/image.d.ts +2 -0
- package/dist/plugins/image/image.js +7 -0
- package/dist/plugins/index.d.ts +14 -1
- package/dist/plugins/index.js +10 -1
- package/dist/plugins/keepInView.d.ts +4 -0
- package/dist/plugins/keepInView.js +6 -0
- package/dist/plugins/markdownShortcuts.d.ts +3 -0
- package/dist/plugins/markdownShortcuts.js +104 -0
- package/dist/plugins/mention/MentionPlugin.svelte +28 -31
- package/dist/plugins/richtext/RichTextPlugin.svelte +411 -200
- package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +8 -7
- package/dist/plugins/richtext/richTextOperations.d.ts +53 -0
- package/dist/plugins/richtext/richTextOperations.js +200 -0
- package/dist/plugins/slashMenu/SlashMenu.svelte +297 -0
- package/dist/plugins/slashMenu/SlashMenu.svelte.d.ts +11 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +56 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.js +275 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.d.ts +25 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.js +105 -0
- package/dist/plugins/suggestions/SuggestionBars.svelte +142 -0
- package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +10 -0
- package/dist/plugins/suggestions/suggestionsPlugin.d.ts +28 -0
- package/dist/plugins/suggestions/suggestionsPlugin.js +53 -0
- package/dist/plugins/toolbar/Toolbar.svelte +341 -0
- package/dist/plugins/toolbar/Toolbar.svelte.d.ts +9 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +85 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.js +150 -0
- package/dist/plugins/toolbar/toolbarPlugin.d.ts +16 -0
- package/dist/plugins/toolbar/toolbarPlugin.js +40 -0
- package/dist/plugins.d.ts +249 -40
- package/dist/plugins.js +11 -5
- package/dist/selection/domSelection.d.ts +29 -0
- package/dist/selection/domSelection.js +230 -0
- package/dist/selection/replaceSelection.d.ts +143 -0
- package/dist/selection/replaceSelection.js +316 -0
- package/dist/selection/selection.svelte.d.ts +275 -37
- package/dist/selection/selection.svelte.js +1162 -331
- package/dist/selection/selection.utils.d.ts +35 -4
- package/dist/selection/selection.utils.js +309 -100
- package/dist/selection/visibility.d.ts +88 -0
- package/dist/selection/visibility.js +140 -0
- package/dist/session/attempt.d.ts +190 -0
- package/dist/session/attempt.js +188 -0
- package/dist/session/bindings.d.ts +16 -0
- package/dist/session/bindings.js +262 -0
- package/dist/session/commands.d.ts +158 -0
- package/dist/session/commands.js +601 -0
- package/dist/session/composition.svelte.d.ts +114 -0
- package/dist/session/composition.svelte.js +489 -0
- package/dist/session/editing/text.d.ts +33 -0
- package/dist/session/editing/text.js +36 -0
- package/dist/session/handles.d.ts +63 -0
- package/dist/session/handles.js +123 -0
- package/dist/session/history.d.ts +49 -0
- package/dist/session/history.js +131 -0
- package/dist/session/keymap.d.ts +42 -0
- package/dist/session/keymap.js +144 -0
- package/dist/session/moves.d.ts +32 -0
- package/dist/session/moves.js +116 -0
- package/dist/session/navigation.d.ts +51 -0
- package/dist/session/navigation.js +312 -0
- package/dist/session/props.d.ts +28 -0
- package/dist/session/props.js +162 -0
- package/dist/session/selection.d.ts +126 -0
- package/dist/session/selection.js +227 -0
- package/dist/session/suggestions.svelte.d.ts +125 -0
- package/dist/session/suggestions.svelte.js +329 -0
- package/dist/session/virtual.d.ts +33 -0
- package/dist/session/virtual.js +182 -0
- package/dist/surface/attributes.d.ts +36 -0
- package/dist/surface/attributes.js +143 -0
- package/dist/surface/cells.d.ts +103 -0
- package/dist/surface/cells.js +215 -0
- package/dist/surface/observer.svelte.d.ts +70 -0
- package/dist/surface/observer.svelte.js +969 -0
- package/dist/surface/overlay.d.ts +33 -0
- package/dist/surface/overlay.js +91 -0
- package/dist/surface/pin.svelte.d.ts +56 -0
- package/dist/surface/pin.svelte.js +108 -0
- package/dist/surface/projector.svelte.d.ts +69 -0
- package/dist/surface/projector.svelte.js +486 -0
- package/dist/text/deltas.d.ts +14 -3
- package/dist/text/deltas.js +27 -90
- package/dist/text/text.svelte.d.ts +43 -31
- package/dist/text/text.svelte.js +88 -69
- package/dist/text/text.utils.d.ts +7 -2
- package/dist/text/text.utils.js +121 -97
- package/dist/themes/notion.css +473 -0
- package/dist/utils/diffText.d.ts +15 -0
- package/dist/utils/diffText.js +26 -0
- package/dist/utils/json.d.ts +90 -3
- package/dist/utils/json.js +369 -2
- package/dist/utils.d.ts +3 -1
- package/dist/utils.js +2 -0
- package/package.json +112 -50
- package/dist/block/content.svelte.d.ts +0 -14
- package/dist/block/content.svelte.js +0 -40
- package/dist/components/ReadonlyEditor.svelte +0 -46
- package/dist/components/ReadonlyEditor.svelte.d.ts +0 -4
- package/dist/components/readonlyElements.svelte.d.ts +0 -82
- package/dist/components/readonlyElements.svelte.js +0 -144
- package/dist/dnd.svelte.d.ts +0 -17
- package/dist/dnd.svelte.js +0 -125
- package/dist/hotkeys.d.ts +0 -27
- package/dist/hotkeys.js +0 -282
- package/dist/localProvider.d.ts +0 -82
- package/dist/localProvider.js +0 -267
- package/dist/plugins/code/prism.css +0 -141
- package/dist/utils/jsx.d.ts +0 -25
- package/dist/utils/jsx.js +0 -66
- package/dist/utils/serialize.js +0 -1
- /package/dist/{utils/serialize.d.ts → crdt/engine-api.js} +0 -0
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* View-side command adapter for block operations (U2 delegation contract).
|
|
3
|
+
*
|
|
4
|
+
* These functions are the `BlockOperations` layer bound onto `Block` via
|
|
5
|
+
* `batch()`, which dispatches each call as a command (admission, plugin
|
|
6
|
+
* interception, one transaction: `session/commands.ts`). The functions own
|
|
7
|
+
* path/offset resolution (target paths → parent blocks, a text's `segStart`,
|
|
8
|
+
* sibling lookup for `nestBlock`), the plan of an operation
|
|
9
|
+
* that is one document op (`prepare*`) and its normalization requests.
|
|
10
|
+
*
|
|
11
|
+
* OPERATIONS READ AND WRITE ONLY THE DOCUMENT (R3): `Block`/`Text` are id-only
|
|
12
|
+
* handles whose getters read the index (R4), so what a caller needs after the
|
|
13
|
+
* write (the new block, the text after an inserted atom, the caret a range op
|
|
14
|
+
* decided) is the op's document result as a handle (`batch`'s `resolve`) —
|
|
15
|
+
* inside an outer transaction too.
|
|
16
|
+
*
|
|
17
|
+
* STRUCTURAL PERMISSION IS DOCUMENT-OWNED: every op delegates to
|
|
18
|
+
* `block.model.*` (the facade through `DocBlock`) and treats a `refused` result
|
|
19
|
+
* as "refused" — no view-side re-checks of the rules the document already
|
|
20
|
+
* enforces (island sealing, void/island destinations, own-subtree moves,
|
|
21
|
+
* merges across island boundaries; see `edytor-doc.ts` `canPlace` and
|
|
22
|
+
* `canMerge`, R5). Removing a view-side semantic guard must never
|
|
23
|
+
* change document behavior — if a rule matters here it belongs in the
|
|
24
|
+
* facade, not in this file.
|
|
25
|
+
*
|
|
26
|
+
* Content preparation produces `BlockSpec`/`ContentItem` DIRECTLY from
|
|
27
|
+
* JSON (`jsonBlockToSpec`/`jsonContentToItems` in `utils/json.ts`): specs are
|
|
28
|
+
* data (K5: `new Block({block})` is gone). The live-content invariant
|
|
29
|
+
* (text-first/text-last, no adjacent same-kind parts) is derived by the
|
|
30
|
+
* document's projection on read, so stored content needs no
|
|
31
|
+
* pre-normalization.
|
|
32
|
+
*/
|
|
33
|
+
import type { Block } from './block.svelte.js';
|
|
34
|
+
import type { Text } from '../text/text.svelte.js';
|
|
35
|
+
import type { Flow, FlowTarget } from '../crdt/flow.js';
|
|
36
|
+
import type { Plan, Prepared } from '../crdt/edytor-doc.js';
|
|
37
|
+
import type { DataPatch } from '../crdt/data.js';
|
|
38
|
+
import type { ResolvedAt } from '../session/suggestions.svelte.js';
|
|
39
|
+
import { type JSONBlock, type JSONInlineBlock, type JSONText } from '../utils/json.js';
|
|
4
40
|
import { InlineBlock } from './inlineBlock.svelte.js';
|
|
5
41
|
export type BlockOperations = {
|
|
6
42
|
removeInlineBlock: {
|
|
7
43
|
index: number;
|
|
8
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Patch the block's `data` (with `atom`, that inline atom's; on the root,
|
|
47
|
+
* the document's), in order: each patch sets the value at its path, or
|
|
48
|
+
* deletes it when it has no `value`. `block.data`'s proxy, `setData` and
|
|
49
|
+
* `atom.setData` issue it.
|
|
50
|
+
*/
|
|
51
|
+
patchData: {
|
|
52
|
+
ops: DataPatch[];
|
|
53
|
+
atom?: string;
|
|
54
|
+
};
|
|
9
55
|
addChildBlock: {
|
|
10
56
|
block: JSONBlock;
|
|
11
57
|
index: number;
|
|
@@ -24,15 +70,18 @@ export type BlockOperations = {
|
|
|
24
70
|
index: number;
|
|
25
71
|
text: Text;
|
|
26
72
|
};
|
|
73
|
+
/** A copy of the block and its subtree right after it, under fresh ids. */
|
|
74
|
+
duplicateBlock: {};
|
|
75
|
+
/** The children take the block's slot unless `keepChildren: false` (the whole subtree). */
|
|
27
76
|
removeBlock: {
|
|
28
|
-
keepChildren
|
|
77
|
+
keepChildren?: boolean;
|
|
29
78
|
};
|
|
30
79
|
unNestBlock: {};
|
|
31
80
|
mergeBlockBackward: {};
|
|
32
81
|
mergeBlockForward: {};
|
|
33
82
|
nestBlock: {};
|
|
34
83
|
setBlock: {
|
|
35
|
-
value: JSONBlock
|
|
84
|
+
value: Partial<JSONBlock>;
|
|
36
85
|
};
|
|
37
86
|
addInlineBlock: {
|
|
38
87
|
index: number;
|
|
@@ -42,41 +91,159 @@ export type BlockOperations = {
|
|
|
42
91
|
moveBlock: {
|
|
43
92
|
path: number[];
|
|
44
93
|
};
|
|
94
|
+
moveBlocks: {
|
|
95
|
+
blocks: Block[];
|
|
96
|
+
path: number[];
|
|
97
|
+
};
|
|
45
98
|
pushContentIntoBlock: {
|
|
46
99
|
value: (Text | InlineBlock)[];
|
|
47
100
|
};
|
|
48
|
-
deleteContentForward: {
|
|
49
|
-
text: Text;
|
|
50
|
-
};
|
|
51
101
|
normalizeContent: {};
|
|
102
|
+
normalizeChildren: {};
|
|
103
|
+
/** @deprecated `edytor.suggestions.add({ end: block.id }, …)`. */
|
|
52
104
|
suggestText: {
|
|
53
105
|
value: (JSONText | JSONInlineBlock)[] | string | null;
|
|
54
106
|
};
|
|
107
|
+
/** @deprecated `suggestion.accept()`; the command hooks see is `acceptSuggestion`. */
|
|
55
108
|
acceptSuggestedText: {};
|
|
109
|
+
/** A suggestion placed in the document (`edytor.suggestions`, `suggestion.accept()`). */
|
|
110
|
+
acceptSuggestion: {
|
|
111
|
+
suggestion: {
|
|
112
|
+
id: string;
|
|
113
|
+
at: ResolvedAt;
|
|
114
|
+
content: readonly JSONBlock[];
|
|
115
|
+
};
|
|
116
|
+
};
|
|
56
117
|
deleteContentAtRange: {
|
|
57
118
|
start: [number, number];
|
|
58
119
|
end: [number, number];
|
|
59
120
|
};
|
|
60
|
-
deleteContentWithinSelection: {
|
|
121
|
+
deleteContentWithinSelection: {
|
|
122
|
+
replace?: boolean;
|
|
123
|
+
};
|
|
124
|
+
insertFlow: {
|
|
125
|
+
flow: Flow;
|
|
126
|
+
target: FlowTarget;
|
|
127
|
+
};
|
|
128
|
+
deleteBlocks: {
|
|
129
|
+
blocks: Block[];
|
|
130
|
+
};
|
|
131
|
+
/** A divider at the caret: its steps are the conversion, insertion or split it plans. */
|
|
132
|
+
insertDivider: {};
|
|
61
133
|
};
|
|
62
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Bind an operation onto its wrapper: every call is dispatched as a command
|
|
136
|
+
* (`session/commands.ts`): admission, hooks before any write (on the command
|
|
137
|
+
* and, when `prepare` answers one document plan, on each planned step), one
|
|
138
|
+
* transaction, normalization, the result. `func` receives the prepared plan
|
|
139
|
+
* and answers the op's document result; `resolve` turns it into wrappers
|
|
140
|
+
* after the commit patched them.
|
|
141
|
+
*/
|
|
142
|
+
export declare function batch<T extends (...args: any[]) => any, O extends keyof BlockOperations, R = ReturnType<T>>(operation: O, func: T, prepare?: (payload: BlockOperations[O]) => Prepared, resolve?: (this: any, out: ReturnType<T> | undefined, payload: Parameters<T>[0]) => R): (...args: Parameters<T>) => R;
|
|
143
|
+
/**
|
|
144
|
+
* The handle of block `id` (null: refused at preparation, or gone; undefined:
|
|
145
|
+
* the command did not run). Inside an outer transaction too: the index shows
|
|
146
|
+
* the block that transaction created.
|
|
147
|
+
*/
|
|
148
|
+
export declare function blockOf(this: Block, id: string | null | undefined): Block | null | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Dispatch `operation` on `block` as the one plan `prepare` answers (a
|
|
151
|
+
* composed command: hooks see it and each planned step, one transaction).
|
|
152
|
+
* `then` runs in that transaction once the plan applied, with the payload
|
|
153
|
+
* hooks left. Answers the applied plan, or null when refused.
|
|
154
|
+
*/
|
|
155
|
+
export declare const dispatchPlan: <O extends keyof BlockOperations>(block: Block, operation: O, payload: BlockOperations[O], prepare: (payload: BlockOperations[O]) => Prepared, touched?: (Block | null | undefined)[], then?: (payload: BlockOperations[O]) => void) => Plan | null;
|
|
156
|
+
/** One child at `index` (a default-kind block without `block`); see {@link addChildBlocks}. */
|
|
63
157
|
export declare function addChildBlock(this: Block, { block, index }: BlockOperations['addChildBlock']): Block;
|
|
158
|
+
/** Children at `index`, clamped to the child list (at its end by default); ids kept or minted. */
|
|
64
159
|
export declare function addChildBlocks(this: Block, { blocks, index }: BlockOperations['addChildBlocks']): Block[];
|
|
65
|
-
export declare function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
export declare function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export declare function
|
|
72
|
-
export declare function
|
|
73
|
-
export declare function
|
|
74
|
-
export declare function
|
|
160
|
+
export declare function prepareInsertAfter(this: Block, { block }: {
|
|
161
|
+
block: JSONBlock;
|
|
162
|
+
}): Prepared;
|
|
163
|
+
export declare function prepareInsertBefore(this: Block, { block }: {
|
|
164
|
+
block: JSONBlock;
|
|
165
|
+
}): Prepared;
|
|
166
|
+
export declare function insertBlockAfter(this: Block, payload: BlockOperations['insertBlockAfter'], plan?: Prepared): string | null;
|
|
167
|
+
export declare function insertBlockBefore(this: Block, payload: BlockOperations['insertBlockBefore'], plan?: Prepared): string | null;
|
|
168
|
+
export declare function prepareDuplicate(this: Block): Prepared;
|
|
169
|
+
export declare function duplicateBlock(this: Block, _?: BlockOperations['duplicateBlock'], plan?: Prepared): string | null;
|
|
170
|
+
export declare function prepareSplit(this: Block, { index, text }: BlockOperations['splitBlock']): Prepared;
|
|
171
|
+
/**
|
|
172
|
+
* A split whose children stay with the block (a container's header): the
|
|
173
|
+
* tail, of `tail`'s kind, becomes the block's first child (`child`) or its
|
|
174
|
+
* next sibling. One plan: the document's split step, placed here, without
|
|
175
|
+
* the move that gives the tail the children.
|
|
176
|
+
*/
|
|
177
|
+
export declare function prepareSplitKeepingChildren(this: Block, { index, text }: BlockOperations['splitBlock'], tail: {
|
|
178
|
+
type: string;
|
|
179
|
+
data?: Record<string, unknown>;
|
|
180
|
+
}, child: boolean): Prepared;
|
|
181
|
+
export declare function splitBlock(this: Block, payload: BlockOperations['splitBlock'], plan?: Prepared): string | null;
|
|
182
|
+
export declare function prepareRemove(this: Block, { keepChildren }?: {
|
|
183
|
+
keepChildren?: boolean;
|
|
184
|
+
}): Prepared;
|
|
185
|
+
export declare function removeBlock(this: Block, payload?: BlockOperations['removeBlock'], plan?: Prepared): void;
|
|
186
|
+
export declare function prepareMergeBackward(this: Block): Prepared;
|
|
187
|
+
export declare function prepareMergeForward(this: Block): Prepared;
|
|
188
|
+
export declare function mergeBlockBackward(this: Block, _?: BlockOperations['mergeBlockBackward'], plan?: Prepared): string | null;
|
|
189
|
+
export declare function mergeBlockForward(this: Block, _?: BlockOperations['mergeBlockForward'], plan?: Prepared): string | null;
|
|
190
|
+
export declare function prepareMove(this: Block, { path }: BlockOperations['moveBlock']): Prepared;
|
|
191
|
+
export declare function moveBlock(this: Block, payload: BlockOperations['moveBlock'], plan?: Prepared): Block | null;
|
|
192
|
+
/**
|
|
193
|
+
* Grouped move — the operation-layer counterpart of `moveBlock` for
|
|
194
|
+
* drags/multi-moves (D5). `path` is the same view-tree address shape:
|
|
195
|
+
* the prefix resolves the destination PARENT block, the last element is
|
|
196
|
+
* the FINAL index — already discounted for the moved members by the
|
|
197
|
+
* caller (the `facade.moveBlocks` contract, which counts the
|
|
198
|
+
* destination's children with the moved members excluded). Structural
|
|
199
|
+
* permission stays in the facade.
|
|
200
|
+
*/
|
|
201
|
+
export declare function prepareMoves(this: Block, { blocks, path }: BlockOperations['moveBlocks']): Prepared;
|
|
202
|
+
export declare function moveBlocks(this: Block, payload: BlockOperations['moveBlocks'], plan?: Prepared): Block[];
|
|
203
|
+
/**
|
|
204
|
+
* The facade owns the refusal rules (`unNestBlock`: top-level blocks,
|
|
205
|
+
* island-sealed blocks and sealed destinations).
|
|
206
|
+
*/
|
|
207
|
+
export declare function prepareUnNest(this: Block): Prepared;
|
|
208
|
+
export declare function unNestBlock(this: Block, _?: BlockOperations['unNestBlock'], plan?: Prepared): Block | null;
|
|
209
|
+
/**
|
|
210
|
+
* Admission resolves the nest target — the previous sibling — and the
|
|
211
|
+
* facade owns permission: `nestBlock` refuses void/island/inside-island
|
|
212
|
+
* targets and island-sealed sources (`canPlace`).
|
|
213
|
+
*/
|
|
214
|
+
export declare function prepareNest(this: Block): Prepared;
|
|
215
|
+
export declare function nestBlock(this: Block, _?: BlockOperations['nestBlock'], plan?: Prepared): Block | null;
|
|
216
|
+
export declare function prepareSet(this: Block, { value }: BlockOperations['setBlock']): Prepared;
|
|
217
|
+
export declare function setBlock(this: Block, payload: BlockOperations['setBlock'], plan?: Prepared): void;
|
|
75
218
|
export declare function pushContentIntoBlock(this: Block, { value }: BlockOperations['pushContentIntoBlock']): void;
|
|
76
|
-
export declare function
|
|
77
|
-
|
|
78
|
-
|
|
219
|
+
export declare function prepareRemoveInline(this: Block, { index }: {
|
|
220
|
+
index: number;
|
|
221
|
+
}): Prepared;
|
|
222
|
+
export declare function removeInlineBlock(this: Block, payload: BlockOperations['removeInlineBlock'], plan?: Prepared): void;
|
|
223
|
+
export declare function preparePatch(this: Block, { ops, atom }: BlockOperations['patchData']): Prepared;
|
|
224
|
+
export declare function patchData(this: Block, payload: BlockOperations['patchData'], plan?: Prepared): void;
|
|
225
|
+
/**
|
|
226
|
+
* Insert an inline atom at `index` of `text`. Answers the atom's id; the
|
|
227
|
+
* batched operation resolves it to the text after the atom once committed
|
|
228
|
+
* ({@link textAfterAtom}), where the caret's pending marks follow.
|
|
229
|
+
*/
|
|
230
|
+
export declare function addInlineBlock(this: Block, { index, block, text }: BlockOperations['addInlineBlock']): string;
|
|
231
|
+
/** The text after atom `atom` of this block; the caret's pending marks follow it there (L4). */
|
|
232
|
+
export declare function textAfterAtom(this: Block, atom: string | undefined): Text | null | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Normalization runs at the end of the command's transaction
|
|
235
|
+
* (`Dispatcher.drain`): a normalizer reads handles over the index; when a
|
|
236
|
+
* plugin hook answers work, the work runs in the same transaction and the
|
|
237
|
+
* block is requested again (bounded by the dispatcher's pass limit, D25).
|
|
238
|
+
*/
|
|
79
239
|
export declare function normalizeContent(this: Block): void;
|
|
240
|
+
export declare function normalizeChildren(this: Block): void;
|
|
241
|
+
/** @deprecated A thin wrapper over an `{ end: block.id }` suggestion (`edytor.suggestions`). */
|
|
80
242
|
export declare function suggestText(this: Block, { value }: BlockOperations['suggestText']): void;
|
|
243
|
+
/** @deprecated Accepts this block's latest `{ end }` suggestion (`suggestion.accept()`). */
|
|
81
244
|
export declare function acceptSuggestedText(this: Block): void;
|
|
82
|
-
export declare function
|
|
245
|
+
export declare function prepareDeleteRange(this: Block, { start: [startIndex, startOffset], end: [endIndex, endOffset] }: {
|
|
246
|
+
start: number[];
|
|
247
|
+
end: number[];
|
|
248
|
+
}): Prepared;
|
|
249
|
+
export declare function deleteContentAtRange(this: Block, payload: BlockOperations['deleteContentAtRange'], plan?: Prepared): void;
|