edytor 1.0.0 → 3.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 +26 -69
- package/dist/block/block.svelte.d.ts +6 -4
- package/dist/block/block.svelte.js +12 -8
- package/dist/block/inlineBlock.svelte.d.ts +6 -2
- package/dist/block/inlineBlock.svelte.js +7 -2
- 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/room/admission.js +3 -3
- package/dist/cloudflare/room/context.d.ts +7 -1
- package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
- package/dist/cloudflare/routeDocumentSocket.js +53 -0
- package/dist/collaboration/awarenessSelection.d.ts +22 -1
- package/dist/collaboration/awarenessSelection.js +42 -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/Block.svelte +3 -1
- package/dist/components/Edytor.svelte +38 -20
- package/dist/components/Edytor.svelte.d.ts +9 -4
- package/dist/components/InlineBlock.svelte +1 -1
- package/dist/crdt/admission.d.ts +5 -10
- package/dist/crdt/admission.js +5 -11
- package/dist/crdt/data.d.ts +10 -0
- package/dist/crdt/data.js +20 -2
- package/dist/crdt/doc/funnel.d.ts +7 -6
- package/dist/crdt/doc/funnel.js +10 -9
- package/dist/crdt/doc/gate.d.ts +0 -17
- package/dist/crdt/doc/gate.js +2 -41
- package/dist/crdt/doc/history.js +2 -2
- package/dist/crdt/doc/reads.d.ts +7 -0
- package/dist/crdt/doc/reads.js +11 -1
- package/dist/crdt/document.d.ts +13 -14
- package/dist/crdt/document.js +17 -19
- package/dist/crdt/edytor-doc.d.ts +22 -4
- package/dist/crdt/edytor-doc.js +5 -8
- package/dist/crdt/index.d.ts +9 -3
- package/dist/crdt/index.js +2 -2
- package/dist/crdt/operations.d.ts +1 -1
- package/dist/crdt/operations.js +1 -0
- package/dist/crdt/props.d.ts +32 -0
- package/dist/crdt/props.js +172 -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 +10 -9
- package/dist/crdt/providers/room.js +13 -10
- package/dist/crdt/providers/websocket.d.ts +1 -1
- package/dist/crdt/providers/websocket.js +28 -29
- package/dist/crdt/semantics.js +3 -1
- package/dist/dnd/autoScroll.d.ts +15 -7
- package/dist/dnd/autoScroll.js +10 -15
- package/dist/{plugins/blockHandles → dnd}/dropIndicator.d.ts +2 -2
- package/dist/{plugins/blockHandles → dnd}/dropIndicator.js +2 -5
- package/dist/dnd/external.d.ts +6 -0
- package/dist/dnd/external.js +17 -0
- package/dist/{plugins/blockHandles → dnd}/geometry.d.ts +4 -2
- package/dist/{plugins/blockHandles → dnd}/geometry.js +3 -4
- package/dist/dnd/placement.d.ts +200 -0
- package/dist/dnd/placement.js +426 -0
- 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 +19 -9
- package/dist/edytor.svelte.js +28 -33
- package/dist/events/beforeInputCommands.d.ts +2 -2
- package/dist/events/beforeInputCommands.js +8 -4
- package/dist/events/onBeforeInput.js +1 -1
- package/dist/events/onDrop.js +25 -10
- package/dist/events/onInput.d.ts +0 -12
- package/dist/events/onInput.js +1 -67
- package/dist/events/onPaste.d.ts +2 -1
- package/dist/events/onPaste.js +8 -3
- 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 +4 -4
- package/dist/index.js +2 -2
- package/dist/kinds.js +1 -1
- package/dist/labels.d.ts +2 -0
- package/dist/labels.js +2 -1
- package/dist/plugins/anchored.svelte.d.ts +21 -25
- package/dist/plugins/anchored.svelte.js +23 -39
- package/dist/plugins/arrowMove/arrowMove.d.ts +1 -1
- package/dist/plugins/arrowMove/arrowMove.js +1 -1
- package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +2 -122
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +48 -414
- package/dist/plugins/blockHandles/BlockHandles.svelte +14 -32
- package/dist/plugins/blockHandles/blockHandlesPlugin.js +2 -1
- 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/CodeHeader.svelte +5 -3
- package/dist/plugins/code/CodePlugin.svelte +15 -12
- 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/code/languages.d.ts +0 -3
- package/dist/plugins/code/languages.js +0 -2
- package/dist/plugins/columns/ColumnResize.svelte +3 -2
- package/dist/plugins/columns/ColumnsPlugin.svelte +8 -21
- package/dist/plugins/columns/gaps.d.ts +7 -5
- package/dist/plugins/columns/gaps.js +11 -6
- package/dist/plugins/columns/resize.svelte.d.ts +5 -6
- package/dist/plugins/columns/resize.svelte.js +12 -14
- 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 +13 -30
- package/dist/plugins/equation/EquationPlugin.svelte.d.ts +1 -0
- package/dist/plugins/equation/equation.css +7 -0
- 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 +43 -0
- package/dist/plugins/fileDrop.js +122 -0
- 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 +56 -84
- package/dist/plugins/image/ImagePlugin.svelte.d.ts +13 -1
- package/dist/plugins/image/controls.svelte.js +16 -2
- package/dist/plugins/image/image.css +17 -0
- 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 +4 -5
- package/dist/plugins/index.js +0 -1
- package/dist/plugins/list.svelte.d.ts +9 -0
- package/dist/plugins/list.svelte.js +18 -0
- package/dist/plugins/markdownShortcuts.js +5 -5
- package/dist/plugins/marquee/marqueePlugin.js +0 -4
- package/dist/plugins/media/AudioPlugin.svelte +13 -1
- package/dist/plugins/media/AudioPlugin.svelte.d.ts +11 -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 +12 -20
- package/dist/plugins/media/FilePlugin.svelte.d.ts +9 -0
- package/dist/plugins/media/MediaEmpty.svelte +2 -55
- package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
- package/dist/plugins/media/SourceBlock.svelte +178 -52
- package/dist/plugins/media/SourceBlock.svelte.d.ts +13 -6
- package/dist/plugins/media/UploadPreview.svelte +32 -0
- package/dist/plugins/media/UploadPreview.svelte.d.ts +11 -0
- package/dist/plugins/media/VideoPlugin.svelte +13 -1
- package/dist/plugins/media/VideoPlugin.svelte.d.ts +11 -1
- package/dist/plugins/media/empty.svelte.d.ts +13 -4
- package/dist/plugins/media/empty.svelte.js +32 -26
- package/dist/plugins/media/media.d.ts +9 -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/upload.css +23 -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 +50 -38
- package/dist/plugins/mention/MentionPlugin.svelte.d.ts +11 -2
- package/dist/plugins/mention/mention.css +6 -0
- package/dist/plugins/page/PagePlugin.svelte +2 -9
- package/dist/plugins/page/page.js +1 -1
- package/dist/plugins/pageLink/PageLinkPlugin.svelte +126 -28
- package/dist/plugins/pageLink/PageLinkPlugin.svelte.d.ts +13 -1
- package/dist/plugins/pageLink/pageLink.css +6 -0
- package/dist/plugins/richtext/RichTextPlugin.svelte +99 -204
- package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +1 -0
- 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/richtext/richtext.css +6 -0
- 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 +33 -56
- 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 +48 -32
- package/dist/plugins/uploads.svelte.js +119 -43
- package/dist/plugins.d.ts +66 -14
- 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/attempt.d.ts +16 -6
- package/dist/session/attempt.js +1 -0
- package/dist/session/bindings.js +35 -32
- package/dist/session/commands.d.ts +7 -11
- package/dist/session/commands.js +15 -19
- package/dist/session/history.js +1 -0
- package/dist/session/inputRules.d.ts +6 -3
- package/dist/session/inputRules.js +10 -6
- package/dist/session/moves.d.ts +33 -0
- package/dist/session/moves.js +71 -1
- package/dist/session/navigation.d.ts +7 -0
- package/dist/session/navigation.js +20 -11
- package/dist/session/props.d.ts +28 -0
- package/dist/session/props.js +65 -0
- package/dist/session/suggestions.svelte.d.ts +0 -11
- package/dist/session/suggestions.svelte.js +15 -3
- package/dist/session/uploads.d.ts +29 -0
- package/dist/session/uploads.js +10 -0
- package/dist/surface/lines.js +1 -3
- package/dist/surface/observer.svelte.d.ts +17 -1
- package/dist/surface/observer.svelte.js +72 -17
- package/dist/surface/overlay.d.ts +0 -14
- package/dist/surface/overlay.js +0 -25
- package/dist/surface/projector.svelte.js +1 -1
- package/dist/text/text.svelte.js +3 -13
- package/dist/themes/notion.css +9 -0
- 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 +18 -1
- 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/{plugins/columns → dnd}/stacking.d.ts +0 -0
- /package/dist/{plugins/columns → dnd}/stacking.js +0 -0
package/dist/crdt/doc/gate.d.ts
CHANGED
|
@@ -86,20 +86,3 @@ export declare class SchemaMismatchError extends Error {
|
|
|
86
86
|
* mutating a synced document.
|
|
87
87
|
*/
|
|
88
88
|
export declare const assertSchema: (doc: EngineDoc, docName?: string) => void;
|
|
89
|
-
/**
|
|
90
|
-
* Error raised by {@link assertUsableDoc} — the doc cannot host a v14 facade:
|
|
91
|
-
* a foreign engine object (a v13 `yjs` Doc — a different CRDT implementation
|
|
92
|
-
* entirely).
|
|
93
|
-
*/
|
|
94
|
-
export declare class UnsupportedDocError extends Error {
|
|
95
|
-
readonly kind: 'foreign';
|
|
96
|
-
constructor(kind: 'foreign');
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Document-boundary guard run by {@link EdytorDocBinding.create} before the
|
|
100
|
-
* runs view attaches. The facade only speaks the v14 unified-node surface —
|
|
101
|
-
* without this gate a foreign doc dies obscurely inside `buildView`
|
|
102
|
-
* (`registry.forEachAttr is not a function`); it fails fast with an
|
|
103
|
-
* actionable error instead.
|
|
104
|
-
*/
|
|
105
|
-
export declare const assertUsableDoc: (doc: EngineDoc) => void;
|
package/dist/crdt/doc/gate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SCHEMA } from '../schema.js';
|
|
2
2
|
export const SCHEMA_VERSION = SCHEMA.version;
|
|
3
3
|
export const SCHEMA_NAME = SCHEMA.name;
|
|
4
4
|
export const META_KEY = SCHEMA.roots.meta;
|
|
@@ -51,13 +51,7 @@ export class SchemaMismatchError extends Error {
|
|
|
51
51
|
docName;
|
|
52
52
|
problem;
|
|
53
53
|
constructor(docName, problem) {
|
|
54
|
-
super(problem.kind
|
|
55
|
-
? `Document "${docName}" carries replicated registry state but no meta.v schema version — refusing to treat it as initialized.`
|
|
56
|
-
: problem.kind === 'unsupported'
|
|
57
|
-
? `Document "${docName}" claims unsupported schema version ${problem.version} (this build speaks ${SCHEMA_VERSION}).`
|
|
58
|
-
: problem.schema === undefined
|
|
59
|
-
? `Document "${docName}" carries meta.v=${problem.version} but no meta.schema manifest name — refusing it as an "${SCHEMA_NAME}" document.`
|
|
60
|
-
: `Document "${docName}" claims foreign schema "${String(problem.schema)}" (this build speaks "${SCHEMA_NAME}").`);
|
|
54
|
+
super(`${docName}: ${problem.kind} schema version ${problem.version} "${String(problem.schema)}" (this build speaks ${SCHEMA_VERSION} "${SCHEMA_NAME}")`);
|
|
61
55
|
this.docName = docName;
|
|
62
56
|
this.problem = problem;
|
|
63
57
|
this.name = 'SchemaMismatchError';
|
|
@@ -73,36 +67,3 @@ export const assertSchema = (doc, docName = 'doc') => {
|
|
|
73
67
|
if (problem !== null)
|
|
74
68
|
throw new SchemaMismatchError(docName, problem);
|
|
75
69
|
};
|
|
76
|
-
/**
|
|
77
|
-
* Error raised by {@link assertUsableDoc} — the doc cannot host a v14 facade:
|
|
78
|
-
* a foreign engine object (a v13 `yjs` Doc — a different CRDT implementation
|
|
79
|
-
* entirely).
|
|
80
|
-
*/
|
|
81
|
-
export class UnsupportedDocError extends Error {
|
|
82
|
-
kind;
|
|
83
|
-
constructor(kind) {
|
|
84
|
-
super('Document is not a v14 engine doc — the `blocks` registry is not a ' +
|
|
85
|
-
'unified Y.Node. Use `crdt.createDoc()` (or `new Y.Doc()` from `edytor/crdt`).');
|
|
86
|
-
this.kind = kind;
|
|
87
|
-
this.name = 'UnsupportedDocError';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Document-boundary guard run by {@link EdytorDocBinding.create} before the
|
|
92
|
-
* runs view attaches. The facade only speaks the v14 unified-node surface —
|
|
93
|
-
* without this gate a foreign doc dies obscurely inside `buildView`
|
|
94
|
-
* (`registry.forEachAttr is not a function`); it fails fast with an
|
|
95
|
-
* actionable error instead.
|
|
96
|
-
*/
|
|
97
|
-
export const assertUsableDoc = (doc) => {
|
|
98
|
-
let registry;
|
|
99
|
-
try {
|
|
100
|
-
registry = typeof doc?.get === 'function' ? doc.get(SCHEMA.roots.registry) : undefined;
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
registry = undefined;
|
|
104
|
-
}
|
|
105
|
-
if (!isNodeLike(registry) || typeof registry.forEachAttr !== 'function') {
|
|
106
|
-
throw new UnsupportedDocError('foreign');
|
|
107
|
-
}
|
|
108
|
-
};
|
package/dist/crdt/doc/history.js
CHANGED
|
@@ -15,7 +15,7 @@ import { readHorizon } from '../purge.js';
|
|
|
15
15
|
import { BLOCK_NODE, DATA_LEAF_PREFIX, DOC_DATA_ROOT, HORIZON_ROOT, INLINE_NODE, LAST_CHANGED_ATTR, TYPE } from '../schema.js';
|
|
16
16
|
import { changedUnder, collectable, collectNow, collects, dropSearchMarkers, engineOps, walkIdSet } from '../structs.js';
|
|
17
17
|
import { isInitialized } from './gate.js';
|
|
18
|
-
import {
|
|
18
|
+
import { DocumentDestroyedError } from './funnel.js';
|
|
19
19
|
import { registryOf, withdrawOnUndo } from '../placement/model.js';
|
|
20
20
|
/** The undo steps a document's history keeps by default: older ones are released. */
|
|
21
21
|
export const DEFAULT_HISTORY_LIMIT = 200;
|
|
@@ -367,7 +367,7 @@ export const docHistory = (c) => {
|
|
|
367
367
|
*/
|
|
368
368
|
const createUndoManager = (options = {}) => {
|
|
369
369
|
if (disposed()) {
|
|
370
|
-
throw new
|
|
370
|
+
throw new DocumentDestroyedError('createUndoManager');
|
|
371
371
|
}
|
|
372
372
|
write(() => {
|
|
373
373
|
if (!isInitialized(doc))
|
package/dist/crdt/doc/reads.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EngineApi, EngineDoc, EngineNode } from '../engine-api.js';
|
|
2
2
|
import { type BlockId, type ContentItem, type Destination, type ModelView } from '../placement/model.js';
|
|
3
3
|
import type { DisplayRoles, RunView } from '../text/runs.js';
|
|
4
|
+
import { type DataPatch } from '../data.js';
|
|
4
5
|
import { type JSONBlock } from '../../utils/json.js';
|
|
5
6
|
import type { BlockRole, DataTarget, JsonObj, OrderPolicy } from './types.js';
|
|
6
7
|
/** What every part of a document facade is built over: one doc, its engine layers, its index and its roles. */
|
|
@@ -25,6 +26,12 @@ export declare const docReads: (c: DocBase) => {
|
|
|
25
26
|
blockDataOf: (id: BlockId) => Record<string, unknown> | undefined;
|
|
26
27
|
docData: () => JsonObj;
|
|
27
28
|
dataItemIds: (target: DataTarget, path: readonly string[]) => string[];
|
|
29
|
+
dataPreview: (target: DataTarget, pending: readonly DataPatch[]) => {
|
|
30
|
+
data: {
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
ids: (path: readonly string[]) => string[];
|
|
34
|
+
} | null;
|
|
28
35
|
childrenIds: (parent: BlockId | null) => BlockId[];
|
|
29
36
|
positionOf: (id: BlockId) => Destination | null;
|
|
30
37
|
pathOf: (id: BlockId) => number[] | null;
|
package/dist/crdt/doc/reads.js
CHANGED
|
@@ -9,7 +9,7 @@ import { DOC_DATA_ROOT, TYPE } from '../schema.js';
|
|
|
9
9
|
import { blockNodeOf, displayParentOf, displaySlotOf, isLive, isLiveIn, positionInView, positionOf as modelPositionOf } from '../placement/model.js';
|
|
10
10
|
import { DEAD, findAtom, ownedLength } from '../text/model.js';
|
|
11
11
|
import { holdsPending } from '../structs.js';
|
|
12
|
-
import { itemIds, readData } from '../data.js';
|
|
12
|
+
import { itemIds, previewData, readData } from '../data.js';
|
|
13
13
|
import { columnIds, listedColumns, unlistedOrder } from '../tables.js';
|
|
14
14
|
import { cloneJsonSafe } from '../../utils/json.js';
|
|
15
15
|
import { ref } from './plan.js';
|
|
@@ -69,6 +69,15 @@ export const docReads = (c) => {
|
|
|
69
69
|
const node = dataNode(id && ref(id), atom && ref(atom));
|
|
70
70
|
return node && Array.isArray(path) ? itemIds(node, path) : [];
|
|
71
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* A block's, an atom's or the document's data once `pending` patches are
|
|
74
|
+
* applied, without writing them, and its array items' ids (`previewData`):
|
|
75
|
+
* what a view reads of its data writes not yet dispatched.
|
|
76
|
+
*/
|
|
77
|
+
const dataPreview = (target, pending) => {
|
|
78
|
+
const [id, atom] = typeof target === 'object' && target ? [target.block, target.atom] : [target ?? undefined];
|
|
79
|
+
return previewData(dataNode(id && ref(id), atom && ref(atom)), pending);
|
|
80
|
+
};
|
|
72
81
|
/** Ordered visible children of `parent` (`null` = root) — canonical read. */
|
|
73
82
|
const childrenIds = (parent) => (view().kids.get(parent) ?? []).map((k) => k.id);
|
|
74
83
|
const positionOf = (id) => modelPositionOf(doc, id);
|
|
@@ -302,6 +311,7 @@ export const docReads = (c) => {
|
|
|
302
311
|
blockDataOf,
|
|
303
312
|
docData,
|
|
304
313
|
dataItemIds,
|
|
314
|
+
dataPreview,
|
|
305
315
|
childrenIds,
|
|
306
316
|
positionOf,
|
|
307
317
|
pathOf,
|
package/dist/crdt/document.d.ts
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
* - `createDocument` — the fresh doc is trivially admitted;
|
|
65
65
|
* - `loadDocument` — the payload is decoded+integrated onto a SCRATCH
|
|
66
66
|
* doc first (`admitUpdate`) and the gate runs on the merged result; a
|
|
67
|
-
* refusal ({@link UndecodableUpdateError},
|
|
67
|
+
* refusal ({@link UndecodableUpdateError},
|
|
68
68
|
* {@link SchemaMismatchError}) leaves nothing composed and never
|
|
69
69
|
* touches the caller's bytes;
|
|
70
70
|
* - `attachDocument` — the borrowed doc is gated BEFORE any composition
|
|
@@ -144,7 +144,7 @@ import type { MarkEdge } from './text/marks.js';
|
|
|
144
144
|
import type { EngineApi, EngineDoc, YDoc, YUndoManager } from './engine-api.js';
|
|
145
145
|
import { type DocumentOperations } from './operations.js';
|
|
146
146
|
import { type AttributionBinding, type DocumentAttribution } from './attribution/index.js';
|
|
147
|
-
import { type BlockRole, type DocFacade, type EdytorDocConfig } from './edytor-doc.js';
|
|
147
|
+
import { DocumentDestroyedError, type BlockRole, type DocFacade, type EdytorDocConfig } from './edytor-doc.js';
|
|
148
148
|
import { Awareness } from './protocols/awareness.js';
|
|
149
149
|
import type { EdytorSync, EdytorSyncCleanup } from './providers/index.js';
|
|
150
150
|
import { SyncRefusedError } from './providers/room.js';
|
|
@@ -243,19 +243,11 @@ export type CreateDocumentOptions = DocumentOptions & {
|
|
|
243
243
|
value?: JSONDoc;
|
|
244
244
|
};
|
|
245
245
|
export type LoadDocumentOptions = DocumentOptions;
|
|
246
|
+
export { DocumentDestroyedError };
|
|
246
247
|
/** Raised when a readiness-gated service is used on a pending document. */
|
|
247
248
|
export declare class DocumentNotReadyError extends Error {
|
|
248
249
|
constructor(service: string);
|
|
249
250
|
}
|
|
250
|
-
/**
|
|
251
|
-
* Raised when an operation runs against a torn-down document — every
|
|
252
|
-
* attach reference has been released and the facade/history/awareness
|
|
253
|
-
* teardown already ran. Distinct from {@link DocumentNotReadyError}:
|
|
254
|
-
* destroyed is terminal, pending may still resolve.
|
|
255
|
-
*/
|
|
256
|
-
export declare class DocumentDestroyedError extends Error {
|
|
257
|
-
constructor(service?: string);
|
|
258
|
-
}
|
|
259
251
|
/**
|
|
260
252
|
* How the document's content state was decided — the distinction the
|
|
261
253
|
* readiness contract requires:
|
|
@@ -353,6 +345,14 @@ export declare class EdytorDocument {
|
|
|
353
345
|
private _destroyed;
|
|
354
346
|
/** {@link DocumentOptions.requireHydration}: an empty document waits for a provider's `synced`. */
|
|
355
347
|
readonly requireHydration: boolean;
|
|
348
|
+
/**
|
|
349
|
+
* The document's properties as a live object (`crdt/props`): a read
|
|
350
|
+
* follows the document, and a write at any depth (`document.data.title
|
|
351
|
+
* = 'Notes'`, `document.data.tags.push('x')`, `delete …`) is the raw
|
|
352
|
+
* `patchData` operation at once, as `document.patchData(null, …)`. Not
|
|
353
|
+
* reactive by itself: a view's `edytor.data` is, and dispatches.
|
|
354
|
+
*/
|
|
355
|
+
get data(): Record<string, any>;
|
|
356
356
|
/** The replica id (`doc.clientID`) — identifies the replica, not the actor. */
|
|
357
357
|
get clientID(): number;
|
|
358
358
|
/**
|
|
@@ -633,9 +633,8 @@ export declare const bindDocument: (Y: EngineApi) => {
|
|
|
633
633
|
* borrowed doc. Content state stays `pending` — the caller (view or
|
|
634
634
|
* provider path) drives `sync()`.
|
|
635
635
|
*
|
|
636
|
-
* Admission runs BEFORE any composition touches the doc:
|
|
637
|
-
* foreign
|
|
638
|
-
* unversioned/unsupported/foreign schema claim with
|
|
636
|
+
* Admission runs BEFORE any composition touches the doc: an
|
|
637
|
+
* unversioned/unsupported/foreign schema claim refuses with
|
|
639
638
|
* {@link SchemaMismatchError} — the borrowed doc is left
|
|
640
639
|
* byte-identical (the gate reads are write-free) and can be
|
|
641
640
|
* attached once its state heals (e.g. a remote update supplies the
|
package/dist/crdt/document.js
CHANGED
|
@@ -2,9 +2,10 @@ import { DEV } from 'esm-env';
|
|
|
2
2
|
import { Y } from './engine.js';
|
|
3
3
|
import { asEngineDoc } from './structs.js';
|
|
4
4
|
import { DOCUMENT_OPERATIONS } from './operations.js';
|
|
5
|
+
import { propsProxy } from './props.js';
|
|
5
6
|
import { bindAttribution } from './attribution/index.js';
|
|
6
7
|
import { profileOf } from './attribution/attribution.js';
|
|
7
|
-
import { docFacade, DEFAULT_HISTORY_LIMIT, isInitialized } from './edytor-doc.js';
|
|
8
|
+
import { docFacade, DocumentDestroyedError, DEFAULT_HISTORY_LIMIT, isInitialized } from './edytor-doc.js';
|
|
8
9
|
import { assertAdmission, assertSchema, bindAdmission, checkSchema } from './admission.js';
|
|
9
10
|
import { Awareness } from './protocols/awareness.js';
|
|
10
11
|
import { callEach } from './protocols/observable.js';
|
|
@@ -17,27 +18,14 @@ const alive = (document, op) => {
|
|
|
17
18
|
if (document.destroyed)
|
|
18
19
|
throw new DocumentDestroyedError(op);
|
|
19
20
|
};
|
|
21
|
+
export { DocumentDestroyedError };
|
|
20
22
|
/** Raised when a readiness-gated service is used on a pending document. */
|
|
21
23
|
export class DocumentNotReadyError extends Error {
|
|
22
24
|
constructor(service) {
|
|
23
|
-
super(
|
|
24
|
-
`(created without a value, provider hydration may be in flight). ` +
|
|
25
|
-
`Wait for the sync callback / call document.sync() first.`);
|
|
25
|
+
super(`${service}: the document is not ready (call document.sync() first)`);
|
|
26
26
|
this.name = 'DocumentNotReadyError';
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Raised when an operation runs against a torn-down document — every
|
|
31
|
-
* attach reference has been released and the facade/history/awareness
|
|
32
|
-
* teardown already ran. Distinct from {@link DocumentNotReadyError}:
|
|
33
|
-
* destroyed is terminal, pending may still resolve.
|
|
34
|
-
*/
|
|
35
|
-
export class DocumentDestroyedError extends Error {
|
|
36
|
-
constructor(service) {
|
|
37
|
-
super(`EdytorDocument${service ? `.${service}` : ''}: document is destroyed.`);
|
|
38
|
-
this.name = 'DocumentDestroyedError';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
29
|
/**
|
|
42
30
|
* How long (ms) an empty document waits for a provider that has not
|
|
43
31
|
* settled before it decides without it (settle-or-bound) — the bound a
|
|
@@ -237,6 +225,17 @@ export class EdytorDocument {
|
|
|
237
225
|
else if (DEV)
|
|
238
226
|
advertise(this.awareness, this.#capability.config, this.#defaultType);
|
|
239
227
|
}
|
|
228
|
+
#data;
|
|
229
|
+
/**
|
|
230
|
+
* The document's properties as a live object (`crdt/props`): a read
|
|
231
|
+
* follows the document, and a write at any depth (`document.data.title
|
|
232
|
+
* = 'Notes'`, `document.data.tags.push('x')`, `delete …`) is the raw
|
|
233
|
+
* `patchData` operation at once, as `document.patchData(null, …)`. Not
|
|
234
|
+
* reactive by itself: a view's `edytor.data` is, and dispatches.
|
|
235
|
+
*/
|
|
236
|
+
get data() {
|
|
237
|
+
return (this.#data ??= propsProxy(() => this.facade.docData(), (patches) => void this.facade.apply(this.facade.prepare.patchData(null, patches)), (path) => this.facade.dataItemIds(null, path)));
|
|
238
|
+
}
|
|
240
239
|
/** The replica id (`doc.clientID`) — identifies the replica, not the actor. */
|
|
241
240
|
get clientID() {
|
|
242
241
|
return this.doc.clientID;
|
|
@@ -914,9 +913,8 @@ export const bindDocument = (Y) => {
|
|
|
914
913
|
* borrowed doc. Content state stays `pending` — the caller (view or
|
|
915
914
|
* provider path) drives `sync()`.
|
|
916
915
|
*
|
|
917
|
-
* Admission runs BEFORE any composition touches the doc:
|
|
918
|
-
* foreign
|
|
919
|
-
* unversioned/unsupported/foreign schema claim with
|
|
916
|
+
* Admission runs BEFORE any composition touches the doc: an
|
|
917
|
+
* unversioned/unsupported/foreign schema claim refuses with
|
|
920
918
|
* {@link SchemaMismatchError} — the borrowed doc is left
|
|
921
919
|
* byte-identical (the gate reads are write-free) and can be
|
|
922
920
|
* attached once its state heals (e.g. a remote update supplies the
|
|
@@ -5,7 +5,7 @@ import { bindText } from './text/model.js';
|
|
|
5
5
|
import { type RunView } from './text/runs.js';
|
|
6
6
|
import { type BlockAttribution } from './attribution/block.js';
|
|
7
7
|
import type { JSONBlock, JSONDoc } from '../utils/json.js';
|
|
8
|
-
import { assertSchema,
|
|
8
|
+
import { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
|
|
9
9
|
import type { EngineNode } from './engine-api.js';
|
|
10
10
|
import type { ContentItem, InlineSpec, ModelView, SplitTail } from './placement/model.js';
|
|
11
11
|
import type { Anchor } from './text/model.js';
|
|
@@ -14,10 +14,10 @@ import type { DocPosition } from './rangeDelete.js';
|
|
|
14
14
|
import type { DataPatch } from './data.js';
|
|
15
15
|
import type { AnchorAffinity, BlockRole, DataTarget, DocAnchor, DocChange, EdytorDocConfig, JsonObj, OpResult, OrderPolicy, Plan, PlanEffect, PlanStep, Prepared, TextRange } from './doc/types.js';
|
|
16
16
|
export { SCHEMA };
|
|
17
|
-
export { assertSchema,
|
|
18
|
-
export {
|
|
17
|
+
export { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
|
|
18
|
+
export type { SchemaProblem } from './doc/gate.js';
|
|
19
19
|
export { SEED_ORIGIN } from './doc/seed.js';
|
|
20
|
-
export {
|
|
20
|
+
export { DocumentDestroyedError } from './doc/funnel.js';
|
|
21
21
|
export { DEFAULT_HISTORY_LIMIT } from './doc/history.js';
|
|
22
22
|
export type { AnchorAffinity, BlockRole, DataTarget, DocAnchor, DocChange, EdytorDocConfig, OpResult, OrderPolicy, Plan, PlanEffect, PlanStep, Prepared, TextRange };
|
|
23
23
|
export type EdytorDoc = ReturnType<EdytorDocBinding['create']>;
|
|
@@ -168,6 +168,12 @@ export declare const docFacade: <L extends Layers>(Y: EngineApi, layers: L) => (
|
|
|
168
168
|
blockDataOf: (id: string) => Record<string, unknown> | undefined;
|
|
169
169
|
docData: () => JsonObj;
|
|
170
170
|
dataItemIds: (target: DataTarget, path: readonly string[]) => string[];
|
|
171
|
+
dataPreview: (target: DataTarget, pending: readonly DataPatch[]) => {
|
|
172
|
+
data: {
|
|
173
|
+
[x: string]: unknown;
|
|
174
|
+
};
|
|
175
|
+
ids: (path: readonly string[]) => string[];
|
|
176
|
+
} | null;
|
|
171
177
|
/**
|
|
172
178
|
* Compact per-block attribution (`{createdBy, contributors,
|
|
173
179
|
* lastChangedBy}`), or `undefined` for unauthored/system blocks.
|
|
@@ -482,6 +488,12 @@ export declare const bindDocModel: (Y: EngineApi) => {
|
|
|
482
488
|
blockDataOf: (id: string) => Record<string, unknown> | undefined;
|
|
483
489
|
docData: () => JsonObj;
|
|
484
490
|
dataItemIds: (target: DataTarget, path: readonly string[]) => string[];
|
|
491
|
+
dataPreview: (target: DataTarget, pending: readonly DataPatch[]) => {
|
|
492
|
+
data: {
|
|
493
|
+
[x: string]: unknown;
|
|
494
|
+
};
|
|
495
|
+
ids: (path: readonly string[]) => string[];
|
|
496
|
+
} | null;
|
|
485
497
|
/**
|
|
486
498
|
* Compact per-block attribution (`{createdBy, contributors,
|
|
487
499
|
* lastChangedBy}`), or `undefined` for unauthored/system blocks.
|
|
@@ -882,6 +894,12 @@ export declare const bindEdytorDoc: (Y: EngineApi) => {
|
|
|
882
894
|
blockDataOf: (id: string) => Record<string, unknown> | undefined;
|
|
883
895
|
docData: () => JsonObj;
|
|
884
896
|
dataItemIds: (target: DataTarget, path: readonly string[]) => string[];
|
|
897
|
+
dataPreview: (target: DataTarget, pending: readonly DataPatch[]) => {
|
|
898
|
+
data: {
|
|
899
|
+
[x: string]: unknown;
|
|
900
|
+
};
|
|
901
|
+
ids: (path: readonly string[]) => string[];
|
|
902
|
+
} | null;
|
|
885
903
|
/**
|
|
886
904
|
* Compact per-block attribution (`{createdBy, contributors,
|
|
887
905
|
* lastChangedBy}`), or `undefined` for unauthored/system blocks.
|
package/dist/crdt/edytor-doc.js
CHANGED
|
@@ -58,7 +58,7 @@ import { bindRuns, indexOf } from './text/runs.js';
|
|
|
58
58
|
import { bindBlockAttribution, blockAttributionOf } from './attribution/block.js';
|
|
59
59
|
import { rangeDeleteOps } from './rangeDelete.js';
|
|
60
60
|
import { flowOps } from './flow.js';
|
|
61
|
-
import { assertSchema,
|
|
61
|
+
import { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
|
|
62
62
|
import { bindSeed, restore } from './doc/seed.js';
|
|
63
63
|
import { applied, ref } from './doc/plan.js';
|
|
64
64
|
import { docReads } from './doc/reads.js';
|
|
@@ -76,10 +76,9 @@ import { metaOps } from './doc/meta.js';
|
|
|
76
76
|
import { contentOps } from './doc/content.js';
|
|
77
77
|
// ── schema manifest and gate (`doc/gate.ts`) ────────────────────────────
|
|
78
78
|
export { SCHEMA };
|
|
79
|
-
export { assertSchema,
|
|
80
|
-
export { UnsupportedDocError } from './doc/gate.js';
|
|
79
|
+
export { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
|
|
81
80
|
export { SEED_ORIGIN } from './doc/seed.js';
|
|
82
|
-
export {
|
|
81
|
+
export { DocumentDestroyedError } from './doc/funnel.js';
|
|
83
82
|
export { DEFAULT_HISTORY_LIMIT } from './doc/history.js';
|
|
84
83
|
/**
|
|
85
84
|
* The per-doc facade factory over the engine `Y` (the editor's documents
|
|
@@ -94,9 +93,6 @@ export const docFacade = (Y, layers) => {
|
|
|
94
93
|
const { init, seed } = bindSeed(Y, BA);
|
|
95
94
|
return (doc, config = {}) => {
|
|
96
95
|
keepingReplaced(doc);
|
|
97
|
-
// Document-boundary check — foreign (v13-engine) and legacy-schema docs
|
|
98
|
-
// fail fast here rather than inside the runs view (see assertUsableDoc).
|
|
99
|
-
assertUsableDoc(doc);
|
|
100
96
|
setMarkEdges(doc, config.markEdge ?? (() => undefined));
|
|
101
97
|
const roleOf = config.roleOf ?? (() => undefined);
|
|
102
98
|
const defaultType = config.defaultType ?? 'paragraph';
|
|
@@ -135,7 +131,7 @@ export const docFacade = (Y, layers) => {
|
|
|
135
131
|
const base = { Y, doc, runsView, roles, roleOf, rendersContentOf };
|
|
136
132
|
const reads = { ...base, ...docReads(base) };
|
|
137
133
|
const shape = { ...reads, ...docCapability(reads) };
|
|
138
|
-
const { blockJSON, view, blockTypeOf, blockDataOf, docData, dataItemIds, childrenIds, positionOf, pathOf, ancestorsOf, slotOf, isVoid, isIsland, isLines, islandOf, insideIsland, isLayout, isLayoutItem, order, compare, next, previous, displayLength, contentItems, hasBlock, live } = reads;
|
|
134
|
+
const { blockJSON, view, blockTypeOf, blockDataOf, docData, dataItemIds, dataPreview, childrenIds, positionOf, pathOf, ancestorsOf, slotOf, isVoid, isIsland, isLines, islandOf, insideIsland, isLayout, isLayoutItem, order, compare, next, previous, displayLength, contentItems, hasBlock, live } = reads;
|
|
139
135
|
const { canPlace, fits, nestParent, canMerge, defaultChild } = shape;
|
|
140
136
|
const funnel = writeFunnel({ ...reads, BA, config });
|
|
141
137
|
const { write, apply } = funnel;
|
|
@@ -262,6 +258,7 @@ export const docFacade = (Y, layers) => {
|
|
|
262
258
|
blockDataOf: byRef(blockDataOf),
|
|
263
259
|
docData,
|
|
264
260
|
dataItemIds,
|
|
261
|
+
dataPreview,
|
|
265
262
|
/**
|
|
266
263
|
* Compact per-block attribution (`{createdBy, contributors,
|
|
267
264
|
* lastChangedBy}`), or `undefined` for unauthored/system blocks.
|
package/dist/crdt/index.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export type { YDoc, YUndoManager, YTransaction } from './engine-api.js';
|
|
|
62
62
|
export { type EdytorSync, type EdytorSyncPayload, type EdytorSyncCleanup, type IndexeddbSyncOptions, type WebsocketSync, type WebsocketSyncOptions, type ProviderStack, type PrefetchOptions, type PrefetchResult, type LastUpdatedOptions } from './providers/index.js';
|
|
63
63
|
export { SyncRefusedError } from './providers/room.js';
|
|
64
64
|
export { Awareness, type AwarenessDoc, type AwarenessStates, type AwarenessUpdate, type MetaClientState } from './protocols/awareness.js';
|
|
65
|
-
export { SchemaMismatchError, UndecodableUpdateError
|
|
65
|
+
export { SchemaMismatchError, UndecodableUpdateError } from './admission.js';
|
|
66
66
|
export { type DocumentAttribution, type AttributionActor, type ActorProfile, type AttributionController } from './attribution/index.js';
|
|
67
67
|
export { type ActorId, type BlockAttribution } from './attribution/index.js';
|
|
68
68
|
import type { EngineApi, YDoc } from './engine-api.js';
|
|
@@ -280,6 +280,12 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
280
280
|
blockDataOf: (id: string) => Record<string, unknown> | undefined;
|
|
281
281
|
docData: () => import("./doc/types.js").JsonObj;
|
|
282
282
|
dataItemIds: (target: import("./edytor-doc.js").DataTarget, path: readonly string[]) => string[];
|
|
283
|
+
dataPreview: (target: import("./edytor-doc.js").DataTarget, pending: readonly import("./data.js").DataPatch[]) => {
|
|
284
|
+
data: {
|
|
285
|
+
[x: string]: unknown;
|
|
286
|
+
};
|
|
287
|
+
ids: (path: readonly string[]) => string[];
|
|
288
|
+
} | null;
|
|
283
289
|
blockAttribution: (id: string) => import("./index.js").BlockAttribution | undefined;
|
|
284
290
|
crdtId: (id: string) => string | null;
|
|
285
291
|
resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
|
|
@@ -577,7 +583,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
577
583
|
off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
|
|
578
584
|
};
|
|
579
585
|
};
|
|
580
|
-
watchComments: (server: string, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
|
|
586
|
+
watchComments: (server: string | null, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
|
|
581
587
|
storeState: (idbPersistence: {
|
|
582
588
|
db: IDBDatabase | null;
|
|
583
589
|
name: string;
|
|
@@ -626,4 +632,4 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
626
632
|
};
|
|
627
633
|
export type Crdt = ReturnType<typeof bindCrdt>;
|
|
628
634
|
export type { EngineApi, EngineDoc, EngineNode, EngineTransaction, EngineItemRef, YNode, YItem } from './engine-api.js';
|
|
629
|
-
export {
|
|
635
|
+
export { DEFAULT_HISTORY_LIMIT } from './edytor-doc.js';
|
package/dist/crdt/index.js
CHANGED
|
@@ -101,7 +101,7 @@ export { Awareness } from './protocols/awareness.js';
|
|
|
101
101
|
// every content-entry path crosses). The gates themselves
|
|
102
102
|
// (`assertAdmission`, `inspectAdmission`, …) are diagnostics vocabulary:
|
|
103
103
|
// `edytor/protocol`.
|
|
104
|
-
export { SchemaMismatchError, UndecodableUpdateError
|
|
104
|
+
export { SchemaMismatchError, UndecodableUpdateError } from './admission.js';
|
|
105
105
|
// ── 5 · Attribution (read surface) ─────────────────────────────────────
|
|
106
106
|
//
|
|
107
107
|
// `document.attribution` hands back a `DocumentAttribution` — compact
|
|
@@ -145,4 +145,4 @@ export const bindCrdt = (Y) => {
|
|
|
145
145
|
// The facade's disposal error and the history's default depth belong
|
|
146
146
|
// to the document; the frame contract, message types and codecs are
|
|
147
147
|
// `edytor/protocol`.
|
|
148
|
-
export {
|
|
148
|
+
export { DEFAULT_HISTORY_LIMIT } from './edytor-doc.js';
|
|
@@ -149,4 +149,4 @@ export interface DocumentOperations extends DocumentWrites, DocumentReads {
|
|
|
149
149
|
/** Every write of `DocumentWrites`: what a view dispatches under the same names (`edytor.insertBlocks(…)`). */
|
|
150
150
|
export declare const DOCUMENT_WRITES: readonly ["insertBlocks", "moveBlocks", "nestBlock", "unNestBlock", "unNestBlocks", "liftOut", "wrapInLayout", "placeBeside", "splitBlock", "mergeBlocks", "mergeBackward", "mergeForward", "deleteBlock", "deleteBlocks", "setBlock", "setBlockType", "patchData", "duplicateBlock", "insertText", "deleteText", "formatRange", "clearMarks", "insertInline", "removeInline", "deleteRange", "replaceRange", "insertFlow"];
|
|
151
151
|
/** Every name of `DocumentOperations`, for the document's own members (`EdytorDocument`). */
|
|
152
|
-
export declare const DOCUMENT_OPERATIONS: readonly ["insertBlocks", "moveBlocks", "nestBlock", "unNestBlock", "unNestBlocks", "liftOut", "wrapInLayout", "placeBeside", "splitBlock", "mergeBlocks", "mergeBackward", "mergeForward", "deleteBlock", "deleteBlocks", "setBlock", "setBlockType", "patchData", "duplicateBlock", "insertText", "deleteText", "formatRange", "clearMarks", "insertInline", "removeInline", "deleteRange", "replaceRange", "insertFlow", "toJSON", "docData", "dataItemIds", "project", "blockJSON", "childrenIds", "parentOf", "ancestorsOf", "positionOf", "pathOf", "blockTypeOf", "blockDataOf", "blockText", "contentItems", "displayLength", "runs", "hasBlock", "isVisibleBlock", "listBlockIds", "blockAttribution", "isVoid", "isIsland", "isLines", "islandOf", "insideIsland", "isLayout", "isLayoutItem", "besideAt", "isTable", "isTableRow", "isTableCell", "tableOf", "tableColumns", "tableGrid", "order", "compare", "next", "previous", "canPlace", "canMerge", "fits", "nestParent", "landingOf", "anchorAt", "resolveAnchor", "prepare", "apply", "compose", "transact", "onChange", "version"];
|
|
152
|
+
export declare const DOCUMENT_OPERATIONS: readonly ["insertBlocks", "moveBlocks", "nestBlock", "unNestBlock", "unNestBlocks", "liftOut", "wrapInLayout", "placeBeside", "splitBlock", "mergeBlocks", "mergeBackward", "mergeForward", "deleteBlock", "deleteBlocks", "setBlock", "setBlockType", "patchData", "duplicateBlock", "insertText", "deleteText", "formatRange", "clearMarks", "insertInline", "removeInline", "deleteRange", "replaceRange", "insertFlow", "toJSON", "docData", "dataItemIds", "dataPreview", "project", "blockJSON", "childrenIds", "parentOf", "ancestorsOf", "positionOf", "pathOf", "blockTypeOf", "blockDataOf", "blockText", "contentItems", "displayLength", "runs", "hasBlock", "isVisibleBlock", "listBlockIds", "blockAttribution", "isVoid", "isIsland", "isLines", "islandOf", "insideIsland", "isLayout", "isLayoutItem", "besideAt", "isTable", "isTableRow", "isTableCell", "tableOf", "tableColumns", "tableGrid", "order", "compare", "next", "previous", "canPlace", "canMerge", "fits", "nestParent", "landingOf", "anchorAt", "resolveAnchor", "prepare", "apply", "compose", "transact", "onChange", "version"];
|
package/dist/crdt/operations.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties: the deep proxy behind `block.data`, `atom.data`,
|
|
3
|
+
* `edytor.data` and `document.data` (SyncedStore's feel, one small module).
|
|
4
|
+
* It is sugar over the one write path: every mutation is a data patch
|
|
5
|
+
* handed to `write`, which is the `patchData` operation (dispatched on a
|
|
6
|
+
* view, raw on a bare document).
|
|
7
|
+
*
|
|
8
|
+
* A read goes to `read()` every time (the live source), so a reactive
|
|
9
|
+
* reader of `block.data.title` re-runs when anyone changes it, and a key a
|
|
10
|
+
* peer deletes is gone. Plain objects read as nested proxies, arrays as
|
|
11
|
+
* array proxies, everything else as the raw value; a proxy is cached per
|
|
12
|
+
* path, so its identity is stable. An object or array held in an array
|
|
13
|
+
* item is that item's (its path names the item by id, from `ids`): it
|
|
14
|
+
* stays on its item wherever peers move it, so `{#each list as item (item)}`
|
|
15
|
+
* keeps a row on its item; once the item is removed, its writes are
|
|
16
|
+
* refused. A key is a path segment as `keySegment` writes it.
|
|
17
|
+
*
|
|
18
|
+
* Writes, each the patch of only what it changes (per-leaf storage, so
|
|
19
|
+
* concurrent edits of other keys and items merge): `obj.key = v`,
|
|
20
|
+
* `arr[i] = v` and `delete obj.key` patch that path; `push`, `pop`,
|
|
21
|
+
* `shift`, `unshift`, `splice` and `length` are one `splice` (the items
|
|
22
|
+
* kept keep their ids), `sort` and `reverse` one `order` (the items move),
|
|
23
|
+
* `fill` and `copyWithin` writes of the items they change. Assigning a
|
|
24
|
+
* value equal to the one there writes nothing. `JSON.stringify` and
|
|
25
|
+
* `$state.snapshot` read plain JSON through it.
|
|
26
|
+
*/
|
|
27
|
+
import { type DataPatch } from './data.js';
|
|
28
|
+
type Json = Record<string, unknown>;
|
|
29
|
+
export declare const propsProxy: <T extends object = Json>(read: () => Json, write: (ops: DataPatch[]) => void,
|
|
30
|
+
/** The ids of the items of the array at a path (`facade.dataItemIds`). */
|
|
31
|
+
ids?: (path: readonly string[]) => string[]) => T;
|
|
32
|
+
export {};
|