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/crdt/doc/layout.js
CHANGED
|
@@ -8,7 +8,7 @@ import { sanitizeSpec } from '../../utils/json.js';
|
|
|
8
8
|
import { ref } from './plan.js';
|
|
9
9
|
/** The layout ops of one facade, prepared. */
|
|
10
10
|
export const layoutOps = (c) => {
|
|
11
|
-
const { roles, view, blockTypeOf, childrenIds, positionOf, ancestorsOf, isIsland, isLines, insideIsland, isLayout, isLayoutItem, holdsLayout, insideItem, live, canPlace, isContainer, fits, fitsIn, REFUSED, plan,
|
|
11
|
+
const { roles, view, blockTypeOf, childrenIds, positionOf, ancestorsOf, isIsland, isLines, insideIsland, isLayout, isLayoutItem, holdsLayout, insideItem, live, canPlace, isContainer, fits, fitsIn, REFUSED, plan, moveTo, landing, emptied } = c;
|
|
12
12
|
/** The layout kind a new layout takes: `kind` when it is one, else the only one the roles declare. */
|
|
13
13
|
const layoutKind = (kind) => {
|
|
14
14
|
if (kind !== undefined)
|
|
@@ -62,8 +62,8 @@ export const layoutOps = (c) => {
|
|
|
62
62
|
* an item, a layout or a block holding one, a block that does not
|
|
63
63
|
* fit an item, a block or a layout inside an island, and, wrapping,
|
|
64
64
|
* when there is no layout kind. The sources are cleaned in the same
|
|
65
|
-
* plan (`emptying`, `dissolving`); plain
|
|
66
|
-
*
|
|
65
|
+
* plan (`emptying`, `dissolving`); a plain move. `ids`: the moved
|
|
66
|
+
* blocks.
|
|
67
67
|
*/
|
|
68
68
|
const placeBeside = (ids, target, side, kind) => {
|
|
69
69
|
const moved = ids.map(ref);
|
|
@@ -98,25 +98,20 @@ export const layoutOps = (c) => {
|
|
|
98
98
|
if (layout !== null && (isIsland(layout) || insideIsland(layout, v)))
|
|
99
99
|
return REFUSED;
|
|
100
100
|
const fresh = spec(item);
|
|
101
|
-
const into = (parent) => moveTo(moved, parent, 0
|
|
101
|
+
const into = (parent) => moveTo(moved, parent, 0);
|
|
102
102
|
let writes;
|
|
103
103
|
let kept;
|
|
104
104
|
if (layout !== null) {
|
|
105
|
-
|
|
106
|
-
writes = [
|
|
107
|
-
{ op: 'insertBlocks', parent: layout, index, specs: [fresh], ranks },
|
|
108
|
-
...into(fresh.id)
|
|
109
|
-
];
|
|
105
|
+
writes = [{ op: 'insertBlocks', parent: layout, index, specs: [fresh] }, ...into(fresh.id)];
|
|
110
106
|
kept = new Set([fresh.id, ...landing(layout)]);
|
|
111
107
|
}
|
|
112
108
|
else {
|
|
113
109
|
const pos = positionOf(at);
|
|
114
110
|
const host = spec(item);
|
|
115
111
|
const wrapper = { ...spec(wrap), children: right ? [host, fresh] : [fresh, host] };
|
|
116
|
-
const ranks = ranksFor(pos.parent, pos.index, 1);
|
|
117
112
|
writes = [
|
|
118
|
-
{ op: 'insertBlocks', parent: pos.parent, index: pos.index, specs: [wrapper]
|
|
119
|
-
...moveTo([at], host.id, 0
|
|
113
|
+
{ op: 'insertBlocks', parent: pos.parent, index: pos.index, specs: [wrapper] },
|
|
114
|
+
...moveTo([at], host.id, 0),
|
|
120
115
|
...into(fresh.id)
|
|
121
116
|
];
|
|
122
117
|
kept = new Set([wrapper.id, host.id, fresh.id, ...landing(pos.parent)]);
|
|
@@ -134,8 +129,8 @@ export const layoutOps = (c) => {
|
|
|
134
129
|
* fewer items than blocks, blocks of different parents, an item, a
|
|
135
130
|
* layout or a block holding one, where the layout does not fit
|
|
136
131
|
* (`fits`: in a list, a code block) or lands inside an item or an
|
|
137
|
-
* island, and for a block that does not fit an item.
|
|
138
|
-
*
|
|
132
|
+
* island, and for a block that does not fit an item. A plain move.
|
|
133
|
+
* `ids`: the new layout.
|
|
139
134
|
*/
|
|
140
135
|
const wrapInLayout = (ids, kind, columns = ids.length) => {
|
|
141
136
|
const blocks = ids.map(ref);
|
|
@@ -165,14 +160,8 @@ export const layoutOps = (c) => {
|
|
|
165
160
|
const wrapper = { ...spec(wrap), children: items };
|
|
166
161
|
const at = positionOf(ordered[0]).index;
|
|
167
162
|
const writes = [
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
parent,
|
|
171
|
-
index: at,
|
|
172
|
-
specs: [wrapper],
|
|
173
|
-
ranks: ranksFor(parent, at, 1)
|
|
174
|
-
},
|
|
175
|
-
...ordered.flatMap((id, i) => moveTo([id], items[i].id, 0, ranksFor(items[i].id, 0, 1)))
|
|
163
|
+
{ op: 'insertBlocks', parent, index: at, specs: [wrapper] },
|
|
164
|
+
...ordered.flatMap((id, i) => moveTo([id], items[i].id, 0))
|
|
176
165
|
];
|
|
177
166
|
const kept = new Set([
|
|
178
167
|
wrapper.id,
|
package/dist/crdt/doc/meta.js
CHANGED
|
@@ -7,11 +7,11 @@ import { randOf } from '../rand.js';
|
|
|
7
7
|
import { TYPE } from '../schema.js';
|
|
8
8
|
import { asBlockSpec, asContentItem, sanitizeSpec, sanitizeWireJson } from '../../utils/json.js';
|
|
9
9
|
import { patchWrites, leafKey, isObject } from '../data.js';
|
|
10
|
-
import { collides
|
|
10
|
+
import { collides } from '../placement/model.js';
|
|
11
11
|
import { ref, refused, sanitizeItem } from './plan.js';
|
|
12
12
|
/** The meta ops of one facade, prepared. */
|
|
13
13
|
export const metaOps = (c) => {
|
|
14
|
-
const { doc, roles, roleOf, dataNode, view, blockTypeOf, blockDataOf, childrenIds, positionOf, is, isVoid, displayLength, live, contentTarget, REFUSED, plan,
|
|
14
|
+
const { doc, roles, roleOf, dataNode, view, blockTypeOf, blockDataOf, childrenIds, positionOf, is, isVoid, displayLength, live, contentTarget, REFUSED, plan, attr, leavingIsland, settle, remove, atomOf, writeContent } = c;
|
|
15
15
|
/**
|
|
16
16
|
* The data step of `patches` (sanitized) on a block, one of its atoms or
|
|
17
17
|
* the document (`crdt/data.ts`): none when it changes nothing, `null`
|
|
@@ -23,12 +23,12 @@ export const metaOps = (c) => {
|
|
|
23
23
|
// A block kind's atomic paths are written as one leaf each (`data.atomic`).
|
|
24
24
|
const type = inlineId === undefined && id !== undefined ? blockTypeOf(id) : undefined;
|
|
25
25
|
const atomic = (type === undefined ? undefined : roleOf(type)?.atomic) ?? [];
|
|
26
|
-
const
|
|
26
|
+
const writes = node
|
|
27
27
|
? patchWrites(node, patches, doc.clientID, randOf(doc), atomic.map((p) => leafKey(typeof p === 'string' ? [p] : p)))
|
|
28
28
|
: [];
|
|
29
|
-
if (
|
|
29
|
+
if (writes === null)
|
|
30
30
|
return null; // a patch fits no value there
|
|
31
|
-
if (
|
|
31
|
+
if (writes.length === 0)
|
|
32
32
|
return [];
|
|
33
33
|
const offset = inlineId === undefined ? undefined : atomOf(id, inlineId)?.at;
|
|
34
34
|
return [
|
|
@@ -37,7 +37,7 @@ export const metaOps = (c) => {
|
|
|
37
37
|
...(id !== undefined && { id }),
|
|
38
38
|
...(inlineId !== undefined && { inlineId, offset }),
|
|
39
39
|
ops: patches,
|
|
40
|
-
|
|
40
|
+
writes
|
|
41
41
|
}
|
|
42
42
|
];
|
|
43
43
|
};
|
|
@@ -65,10 +65,8 @@ export const metaOps = (c) => {
|
|
|
65
65
|
/**
|
|
66
66
|
* The target role decides: nothing renders a void's children,
|
|
67
67
|
* so a block retyped to a void kind hands them to the slot right after
|
|
68
|
-
* it, as the kind they show there (`settledKind`)
|
|
69
|
-
*
|
|
70
|
-
* shedding gives it (`promotedRank`), so a child a peer adds
|
|
71
|
-
* meanwhile keeps its place in the void's order among them. An island
|
|
68
|
+
* it, as the kind they show there (`settledKind`), in their order (where
|
|
69
|
+
* the read-time shedding shows a child a peer adds meanwhile). An island
|
|
72
70
|
* declared `lines` retyped to an ordinary kind keeps its lines, each
|
|
73
71
|
* retyped to the new kind's default child (the document's where that
|
|
74
72
|
* renders no content): no line kind outside its island. Any other
|
|
@@ -95,12 +93,11 @@ export const metaOps = (c) => {
|
|
|
95
93
|
}
|
|
96
94
|
if (!roles.childless(type) || moved.length === 0 || pos === null)
|
|
97
95
|
return steps;
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
// The children keep their home slots: the read shows them in the void's
|
|
97
|
+
// slot (`conc.void-children`), settled for its parent.
|
|
100
98
|
return [
|
|
101
99
|
...steps,
|
|
102
|
-
...
|
|
103
|
-
...settle(id, ids, pos.parent)
|
|
100
|
+
...settle(id, moved.map((k) => k.id), pos.parent)
|
|
104
101
|
];
|
|
105
102
|
};
|
|
106
103
|
/** Set the block type (attr write — the block keeps its identity; see `retypeSteps`). */
|
|
@@ -187,10 +184,8 @@ export const metaOps = (c) => {
|
|
|
187
184
|
if (children !== undefined) {
|
|
188
185
|
for (const kid of childrenIds(id))
|
|
189
186
|
writes.push(remove(kid));
|
|
190
|
-
// Every current child is deleted, so the new ones rank from an empty list.
|
|
191
|
-
const ranks = ranksAt([], 0, children.length, doc.clientID, randOf(doc));
|
|
192
187
|
if (children.length > 0)
|
|
193
|
-
writes.push({ op: 'insertBlocks', parent: id, index: 0, specs: children
|
|
188
|
+
writes.push({ op: 'insertBlocks', parent: id, index: 0, specs: children });
|
|
194
189
|
}
|
|
195
190
|
return plan([id], writes);
|
|
196
191
|
};
|
package/dist/crdt/doc/moves.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type JSONBlock } from '../../utils/json.js';
|
|
2
2
|
import { type BlockId, type BlockSpec, type Destination } from '../placement/model.js';
|
|
3
3
|
import type { Prepared } from './types.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type OpsContext } from './steps.js';
|
|
5
5
|
/** The moves ops of one facade, prepared. */
|
|
6
6
|
export declare const moveOps: (c: OpsContext) => {
|
|
7
7
|
insertBlocks: (dest: Destination, specs: readonly (BlockSpec | JSONBlock)[]) => Prepared;
|
package/dist/crdt/doc/moves.js
CHANGED
|
@@ -7,9 +7,10 @@ import { id as newId } from '../../utils.js';
|
|
|
7
7
|
import { asBlockSpec, sanitizeSpec } from '../../utils/json.js';
|
|
8
8
|
import { collides } from '../placement/model.js';
|
|
9
9
|
import { ref } from './plan.js';
|
|
10
|
+
import { PART } from './steps.js';
|
|
10
11
|
/** The moves ops of one facade, prepared. */
|
|
11
12
|
export const moveOps = (c) => {
|
|
12
|
-
const { doc, blockTypeOf, blockDataOf, childrenIds, positionOf, isVoid, isIsland, isLine, contentItems, live, canPlace, isContainer, fits, kindToCopy, REFUSED,
|
|
13
|
+
const { doc, blockTypeOf, blockDataOf, childrenIds, positionOf, isVoid, isIsland, isLine, contentItems, live, canPlace, isContainer, fits, kindToCopy, REFUSED, plan, moveTo, move, leaving, settledKind, settle, landing, emptying, emptied } = c;
|
|
13
14
|
/**
|
|
14
15
|
* Insert blocks (specs may carry children/content/data; the batch is
|
|
15
16
|
* all-or-nothing). A spec is a `BlockSpec` or the `JSONBlock` that
|
|
@@ -29,8 +30,7 @@ export const moveOps = (c) => {
|
|
|
29
30
|
return plan([], []);
|
|
30
31
|
if ((parent !== null && !live(parent)) || collides(doc, clean))
|
|
31
32
|
return REFUSED;
|
|
32
|
-
|
|
33
|
-
return plan(clean.map((s) => s.id), [{ op: 'insertBlocks', parent, index: dest.index, specs: clean, ranks }]);
|
|
33
|
+
return plan(clean.map((s) => s.id), [{ op: 'insertBlocks', parent, index: dest.index, specs: clean }]);
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* Grouped move — one step, per-member conflict resolution; refused
|
|
@@ -80,8 +80,7 @@ export const moveOps = (c) => {
|
|
|
80
80
|
const retype = settle(from, moved, ppos.parent);
|
|
81
81
|
if (isContainer(from))
|
|
82
82
|
return splitOut(moved, [from], [], false, retype);
|
|
83
|
-
const
|
|
84
|
-
const writes = [...moveTo(moved, ppos.parent, ppos.index + 1, out), ...retype];
|
|
83
|
+
const writes = [...moveTo(moved, ppos.parent, ppos.index + 1, leaving(true)), ...retype];
|
|
85
84
|
const adopts = after.length > 0 &&
|
|
86
85
|
!isVoid(last) &&
|
|
87
86
|
!isIsland(last) &&
|
|
@@ -123,13 +122,11 @@ export const moveOps = (c) => {
|
|
|
123
122
|
const splitOut = (ids, levels, specs, keep, retype = []) => {
|
|
124
123
|
const moved = keep ? [] : [...ids];
|
|
125
124
|
const placed = [...moved, ...specs.map((s) => s.id)];
|
|
126
|
-
const insert = (at, index, s
|
|
125
|
+
const insert = (at, index, s) => s.length ? [{ op: 'insertBlocks', parent: at, index, specs: s }] : [];
|
|
127
126
|
const last = ids.at(-1);
|
|
128
127
|
const { parent, index } = positionOf(levels.at(-1) ?? last);
|
|
129
|
-
if (levels.length === 0)
|
|
130
|
-
|
|
131
|
-
return plan(placed, [...insert(parent, index + 1, specs, ranks), ...retype]);
|
|
132
|
-
}
|
|
128
|
+
if (levels.length === 0)
|
|
129
|
+
return plan(placed, [...insert(parent, index + 1, specs), ...retype]);
|
|
133
130
|
// Bottom up: what stays before the split at each level (the level
|
|
134
131
|
// itself, or a new head holding it), and whether anything follows it.
|
|
135
132
|
const heads = [];
|
|
@@ -141,10 +138,8 @@ export const moveOps = (c) => {
|
|
|
141
138
|
for (const level of levels) {
|
|
142
139
|
const kids = childrenIds(level);
|
|
143
140
|
const at = kids.indexOf(child);
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
...(before && !before.head ? [before.id] : [])
|
|
147
|
-
];
|
|
141
|
+
const stays = (keep && child === last) || (before !== null && !before.head);
|
|
142
|
+
const lead = kids.slice(0, at + (stays ? 1 : 0)).filter((k) => !moved.includes(k));
|
|
148
143
|
if (!follows && at + 1 < kids.length)
|
|
149
144
|
[follows, next] = [true, kids[at + 1]];
|
|
150
145
|
if ((lead.length > 0 || before?.head) && follows) {
|
|
@@ -160,27 +155,52 @@ export const moveOps = (c) => {
|
|
|
160
155
|
before = lead.length > 0 ? { id: level } : null;
|
|
161
156
|
child = level;
|
|
162
157
|
}
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
158
|
+
// Written in one gap, each right after the block before it, as an
|
|
159
|
+
// after-record out of the level's slot or a before-record into the gap
|
|
160
|
+
// before it (`leaving`): the engine's sort decides their order against
|
|
161
|
+
// a peer's records there (fork patch YP22, `sourceOrder`: the block a
|
|
162
|
+
// record stands at, then its part), so a peer's heads, pieces, lifts
|
|
163
|
+
// and new blocks in the same gap keep the serial order whatever the
|
|
164
|
+
// client ids (`del.merge.container`). The head stands at the first block
|
|
165
|
+
// (with `keep`, at it: `with`), the blocks at themselves, the new
|
|
166
|
+
// blocks after the last (`after`) — or, kept before the block that
|
|
167
|
+
// follows, at that block (`kept`). The records are written last first,
|
|
168
|
+
// so each stands before the one written before it, in the order the
|
|
169
|
+
// sort gives them; the head and the new blocks are created in the
|
|
170
|
+
// innermost level right after the block they stand at (their home,
|
|
171
|
+
// hidden while their records show them) and moved out by them.
|
|
168
172
|
const outside = before !== null && !before.head;
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
const side = leaving(outside);
|
|
174
|
+
const gap = index + (outside ? 1 : 0);
|
|
175
|
+
const at = moved[0] ?? last;
|
|
176
|
+
const kids0 = childrenIds(levels[0]);
|
|
177
|
+
const home = kids0.indexOf(last) + 1;
|
|
178
|
+
const specIds = specs.map((sp) => sp.id);
|
|
179
|
+
const [stands, part] = keep && !outside ? [next, PART.kept] : [last, PART.after];
|
|
180
|
+
// One record per run of adjacent blocks, each standing at its first: a
|
|
181
|
+
// block a peer's move takes out of a run leaves the others at their own place.
|
|
182
|
+
const runs = [];
|
|
183
|
+
for (const id of moved) {
|
|
184
|
+
const run = runs.at(-1);
|
|
185
|
+
if (run !== undefined && kids0.indexOf(run.at(-1)) + 1 === kids0.indexOf(id))
|
|
186
|
+
run.push(id);
|
|
187
|
+
else
|
|
188
|
+
runs.push([id]);
|
|
189
|
+
}
|
|
190
|
+
const writes = [
|
|
191
|
+
...insert(levels[0], home, specs),
|
|
192
|
+
...(before?.head ? insert(levels[0], home, [before.head]) : []),
|
|
193
|
+
...moveTo(specIds, parent, gap, side, stands, part),
|
|
194
|
+
...runs.reverse().flatMap((run) => moveTo(run, parent, gap, side, run[0], PART.self)),
|
|
195
|
+
...(before?.head
|
|
196
|
+
? moveTo([before.head.id], parent, gap, side, at, keep ? PART.with : PART.head)
|
|
197
|
+
: [])
|
|
198
|
+
];
|
|
178
199
|
for (const { spec, kids, inner } of heads.reverse()) {
|
|
179
|
-
|
|
180
|
-
writes.push(...moveTo(kids, spec.id, 0, inside.slice(0, kids.length)), ...(inner ? insert(spec.id, kids.length, [inner], inside.slice(-1)) : []));
|
|
200
|
+
writes.push(...moveTo(kids, spec.id, 0), ...(inner ? insert(spec.id, kids.length, [inner]) : []));
|
|
181
201
|
}
|
|
182
|
-
|
|
183
|
-
|
|
202
|
+
writes.push(...retype);
|
|
203
|
+
void next;
|
|
184
204
|
return plan(placed, emptying(levels[0], moved, writes, landing(parent)));
|
|
185
205
|
};
|
|
186
206
|
/**
|
package/dist/crdt/doc/reads.js
CHANGED
|
@@ -301,8 +301,8 @@ export const docReads = (c) => {
|
|
|
301
301
|
const hasBlock = (id) => blockNodeOf(doc, id) !== null;
|
|
302
302
|
/** The one liveness answer (`isLive`): `id` renders in `project()`. O(depth). */
|
|
303
303
|
const live = (id) => isLive(doc, id);
|
|
304
|
-
/** A live block that can hold content
|
|
305
|
-
const contentTarget = (id) => live(id) && view().blocks.
|
|
304
|
+
/** A live block that can hold content (a streamless block gets its own text on first write). */
|
|
305
|
+
const contentTarget = (id) => live(id) && view().blocks.has(id);
|
|
306
306
|
return {
|
|
307
307
|
dataNode,
|
|
308
308
|
blockJSON,
|
package/dist/crdt/doc/seed.js
CHANGED
|
@@ -3,7 +3,7 @@ import { hash32, setDocRand } from '../rand.js';
|
|
|
3
3
|
import { keepingReplaced } from '../incarnations.js';
|
|
4
4
|
import { asEngineDoc, asYDoc } from '../structs.js';
|
|
5
5
|
import { DOC_DATA_ROOT, SCHEMA } from '../schema.js';
|
|
6
|
-
import {
|
|
6
|
+
import { dataWrites, isObject, writeData } from '../data.js';
|
|
7
7
|
import { jsonBlockToSpec, sanitizeSpec, sanitizeWireJson, sanitizeWireString } from '../../utils/json.js';
|
|
8
8
|
import { isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION } from './gate.js';
|
|
9
9
|
/** Origin of the seed update's apply — non-local, like any integrated update. */
|
|
@@ -100,7 +100,7 @@ export const bindSeed = (Y, BA) => {
|
|
|
100
100
|
};
|
|
101
101
|
scratch.transact(() => {
|
|
102
102
|
specs.forEach(records);
|
|
103
|
-
|
|
103
|
+
writeData(scratch.get(DOC_DATA_ROOT), dataWrites(own));
|
|
104
104
|
});
|
|
105
105
|
return Y.encodeStateAsUpdate(raw);
|
|
106
106
|
};
|
|
@@ -11,7 +11,7 @@ import { blockNodeOf, isSelfOrDescendant } from '../placement/model.js';
|
|
|
11
11
|
import { ref } from './plan.js';
|
|
12
12
|
/** The split-merge ops of one facade, prepared. */
|
|
13
13
|
export const splitMergeOps = (c) => {
|
|
14
|
-
const { doc, view, childrenIds, positionOf, isVoid, isCellKind, blockTypeOf, insideIsland, isLayoutItem, next, previous, displayLength, contentTarget, isContainer, fits, canMerge, rendersContent, kindToCopy, REFUSED, plan,
|
|
14
|
+
const { doc, view, childrenIds, positionOf, isVoid, isCellKind, blockTypeOf, insideIsland, isLayoutItem, next, previous, displayLength, contentTarget, isContainer, fits, canMerge, rendersContent, kindToCopy, REFUSED, plan, moveTo, move, leaving, settledKind, settle, landing, emptying, emptied, merge, clamp } = c;
|
|
15
15
|
/**
|
|
16
16
|
* Split `id` at content `offset` into a new sibling `newId` (one boundary
|
|
17
17
|
* item and the claims that follow it, no text copied; children follow).
|
|
@@ -26,7 +26,7 @@ export const splitMergeOps = (c) => {
|
|
|
26
26
|
const born = ref(newId);
|
|
27
27
|
const pos = positionOf(id);
|
|
28
28
|
const rec = view().blocks.get(id);
|
|
29
|
-
if (pos === null || isVoid(id) || !rendersContent(id) ||
|
|
29
|
+
if (pos === null || isVoid(id) || !rendersContent(id) || rec === undefined)
|
|
30
30
|
return REFUSED;
|
|
31
31
|
// A table's cell holds its lines as line breaks: it never splits (`table.split`).
|
|
32
32
|
if (isCellKind(blockTypeOf(id)))
|
|
@@ -39,7 +39,6 @@ export const splitMergeOps = (c) => {
|
|
|
39
39
|
const t = tail
|
|
40
40
|
? { type, data: tail.data && sanitizeWireJson(tail.data) }
|
|
41
41
|
: { type, data: readData(rec.node) };
|
|
42
|
-
const [rank] = pieceRanks(id, at, 1);
|
|
43
42
|
const length = displayLength(id) - at;
|
|
44
43
|
const split = {
|
|
45
44
|
op: 'splitBlock',
|
|
@@ -49,7 +48,7 @@ export const splitMergeOps = (c) => {
|
|
|
49
48
|
newId: born,
|
|
50
49
|
tail: t,
|
|
51
50
|
parent: pos.parent,
|
|
52
|
-
|
|
51
|
+
index: pos.index + 1
|
|
53
52
|
};
|
|
54
53
|
return plan([born], [split, ...move(childrenIds(id), born, 0)]);
|
|
55
54
|
};
|
|
@@ -58,11 +57,11 @@ export const splitMergeOps = (c) => {
|
|
|
58
57
|
* children ADOPTED as `into`'s last children — an island's take
|
|
59
58
|
* `into`'s default child, like a baseline merge's — and `from` is
|
|
60
59
|
* hidden via the claim (undo restores it). The children stay under
|
|
61
|
-
* `from
|
|
62
|
-
*
|
|
63
|
-
* claim and `from` comes back with its children,
|
|
64
|
-
* Role rules are `canMerge`'s; a merge that would
|
|
65
|
-
* cycle is refused. `ids`: `into`.
|
|
60
|
+
* `from` and display under `into` through the claim, after `into`'s
|
|
61
|
+
* own children (the display's claim order): a concurrent delete of
|
|
62
|
+
* `into` voids the claim and `from` comes back with its children,
|
|
63
|
+
* never below them. Role rules are `canMerge`'s; a merge that would
|
|
64
|
+
* close a display cycle is refused. `ids`: `into`.
|
|
66
65
|
*/
|
|
67
66
|
const mergeBlocks = (fromId, intoId) => {
|
|
68
67
|
const from = ref(fromId);
|
|
@@ -74,9 +73,8 @@ export const splitMergeOps = (c) => {
|
|
|
74
73
|
return REFUSED;
|
|
75
74
|
const kids = childrenIds(from);
|
|
76
75
|
const retype = settle(from, kids, into);
|
|
77
|
-
const adopt = moveTo(kids, from, kids.length, ranksFor(into, Infinity, kids.length, kids));
|
|
78
76
|
// A list its only item leaves goes, as with every sibling op.
|
|
79
|
-
return plan([into], emptied([from], [merge(from, into), ...
|
|
77
|
+
return plan([into], emptied([from], [merge(from, into), ...retype], landing(into)));
|
|
80
78
|
};
|
|
81
79
|
/**
|
|
82
80
|
* Baseline-shaped merge (both `mergeBackward` and `mergeForward`):
|
|
@@ -84,7 +82,7 @@ export const splitMergeOps = (c) => {
|
|
|
84
82
|
* NOT adopted into `into` — and take the kind they show there
|
|
85
83
|
* (`settledKind`: an island's children its parent's default child, a
|
|
86
84
|
* paragraph in a list its item); then `from`'s content claims
|
|
87
|
-
* into `into`.
|
|
85
|
+
* into `into`. Placed after `from`, not at it: a concurrent delete of
|
|
88
86
|
* `into` revives `from` above its former children.
|
|
89
87
|
*/
|
|
90
88
|
const mergeUnnesting = (from, into) => {
|
|
@@ -93,8 +91,7 @@ export const splitMergeOps = (c) => {
|
|
|
93
91
|
return REFUSED;
|
|
94
92
|
const kids = childrenIds(from);
|
|
95
93
|
const retype = settle(from, kids, pos.parent);
|
|
96
|
-
|
|
97
|
-
return plan([into], [...moveTo(kids, pos.parent, pos.index + 1, out), ...retype, merge(from, into)]);
|
|
94
|
+
return plan([into], [...moveTo(kids, pos.parent, pos.index + 1, leaving(true)), ...retype, merge(from, into)]);
|
|
98
95
|
};
|
|
99
96
|
/** Remove `container`, left empty, for the key at `id` (refused if it holds text). */
|
|
100
97
|
const gone = (id, container) => {
|
|
@@ -143,7 +140,7 @@ export const splitMergeOps = (c) => {
|
|
|
143
140
|
if (!fits(slot.parent, settledKind(prev, id, slot.parent)))
|
|
144
141
|
return REFUSED;
|
|
145
142
|
const lift = [
|
|
146
|
-
...moveTo([id], slot.parent, slot.index, leaving(
|
|
143
|
+
...moveTo([id], slot.parent, slot.index, leaving(false)),
|
|
147
144
|
...settle(prev, [id], slot.parent)
|
|
148
145
|
];
|
|
149
146
|
return plan([id], emptying(prev, [id], lift, landing(slot.parent)));
|
package/dist/crdt/doc/steps.d.ts
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The step writers every prepared op composes: the plan itself, moves (a
|
|
3
|
+
* move's place and side), type steps and the kind a block shows where it
|
|
4
|
+
* lands (`settle`), the containers and layouts a write leaves empty
|
|
5
|
+
* (`emptying`, `dissolving`), delete and merge steps, and display spans of a
|
|
6
|
+
* block's content.
|
|
7
|
+
*/
|
|
1
8
|
import { TYPE } from '../schema.js';
|
|
2
9
|
import { type BlockId, type ContentItem } from '../placement/model.js';
|
|
3
10
|
import type { Plan, PlanStep } from './types.js';
|
|
4
11
|
import type { DocBase, DocReads } from './reads.js';
|
|
5
12
|
import type { DocCapability } from './capability.js';
|
|
6
13
|
/** What the step writers read: the reads and the structural capability. */
|
|
14
|
+
/**
|
|
15
|
+
* A record's order among the records standing at one block, for the
|
|
16
|
+
* engine's sort of two records at one origin (fork patch YP22): what a split
|
|
17
|
+
* of a list around a block writes there — a new head list holding the items
|
|
18
|
+
* before it (`head`), new blocks placed after the items before it, which
|
|
19
|
+
* stay (`kept`), a head holding those items and the block (`with`), the
|
|
20
|
+
* block itself leaving (`self`), new blocks after it (`after`) — in the
|
|
21
|
+
* order every serial run of the gestures gives (`del.merge.container`).
|
|
22
|
+
*/
|
|
23
|
+
export declare const PART: {
|
|
24
|
+
readonly head: 0;
|
|
25
|
+
readonly kept: 1;
|
|
26
|
+
readonly with: 2;
|
|
27
|
+
readonly self: 3;
|
|
28
|
+
readonly after: 4;
|
|
29
|
+
};
|
|
7
30
|
export type StepsContext = DocBase & DocReads & DocCapability;
|
|
8
31
|
/** The step writers of one facade. */
|
|
9
32
|
export declare const planSteps: (c: StepsContext) => {
|
|
10
33
|
REFUSED: import("./types.js").OpResult;
|
|
11
|
-
HEAD: number;
|
|
12
|
-
KEPT: number;
|
|
13
|
-
WITH: number;
|
|
14
|
-
SELF: number;
|
|
15
|
-
AFTER: number;
|
|
16
34
|
plan: (ids: readonly BlockId[], writes: PlanStep[]) => Plan;
|
|
17
|
-
|
|
18
|
-
moveTo: (ids: BlockId[], parent: BlockId | null, index: number, ranks: string[]) => PlanStep[];
|
|
35
|
+
moveTo: (ids: BlockId[], parent: BlockId | null, index: number, side?: 0 | 1, at?: BlockId, part?: number) => PlanStep[];
|
|
19
36
|
move: (ids: BlockId[], parent: BlockId | null, index: number) => PlanStep[];
|
|
20
|
-
|
|
21
|
-
at: BlockId;
|
|
22
|
-
part: readonly number[];
|
|
23
|
-
}[]) => string[];
|
|
24
|
-
pieceRanks: (id: BlockId, at: number, count: number) => string[];
|
|
25
|
-
leaving: (outer: BlockId, after: boolean, ids: readonly BlockId[]) => string[];
|
|
37
|
+
leaving: (after: boolean) => 0 | 1;
|
|
26
38
|
attr: (id: BlockId, key: typeof TYPE, value: string) => PlanStep[];
|
|
27
39
|
leavingIsland: (island: BlockId, kind: string | undefined, to: string) => string | undefined;
|
|
28
40
|
settledKind: (from: BlockId | null, kid: BlockId, parent: BlockId | null) => string | undefined;
|