edytor 4.0.0 → 6.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 +2 -2
- package/dist/block/block.svelte.js +6 -21
- package/dist/block/inlineBlock.svelte.js +4 -6
- package/dist/clipboard/moveText.js +6 -8
- package/dist/cloudflare/DocumentRoom.d.ts +10 -3
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/room/access.d.ts +8 -3
- package/dist/cloudflare/room/access.js +44 -20
- package/dist/cloudflare/room/admission.js +28 -5
- package/dist/cloudflare/room/comments.js +28 -1
- package/dist/cloudflare/room/context.d.ts +106 -109
- package/dist/cloudflare/room/context.js +10 -3
- package/dist/cloudflare/room/forged.d.ts +14 -0
- package/dist/cloudflare/room/forged.js +30 -2
- package/dist/cloudflare/room/frames.d.ts +4 -0
- package/dist/cloudflare/room/frames.js +5 -1
- package/dist/cloudflare/room/purge.js +2 -1
- package/dist/cloudflare/room/replicas.d.ts +4 -2
- package/dist/cloudflare/room/replicas.js +8 -3
- package/dist/cloudflare/room/suggest.d.ts +7 -0
- package/dist/cloudflare/room/suggest.js +143 -0
- package/dist/cloudflare/routeDocumentSocket.d.ts +10 -1
- package/dist/cloudflare/routeDocumentSocket.js +5 -3
- package/dist/components/Content.svelte +9 -1
- package/dist/crdt/anchors.js +3 -2
- package/dist/crdt/attribution/attribution.d.ts +3 -0
- package/dist/crdt/attribution/attribution.js +3 -3
- package/dist/crdt/doc/funnel.d.ts +1 -1
- package/dist/crdt/doc/funnel.js +5 -2
- package/dist/crdt/doc/gate.d.ts +1 -1
- package/dist/crdt/doc/history.d.ts +6 -0
- package/dist/crdt/doc/history.js +79 -59
- package/dist/crdt/doc/ops.d.ts +81 -0
- package/dist/crdt/doc/ops.js +1898 -0
- package/dist/crdt/doc/reads.d.ts +2 -2
- package/dist/crdt/doc/reads.js +18 -28
- package/dist/crdt/doc/suggest.d.ts +167 -0
- package/dist/crdt/doc/suggest.js +579 -0
- package/dist/crdt/document.d.ts +10 -1
- package/dist/crdt/document.js +19 -11
- package/dist/crdt/edytor-doc.d.ts +294 -272
- package/dist/crdt/edytor-doc.js +123 -108
- package/dist/crdt/engine-api.d.ts +8 -2
- package/dist/crdt/engine.d.ts +2 -1
- package/dist/crdt/engine.js +3 -1
- package/dist/crdt/flow.d.ts +5 -47
- package/dist/crdt/flow.js +3 -269
- package/dist/crdt/index.d.ts +102 -108
- package/dist/crdt/index.js +3 -0
- package/dist/crdt/operations.d.ts +13 -4
- package/dist/crdt/parts.d.ts +43 -0
- package/dist/crdt/parts.js +44 -0
- package/dist/crdt/placement/display.d.ts +1 -1
- package/dist/crdt/placement/display.js +3 -3
- package/dist/crdt/placement/keys.d.ts +5 -0
- package/dist/crdt/placement/keys.js +5 -0
- package/dist/crdt/placement/resolve.d.ts +1 -1
- package/dist/crdt/placement/resolve.js +2 -1
- package/dist/crdt/protocol.d.ts +1 -1
- package/dist/crdt/protocol.js +1 -1
- package/dist/crdt/protocols/auth.d.ts +11 -1
- package/dist/crdt/protocols/auth.js +17 -1
- package/dist/crdt/protocols/awareness.js +46 -81
- package/dist/crdt/protocols/comments.d.ts +16 -1
- package/dist/crdt/protocols/comments.js +9 -1
- package/dist/crdt/providers/index.d.ts +12 -22
- package/dist/crdt/providers/index.js +3 -1
- package/dist/crdt/providers/indexeddb.d.ts +6 -10
- package/dist/crdt/providers/indexeddb.js +10 -16
- package/dist/crdt/providers/room.d.ts +11 -0
- package/dist/crdt/providers/room.js +26 -12
- package/dist/crdt/providers/websocket.d.ts +8 -12
- package/dist/crdt/providers/websocket.js +17 -19
- package/dist/crdt/purge.d.ts +7 -1
- package/dist/crdt/purge.js +32 -2
- package/dist/crdt/rangeDelete.d.ts +2 -47
- package/dist/crdt/rangeDelete.js +1 -169
- package/dist/crdt/restore.d.ts +2 -1
- package/dist/crdt/restore.js +9 -0
- package/dist/crdt/schema.d.ts +9 -1
- package/dist/crdt/schema.js +13 -3
- package/dist/crdt/structs.d.ts +2 -0
- package/dist/crdt/structs.js +2 -0
- package/dist/crdt/text/index/build.d.ts +125 -0
- package/dist/crdt/text/index/build.js +2895 -0
- package/dist/crdt/text/index/shared.d.ts +2 -6
- package/dist/crdt/text/index/shared.js +19 -19
- package/dist/crdt/text/model.d.ts +10 -0
- package/dist/crdt/text/model.js +10 -4
- package/dist/crdt/text/runs.d.ts +43 -42
- package/dist/crdt/text/runs.js +2 -165
- package/dist/crdt/vendor/yjs/UPSTREAM.md +83 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +6 -3
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +13 -2
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/Item.js +44 -5
- package/dist/crdt/vendor/yjs/src/ynode.js +29 -7
- package/dist/edytor.svelte.d.ts +1 -1
- package/dist/edytor.svelte.js +100 -75
- package/dist/events/beforeInputCommands.d.ts +2 -2
- package/dist/events/domTextOffset.d.ts +2 -0
- package/dist/events/domTextOffset.js +8 -0
- package/dist/events/nativeInteractiveControl.d.ts +11 -1
- package/dist/events/nativeInteractiveControl.js +41 -1
- package/dist/events/onBeforeInput.js +3 -3
- package/dist/events/onFocus.js +9 -11
- package/dist/export/forms.d.ts +75 -75
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/labels.d.ts +8 -0
- package/dist/labels.js +6 -1
- package/dist/plugins/comments/CommentsController.svelte.d.ts +5 -1
- package/dist/plugins/comments/CommentsController.svelte.js +14 -4
- package/dist/plugins/find/search.js +2 -2
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
- package/dist/plugins/richtext/richTextOperations.js +26 -32
- package/dist/plugins/suggestions/SuggestionBars.svelte +40 -23
- package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +3 -1
- package/dist/plugins/suggestions/SuggestionRuns.svelte +77 -0
- package/dist/plugins/suggestions/SuggestionRuns.svelte.d.ts +9 -0
- package/dist/plugins/suggestions/shared.svelte.d.ts +58 -0
- package/dist/plugins/suggestions/shared.svelte.js +421 -0
- package/dist/plugins/suggestions/suggestionsPlugin.d.ts +15 -4
- package/dist/selection/domSelection.d.ts +2 -0
- package/dist/selection/domSelection.js +6 -2
- package/dist/selection/pointer.svelte.js +75 -48
- package/dist/selection/replaceSelection.js +2 -6
- package/dist/selection/selection.svelte.d.ts +3 -3
- package/dist/selection/selection.svelte.js +39 -32
- package/dist/selection/selection.utils.d.ts +14 -0
- package/dist/selection/selection.utils.js +33 -11
- package/dist/session/commands.js +21 -11
- package/dist/session/composition.svelte.d.ts +5 -3
- package/dist/session/composition.svelte.js +21 -17
- package/dist/session/handles.d.ts +4 -17
- package/dist/session/handles.js +14 -44
- package/dist/session/navigation.js +6 -9
- package/dist/session/selection.d.ts +11 -5
- package/dist/session/selection.js +14 -48
- package/dist/session/suggestions.svelte.d.ts +38 -9
- package/dist/session/suggestions.svelte.js +37 -18
- package/dist/session/virtual.d.ts +1 -1
- package/dist/surface/attributes.d.ts +5 -0
- package/dist/surface/attributes.js +2 -2
- package/dist/surface/cells.d.ts +2 -26
- package/dist/surface/cells.js +2 -33
- package/dist/surface/observer.svelte.d.ts +6 -1
- package/dist/surface/observer.svelte.js +143 -111
- package/dist/surface/pin.svelte.d.ts +9 -9
- package/dist/surface/pin.svelte.js +15 -22
- package/dist/surface/projector.svelte.js +10 -16
- package/dist/text/text.svelte.js +14 -19
- package/dist/themes/notion.css +29 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +7 -0
- package/package.json +3 -1
- package/dist/crdt/doc/capability.d.ts +0 -56
- package/dist/crdt/doc/capability.js +0 -211
- package/dist/crdt/doc/content.d.ts +0 -16
- package/dist/crdt/doc/content.js +0 -77
- package/dist/crdt/doc/delete.d.ts +0 -15
- package/dist/crdt/doc/delete.js +0 -84
- package/dist/crdt/doc/layout.d.ts +0 -9
- package/dist/crdt/doc/layout.js +0 -178
- package/dist/crdt/doc/meta.d.ts +0 -19
- package/dist/crdt/doc/meta.js +0 -199
- package/dist/crdt/doc/moves.d.ts +0 -21
- package/dist/crdt/doc/moves.js +0 -274
- package/dist/crdt/doc/split-merge.d.ts +0 -10
- package/dist/crdt/doc/split-merge.js +0 -179
- package/dist/crdt/doc/steps.d.ts +0 -65
- package/dist/crdt/doc/steps.js +0 -311
- package/dist/crdt/text/index/cache.d.ts +0 -16
- package/dist/crdt/text/index/cache.js +0 -175
- package/dist/crdt/text/index/claims.d.ts +0 -18
- package/dist/crdt/text/index/claims.js +0 -225
- package/dist/crdt/text/index/fold.d.ts +0 -21
- package/dist/crdt/text/index/fold.js +0 -656
- package/dist/crdt/text/index/layout.d.ts +0 -24
- package/dist/crdt/text/index/layout.js +0 -271
- package/dist/crdt/text/index/placement.d.ts +0 -47
- package/dist/crdt/text/index/placement.js +0 -741
- package/dist/crdt/text/index/records.d.ts +0 -13
- package/dist/crdt/text/index/records.js +0 -139
- package/dist/crdt/text/index/report.d.ts +0 -18
- package/dist/crdt/text/index/report.js +0 -337
- package/dist/crdt/text/index/state.d.ts +0 -197
- package/dist/crdt/text/index/state.js +0 -116
- package/dist/crdt/text/index/streams.d.ts +0 -25
- package/dist/crdt/text/index/streams.js +0 -248
package/dist/crdt/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
*/
|
|
47
47
|
export { EdytorDocument, createDocument, loadDocument, attachDocument, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, DEFAULT_READINESS_BOUND, type DocumentActor, type DocumentOptions, type DocumentReadiness, type DocumentSemanticsConfig, type CreateDocumentOptions, type LoadDocumentOptions } from './document.js';
|
|
48
48
|
export { defaultSemantics, richTextSemantics, codeSemantics, imageSemantics, mediaKinds, mediaSemantics, layoutSemantics, pageKinds, pageSemantics, tocKinds, tocSemantics, tableKinds, tableSemantics, equationKinds, equationSemantics, richTextKinds, codeKinds, imageKinds, layoutKinds, richTextMarks, commentMarks, facadeConfigOf, semanticsOf, mergeSemantics, semanticsDigest, semanticsMismatch, type KindSemantics, type KindRecord, type MergedSemantics } from './semantics.js';
|
|
49
|
+
export { adoptSharedSuggestions, type SuggestedChange } from './doc/suggest.js';
|
|
49
50
|
export { tableBlock, type TableBlockOptions } from './tables.js';
|
|
50
51
|
export { markName, type MarkEdge } from './text/marks.js';
|
|
51
52
|
export type { JSONDoc, JSONBlock, JSONText, JSONInlineBlock, SerializableContent } from '../utils/json.js';
|
|
@@ -75,7 +76,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
75
76
|
Awareness: typeof _Awareness;
|
|
76
77
|
doc: {
|
|
77
78
|
SCHEMA: {
|
|
78
|
-
readonly version:
|
|
79
|
+
readonly version: 11;
|
|
79
80
|
readonly name: "edytor-doc";
|
|
80
81
|
readonly roots: {
|
|
81
82
|
readonly registry: "blocks";
|
|
@@ -86,7 +87,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
86
87
|
readonly schema: "schema";
|
|
87
88
|
};
|
|
88
89
|
};
|
|
89
|
-
SCHEMA_VERSION:
|
|
90
|
+
SCHEMA_VERSION: 11;
|
|
90
91
|
SCHEMA_NAME: "edytor-doc";
|
|
91
92
|
META_KEY: "meta";
|
|
92
93
|
init: (doc: import("./engine-api.js").EngineDoc, opts?: {
|
|
@@ -102,48 +103,36 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
102
103
|
assertSchema: (doc: import("./engine-api.js").EngineDoc, docName?: string) => void;
|
|
103
104
|
SchemaMismatchError: typeof import("./edytor-doc.js").SchemaMismatchError;
|
|
104
105
|
create: (doc: import("./engine-api.js").EngineDoc, config?: import("./edytor-doc.js").EdytorDocConfig) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
|
|
136
|
-
insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
137
|
-
deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
138
|
-
formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
139
|
-
clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
140
|
-
insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").Prepared;
|
|
141
|
-
removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
|
|
142
|
-
deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
|
|
143
|
-
};
|
|
144
|
-
apply: (p: import("./edytor-doc.js").Prepared) => import("./edytor-doc.js").OpResult;
|
|
145
|
-
compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
|
|
146
|
-
transact: <R>(fn: () => R, origin?: unknown) => R;
|
|
106
|
+
init: (opts?: Parameters<(doc: import("./engine-api.js").EngineDoc, opts?: {
|
|
107
|
+
content?: import("./index.js").BlockSpec[];
|
|
108
|
+
defaultType?: string;
|
|
109
|
+
}) => void>[1]) => void;
|
|
110
|
+
seed: (value: import("./index.js").JSONBlock[], data?: import("./doc/types.js").JsonObj) => void;
|
|
111
|
+
isInitialized: () => boolean;
|
|
112
|
+
schemaVersion: () => number | undefined;
|
|
113
|
+
checkSchema: () => import("./edytor-doc.js").SchemaProblem | null;
|
|
114
|
+
assertSchema: () => void;
|
|
115
|
+
dispose: () => void;
|
|
116
|
+
createUndoManager: (options?: import("./doc/history.js").HistoryOptions) => import("./doc/history.js").UndoManager;
|
|
117
|
+
part: import("./doc/suggest.js").SuggestContext;
|
|
118
|
+
childSlots: (parent: import("./index.js").BlockId | null) => import("./placement/model.js").ChildSlot[];
|
|
119
|
+
slotOf: (id: string) => {
|
|
120
|
+
parent: import("./index.js").BlockId | null;
|
|
121
|
+
rank: string;
|
|
122
|
+
} | null;
|
|
123
|
+
crdtId: (id: string) => string | null;
|
|
124
|
+
resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
|
|
125
|
+
followUndo: (anchor: import("./edytor-doc.js").DocAnchor) => import("./edytor-doc.js").DocAnchor;
|
|
126
|
+
rolesChanged: (place?: boolean) => void;
|
|
127
|
+
defaultChild: (id: string | null) => string;
|
|
128
|
+
contentJSON: (id: string) => ({
|
|
129
|
+
text: string;
|
|
130
|
+
marks?: Record<string, unknown>;
|
|
131
|
+
} | {
|
|
132
|
+
id?: string;
|
|
133
|
+
type: string;
|
|
134
|
+
data?: unknown;
|
|
135
|
+
})[];
|
|
147
136
|
model: {
|
|
148
137
|
REGISTRY_KEY: string;
|
|
149
138
|
registryOf: (doc: import("./engine-api.js").EngineDoc) => import("./engine-api.js").EngineNode;
|
|
@@ -213,19 +202,62 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
213
202
|
};
|
|
214
203
|
};
|
|
215
204
|
runsView: import("./text/runs.js").RunView;
|
|
205
|
+
api: object;
|
|
206
|
+
} & {
|
|
207
|
+
prepare: {
|
|
208
|
+
nestBlock: (id: import("./index.js").BlockId, parent: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
209
|
+
deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
|
|
210
|
+
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").Prepared;
|
|
211
|
+
moveBlocks: (ids: readonly import("./index.js").BlockId[], dest: import("./index.js").Destination) => import("./edytor-doc.js").Prepared;
|
|
212
|
+
unNestBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
|
|
213
|
+
unNestBlock: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
214
|
+
liftOut: (id: import("./index.js").BlockId, kind: string, { keep, after }?: {
|
|
215
|
+
keep?: boolean;
|
|
216
|
+
after?: readonly import("./index.js").BlockSpec[];
|
|
217
|
+
}) => import("./edytor-doc.js").Prepared;
|
|
218
|
+
duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
|
|
219
|
+
placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
|
|
220
|
+
wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
|
|
221
|
+
splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
|
|
222
|
+
mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
223
|
+
mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
224
|
+
mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
225
|
+
deleteBlock: (id: import("./index.js").BlockId, opts?: {
|
|
226
|
+
keepChildren?: boolean;
|
|
227
|
+
}) => import("./edytor-doc.js").Prepared;
|
|
228
|
+
setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
|
|
229
|
+
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
|
|
230
|
+
setBlock: (id: import("./index.js").BlockId, value: {
|
|
231
|
+
type?: string;
|
|
232
|
+
data?: Record<string, unknown>;
|
|
233
|
+
content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
234
|
+
children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
|
|
235
|
+
}) => import("./edytor-doc.js").Prepared;
|
|
236
|
+
insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
237
|
+
deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
238
|
+
formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
239
|
+
clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
240
|
+
insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/ops.js").NewInline) => import("./edytor-doc.js").Prepared;
|
|
241
|
+
removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
|
|
242
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
|
|
243
|
+
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
|
|
244
|
+
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
|
|
245
|
+
};
|
|
246
|
+
apply: (p: import("./edytor-doc.js").Prepared, quiet?: boolean) => import("./edytor-doc.js").OpResult;
|
|
247
|
+
compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
|
|
248
|
+
transact: <R>(fn: () => R, origin?: unknown) => R;
|
|
216
249
|
version: number;
|
|
217
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => import("./edytor-doc.js").OpResult;
|
|
218
|
-
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
219
|
-
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
220
|
-
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").OpResult;
|
|
221
|
-
moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
|
|
222
250
|
nestBlock: (id: string, parent: string) => import("./edytor-doc.js").OpResult;
|
|
223
|
-
|
|
251
|
+
deleteBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
|
|
252
|
+
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").JSONBlock | import("./index.js").BlockSpec)[]) => import("./edytor-doc.js").OpResult;
|
|
253
|
+
moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
|
|
224
254
|
unNestBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
|
|
255
|
+
unNestBlock: (id: string) => import("./edytor-doc.js").OpResult;
|
|
225
256
|
liftOut: (id: string, kind: string, args_2?: {
|
|
226
257
|
keep?: boolean;
|
|
227
258
|
after?: readonly import("./index.js").BlockSpec[];
|
|
228
259
|
} | undefined) => import("./edytor-doc.js").OpResult;
|
|
260
|
+
duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("./edytor-doc.js").OpResult;
|
|
229
261
|
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
|
|
230
262
|
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
|
|
231
263
|
splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
|
|
@@ -235,42 +267,29 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
235
267
|
deleteBlock: (id: string, opts?: {
|
|
236
268
|
keepChildren?: boolean;
|
|
237
269
|
} | undefined) => import("./edytor-doc.js").OpResult;
|
|
270
|
+
setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
|
|
271
|
+
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
|
|
238
272
|
setBlock: (id: string, value: {
|
|
239
273
|
type?: string;
|
|
240
274
|
data?: Record<string, unknown>;
|
|
241
275
|
content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
242
276
|
children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
|
|
243
277
|
}) => import("./edytor-doc.js").OpResult;
|
|
244
|
-
setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
|
|
245
|
-
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
|
|
246
|
-
duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("./edytor-doc.js").OpResult;
|
|
247
278
|
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
|
|
248
279
|
deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
|
|
249
280
|
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
|
|
250
281
|
clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
|
|
251
|
-
insertInline: (id: string, offset: number, atom: import("./doc/
|
|
282
|
+
insertInline: (id: string, offset: number, atom: import("./doc/ops.js").NewInline) => import("./edytor-doc.js").OpResult;
|
|
252
283
|
removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
defaultType?: string;
|
|
257
|
-
}) => void>[1]) => void;
|
|
258
|
-
seed: (value: import("./index.js").JSONBlock[], data?: import("./doc/types.js").JsonObj) => void;
|
|
259
|
-
isInitialized: () => boolean;
|
|
260
|
-
schemaVersion: () => number | undefined;
|
|
261
|
-
checkSchema: () => import("./edytor-doc.js").SchemaProblem | null;
|
|
262
|
-
assertSchema: () => void;
|
|
263
|
-
dispose: () => void;
|
|
264
|
-
createUndoManager: (options?: import("./doc/history.js").HistoryOptions) => import("./doc/history.js").UndoManager;
|
|
284
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => import("./edytor-doc.js").OpResult;
|
|
285
|
+
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
286
|
+
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
265
287
|
project: () => import("./index.js").ProjectedDoc;
|
|
266
|
-
toJSON: (
|
|
288
|
+
toJSON: (options?: {
|
|
289
|
+
suggestions?: boolean;
|
|
290
|
+
} | undefined) => import("./index.js").JSONDoc;
|
|
267
291
|
blockJSON: (id: string) => import("./index.js").JSONBlock;
|
|
268
292
|
childrenIds: (id: string | null) => string[];
|
|
269
|
-
childSlots: (parent: import("./index.js").BlockId | null) => import("./placement/model.js").ChildSlot[];
|
|
270
|
-
slotOf: (id: string) => {
|
|
271
|
-
parent: import("./index.js").BlockId | null;
|
|
272
|
-
rank: string;
|
|
273
|
-
} | null;
|
|
274
293
|
positionOf: (id: string) => import("./index.js").Destination | null;
|
|
275
294
|
pathOf: (id: string) => number[] | null;
|
|
276
295
|
parentOf: (id: string) => string | null;
|
|
@@ -288,8 +307,6 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
288
307
|
ids: (path: readonly string[]) => string[];
|
|
289
308
|
} | null;
|
|
290
309
|
blockAttribution: (id: string) => import("./index.js").BlockAttribution | undefined;
|
|
291
|
-
crdtId: (id: string) => string | null;
|
|
292
|
-
resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
|
|
293
310
|
displayLength: (id: string) => number;
|
|
294
311
|
contentItems: (id: string) => import("./index.js").ContentItem[];
|
|
295
312
|
hasBlock: (id: string) => boolean;
|
|
@@ -303,8 +320,6 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
303
320
|
blockId: import("./index.js").BlockId;
|
|
304
321
|
offset: number;
|
|
305
322
|
} | null;
|
|
306
|
-
followUndo: (anchor: import("./edytor-doc.js").DocAnchor) => import("./edytor-doc.js").DocAnchor;
|
|
307
|
-
rolesChanged: () => void;
|
|
308
323
|
isVoid: (id: string) => boolean;
|
|
309
324
|
isIsland: (id: string) => boolean;
|
|
310
325
|
isLines: (id: string) => boolean;
|
|
@@ -336,20 +351,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
336
351
|
parent: string | null;
|
|
337
352
|
levels: string[];
|
|
338
353
|
};
|
|
339
|
-
defaultChild: (id: string | null) => string;
|
|
340
354
|
runs: (id: string) => readonly import("./index.js").ContentRun[];
|
|
341
|
-
contentJSON: (id: string) => ({
|
|
342
|
-
text: string;
|
|
343
|
-
marks?: Record<string, unknown>;
|
|
344
|
-
} | {
|
|
345
|
-
id?: string;
|
|
346
|
-
type: string;
|
|
347
|
-
data?: unknown;
|
|
348
|
-
})[];
|
|
349
355
|
onChange: (cb: (change: import("./edytor-doc.js").DocChange) => void) => (() => void);
|
|
350
356
|
};
|
|
351
357
|
newDoc: (opts?: ConstructorParameters<EngineApi["Doc"]>[0]) => YDoc;
|
|
352
|
-
purge: (doc: import("./engine-api.js").EngineDoc, facade: {
|
|
358
|
+
purge: (doc: import("./engine-api.js").EngineDoc, facade: Partial<import("./doc/suggest.js").SuggestFacade> & {
|
|
353
359
|
model: import("./placement/model.js").PlacementModel;
|
|
354
360
|
text: import("./text/model.js").TextEngine;
|
|
355
361
|
}, horizon: import("./purge.js").Horizon | null) => import("./purge.js").PurgeReport;
|
|
@@ -449,17 +455,12 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
449
455
|
loadError: unknown;
|
|
450
456
|
_storeTimeout: number;
|
|
451
457
|
_storeTimeoutId: ReturnType<typeof setTimeout> | null;
|
|
452
|
-
|
|
458
|
+
_unlisten: () => void;
|
|
453
459
|
awareness: _Awareness;
|
|
454
460
|
bcconnected: boolean;
|
|
455
461
|
disableBc: boolean;
|
|
456
462
|
_ownsAwareness: boolean;
|
|
457
463
|
_bcSubscriber: (data: ArrayBuffer | Uint8Array, origin: unknown) => void;
|
|
458
|
-
_awarenessUpdateHandler: (updates: {
|
|
459
|
-
added: number[];
|
|
460
|
-
updated: number[];
|
|
461
|
-
removed: number[];
|
|
462
|
-
}, origin: unknown) => void;
|
|
463
464
|
get synced(): boolean;
|
|
464
465
|
messageHandlers: Record<number, import("./providers/room.js").RoomMessageHandler</*elided*/ any>>;
|
|
465
466
|
readMessage: (buf: Uint8Array, emitSynced: boolean) => import("lib0-v14/encoding").Encoder;
|
|
@@ -467,7 +468,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
467
468
|
connectBc(): void;
|
|
468
469
|
disconnectBc(): void;
|
|
469
470
|
destroy(): Promise<void>;
|
|
470
|
-
emit<N extends "failed" | "
|
|
471
|
+
emit<N extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: N, args: Parameters<{
|
|
471
472
|
synced: (provider: /*elided*/ any) => void;
|
|
472
473
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
473
474
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -476,7 +477,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
476
477
|
failed: (error: unknown, provider: /*elided*/ any) => void;
|
|
477
478
|
}[N]>): void;
|
|
478
479
|
_observers: Map<string, Set<any>>;
|
|
479
|
-
on<NAME extends "failed" | "
|
|
480
|
+
on<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
|
|
480
481
|
synced: (provider: /*elided*/ any) => void;
|
|
481
482
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
482
483
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -491,7 +492,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
491
492
|
'schema-mismatch': (detail: import("./protocol.js").SchemaMismatchDetail, provider: /*elided*/ any) => void;
|
|
492
493
|
failed: (error: unknown, provider: /*elided*/ any) => void;
|
|
493
494
|
}[NAME];
|
|
494
|
-
once<NAME extends "failed" | "
|
|
495
|
+
once<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
|
|
495
496
|
synced: (provider: /*elided*/ any) => void;
|
|
496
497
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
497
498
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -499,7 +500,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
499
500
|
'schema-mismatch': (detail: import("./protocol.js").SchemaMismatchDetail, provider: /*elided*/ any) => void;
|
|
500
501
|
failed: (error: unknown, provider: /*elided*/ any) => void;
|
|
501
502
|
}[NAME]): void;
|
|
502
|
-
off<NAME extends "failed" | "
|
|
503
|
+
off<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
|
|
503
504
|
synced: (provider: /*elided*/ any) => void;
|
|
504
505
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
505
506
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -560,14 +561,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
560
561
|
_resync: ReturnType<typeof setInterval> | undefined;
|
|
561
562
|
_connectTimer: ReturnType<typeof setTimeout> | undefined;
|
|
562
563
|
_checkInterval: ReturnType<typeof setInterval>;
|
|
563
|
-
|
|
564
|
-
local: boolean;
|
|
565
|
-
}) => void;
|
|
566
|
-
_awarenessUpdateHandler: (updates: {
|
|
567
|
-
added: number[];
|
|
568
|
-
updated: number[];
|
|
569
|
-
removed: number[];
|
|
570
|
-
}, origin: unknown) => void;
|
|
564
|
+
_unlisten: () => void;
|
|
571
565
|
get url(): string;
|
|
572
566
|
get unsaved(): number;
|
|
573
567
|
get saved(): boolean;
|
|
@@ -577,11 +571,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
577
571
|
destroy(): void;
|
|
578
572
|
disconnect(): void;
|
|
579
573
|
connect(): void;
|
|
580
|
-
emit<N extends "refused" | "status" | "failed" | "
|
|
574
|
+
emit<N extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
|
|
581
575
|
_observers: Map<string, Set<any>>;
|
|
582
|
-
on<NAME extends "refused" | "status" | "failed" | "
|
|
583
|
-
once<NAME extends "refused" | "status" | "failed" | "
|
|
584
|
-
off<NAME extends "refused" | "status" | "failed" | "
|
|
576
|
+
on<NAME extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): import("./protocol.js").WebsocketProviderEvents[NAME];
|
|
577
|
+
once<NAME extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
|
|
578
|
+
off<NAME extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
|
|
585
579
|
};
|
|
586
580
|
};
|
|
587
581
|
watchComments: (server: string | null, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
|
package/dist/crdt/index.js
CHANGED
|
@@ -61,6 +61,9 @@ export { EdytorDocument, createDocument, loadDocument, attachDocument, SemanticC
|
|
|
61
61
|
// `blocks`), `mergeSemantics` merges configs field by field, and the digest
|
|
62
62
|
// is the dev-time check a room logs mismatches with. Frozen.
|
|
63
63
|
export { defaultSemantics, richTextSemantics, codeSemantics, imageSemantics, mediaKinds, mediaSemantics, layoutSemantics, pageKinds, pageSemantics, tocKinds, tocSemantics, tableKinds, tableSemantics, equationKinds, equationSemantics, richTextKinds, codeKinds, imageKinds, layoutKinds, richTextMarks, commentMarks, facadeConfigOf, semanticsOf, mergeSemantics, semanticsDigest, semanticsMismatch } from './semantics.js';
|
|
64
|
+
// A document read without a view leaves its pending shared suggestions out
|
|
65
|
+
// of `toJSON()` once they are built over it (`sugg.json.base`).
|
|
66
|
+
export { adoptSharedSuggestions } from './doc/suggest.js';
|
|
64
67
|
// A new table as document JSON (`table.*`).
|
|
65
68
|
export { tableBlock } from './tables.js';
|
|
66
69
|
// Paired marks — a mark's edge as document semantics, the record a key names.
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* a view (`edytor.insertBlocks(…)`) they are dispatched. The facade a
|
|
8
8
|
* document binds has more (the index, the engine hooks): those stay
|
|
9
9
|
* internal. `DOCUMENT_OPERATIONS` lists the names, `DOCUMENT_WRITES` the
|
|
10
|
-
* writes, checked against the interfaces here and
|
|
11
|
-
*
|
|
10
|
+
* writes, checked against the interfaces here; the document and the view
|
|
11
|
+
* read the names from the facade itself (its `api` and `prepare`, checked
|
|
12
|
+
* against `DocumentOperations` in `document.ts`). Worker-safe: types and
|
|
13
|
+
* two lists.
|
|
12
14
|
*/
|
|
13
15
|
import type { BlockAttribution } from './attribution/block.js';
|
|
14
16
|
import type { AnchorAffinity, DataTarget, DocAnchor, DocChange, JsonObj, OpResult, OrderPolicy, Prepared } from './doc/types.js';
|
|
15
17
|
import type { DataPatch } from './data.js';
|
|
16
|
-
import type { NewInline } from './doc/
|
|
18
|
+
import type { NewInline } from './doc/ops.js';
|
|
17
19
|
import type { Flow, FlowTarget, FlowView } from './flow.js';
|
|
18
20
|
import type { BlockId, BlockSpec, ContentItem, Destination, ProjectedDoc, SplitTail } from './placement/model.js';
|
|
19
21
|
import type { DocPosition, RangeView } from './rangeDelete.js';
|
|
@@ -63,7 +65,14 @@ export interface DocumentWrites {
|
|
|
63
65
|
}
|
|
64
66
|
/** The document's reads (transaction-aware where the reference says so). */
|
|
65
67
|
export interface DocumentReads {
|
|
66
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The document as JSON, without its pending suggestions (their inserted
|
|
70
|
+
* text and blocks left out, their proposals not applied); with
|
|
71
|
+
* `suggestions: true`, as shown, pending suggestions included.
|
|
72
|
+
*/
|
|
73
|
+
toJSON(options?: {
|
|
74
|
+
suggestions?: boolean;
|
|
75
|
+
}): JSONDoc;
|
|
67
76
|
docData(): JsonObj;
|
|
68
77
|
dataItemIds(target: DataTarget, path: readonly string[]): string[];
|
|
69
78
|
project(): ProjectedDoc;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A block's content as its parts: the text segments between inline atoms
|
|
3
|
+
* and the atoms, alternating, starting and ending with a segment (an empty
|
|
4
|
+
* content is one empty `start` segment), each at its display offsets (an
|
|
5
|
+
* atom counts 1). One pure function of the index's runs, memoized per runs
|
|
6
|
+
* array: the cells render it, the handles and the projection read it.
|
|
7
|
+
*/
|
|
8
|
+
import type { ContentRun } from './text/runs.js';
|
|
9
|
+
export declare const START = "start";
|
|
10
|
+
type TextRun = Extract<ContentRun, {
|
|
11
|
+
kind: 'text';
|
|
12
|
+
}>;
|
|
13
|
+
/** The text between two inline atoms (or a content edge), keyed causally. */
|
|
14
|
+
export type Segment = {
|
|
15
|
+
readonly kind: 'text';
|
|
16
|
+
/** The id of the atom before this segment, or {@link START}. */
|
|
17
|
+
readonly key: string;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly runs: readonly TextRun[];
|
|
20
|
+
/** Its position among the block's segments. */
|
|
21
|
+
readonly segOrd: number;
|
|
22
|
+
readonly start: number;
|
|
23
|
+
readonly end: number;
|
|
24
|
+
};
|
|
25
|
+
export type AtomPart = {
|
|
26
|
+
readonly kind: 'inline';
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly type: string;
|
|
30
|
+
readonly data: Readonly<Record<string, unknown>> | undefined;
|
|
31
|
+
readonly start: number;
|
|
32
|
+
readonly end: number;
|
|
33
|
+
};
|
|
34
|
+
export type Part = Segment | AtomPart;
|
|
35
|
+
export declare const partsOf: (runs: readonly ContentRun[]) => readonly Part[];
|
|
36
|
+
/** The text segment showing `offset`: the first ending at or after it (a seam belongs to the left text), else the last. */
|
|
37
|
+
export declare const segmentAt: <P extends {
|
|
38
|
+
kind: string;
|
|
39
|
+
end: number;
|
|
40
|
+
}>(parts: readonly P[], offset: number) => Extract<P, {
|
|
41
|
+
kind: "text";
|
|
42
|
+
}>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const START = 'start';
|
|
2
|
+
const memo = new WeakMap();
|
|
3
|
+
export const partsOf = (runs) => {
|
|
4
|
+
const hit = memo.get(runs);
|
|
5
|
+
if (hit)
|
|
6
|
+
return hit;
|
|
7
|
+
const parts = [];
|
|
8
|
+
let [key, segment, start, at, segOrd] = [START, [], 0, 0, 0];
|
|
9
|
+
const close = () => parts.push(Object.freeze({
|
|
10
|
+
kind: 'text',
|
|
11
|
+
key,
|
|
12
|
+
text: segment.map((run) => run.text).join(''),
|
|
13
|
+
runs: Object.freeze(segment),
|
|
14
|
+
segOrd: segOrd++,
|
|
15
|
+
start,
|
|
16
|
+
end: at
|
|
17
|
+
}));
|
|
18
|
+
for (const run of runs) {
|
|
19
|
+
if (run.kind === 'text') {
|
|
20
|
+
segment.push(run);
|
|
21
|
+
at += run.text.length;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
close();
|
|
25
|
+
parts.push(Object.freeze({
|
|
26
|
+
kind: 'inline',
|
|
27
|
+
key: run.id,
|
|
28
|
+
id: run.id,
|
|
29
|
+
type: run.type,
|
|
30
|
+
data: run.data,
|
|
31
|
+
start: at,
|
|
32
|
+
end: ++at
|
|
33
|
+
}));
|
|
34
|
+
[key, segment, start] = [run.id, [], at];
|
|
35
|
+
}
|
|
36
|
+
close();
|
|
37
|
+
memo.set(runs, Object.freeze(parts));
|
|
38
|
+
return parts;
|
|
39
|
+
};
|
|
40
|
+
/** The text segment showing `offset`: the first ending at or after it (a seam belongs to the left text), else the last. */
|
|
41
|
+
export const segmentAt = (parts, offset) => {
|
|
42
|
+
const texts = parts.filter((part) => part.kind === 'text');
|
|
43
|
+
return texts.find((part) => offset <= part.end) ?? texts.at(-1);
|
|
44
|
+
};
|
|
@@ -68,7 +68,7 @@ export declare const displayParentOf: (own: DisplayOwnership, pl: ResolvedPlacem
|
|
|
68
68
|
* promoted one ({@link displaySlotOf}).
|
|
69
69
|
*/
|
|
70
70
|
export declare const childrenIndex: (placements: Map<BlockId, ResolvedPlacement>, own: DisplayOwnership) => Map<BlockId | null, ChildSlot[]>;
|
|
71
|
-
/** The order of a children list: by rank, ties by id. */
|
|
71
|
+
/** The order of a children list: by rank, ties by id ({@link compareIds}). */
|
|
72
72
|
export declare const bySlot: (a: {
|
|
73
73
|
id: BlockId;
|
|
74
74
|
rank: string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* (`order.split.text`: a split-born slot's key, fork patch YP22).
|
|
8
8
|
*/
|
|
9
9
|
import { DEAD } from '../text/model.js';
|
|
10
|
-
import { claimedRank, promotedRank } from './keys.js';
|
|
10
|
+
import { claimedRank, compareIds, promotedRank } from './keys.js';
|
|
11
11
|
/**
|
|
12
12
|
* THE liveness answer: `id` carries no live delete mark, owns
|
|
13
13
|
* itself (`own.hidden` covers both: a delete-marked or unknown block owns
|
|
@@ -210,8 +210,8 @@ export const childrenIndex = (placements, own) => {
|
|
|
210
210
|
bucket.sort(bySlot);
|
|
211
211
|
return index;
|
|
212
212
|
};
|
|
213
|
-
/** The order of a children list: by rank, ties by id. */
|
|
214
|
-
export const bySlot = (a, b) => (a.rank === b.rank ? a.id
|
|
213
|
+
/** The order of a children list: by rank, ties by id ({@link compareIds}). */
|
|
214
|
+
export const bySlot = (a, b) => (a.rank === b.rank ? compareIds(a.id, b.id) : a.rank < b.rank ? -1 : 1);
|
|
215
215
|
export const documentOrder = (kids) => {
|
|
216
216
|
const ids = [];
|
|
217
217
|
const at = new Map();
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
* above every key character;
|
|
23
23
|
* - a table's cells show in column order ({@link cellKey}).
|
|
24
24
|
*/
|
|
25
|
+
/**
|
|
26
|
+
* The one order of two ids on a tie (a children list, the seam, the root's
|
|
27
|
+
* tail): their code units, the order every replica computes the same.
|
|
28
|
+
*/
|
|
29
|
+
export declare const compareIds: (a: string, b: string) => number;
|
|
25
30
|
/** Sorts below every key character: the separator of a promoted child's key. */
|
|
26
31
|
export declare const PROMOTED = "!";
|
|
27
32
|
/**
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
* above every key character;
|
|
23
23
|
* - a table's cells show in column order ({@link cellKey}).
|
|
24
24
|
*/
|
|
25
|
+
/**
|
|
26
|
+
* The one order of two ids on a tie (a children list, the seam, the root's
|
|
27
|
+
* tail): their code units, the order every replica computes the same.
|
|
28
|
+
*/
|
|
29
|
+
export const compareIds = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
25
30
|
/**
|
|
26
31
|
* Order-preserving alphabet: charCode order equals numeric order (64
|
|
27
32
|
* characters, all safe inside a JSON string).
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* slot belongs to, each block's display edges (the sequences that can show
|
|
4
4
|
* its slot: its live move records', strongest first, then its parent's), the
|
|
5
5
|
* places of every sequence, and the cycle walk. Which edge a block takes is
|
|
6
|
-
* the index's acceptance (`text/index/
|
|
6
|
+
* the index's acceptance (`text/index/build.ts` `settle`). Pure over
|
|
7
7
|
* replicated state.
|
|
8
8
|
*/
|
|
9
9
|
import type { EngineDoc, EngineNode } from '../engine-api.js';
|
|
@@ -3,6 +3,7 @@ import { baseIdOf, incarnationId, incarnationsOf, LIVE_WRITERS } from '../incarn
|
|
|
3
3
|
import { attrItems, firstItem, itemOf } from '../structs.js';
|
|
4
4
|
import { cmpStamp, isBlockSlot, isRecord, itemAt, sameUnit, stampOf, unitsOf } from './slots.js';
|
|
5
5
|
import { DEAD } from '../text/model.js';
|
|
6
|
+
import { compareIds } from './keys.js';
|
|
6
7
|
/** The stamp of a home slot's edge: below every record's. */
|
|
7
8
|
const HOME = 0;
|
|
8
9
|
/** The stamp of a block with no slot: below every edge (it shows at the root's tail). */
|
|
@@ -130,7 +131,7 @@ export const cycleThrough = (accepted, ownerOf, block, parent) => {
|
|
|
130
131
|
return null;
|
|
131
132
|
};
|
|
132
133
|
/** The order of the blocks at the root's tail (rejected or slotless): by their edge's stamp, then id. */
|
|
133
|
-
export const byTail = (a, b) => cmpStamp(a.stamp, b.stamp) || (a.id
|
|
134
|
+
export const byTail = (a, b) => cmpStamp(a.stamp, b.stamp) || compareIds(a.id, b.id);
|
|
134
135
|
/**
|
|
135
136
|
* The home slot of block `id` among the slots naming its registry id
|
|
136
137
|
* (`slots`: every `{ b }` slot by `b`): the one its writer wrote
|
package/dist/crdt/protocol.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { SCHEMA_VERSION, META_KEY } from './edytor-doc.js';
|
|
|
29
29
|
export { GENERATION, generationWord, frame, PROTOCOL_VERSION, GENERATION_RECORD, GenerationMismatchError, readProtocolVersion, type GenerationRecord } from './protocols/envelope.js';
|
|
30
30
|
export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkError, type ChunkReader, CLOSE } from './providers/room.js';
|
|
31
31
|
export { messageYjsSyncStep1, messageYjsSyncStep2, messageYjsUpdate, type SyncProtocol } from './protocols/sync.js';
|
|
32
|
-
export { messagePermissionDenied, messageReadOnly, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
|
|
32
|
+
export { messageAccess, messagePermissionDenied, messageReadOnly, writeAccess, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
|
|
33
33
|
export { commentsSubscribe, commentsSnapshot, commentsChange, writeCommentsSubscribe, writeCommentsSnapshot, writeCommentsChange, readCommentsMessage, type CommentChange, type CommentMessage, type CommentSnapshot, type CommentThread, type ThreadComment } from './protocols/comments.js';
|
|
34
34
|
export { applyAwarenessUpdate, encodeAwarenessUpdate, readAwarenessEntries, writeAwarenessEntries, type AwarenessEntry } from './protocols/awareness.js';
|
|
35
35
|
export { createDecoder, readVarUint, readVarUint8Array, type Decoder } from 'lib0-v14/decoding';
|
package/dist/crdt/protocol.js
CHANGED
|
@@ -32,7 +32,7 @@ export { GENERATION, generationWord, frame, PROTOCOL_VERSION, GENERATION_RECORD,
|
|
|
32
32
|
// ── Message types, acknowledgements and chunks ─────────────────────────
|
|
33
33
|
export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkError, CLOSE } from './providers/room.js';
|
|
34
34
|
export { messageYjsSyncStep1, messageYjsSyncStep2, messageYjsUpdate } from './protocols/sync.js';
|
|
35
|
-
export { messagePermissionDenied, messageReadOnly, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
|
|
35
|
+
export { messageAccess, messagePermissionDenied, messageReadOnly, writeAccess, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
|
|
36
36
|
export { commentsSubscribe, commentsSnapshot, commentsChange, writeCommentsSubscribe, writeCommentsSnapshot, writeCommentsChange, readCommentsMessage } from './protocols/comments.js';
|
|
37
37
|
export { applyAwarenessUpdate, encodeAwarenessUpdate, readAwarenessEntries, writeAwarenessEntries } from './protocols/awareness.js';
|
|
38
38
|
// Minimal wire codec for frame bodies (lib0 — the codec the frames are
|