edytor 0.1.0-next.38 → 0.1.0-next.41
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 +2 -2
- package/dist/block/block.svelte.d.ts +1 -24
- package/dist/block/block.svelte.js +21 -37
- package/dist/block/block.utils.d.ts +9 -19
- package/dist/block/block.utils.js +4 -15
- package/dist/clipboard/createClipboardFragment.js +1 -1
- package/dist/clipboard/htmlFlow.d.ts +2 -2
- package/dist/clipboard/htmlFlow.js +2 -2
- package/dist/clipboard/serializeClipboardFragment.js +1 -1
- package/dist/cloudflare/DocumentRoom.d.ts +3 -11
- package/dist/cloudflare/DocumentRoom.js +6 -12
- package/dist/cloudflare/history.d.ts +6 -6
- package/dist/cloudflare/history.js +4 -3
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/cloudflare/locks.d.ts +2 -2
- package/dist/cloudflare/move.d.ts +1 -11
- package/dist/cloudflare/move.js +0 -5
- package/dist/cloudflare/room/access.js +2 -2
- package/dist/cloudflare/room/admission.js +7 -7
- package/dist/cloudflare/room/comments.d.ts +1 -1
- package/dist/cloudflare/room/comments.js +1 -1
- package/dist/cloudflare/room/context.d.ts +1 -4
- package/dist/cloudflare/room/forged.d.ts +3 -3
- package/dist/cloudflare/room/forged.js +6 -6
- package/dist/cloudflare/room/storage.js +1 -1
- package/dist/cloudflare/room/updates.d.ts +2 -2
- package/dist/cloudflare/room/updates.js +3 -3
- package/dist/cloudflare/routeDocumentSocket.js +3 -3
- package/dist/collaboration/RemoteSelections.svelte +1 -1
- package/dist/collaboration/awarenessSelection.d.ts +4 -4
- package/dist/collaboration/awarenessSelection.js +2 -2
- package/dist/collaboration/documentSync.d.ts +1 -1
- package/dist/collaboration/remoteSelection.d.ts +1 -1
- package/dist/collaboration/remoteSelection.js +3 -3
- package/dist/components/Block.svelte +6 -6
- package/dist/components/Content.svelte +3 -3
- package/dist/components/Content.svelte.d.ts +1 -1
- package/dist/components/Edytor.svelte +10 -17
- package/dist/components/Edytor.svelte.d.ts +0 -4
- package/dist/components/InlineBlock.svelte +1 -1
- package/dist/components/Mark.svelte +2 -2
- package/dist/components/SuggestionRanges.svelte +1 -1
- package/dist/components/Text.svelte +5 -5
- package/dist/crdt/admission.d.ts +1 -1
- package/dist/crdt/admission.js +1 -1
- package/dist/crdt/anchors.d.ts +3 -3
- package/dist/crdt/attribution/attribution.d.ts +6 -6
- package/dist/crdt/attribution/attribution.js +3 -3
- package/dist/crdt/attribution/block.d.ts +7 -7
- package/dist/crdt/attribution/block.js +3 -3
- package/dist/crdt/attribution/index.d.ts +2 -2
- package/dist/crdt/attribution/index.js +2 -2
- package/dist/crdt/data.d.ts +1 -1
- package/dist/crdt/data.js +5 -5
- package/dist/crdt/doc/anchors.js +1 -1
- package/dist/crdt/doc/capability.d.ts +5 -5
- package/dist/crdt/doc/capability.js +16 -16
- package/dist/crdt/doc/delete.js +1 -1
- package/dist/crdt/doc/events.js +3 -3
- package/dist/crdt/doc/funnel.js +6 -6
- package/dist/crdt/doc/gate.d.ts +2 -2
- package/dist/crdt/doc/history.js +10 -10
- package/dist/crdt/doc/layout.js +4 -4
- package/dist/crdt/doc/meta.js +8 -8
- package/dist/crdt/doc/moves.js +9 -9
- package/dist/crdt/doc/plan.d.ts +1 -1
- package/dist/crdt/doc/plan.js +1 -1
- package/dist/crdt/doc/reads.js +8 -8
- package/dist/crdt/doc/seed.d.ts +2 -2
- package/dist/crdt/doc/seed.js +5 -5
- package/dist/crdt/doc/split-merge.js +12 -12
- package/dist/crdt/doc/steps.js +18 -18
- package/dist/crdt/document.d.ts +6 -6
- package/dist/crdt/document.js +8 -8
- package/dist/crdt/edytor-doc.js +17 -17
- package/dist/crdt/engine.js +4 -4
- package/dist/crdt/flow.d.ts +10 -10
- package/dist/crdt/flow.js +6 -6
- package/dist/crdt/incarnations.d.ts +8 -8
- package/dist/crdt/incarnations.js +3 -3
- package/dist/crdt/index.d.ts +2 -5
- package/dist/crdt/index.js +6 -6
- package/dist/crdt/migration/generation.d.ts +2 -2
- package/dist/crdt/migration/legacy-schema.d.ts +1 -1
- package/dist/crdt/migration/migrate.d.ts +1 -12
- package/dist/crdt/migration/migrate.js +9 -9
- package/dist/crdt/nodes.d.ts +4 -4
- package/dist/crdt/placement/display.d.ts +8 -8
- package/dist/crdt/placement/display.js +12 -12
- package/dist/crdt/placement/model.d.ts +5 -5
- package/dist/crdt/placement/model.js +15 -15
- package/dist/crdt/placement/rank.d.ts +4 -4
- package/dist/crdt/placement/rank.js +8 -8
- package/dist/crdt/placement/resolve.js +2 -2
- package/dist/crdt/placement/source.d.ts +4 -4
- package/dist/crdt/placement/source.js +4 -4
- package/dist/crdt/protocols/awareness.js +1 -1
- package/dist/crdt/protocols/comments.d.ts +1 -1
- package/dist/crdt/protocols/comments.js +1 -1
- package/dist/crdt/protocols/envelope.d.ts +1 -1
- package/dist/crdt/protocols/envelope.js +1 -1
- package/dist/crdt/protocols/sync.d.ts +1 -1
- package/dist/crdt/protocols/sync.js +3 -3
- package/dist/crdt/providers/container.d.ts +2 -2
- package/dist/crdt/providers/container.js +3 -3
- package/dist/crdt/providers/index.d.ts +1 -6
- package/dist/crdt/providers/index.js +18 -14
- package/dist/crdt/providers/indexeddb.js +8 -8
- package/dist/crdt/providers/room.d.ts +2 -2
- package/dist/crdt/providers/room.js +7 -7
- package/dist/crdt/providers/websocket.js +9 -9
- package/dist/crdt/purge.d.ts +1 -1
- package/dist/crdt/purge.js +3 -3
- package/dist/crdt/rand.d.ts +3 -3
- package/dist/crdt/rand.js +3 -3
- package/dist/crdt/rangeDelete.d.ts +2 -2
- package/dist/crdt/rangeDelete.js +2 -2
- package/dist/crdt/restore.d.ts +2 -2
- package/dist/crdt/schema.d.ts +7 -7
- package/dist/crdt/schema.js +8 -8
- package/dist/crdt/semantics.d.ts +1 -1
- package/dist/crdt/semantics.js +1 -1
- package/dist/crdt/storage.d.ts +1 -1
- package/dist/crdt/storage.js +1 -1
- package/dist/crdt/structs.d.ts +1 -1
- package/dist/crdt/structs.js +1 -1
- package/dist/crdt/text/delete-index.d.ts +3 -3
- package/dist/crdt/text/delete-index.js +3 -3
- package/dist/crdt/text/deletes.d.ts +5 -5
- package/dist/crdt/text/deletes.js +8 -8
- package/dist/crdt/text/index/anchored.js +1 -1
- package/dist/crdt/text/index/checks.js +2 -2
- package/dist/crdt/text/index/claims.d.ts +1 -1
- package/dist/crdt/text/index/claims.js +1 -1
- package/dist/crdt/text/index/fold.js +8 -8
- package/dist/crdt/text/index/placement.d.ts +1 -1
- package/dist/crdt/text/index/placement.js +13 -13
- package/dist/crdt/text/index/records.js +4 -4
- package/dist/crdt/text/index/report.js +6 -6
- package/dist/crdt/text/index/shared.d.ts +1 -1
- package/dist/crdt/text/index/shared.js +2 -2
- package/dist/crdt/text/index/state.d.ts +3 -3
- package/dist/crdt/text/index/state.js +3 -3
- package/dist/crdt/text/index/streams.d.ts +1 -1
- package/dist/crdt/text/index/streams.js +3 -3
- package/dist/crdt/text/marks.d.ts +1 -1
- package/dist/crdt/text/marks.js +1 -1
- package/dist/crdt/text/model.d.ts +4 -4
- package/dist/crdt/text/model.js +11 -11
- package/dist/crdt/text/ranges.d.ts +2 -2
- package/dist/crdt/text/ranges.js +2 -2
- package/dist/crdt/text/rows.d.ts +1 -1
- package/dist/crdt/text/runs.d.ts +4 -4
- package/dist/crdt/text/runs.js +1 -1
- package/dist/crdt/vendor/yjs/API-NOTES.md +1 -1
- package/dist/crdt/vendor/yjs/UPSTREAM.md +79 -79
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +3 -3
- package/dist/crdt/vendor/yjs/dts/utils/RangeCursor.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/utils/UndoManager.d.ts +6 -6
- package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +1 -1
- package/dist/crdt/vendor/yjs/src/index.js +2 -2
- package/dist/crdt/vendor/yjs/src/structs/Item.js +7 -7
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +3 -3
- package/dist/crdt/vendor/yjs/src/utils/RangeCursor.js +5 -5
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +3 -3
- package/dist/crdt/vendor/yjs/src/utils/UndoManager.js +14 -14
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +6 -6
- package/dist/crdt/vendor/yjs/src/utils/marks.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/renderer-helpers.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +7 -7
- package/dist/crdt/vendor/yjs/src/ynode.js +15 -15
- package/dist/edytor.svelte.d.ts +1 -3
- package/dist/edytor.svelte.js +42 -20
- package/dist/events/beforeInputCommands.js +5 -5
- package/dist/events/beforeInputDeleteCommands.js +5 -5
- package/dist/events/nativeInteractiveControl.d.ts +1 -1
- package/dist/events/nativeInteractiveControl.js +1 -1
- package/dist/events/onBeforeInput.js +4 -4
- package/dist/events/onFocus.js +1 -1
- package/dist/events/onInput.d.ts +1 -1
- package/dist/events/onInput.js +3 -3
- package/dist/events/onKeyDown.js +1 -1
- package/dist/events/onPaste.js +1 -1
- package/dist/kinds.d.ts +6 -6
- package/dist/kinds.js +9 -9
- package/dist/plugins/arrowMove/arrowMove.js +1 -1
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +1 -1
- package/dist/plugins/blockHandles/BlockHandles.svelte +3 -3
- package/dist/plugins/blockHandles/blockHandlesPlugin.js +1 -1
- package/dist/plugins/code/CodePlugin.svelte +1 -1
- package/dist/plugins/code/languages.d.ts +1 -1
- package/dist/plugins/code/languages.js +1 -1
- package/dist/plugins/columns/ColumnsPlugin.svelte +4 -4
- package/dist/plugins/columns/columns.css +3 -3
- package/dist/plugins/columns/resize.svelte.d.ts +2 -2
- package/dist/plugins/columns/resize.svelte.js +2 -2
- package/dist/plugins/columns/stacking.d.ts +1 -1
- package/dist/plugins/columns/stacking.js +1 -1
- package/dist/plugins/comments/CommentsSidebar.svelte +1 -1
- package/dist/plugins/find/FindHighlights.svelte +1 -1
- package/dist/plugins/find/findPlugin.js +1 -1
- package/dist/plugins/image/ImageEmpty.svelte +1 -1
- package/dist/plugins/image/ImagePlugin.svelte +1 -1
- package/dist/plugins/image/controls.svelte.d.ts +1 -1
- package/dist/plugins/image/controls.svelte.js +1 -1
- package/dist/plugins/richtext/RichTextPlugin.svelte +2 -2
- package/dist/plugins/richtext/richTextOperations.js +1 -1
- package/dist/plugins/slashMenu/slashMenuPlugin.js +1 -1
- package/dist/plugins/suggestions/SuggestionBars.svelte +1 -1
- package/dist/plugins/toolbar/toolbarPlugin.js +1 -1
- package/dist/selection/replaceSelection.d.ts +13 -13
- package/dist/selection/replaceSelection.js +15 -15
- package/dist/selection/selection.svelte.d.ts +1 -1
- package/dist/selection/selection.svelte.js +17 -17
- package/dist/selection/selection.utils.d.ts +1 -1
- package/dist/selection/selection.utils.js +2 -2
- package/dist/selection/visibility.d.ts +4 -4
- package/dist/selection/visibility.js +5 -5
- package/dist/session/attempt.d.ts +4 -4
- package/dist/session/attempt.js +1 -1
- package/dist/session/bindings.d.ts +2 -2
- package/dist/session/bindings.js +8 -8
- package/dist/session/commands.d.ts +2 -2
- package/dist/session/commands.js +3 -3
- package/dist/session/composition.svelte.d.ts +7 -7
- package/dist/session/composition.svelte.js +12 -12
- package/dist/session/editing/text.d.ts +6 -6
- package/dist/session/editing/text.js +1 -1
- package/dist/session/handles.d.ts +2 -2
- package/dist/session/handles.js +2 -2
- package/dist/session/history.d.ts +4 -4
- package/dist/session/history.js +1 -1
- package/dist/session/keymap.js +1 -1
- package/dist/session/moves.d.ts +1 -1
- package/dist/session/moves.js +7 -7
- package/dist/session/navigation.d.ts +4 -4
- package/dist/session/navigation.js +7 -7
- package/dist/session/selection.d.ts +2 -2
- package/dist/session/selection.js +1 -1
- package/dist/surface/attributes.d.ts +3 -4
- package/dist/surface/attributes.js +2 -2
- package/dist/surface/cells.d.ts +1 -1
- package/dist/surface/cells.js +7 -8
- package/dist/surface/observer.svelte.d.ts +2 -2
- package/dist/surface/observer.svelte.js +10 -11
- package/dist/surface/overlay.d.ts +2 -2
- package/dist/surface/overlay.js +2 -2
- package/dist/surface/pin.svelte.d.ts +3 -3
- package/dist/surface/pin.svelte.js +2 -2
- package/dist/surface/popups.svelte.js +1 -1
- package/dist/surface/projector.svelte.d.ts +5 -5
- package/dist/surface/projector.svelte.js +17 -17
- package/dist/text/text.svelte.d.ts +0 -6
- package/dist/text/text.svelte.js +12 -6
- package/dist/text/text.utils.js +1 -1
- package/dist/themes/notion.css +2 -2
- package/dist/utils/diffText.d.ts +1 -1
- package/dist/utils/json.d.ts +3 -3
- package/dist/utils/json.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable editor with an API to build any kind of collaborative rich text editor.
|
|
18
18
|
|
|
19
|
-
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.
|
|
19
|
+
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.41`, `edytor@next` on npm) and not ready for production; the API changes between releases without a compatibility layer. The untagged `edytor@0.0.11` on npm predates the current API. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
@@ -108,7 +108,7 @@ The [documentation site](https://edytor.dev/docs) is the single source for the A
|
|
|
108
108
|
|
|
109
109
|
## Contributing
|
|
110
110
|
|
|
111
|
-
`CONTRIBUTING.md` lists the test lanes, what CI runs, and the pull request checklist; `AGENTS.md` describes the architecture (one owner per fact) and where to fix what. The docs live in `site/content/docs`; a change to public behavior updates them in the same commit.
|
|
111
|
+
`CONTRIBUTING.md` lists the test lanes, what CI runs, and the pull request checklist; `AGENTS.md` describes the architecture (one owner per fact) and where to fix what, and `docs/agents/` holds the rules of each area. The docs live in `site/content/docs`; a change to public behavior updates them in the same commit.
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
114
|
pnpm install
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Text } from '../text/text.svelte.js';
|
|
2
2
|
import type { Edytor } from '../edytor.svelte.js';
|
|
3
|
-
import type { JSONBlock,
|
|
3
|
+
import type { JSONBlock, JSONInlineBlock } from '../utils/json.js';
|
|
4
4
|
import { type BlockOperations } from './block.utils.js';
|
|
5
5
|
import type { BlockDefinition } from '../plugins.js';
|
|
6
6
|
import { InlineBlock } from './inlineBlock.svelte.js';
|
|
@@ -64,13 +64,6 @@ export declare class Block {
|
|
|
64
64
|
get path(): number[];
|
|
65
65
|
/** The block is visible in the document (a dead handle answers false). */
|
|
66
66
|
get isInTree(): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated `edytor.suggestions` with `{ end: block.id }`. The content of
|
|
69
|
-
* this block's latest `end` suggestion, as parts (a text's runs, or an
|
|
70
|
-
* atom); setting it replaces this block's `end` suggestions, `null` drops them.
|
|
71
|
-
*/
|
|
72
|
-
get suggestions(): (JSONText[] | JSONInlineBlock)[] | null;
|
|
73
|
-
set suggestions(value: (JSONText[] | JSONInlineBlock)[] | null);
|
|
74
67
|
get nextBlock(): Block | null;
|
|
75
68
|
get previousBlock(): Block | null;
|
|
76
69
|
get closestPreviousBlock(): Block | null;
|
|
@@ -177,10 +170,6 @@ export declare class Block {
|
|
|
177
170
|
}) => Text | null | undefined;
|
|
178
171
|
normalizeContent: () => void;
|
|
179
172
|
normalizeChildren: () => void;
|
|
180
|
-
/** @deprecated `edytor.suggestions.add({ end: block.id }, …)`. */
|
|
181
|
-
suggestText: (payload: BlockOperations["suggestText"]) => void;
|
|
182
|
-
/** @deprecated `suggestion.accept()`. */
|
|
183
|
-
acceptSuggestedText: () => void;
|
|
184
173
|
deleteContentAtRange: (payload: {
|
|
185
174
|
start: [number, number];
|
|
186
175
|
end: [number, number];
|
|
@@ -197,16 +186,4 @@ export declare class Block {
|
|
|
197
186
|
text: Text;
|
|
198
187
|
offset: number;
|
|
199
188
|
} | null;
|
|
200
|
-
/**
|
|
201
|
-
* Insert children at `index`: a JSON spec is created (its id kept, minted
|
|
202
|
-
* when missing); a block handle moves there with its identity.
|
|
203
|
-
*/
|
|
204
|
-
insertChildren: (index: number, blocks: (JSONBlock | Block)[]) => void;
|
|
205
|
-
/** Delete `length` visible children from `index`, each with its subtree (a document delete). */
|
|
206
|
-
deleteChildren: (index: number, length?: number) => void;
|
|
207
|
-
/**
|
|
208
|
-
* Insert content before part `index` (a text segment or an inline atom):
|
|
209
|
-
* each entry is a text's runs or an atom, as JSON.
|
|
210
|
-
*/
|
|
211
|
-
insertParts: (index: number, parts: (JSONText[] | JSONInlineBlock)[]) => void;
|
|
212
189
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Text } from '../text/text.svelte.js';
|
|
2
|
-
import { batch, removeInlineBlock, addChildBlock, insertBlockAfter, insertBlockBefore, mergeBlockBackward, mergeBlockForward, nestBlock, removeBlock, setBlock, splitBlock, prepareSplit, duplicateBlock, prepareDuplicate, prepareSet, prepareMove, prepareMoves, prepareInsertAfter, prepareInsertBefore, prepareRemove, prepareMergeBackward, prepareMergeForward, prepareUnNest, prepareNest, prepareRemoveInline, preparePatch, patchData, prepareDeleteRange, addChildBlocks, pushContentIntoBlock, unNestBlock, moveBlock, moveBlocks, normalizeContent, addInlineBlock, textAfterAtom, blockOf,
|
|
2
|
+
import { batch, removeInlineBlock, addChildBlock, insertBlockAfter, insertBlockBefore, mergeBlockBackward, mergeBlockForward, nestBlock, removeBlock, setBlock, splitBlock, prepareSplit, duplicateBlock, prepareDuplicate, prepareSet, prepareMove, prepareMoves, prepareInsertAfter, prepareInsertBefore, prepareRemove, prepareMergeBackward, prepareMergeForward, prepareUnNest, prepareNest, prepareRemoveInline, preparePatch, patchData, prepareDeleteRange, addChildBlocks, pushContentIntoBlock, unNestBlock, moveBlock, moveBlocks, normalizeContent, addInlineBlock, textAfterAtom, blockOf, deleteContentAtRange, normalizeChildren } from './block.utils.js';
|
|
3
3
|
import { jsonBlockToSpec, jsonContentToItems } from '../utils/json.js';
|
|
4
4
|
import { InlineBlock } from './inlineBlock.svelte.js';
|
|
5
5
|
import { revealed } from '../selection/replaceSelection.js';
|
|
@@ -194,32 +194,6 @@ export class Block {
|
|
|
194
194
|
this.#track();
|
|
195
195
|
return this.edytor.facade.isVisibleBlock(this.id);
|
|
196
196
|
}
|
|
197
|
-
/**
|
|
198
|
-
* @deprecated `edytor.suggestions` with `{ end: block.id }`. The content of
|
|
199
|
-
* this block's latest `end` suggestion, as parts (a text's runs, or an
|
|
200
|
-
* atom); setting it replaces this block's `end` suggestions, `null` drops them.
|
|
201
|
-
*/
|
|
202
|
-
get suggestions() {
|
|
203
|
-
const content = this.edytor.suggestions?.at(this.id).end.at(-1)?.content[0]?.content;
|
|
204
|
-
if (!content?.length)
|
|
205
|
-
return null;
|
|
206
|
-
const parts = [];
|
|
207
|
-
for (const part of content)
|
|
208
|
-
if ('type' in part)
|
|
209
|
-
parts.push(part);
|
|
210
|
-
else if (Array.isArray(parts.at(-1)))
|
|
211
|
-
parts.at(-1).push(part);
|
|
212
|
-
else
|
|
213
|
-
parts.push([part]);
|
|
214
|
-
return parts;
|
|
215
|
-
}
|
|
216
|
-
set suggestions(value) {
|
|
217
|
-
const { suggestions } = this.edytor;
|
|
218
|
-
for (const suggestion of suggestions.at(this.id).end)
|
|
219
|
-
suggestion.discard();
|
|
220
|
-
if (value)
|
|
221
|
-
suggestions.add({ end: this.id }, [{ type: this.type, content: value.flat() }]);
|
|
222
|
-
}
|
|
223
197
|
get nextBlock() {
|
|
224
198
|
return this.parent ? this.parent.children[this.index + 1] : null;
|
|
225
199
|
}
|
|
@@ -350,10 +324,6 @@ export class Block {
|
|
|
350
324
|
};
|
|
351
325
|
normalizeContent = batch('normalizeContent', normalizeContent);
|
|
352
326
|
normalizeChildren = batch('normalizeChildren', normalizeChildren);
|
|
353
|
-
/** @deprecated `edytor.suggestions.add({ end: block.id }, …)`. */
|
|
354
|
-
suggestText = (payload) => suggestText.call(this, payload);
|
|
355
|
-
/** @deprecated `suggestion.accept()`. */
|
|
356
|
-
acceptSuggestedText = () => acceptSuggestedText.call(this);
|
|
357
327
|
deleteContentAtRange = batch('deleteContentAtRange', deleteContentAtRange, prepareDeleteRange);
|
|
358
328
|
/** Mark an element inside the block's markup as non-editable chrome (a header, a caption bar). */
|
|
359
329
|
void = voidChrome;
|
|
@@ -382,12 +352,17 @@ export class Block {
|
|
|
382
352
|
}
|
|
383
353
|
return hit;
|
|
384
354
|
};
|
|
385
|
-
// ── JSON insertion (
|
|
355
|
+
// ── JSON insertion (specs are data; `new Block({block})` is gone) ──
|
|
386
356
|
/**
|
|
387
357
|
* Insert children at `index`: a JSON spec is created (its id kept, minted
|
|
388
|
-
* when missing); a block handle moves there with its identity.
|
|
358
|
+
* when missing); a block handle moves there with its identity. A raw
|
|
359
|
+
* write for the editor's own commands: nothing on a view whose dispatcher
|
|
360
|
+
* refuses writes (readonly, a read-only document).
|
|
361
|
+
* @internal
|
|
389
362
|
*/
|
|
390
363
|
insertChildren = (index, blocks) => {
|
|
364
|
+
if (!this.edytor.dispatcher.permits())
|
|
365
|
+
return;
|
|
391
366
|
const { facade } = this.edytor;
|
|
392
367
|
const parent = this.isRoot ? null : this.id;
|
|
393
368
|
blocks.forEach((block, k) => {
|
|
@@ -397,17 +372,26 @@ export class Block {
|
|
|
397
372
|
facade.insertBlock({ parent, index: index + k }, jsonBlockToSpec(block));
|
|
398
373
|
});
|
|
399
374
|
};
|
|
400
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* Delete `length` visible children from `index`, each with its subtree (a
|
|
377
|
+
* document delete). Raw, as `insertChildren`.
|
|
378
|
+
* @internal
|
|
379
|
+
*/
|
|
401
380
|
deleteChildren = (index, length = 1) => {
|
|
381
|
+
if (!this.edytor.dispatcher.permits())
|
|
382
|
+
return;
|
|
402
383
|
const ids = this.edytor.facade.childrenIds(this.isRoot ? null : this.id);
|
|
403
384
|
for (const id of ids.slice(index, index + length).reverse())
|
|
404
385
|
this.edytor.facade.block(id).delete({ keepChildren: false });
|
|
405
386
|
};
|
|
406
387
|
/**
|
|
407
388
|
* Insert content before part `index` (a text segment or an inline atom):
|
|
408
|
-
* each entry is a text's runs or an atom, as JSON.
|
|
389
|
+
* each entry is a text's runs or an atom, as JSON. Raw, as `insertChildren`.
|
|
390
|
+
* @internal
|
|
409
391
|
*/
|
|
410
392
|
insertParts = (index, parts) => {
|
|
393
|
+
if (!this.edytor.dispatcher.permits())
|
|
394
|
+
return;
|
|
411
395
|
const model = this.model;
|
|
412
396
|
if (!model)
|
|
413
397
|
return;
|
|
@@ -425,9 +409,9 @@ export class Block {
|
|
|
425
409
|
/** The declared view state (`open` on a `details`) the block's last element held. */
|
|
426
410
|
#viewState = [];
|
|
427
411
|
/**
|
|
428
|
-
* Register the element the core rendered for this block
|
|
412
|
+
* Register the element the core rendered for this block and run the
|
|
429
413
|
* attach hooks. A re-rendered block (moved, re-parented) keeps its declared
|
|
430
|
-
* view state
|
|
414
|
+
* view state: an open toggle stays open.
|
|
431
415
|
* @internal
|
|
432
416
|
*/
|
|
433
417
|
attach = (node) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* View-side command adapter for block operations
|
|
2
|
+
* View-side command adapter for block operations: each delegates to one document operation.
|
|
3
3
|
*
|
|
4
4
|
* These functions are the `BlockOperations` layer bound onto `Block` via
|
|
5
5
|
* `batch()`, which dispatches each call as a command (admission, plugin
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* sibling lookup for `nestBlock`), the plan of an operation
|
|
9
9
|
* that is one document op (`prepare*`) and its normalization requests.
|
|
10
10
|
*
|
|
11
|
-
* OPERATIONS READ AND WRITE ONLY THE DOCUMENT
|
|
12
|
-
* handles whose getters read the index
|
|
11
|
+
* OPERATIONS READ AND WRITE ONLY THE DOCUMENT: `Block`/`Text` are id-only
|
|
12
|
+
* handles whose getters read the index, so what a caller needs after the
|
|
13
13
|
* write (the new block, the text after an inserted atom, the caret a range op
|
|
14
14
|
* decided) is the op's document result as a handle (`batch`'s `resolve`) —
|
|
15
15
|
* inside an outer transaction too.
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
* as "refused" — no view-side re-checks of the rules the document already
|
|
20
20
|
* enforces (island sealing, void/island destinations, own-subtree moves,
|
|
21
21
|
* merges across island boundaries; see `edytor-doc.ts` `canPlace` and
|
|
22
|
-
* `canMerge
|
|
22
|
+
* `canMerge`). Removing a view-side semantic guard must never
|
|
23
23
|
* change document behavior — if a rule matters here it belongs in the
|
|
24
24
|
* facade, not in this file.
|
|
25
25
|
*
|
|
26
26
|
* Content preparation produces `BlockSpec`/`ContentItem` DIRECTLY from
|
|
27
27
|
* JSON (`jsonBlockToSpec`/`jsonContentToItems` in `utils/json.ts`): specs are
|
|
28
|
-
* data (
|
|
28
|
+
* data (`new Block({block})` is gone). The live-content invariant
|
|
29
29
|
* (text-first/text-last, no adjacent same-kind parts) is derived by the
|
|
30
30
|
* document's projection on read, so stored content needs no
|
|
31
31
|
* pre-normalization.
|
|
@@ -36,7 +36,7 @@ import type { Flow, FlowTarget } from '../crdt/flow.js';
|
|
|
36
36
|
import type { Plan, Prepared } from '../crdt/edytor-doc.js';
|
|
37
37
|
import type { DataPatch } from '../crdt/data.js';
|
|
38
38
|
import type { ResolvedAt } from '../session/suggestions.svelte.js';
|
|
39
|
-
import { type JSONBlock, type JSONInlineBlock
|
|
39
|
+
import { type JSONBlock, type JSONInlineBlock } from '../utils/json.js';
|
|
40
40
|
import { InlineBlock } from './inlineBlock.svelte.js';
|
|
41
41
|
/** A move beside `target`, to its `side` (`prepare.placeBeside`, `layout.place-beside`). */
|
|
42
42
|
export type BlockBeside = {
|
|
@@ -108,12 +108,6 @@ export type BlockOperations = {
|
|
|
108
108
|
};
|
|
109
109
|
normalizeContent: {};
|
|
110
110
|
normalizeChildren: {};
|
|
111
|
-
/** @deprecated `edytor.suggestions.add({ end: block.id }, …)`. */
|
|
112
|
-
suggestText: {
|
|
113
|
-
value: (JSONText | JSONInlineBlock)[] | string | null;
|
|
114
|
-
};
|
|
115
|
-
/** @deprecated `suggestion.accept()`; the command hooks see is `acceptSuggestion`. */
|
|
116
|
-
acceptSuggestedText: {};
|
|
117
111
|
/** A suggestion placed in the document (`edytor.suggestions`, `suggestion.accept()`). */
|
|
118
112
|
acceptSuggestion: {
|
|
119
113
|
suggestion: {
|
|
@@ -292,7 +286,7 @@ export declare function prepareMove(this: Block, { path }: BlockOperations['move
|
|
|
292
286
|
export declare function moveBlock(this: Block, payload: BlockOperations['moveBlock'], plan?: Prepared): Block | null;
|
|
293
287
|
/**
|
|
294
288
|
* Grouped move — the operation-layer counterpart of `moveBlock` for
|
|
295
|
-
* drags/multi-moves
|
|
289
|
+
* drags/multi-moves. `path` is the same view-tree address shape:
|
|
296
290
|
* the prefix resolves the destination PARENT block, the last element is
|
|
297
291
|
* the FINAL index — already discounted for the moved members by the
|
|
298
292
|
* caller (the `facade.moveBlocks` contract, which counts the
|
|
@@ -329,20 +323,16 @@ export declare function patchData(this: Block, payload: BlockOperations['patchDa
|
|
|
329
323
|
* ({@link textAfterAtom}), where the caret's pending marks follow.
|
|
330
324
|
*/
|
|
331
325
|
export declare function addInlineBlock(this: Block, { index, block, text }: BlockOperations['addInlineBlock']): string;
|
|
332
|
-
/** The text after atom `atom` of this block; the caret's pending marks follow it there
|
|
326
|
+
/** The text after atom `atom` of this block; the caret's pending marks follow it there. */
|
|
333
327
|
export declare function textAfterAtom(this: Block, atom: string | undefined): Text | null | undefined;
|
|
334
328
|
/**
|
|
335
329
|
* Normalization runs at the end of the command's transaction
|
|
336
330
|
* (`Dispatcher.drain`): a normalizer reads handles over the index; when a
|
|
337
331
|
* plugin hook answers work, the work runs in the same transaction and the
|
|
338
|
-
* block is requested again (bounded by the dispatcher's pass limit
|
|
332
|
+
* block is requested again (bounded by the dispatcher's pass limit).
|
|
339
333
|
*/
|
|
340
334
|
export declare function normalizeContent(this: Block): void;
|
|
341
335
|
export declare function normalizeChildren(this: Block): void;
|
|
342
|
-
/** @deprecated A thin wrapper over an `{ end: block.id }` suggestion (`edytor.suggestions`). */
|
|
343
|
-
export declare function suggestText(this: Block, { value }: BlockOperations['suggestText']): void;
|
|
344
|
-
/** @deprecated Accepts this block's latest `{ end }` suggestion (`suggestion.accept()`). */
|
|
345
|
-
export declare function acceptSuggestedText(this: Block): void;
|
|
346
336
|
export declare function prepareDeleteRange(this: Block, { start: [startIndex, startOffset], end: [endIndex, endOffset] }: {
|
|
347
337
|
start: number[];
|
|
348
338
|
end: number[];
|
|
@@ -96,7 +96,7 @@ export function duplicateBlock(_ = {}, plan = prepareDuplicate.call(this)) {
|
|
|
96
96
|
export function prepareSplit({ index, text }) {
|
|
97
97
|
if (!text || !this.parent || !this.model)
|
|
98
98
|
return REFUSED;
|
|
99
|
-
//
|
|
99
|
+
// The sibling takes its parent's default child type and no data — a
|
|
100
100
|
// list-like kind (`continues`) keeps its own, with its first preset's data.
|
|
101
101
|
const { continues, presets } = this.definition;
|
|
102
102
|
const tail = continues
|
|
@@ -183,7 +183,7 @@ export function moveBlock(payload, plan = prepareMove.call(this, payload)) {
|
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Grouped move — the operation-layer counterpart of `moveBlock` for
|
|
186
|
-
* drags/multi-moves
|
|
186
|
+
* drags/multi-moves. `path` is the same view-tree address shape:
|
|
187
187
|
* the prefix resolves the destination PARENT block, the last element is
|
|
188
188
|
* the FINAL index — already discounted for the moved members by the
|
|
189
189
|
* caller (the `facade.moveBlocks` contract, which counts the
|
|
@@ -298,7 +298,7 @@ export function addInlineBlock({ index, block, text }) {
|
|
|
298
298
|
this.normalizeContent();
|
|
299
299
|
return atom.id;
|
|
300
300
|
}
|
|
301
|
-
/** The text after atom `atom` of this block; the caret's pending marks follow it there
|
|
301
|
+
/** The text after atom `atom` of this block; the caret's pending marks follow it there. */
|
|
302
302
|
export function textAfterAtom(atom) {
|
|
303
303
|
if (atom === undefined)
|
|
304
304
|
return undefined;
|
|
@@ -317,7 +317,7 @@ export function textAfterAtom(atom) {
|
|
|
317
317
|
* Normalization runs at the end of the command's transaction
|
|
318
318
|
* (`Dispatcher.drain`): a normalizer reads handles over the index; when a
|
|
319
319
|
* plugin hook answers work, the work runs in the same transaction and the
|
|
320
|
-
* block is requested again (bounded by the dispatcher's pass limit
|
|
320
|
+
* block is requested again (bounded by the dispatcher's pass limit).
|
|
321
321
|
*/
|
|
322
322
|
export function normalizeContent() {
|
|
323
323
|
if (this.edytor.dispatcher.defer(this, normalizeContent))
|
|
@@ -341,17 +341,6 @@ export function normalizeChildren() {
|
|
|
341
341
|
this.normalizeChildren();
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
/** @deprecated A thin wrapper over an `{ end: block.id }` suggestion (`edytor.suggestions`). */
|
|
345
|
-
export function suggestText({ value }) {
|
|
346
|
-
this.suggestions =
|
|
347
|
-
typeof value === 'string'
|
|
348
|
-
? [[{ text: value }]]
|
|
349
|
-
: (value?.map((part) => ('type' in part ? part : [part])) ?? null);
|
|
350
|
-
}
|
|
351
|
-
/** @deprecated Accepts this block's latest `{ end }` suggestion (`suggestion.accept()`). */
|
|
352
|
-
export function acceptSuggestedText() {
|
|
353
|
-
this.edytor.suggestions.at(this.id).end.at(-1)?.accept();
|
|
354
|
-
}
|
|
355
344
|
export function prepareDeleteRange({ start: [startIndex, startOffset], end: [endIndex, endOffset] }) {
|
|
356
345
|
const parts = this.edytor.idToBlock.parts(this.id);
|
|
357
346
|
const [startPart, endPart] = [parts.at(startIndex), parts.at(endIndex)];
|
|
@@ -101,7 +101,7 @@ const withoutUncopied = (edytor, fragment) => {
|
|
|
101
101
|
};
|
|
102
102
|
export const createEdytorClipboardFragment = (edytor) => withoutUncopied(edytor, fragmentOf(edytor));
|
|
103
103
|
const fragmentOf = (edytor) => {
|
|
104
|
-
// A layout the block selection covers whole is copied as the layout
|
|
104
|
+
// A layout the block selection covers whole is copied as the layout.
|
|
105
105
|
const selectedBlocks = selectedMembers(edytor, liftLayouts(edytor.selection.selectedBlocks));
|
|
106
106
|
if (selectedBlocks.length > 0) {
|
|
107
107
|
return {
|
|
@@ -10,7 +10,7 @@ type Values = Record<string, SerializableContent>;
|
|
|
10
10
|
/** The tag a kind writes for `data`: its export form's first tag, else its element's, else its content element's. */
|
|
11
11
|
export declare const tagOf: (type: string, kind: BlockDefinition, data: Values) => string | undefined;
|
|
12
12
|
/**
|
|
13
|
-
* External HTML as a flow
|
|
13
|
+
* External HTML as a flow: the browser parses (inert: no script
|
|
14
14
|
* runs, nothing loads), and the tag tables are the records inverted — a
|
|
15
15
|
* catalogue kind's tag per preset (a content-less container takes its
|
|
16
16
|
* default child's tag, one child per text line), a value-less mark's
|
|
@@ -20,7 +20,7 @@ export declare const tagOf: (type: string, kind: BlockDefinition, data: Values)
|
|
|
20
20
|
* `iframe`, `video` or `audio` no hook claims carries nothing. An atom
|
|
21
21
|
* kind's `parse` hook claims inline elements (an equation's `<math>`): the
|
|
22
22
|
* atom, never its text. Unknown
|
|
23
|
-
* elements degrade to text runs; whitespace collapses as HTML renders it. `null` when the HTML carries nothing (`flow.shape
|
|
23
|
+
* elements degrade to text runs; whitespace collapses as HTML renders it. `null` when the HTML carries nothing (`flow.shape`).
|
|
24
24
|
*/
|
|
25
25
|
export declare const flowOfHtml: (kinds: ImportKinds, html: string | undefined) => Flow | null;
|
|
26
26
|
export {};
|
|
@@ -54,7 +54,7 @@ export const tagOf = (type, kind, data) => {
|
|
|
54
54
|
return undefined;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
* External HTML as a flow
|
|
57
|
+
* External HTML as a flow: the browser parses (inert: no script
|
|
58
58
|
* runs, nothing loads), and the tag tables are the records inverted — a
|
|
59
59
|
* catalogue kind's tag per preset (a content-less container takes its
|
|
60
60
|
* default child's tag, one child per text line), a value-less mark's
|
|
@@ -64,7 +64,7 @@ export const tagOf = (type, kind, data) => {
|
|
|
64
64
|
* `iframe`, `video` or `audio` no hook claims carries nothing. An atom
|
|
65
65
|
* kind's `parse` hook claims inline elements (an equation's `<math>`): the
|
|
66
66
|
* atom, never its text. Unknown
|
|
67
|
-
* elements degrade to text runs; whitespace collapses as HTML renders it. `null` when the HTML carries nothing (`flow.shape
|
|
67
|
+
* elements degrade to text runs; whitespace collapses as HTML renders it. `null` when the HTML carries nothing (`flow.shape`).
|
|
68
68
|
*/
|
|
69
69
|
export const flowOfHtml = (kinds, html) => {
|
|
70
70
|
if (!html || html.length > 8 * 1024 * 1024 || typeof DOMParser === 'undefined')
|
|
@@ -7,7 +7,7 @@ const escapeHtml = (value) => value.replace(/&/g, '&').replace(/</g, '<')
|
|
|
7
7
|
const tag = (name, inner, attributes = {}) => `<${name}${Object.entries(attributes)
|
|
8
8
|
.map(([key, value]) => (value === undefined ? '' : ` ${key}="${escapeHtml(value)}"`))
|
|
9
9
|
.join('')}>${inner}</${name}>`;
|
|
10
|
-
/** A mark exports the element it renders
|
|
10
|
+
/** A mark exports the element it renders: its `tag` and `attributes`. */
|
|
11
11
|
const textHtml = (part, kinds) => {
|
|
12
12
|
let html = escapeHtml(part.text).replace(/\n/g, '<br>');
|
|
13
13
|
for (const [name, mark] of kinds.marks) {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* rows ≤ `maxRowBytes` (2 MB row cap) in one `transactionSync`, then
|
|
37
37
|
* broadcast; after `compactAfter` update records the rows are replaced
|
|
38
38
|
* by one snapshot record of the live document's state (its healed
|
|
39
|
-
* state, deleted content collected
|
|
39
|
+
* state, deleted content collected), after the message is
|
|
40
40
|
* acknowledged — never inside the engine's `update` observer, where one
|
|
41
41
|
* throw would silence every later emit. Memory never runs ahead of
|
|
42
42
|
* storage: when an append fails, nothing is relayed or acknowledged, the
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
* left out of the ack), the rest applied. Compaction reclaims the
|
|
53
53
|
* waiting deletes of client ids no user registered and no socket holds;
|
|
54
54
|
* `dropWaitingDeletes()` every one.
|
|
55
|
-
* - storage format
|
|
55
|
+
* - storage format: the generation record says `storage: 'v2'` —
|
|
56
56
|
* snapshots in the v2 encoding, compressed in place after they are
|
|
57
57
|
* stored (`compressLater`), inflated at start (`inflate`); update and
|
|
58
58
|
* pending records stay v1. A container without `storage` (0.1.0-next.22)
|
|
@@ -216,7 +216,7 @@ export declare const ROOM_ORIGIN: unique symbol;
|
|
|
216
216
|
export declare const RESTORE_ORIGIN: unique symbol;
|
|
217
217
|
/** The transaction origin of the room's purge: tracked by no history. */
|
|
218
218
|
export declare const PURGE_ORIGIN: unique symbol;
|
|
219
|
-
/** The header `routeDocumentHistory` sets on an authorized history request
|
|
219
|
+
/** The header `routeDocumentHistory` sets on an authorized history request. */
|
|
220
220
|
export declare const HISTORY_HEADER = "X-Edytor-History";
|
|
221
221
|
/** The version key of a history `read` or `restore` request. */
|
|
222
222
|
export declare const HISTORY_KEY_HEADER = "X-Edytor-History-Key";
|
|
@@ -888,14 +888,6 @@ export declare class AttachedDocument {
|
|
|
888
888
|
* `false` for a socket that is not the document's).
|
|
889
889
|
*/
|
|
890
890
|
export declare const attachRoom: (host: DurableObject<any>, options?: AttachRoomOptions) => AttachedDocument;
|
|
891
|
-
/**
|
|
892
|
-
* @deprecated Use {@link attachRoom} (the client's `attachDocument` attaches
|
|
893
|
-
* a document to an engine doc, a different thing). Removed in the next
|
|
894
|
-
* release.
|
|
895
|
-
*/
|
|
896
|
-
export declare const attachDocument: (host: DurableObject<any>, options?: AttachRoomOptions) => AttachedDocument;
|
|
897
|
-
/** @deprecated Use {@link AttachRoomOptions}. Removed in the next release. */
|
|
898
|
-
export type AttachDocumentOptions = AttachRoomOptions;
|
|
899
891
|
/**
|
|
900
892
|
* The ready-made room: a Durable Object hosting one document, configured
|
|
901
893
|
* by `vars` ({@link DocumentRoomEnv}). Subclass it to override `onLoad` and
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* rows ≤ `maxRowBytes` (2 MB row cap) in one `transactionSync`, then
|
|
37
37
|
* broadcast; after `compactAfter` update records the rows are replaced
|
|
38
38
|
* by one snapshot record of the live document's state (its healed
|
|
39
|
-
* state, deleted content collected
|
|
39
|
+
* state, deleted content collected), after the message is
|
|
40
40
|
* acknowledged — never inside the engine's `update` observer, where one
|
|
41
41
|
* throw would silence every later emit. Memory never runs ahead of
|
|
42
42
|
* storage: when an append fails, nothing is relayed or acknowledged, the
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
* left out of the ack), the rest applied. Compaction reclaims the
|
|
53
53
|
* waiting deletes of client ids no user registered and no socket holds;
|
|
54
54
|
* `dropWaitingDeletes()` every one.
|
|
55
|
-
* - storage format
|
|
55
|
+
* - storage format: the generation record says `storage: 'v2'` —
|
|
56
56
|
* snapshots in the v2 encoding, compressed in place after they are
|
|
57
57
|
* stored (`compressLater`), inflated at start (`inflate`); update and
|
|
58
58
|
* pending records stay v1. A container without `storage` (0.1.0-next.22)
|
|
@@ -193,7 +193,7 @@ export const ROOM_ORIGIN = Symbol('edytor-room');
|
|
|
193
193
|
export const RESTORE_ORIGIN = Symbol('edytor-restore');
|
|
194
194
|
/** The transaction origin of the room's purge: tracked by no history. */
|
|
195
195
|
export const PURGE_ORIGIN = Symbol('edytor-purge');
|
|
196
|
-
/** The header `routeDocumentHistory` sets on an authorized history request
|
|
196
|
+
/** The header `routeDocumentHistory` sets on an authorized history request. */
|
|
197
197
|
export const HISTORY_HEADER = 'X-Edytor-History';
|
|
198
198
|
/** The version key of a history `read` or `restore` request. */
|
|
199
199
|
export const HISTORY_KEY_HEADER = 'X-Edytor-History-Key';
|
|
@@ -430,7 +430,7 @@ export class AttachedDocument {
|
|
|
430
430
|
lastUpdated() {
|
|
431
431
|
return this.room.storage.lastUpdated();
|
|
432
432
|
}
|
|
433
|
-
// ── History
|
|
433
|
+
// ── History ────────────────────────────────────────────────────
|
|
434
434
|
/**
|
|
435
435
|
* Resolves once the versions the room is writing are stored (a slot a
|
|
436
436
|
* write closed is written in the background).
|
|
@@ -485,7 +485,7 @@ export class AttachedDocument {
|
|
|
485
485
|
comment(request, actor) {
|
|
486
486
|
return this.room.comments.apply(request, actor);
|
|
487
487
|
}
|
|
488
|
-
// ── Moves (
|
|
488
|
+
// ── Moves (`room.move`) ─────────────────────────────────────────
|
|
489
489
|
/**
|
|
490
490
|
* Export blocks `ids` for a move (`room.move`, step 1): their visible
|
|
491
491
|
* subtrees as JSON, the outermost only, in document order. Writes
|
|
@@ -537,7 +537,7 @@ export class AttachedDocument {
|
|
|
537
537
|
applyLateEdits(batch) {
|
|
538
538
|
return this.room.moves.applyLateEdits(batch);
|
|
539
539
|
}
|
|
540
|
-
// ── Purge
|
|
540
|
+
// ── Purge ───────────────────────────────────────────────────────
|
|
541
541
|
/**
|
|
542
542
|
* The purge task, also over RPC (`room.purge.timing`): record an epoch
|
|
543
543
|
* (the state vector, now) when the document changed since the last one,
|
|
@@ -685,12 +685,6 @@ export const attachRoom = (host, options = {}) => {
|
|
|
685
685
|
}
|
|
686
686
|
return document;
|
|
687
687
|
};
|
|
688
|
-
/**
|
|
689
|
-
* @deprecated Use {@link attachRoom} (the client's `attachDocument` attaches
|
|
690
|
-
* a document to an engine doc, a different thing). Removed in the next
|
|
691
|
-
* release.
|
|
692
|
-
*/
|
|
693
|
-
export const attachDocument = attachRoom;
|
|
694
688
|
/**
|
|
695
689
|
* The ready-made room: a Durable Object hosting one document, configured
|
|
696
690
|
* by `vars` ({@link DocumentRoomEnv}). Subclass it to override `onLoad` and
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* The structural subset of a KV namespace {@link kvHistory} uses — a
|
|
12
12
|
* Workers `KVNamespace` binding satisfies it, and so does an in-memory
|
|
13
|
-
* fake.
|
|
14
|
-
* {@link kvHistory} (deprecated: pass `kvHistory(namespace)`).
|
|
13
|
+
* fake. As `history.store` it goes through {@link kvHistory}.
|
|
15
14
|
*/
|
|
16
15
|
export type KVLike = {
|
|
17
16
|
put(key: string, value: ArrayBuffer | ArrayBufferView | string, options?: {
|
|
@@ -110,10 +109,10 @@ export type HistoryStoreFactory = (room: HistoryRoomStorage) => HistoryStore;
|
|
|
110
109
|
export type HistoryOptions = {
|
|
111
110
|
/**
|
|
112
111
|
* The store: a {@link HistoryStore} ({@link kvHistory}, {@link r2History}
|
|
113
|
-
* or your own)
|
|
114
|
-
*
|
|
112
|
+
* or your own) or {@link roomHistory}`()`. A KV namespace goes through
|
|
113
|
+
* {@link kvHistory}.
|
|
115
114
|
*/
|
|
116
|
-
store: HistoryStore | HistoryStoreFactory
|
|
115
|
+
store: HistoryStore | HistoryStoreFactory;
|
|
117
116
|
/** How long a version is kept, in days (default 30). */
|
|
118
117
|
retentionDays?: number;
|
|
119
118
|
/** The IANA time zone whose noon and midnight end the slots (default `'UTC'`). */
|
|
@@ -235,6 +234,7 @@ export declare const isR2Bucket: (store: unknown) => store is R2BucketLike;
|
|
|
235
234
|
/**
|
|
236
235
|
* The store `history.store` names, built for this room: a
|
|
237
236
|
* {@link HistoryStore} as it is, a factory ({@link roomHistory}) over the
|
|
238
|
-
* room's storage
|
|
237
|
+
* room's storage. Anything else (a KV namespace itself) is refused: it goes
|
|
238
|
+
* through {@link kvHistory}.
|
|
239
239
|
*/
|
|
240
240
|
export declare const resolveHistoryStore: (store: HistoryOptions["store"], room: HistoryRoomStorage) => HistoryStore;
|
|
@@ -324,7 +324,7 @@ export const roomHistory = (options = {}) => ({ sql, transactionSync, tablePrefi
|
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
};
|
|
327
|
-
/** A {@link HistoryStore} (its numeric `maxValueBytes`
|
|
327
|
+
/** A {@link HistoryStore} (its numeric `maxValueBytes` and its `delete` say so). */
|
|
328
328
|
const isHistoryStore = (store) => typeof store?.maxValueBytes === 'number' &&
|
|
329
329
|
typeof store.delete === 'function';
|
|
330
330
|
/** An R2 bucket binding (it has multipart uploads; a KV namespace does not). */
|
|
@@ -333,12 +333,13 @@ export const isR2Bucket = (store) => typeof store?.createMultipartUpload ===
|
|
|
333
333
|
/**
|
|
334
334
|
* The store `history.store` names, built for this room: a
|
|
335
335
|
* {@link HistoryStore} as it is, a factory ({@link roomHistory}) over the
|
|
336
|
-
* room's storage
|
|
336
|
+
* room's storage. Anything else (a KV namespace itself) is refused: it goes
|
|
337
|
+
* through {@link kvHistory}.
|
|
337
338
|
*/
|
|
338
339
|
export const resolveHistoryStore = (store, room) => {
|
|
339
340
|
if (typeof store === 'function')
|
|
340
341
|
return store(room);
|
|
341
342
|
if (isHistoryStore(store))
|
|
342
343
|
return store;
|
|
343
|
-
|
|
344
|
+
throw new TypeError('history.store: not a HistoryStore. Wrap a KV namespace in kvHistory(namespace), an R2 bucket in r2History(bucket)');
|
|
344
345
|
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* `cloudflare:workers`); built on the Worker-safe CRDT entry. Documented in
|
|
5
5
|
* the site's `server/` section (room, authorization, extending, protocol).
|
|
6
6
|
*/
|
|
7
|
-
export { DocumentRoom, AttachedDocument, attachRoom,
|
|
7
|
+
export { DocumentRoom, AttachedDocument, attachRoom, SOCKET_TAG, closedSocket, type AttachRoomOptions, type CommentOptions, DEFAULT_COMPACT_AFTER, DEFAULT_MAX_ROW_BYTES, DEFAULT_SAVE_AFTER, DEFAULT_MAX_DOCUMENT_BYTES, DEFAULT_MAX_INBOUND_FRAME_BYTES, DEFAULT_MAX_BUFFERED_BYTES, DEFAULT_MAX_UPDATES_PER_SECOND, DEFAULT_MAX_PRESENCE_BYTES, DEFAULT_MAX_PRESENCE_PER_SECOND, DEFAULT_MAX_PRESENCE_FANOUT, MAX_REFUSALS, MAX_WAITING_DELETES, ROOM_ORIGIN, RESTORE_ORIGIN, PURGE_ORIGIN, IDENTITY_HEADERS, PROBE_HEADER, noTimers, type Attachment, type DocumentRoomEnv, type LoadedDocument, type Refusal, type ReplicaOwner, type SavedDocument, type SocketIdentity, type StoredRecord, type FrameValidation, type ValidatedBlock, type RoomMetrics, type RoomLogEntry, type RestoreResult, type Timing } from './DocumentRoom.js';
|
|
8
8
|
export { DEFAULT_RETENTION_DAYS, HISTORY_MAX_VALUE_BYTES, R2_HISTORY_MAX_VALUE_BYTES, ROOM_HISTORY_MAX_BYTES, ROOM_HISTORY_MAX_VALUE_BYTES, kvHistory, r2History, roomHistory, type HistoryEntry, type HistoryMetadata, type HistoryOptions, type HistoryRoomStorage, type HistoryStore, type HistoryStoreFactory, type HistoryStoreRecord, type KVLike, type R2BucketLike } from './history.js';
|
|
9
9
|
export { type PurgeReport } from '../crdt/purge.js';
|
|
10
10
|
export { COMMENT_STATUS, MAX_COMMENT_LENGTH, MAX_COMMENTS_PER_THREAD, MAX_THREADS, commentAnchors, decideComment, type ThreadComment, type CommentActor, type CommentChange, type CommentOutcome, type CommentRefusal, type CommentRequest, type CommentRun, type CommentSnapshot, type CommentThread } from '../crdt/protocols/comments.js';
|
|
11
11
|
export { lockedBlocks, type LockOptions } from './locks.js';
|
|
12
|
-
export { moveBlocksBetweenRooms,
|
|
12
|
+
export { moveBlocksBetweenRooms, forwardLateEdits, DEFAULT_MOVE_GRACE_DAYS, type CommitResult, type ExportedBlocks, type ImportReceipt, type ImportRequest, type LateEdit, type LateEditBatch, type MoveDestination, type MovedState, type MoveNamespace, type MoveRoom } from './move.js';
|
|
13
13
|
export { routeDocumentSocket, routeDocumentHistory, routeDocumentComments, requestedReplica, type AuthorizeDocumentSocket, type ExpiredCredential, type DocumentNamespace, type DocumentIdentity, type RouteDocumentOptions } from './routeDocumentSocket.js';
|
package/dist/cloudflare/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* `cloudflare:workers`); built on the Worker-safe CRDT entry. Documented in
|
|
5
5
|
* the site's `server/` section (room, authorization, extending, protocol).
|
|
6
6
|
*/
|
|
7
|
-
export { DocumentRoom, AttachedDocument, attachRoom,
|
|
7
|
+
export { DocumentRoom, AttachedDocument, attachRoom, SOCKET_TAG, closedSocket, DEFAULT_COMPACT_AFTER, DEFAULT_MAX_ROW_BYTES, DEFAULT_SAVE_AFTER, DEFAULT_MAX_DOCUMENT_BYTES, DEFAULT_MAX_INBOUND_FRAME_BYTES, DEFAULT_MAX_BUFFERED_BYTES, DEFAULT_MAX_UPDATES_PER_SECOND, DEFAULT_MAX_PRESENCE_BYTES, DEFAULT_MAX_PRESENCE_PER_SECOND, DEFAULT_MAX_PRESENCE_FANOUT, MAX_REFUSALS, MAX_WAITING_DELETES, ROOM_ORIGIN, RESTORE_ORIGIN, PURGE_ORIGIN, IDENTITY_HEADERS, PROBE_HEADER, noTimers } from './DocumentRoom.js';
|
|
8
8
|
export { DEFAULT_RETENTION_DAYS, HISTORY_MAX_VALUE_BYTES, R2_HISTORY_MAX_VALUE_BYTES, ROOM_HISTORY_MAX_BYTES, ROOM_HISTORY_MAX_VALUE_BYTES, kvHistory, r2History, roomHistory } from './history.js';
|
|
9
9
|
export {} from '../crdt/purge.js';
|
|
10
10
|
export { COMMENT_STATUS, MAX_COMMENT_LENGTH, MAX_COMMENTS_PER_THREAD, MAX_THREADS, commentAnchors, decideComment } from '../crdt/protocols/comments.js';
|
|
11
11
|
export { lockedBlocks } from './locks.js';
|
|
12
|
-
export { moveBlocksBetweenRooms,
|
|
12
|
+
export { moveBlocksBetweenRooms, forwardLateEdits, DEFAULT_MOVE_GRACE_DAYS } from './move.js';
|
|
13
13
|
export { routeDocumentSocket, routeDocumentHistory, routeDocumentComments, requestedReplica } from './routeDocumentSocket.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-block locks (
|
|
3
|
-
* a `validate` hook (
|
|
2
|
+
* Per-block locks (`room.locks` in `docs/editor-delete-contract.md`):
|
|
3
|
+
* a `validate` hook (accept-then-compensate) that keeps a locked block
|
|
4
4
|
* its owner's. Worker-safe: no timers, no browser globals.
|
|
5
5
|
*
|
|
6
6
|
* A block is locked when its data names a user under `key` (default
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cross-document moves (
|
|
2
|
+
* Cross-document moves (`room.move` in `docs/editor-delete-contract.md`):
|
|
3
3
|
* blocks leave document A for document B so that no concurrent edit is
|
|
4
4
|
* lost. Worker-safe; the room (`DocumentRoom.ts`) owns the storage and the
|
|
5
5
|
* transactions, this module the protocol and the merge.
|
|
@@ -150,16 +150,6 @@ export declare const moveBlocksBetweenRooms: (namespace: MoveNamespace, move: {
|
|
|
150
150
|
ids: string[];
|
|
151
151
|
dest: MoveDestination;
|
|
152
152
|
}) => Promise<ImportReceipt>;
|
|
153
|
-
/**
|
|
154
|
-
* @deprecated Use {@link moveBlocksBetweenRooms} (`edytor.moveBlocks` moves
|
|
155
|
-
* blocks inside one document). Removed in the next release.
|
|
156
|
-
*/
|
|
157
|
-
export declare const moveBlocks: (namespace: MoveNamespace, move: {
|
|
158
|
-
from: string;
|
|
159
|
-
to: string;
|
|
160
|
-
ids: string[];
|
|
161
|
-
dest: MoveDestination;
|
|
162
|
-
}) => Promise<ImportReceipt>;
|
|
163
153
|
/**
|
|
164
154
|
* Forward the late edits document `from` holds (`room.move.late`) to their
|
|
165
155
|
* destinations and acknowledge them — for a room without `rooms()`, which
|
package/dist/cloudflare/move.js
CHANGED
|
@@ -148,11 +148,6 @@ export const moveBlocksBetweenRooms = async (namespace, move) => {
|
|
|
148
148
|
throw new Error(`moveBlocksBetweenRooms: commit refused (${committed.reason ?? 'unknown'})`);
|
|
149
149
|
return receipt;
|
|
150
150
|
};
|
|
151
|
-
/**
|
|
152
|
-
* @deprecated Use {@link moveBlocksBetweenRooms} (`edytor.moveBlocks` moves
|
|
153
|
-
* blocks inside one document). Removed in the next release.
|
|
154
|
-
*/
|
|
155
|
-
export const moveBlocks = moveBlocksBetweenRooms;
|
|
156
151
|
/**
|
|
157
152
|
* Forward the late edits document `from` holds (`room.move.late`) to their
|
|
158
153
|
* destinations and acknowledge them — for a room without `rooms()`, which
|