edytor 5.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/cloudflare/room/context.d.ts +62 -74
- package/dist/crdt/doc/history.js +2 -3
- package/dist/crdt/doc/ops.d.ts +81 -0
- package/dist/crdt/doc/ops.js +1898 -0
- package/dist/crdt/edytor-doc.d.ts +156 -156
- package/dist/crdt/edytor-doc.js +14 -42
- package/dist/crdt/flow.d.ts +4 -46
- package/dist/crdt/flow.js +2 -262
- package/dist/crdt/index.d.ts +62 -74
- package/dist/crdt/operations.d.ts +1 -1
- package/dist/crdt/placement/resolve.d.ts +1 -1
- package/dist/crdt/protocols/awareness.js +46 -81
- package/dist/crdt/providers/index.d.ts +10 -22
- 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 +6 -12
- package/dist/crdt/providers/websocket.js +8 -15
- package/dist/crdt/rangeDelete.d.ts +2 -47
- package/dist/crdt/rangeDelete.js +1 -169
- 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 +2 -5
- package/dist/crdt/text/model.js +2 -3
- package/dist/crdt/text/runs.d.ts +9 -12
- package/dist/crdt/text/runs.js +2 -165
- package/dist/events/domTextOffset.d.ts +2 -0
- package/dist/events/domTextOffset.js +8 -0
- package/dist/export/forms.d.ts +50 -50
- package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
- package/dist/plugins/richtext/richTextOperations.js +26 -32
- package/dist/selection/selection.utils.js +5 -8
- package/dist/session/handles.js +3 -7
- package/dist/surface/observer.svelte.js +15 -30
- package/dist/surface/projector.svelte.js +2 -2
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +7 -0
- package/package.json +1 -1
- package/dist/crdt/doc/capability.d.ts +0 -56
- package/dist/crdt/doc/capability.js +0 -207
- 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 -198
- 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 -203
- 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 -22
- package/dist/crdt/text/index/layout.js +0 -258
- package/dist/crdt/text/index/placement.d.ts +0 -47
- package/dist/crdt/text/index/placement.js +0 -738
- 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
|
@@ -99,9 +99,6 @@ export declare const docFacade: <L extends Layers>(Y: EngineApi, layers: L) => (
|
|
|
99
99
|
} & {
|
|
100
100
|
/** Every op prepared: pure, a plan of named steps + its effect, or `refused`. */
|
|
101
101
|
prepare: {
|
|
102
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => Prepared;
|
|
103
|
-
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
104
|
-
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
105
102
|
/**
|
|
106
103
|
* Move `id` to the last position under `parent` — under a container
|
|
107
104
|
* it is no item of, under its last item (`nestParent`: Tab after a list).
|
|
@@ -109,29 +106,6 @@ export declare const docFacade: <L extends Layers>(Y: EngineApi, layers: L) => (
|
|
|
109
106
|
nestBlock: (id: BlockId, parent: BlockId) => Prepared;
|
|
110
107
|
/** Delete a block selection — one plan; only the members leave (`deleteBlocks` above). */
|
|
111
108
|
deleteBlocks: (ids: readonly BlockId[]) => Prepared;
|
|
112
|
-
insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
|
|
113
|
-
deleteText: (id: BlockId, offset: number, length: number) => Prepared;
|
|
114
|
-
formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
|
|
115
|
-
clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
|
|
116
|
-
insertInline: (id: BlockId, offset: number, atom: import("./doc/content.js").NewInline) => Prepared;
|
|
117
|
-
removeInline: (id: BlockId, inlineId: string) => Prepared;
|
|
118
|
-
setBlockType: (id: BlockId, type: string) => Prepared;
|
|
119
|
-
patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
|
|
120
|
-
setBlock: (id: BlockId, value: {
|
|
121
|
-
type?: string;
|
|
122
|
-
data?: Record<string, unknown>;
|
|
123
|
-
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
124
|
-
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
125
|
-
}) => Prepared;
|
|
126
|
-
deleteBlock: (id: BlockId, opts?: {
|
|
127
|
-
keepChildren?: boolean;
|
|
128
|
-
}) => Prepared;
|
|
129
|
-
splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
|
|
130
|
-
mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
|
|
131
|
-
mergeBackward: (id: BlockId) => Prepared;
|
|
132
|
-
mergeForward: (id: BlockId) => Prepared;
|
|
133
|
-
placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
|
|
134
|
-
wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
|
|
135
109
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | JSONBlock)[]) => Prepared;
|
|
136
110
|
moveBlocks: (ids: readonly BlockId[], dest: import("./index.js").Destination) => Prepared;
|
|
137
111
|
unNestBlocks: (ids: readonly BlockId[]) => Prepared;
|
|
@@ -141,40 +115,40 @@ export declare const docFacade: <L extends Layers>(Y: EngineApi, layers: L) => (
|
|
|
141
115
|
after?: readonly import("./index.js").BlockSpec[];
|
|
142
116
|
}) => Prepared;
|
|
143
117
|
duplicateBlock: (id: BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => Prepared;
|
|
118
|
+
placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
|
|
119
|
+
wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
|
|
120
|
+
splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
|
|
121
|
+
mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
|
|
122
|
+
mergeBackward: (id: BlockId) => Prepared;
|
|
123
|
+
mergeForward: (id: BlockId) => Prepared;
|
|
124
|
+
deleteBlock: (id: BlockId, opts?: {
|
|
125
|
+
keepChildren?: boolean;
|
|
126
|
+
}) => Prepared;
|
|
127
|
+
setBlockType: (id: BlockId, type: string) => Prepared;
|
|
128
|
+
patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
|
|
129
|
+
setBlock: (id: BlockId, value: {
|
|
130
|
+
type?: string;
|
|
131
|
+
data?: Record<string, unknown>;
|
|
132
|
+
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
133
|
+
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
134
|
+
}) => Prepared;
|
|
135
|
+
insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
|
|
136
|
+
deleteText: (id: BlockId, offset: number, length: number) => Prepared;
|
|
137
|
+
formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
|
|
138
|
+
clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
|
|
139
|
+
insertInline: (id: BlockId, offset: number, atom: import("./doc/ops.js").NewInline) => Prepared;
|
|
140
|
+
removeInline: (id: BlockId, inlineId: string) => Prepared;
|
|
141
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => Prepared;
|
|
142
|
+
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
143
|
+
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
144
144
|
};
|
|
145
145
|
/** Write a prepared plan exactly (refusals pass through). */
|
|
146
146
|
apply: (p: Prepared, quiet?: boolean) => OpResult;
|
|
147
147
|
compose: (...parts: Prepared[]) => Prepared;
|
|
148
148
|
transact: <R>(fn: () => R, origin?: unknown) => R;
|
|
149
149
|
version: number;
|
|
150
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => OpResult;
|
|
151
|
-
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
152
|
-
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
153
150
|
nestBlock: (id: string, parent: string) => OpResult;
|
|
154
151
|
deleteBlocks: (ids: readonly string[]) => OpResult;
|
|
155
|
-
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => OpResult;
|
|
156
|
-
deleteText: (id: string, offset: number, length: number) => OpResult;
|
|
157
|
-
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => OpResult;
|
|
158
|
-
clearMarks: (id: string, offset: number, length: number) => OpResult;
|
|
159
|
-
insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => OpResult;
|
|
160
|
-
removeInline: (id: string, inlineId: string) => OpResult;
|
|
161
|
-
setBlockType: (id: string, type: string) => OpResult;
|
|
162
|
-
patchData: (target: DataTarget, patches: readonly DataPatch[]) => OpResult;
|
|
163
|
-
setBlock: (id: string, value: {
|
|
164
|
-
type?: string;
|
|
165
|
-
data?: Record<string, unknown>;
|
|
166
|
-
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
167
|
-
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
168
|
-
}) => OpResult;
|
|
169
|
-
deleteBlock: (id: string, opts?: {
|
|
170
|
-
keepChildren?: boolean;
|
|
171
|
-
} | undefined) => OpResult;
|
|
172
|
-
splitBlock: (id: string, offset: number, newId: string, tail?: SplitTail | undefined) => OpResult;
|
|
173
|
-
mergeBlocks: (fromId: string, intoId: string) => OpResult;
|
|
174
|
-
mergeBackward: (id: string) => OpResult;
|
|
175
|
-
mergeForward: (id: string) => OpResult;
|
|
176
|
-
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => OpResult;
|
|
177
|
-
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => OpResult;
|
|
178
152
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (JSONBlock | import("./index.js").BlockSpec)[]) => OpResult;
|
|
179
153
|
moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => OpResult;
|
|
180
154
|
unNestBlocks: (ids: readonly string[]) => OpResult;
|
|
@@ -184,6 +158,32 @@ export declare const docFacade: <L extends Layers>(Y: EngineApi, layers: L) => (
|
|
|
184
158
|
after?: readonly import("./index.js").BlockSpec[];
|
|
185
159
|
} | undefined) => OpResult;
|
|
186
160
|
duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => OpResult;
|
|
161
|
+
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => OpResult;
|
|
162
|
+
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => OpResult;
|
|
163
|
+
splitBlock: (id: string, offset: number, newId: string, tail?: SplitTail | undefined) => OpResult;
|
|
164
|
+
mergeBlocks: (fromId: string, intoId: string) => OpResult;
|
|
165
|
+
mergeBackward: (id: string) => OpResult;
|
|
166
|
+
mergeForward: (id: string) => OpResult;
|
|
167
|
+
deleteBlock: (id: string, opts?: {
|
|
168
|
+
keepChildren?: boolean;
|
|
169
|
+
} | undefined) => OpResult;
|
|
170
|
+
setBlockType: (id: string, type: string) => OpResult;
|
|
171
|
+
patchData: (target: DataTarget, patches: readonly DataPatch[]) => OpResult;
|
|
172
|
+
setBlock: (id: string, value: {
|
|
173
|
+
type?: string;
|
|
174
|
+
data?: Record<string, unknown>;
|
|
175
|
+
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
176
|
+
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
177
|
+
}) => OpResult;
|
|
178
|
+
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => OpResult;
|
|
179
|
+
deleteText: (id: string, offset: number, length: number) => OpResult;
|
|
180
|
+
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => OpResult;
|
|
181
|
+
clearMarks: (id: string, offset: number, length: number) => OpResult;
|
|
182
|
+
insertInline: (id: string, offset: number, atom: import("./doc/ops.js").NewInline) => OpResult;
|
|
183
|
+
removeInline: (id: string, inlineId: string) => OpResult;
|
|
184
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => OpResult;
|
|
185
|
+
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
186
|
+
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
187
187
|
project: () => import("./index.js").ProjectedDoc;
|
|
188
188
|
toJSON: (options?: {
|
|
189
189
|
suggestions?: boolean;
|
|
@@ -427,9 +427,6 @@ export declare const bindDocModel: (Y: EngineApi) => {
|
|
|
427
427
|
} & {
|
|
428
428
|
/** Every op prepared: pure, a plan of named steps + its effect, or `refused`. */
|
|
429
429
|
prepare: {
|
|
430
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => Prepared;
|
|
431
|
-
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
432
|
-
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
433
430
|
/**
|
|
434
431
|
* Move `id` to the last position under `parent` — under a container
|
|
435
432
|
* it is no item of, under its last item (`nestParent`: Tab after a list).
|
|
@@ -437,29 +434,6 @@ export declare const bindDocModel: (Y: EngineApi) => {
|
|
|
437
434
|
nestBlock: (id: BlockId, parent: BlockId) => Prepared;
|
|
438
435
|
/** Delete a block selection — one plan; only the members leave (`deleteBlocks` above). */
|
|
439
436
|
deleteBlocks: (ids: readonly BlockId[]) => Prepared;
|
|
440
|
-
insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
|
|
441
|
-
deleteText: (id: BlockId, offset: number, length: number) => Prepared;
|
|
442
|
-
formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
|
|
443
|
-
clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
|
|
444
|
-
insertInline: (id: BlockId, offset: number, atom: import("./doc/content.js").NewInline) => Prepared;
|
|
445
|
-
removeInline: (id: BlockId, inlineId: string) => Prepared;
|
|
446
|
-
setBlockType: (id: BlockId, type: string) => Prepared;
|
|
447
|
-
patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
|
|
448
|
-
setBlock: (id: BlockId, value: {
|
|
449
|
-
type?: string;
|
|
450
|
-
data?: Record<string, unknown>;
|
|
451
|
-
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
452
|
-
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
453
|
-
}) => Prepared;
|
|
454
|
-
deleteBlock: (id: BlockId, opts?: {
|
|
455
|
-
keepChildren?: boolean;
|
|
456
|
-
}) => Prepared;
|
|
457
|
-
splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
|
|
458
|
-
mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
|
|
459
|
-
mergeBackward: (id: BlockId) => Prepared;
|
|
460
|
-
mergeForward: (id: BlockId) => Prepared;
|
|
461
|
-
placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
|
|
462
|
-
wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
|
|
463
437
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | JSONBlock)[]) => Prepared;
|
|
464
438
|
moveBlocks: (ids: readonly BlockId[], dest: import("./index.js").Destination) => Prepared;
|
|
465
439
|
unNestBlocks: (ids: readonly BlockId[]) => Prepared;
|
|
@@ -469,40 +443,40 @@ export declare const bindDocModel: (Y: EngineApi) => {
|
|
|
469
443
|
after?: readonly import("./index.js").BlockSpec[];
|
|
470
444
|
}) => Prepared;
|
|
471
445
|
duplicateBlock: (id: BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => Prepared;
|
|
446
|
+
placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
|
|
447
|
+
wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
|
|
448
|
+
splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
|
|
449
|
+
mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
|
|
450
|
+
mergeBackward: (id: BlockId) => Prepared;
|
|
451
|
+
mergeForward: (id: BlockId) => Prepared;
|
|
452
|
+
deleteBlock: (id: BlockId, opts?: {
|
|
453
|
+
keepChildren?: boolean;
|
|
454
|
+
}) => Prepared;
|
|
455
|
+
setBlockType: (id: BlockId, type: string) => Prepared;
|
|
456
|
+
patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
|
|
457
|
+
setBlock: (id: BlockId, value: {
|
|
458
|
+
type?: string;
|
|
459
|
+
data?: Record<string, unknown>;
|
|
460
|
+
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
461
|
+
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
462
|
+
}) => Prepared;
|
|
463
|
+
insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
|
|
464
|
+
deleteText: (id: BlockId, offset: number, length: number) => Prepared;
|
|
465
|
+
formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
|
|
466
|
+
clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
|
|
467
|
+
insertInline: (id: BlockId, offset: number, atom: import("./doc/ops.js").NewInline) => Prepared;
|
|
468
|
+
removeInline: (id: BlockId, inlineId: string) => Prepared;
|
|
469
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => Prepared;
|
|
470
|
+
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
471
|
+
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
472
472
|
};
|
|
473
473
|
/** Write a prepared plan exactly (refusals pass through). */
|
|
474
474
|
apply: (p: Prepared, quiet?: boolean) => OpResult;
|
|
475
475
|
compose: (...parts: Prepared[]) => Prepared;
|
|
476
476
|
transact: <R>(fn: () => R, origin?: unknown) => R;
|
|
477
477
|
version: number;
|
|
478
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => OpResult;
|
|
479
|
-
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
480
|
-
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
481
478
|
nestBlock: (id: string, parent: string) => OpResult;
|
|
482
479
|
deleteBlocks: (ids: readonly string[]) => OpResult;
|
|
483
|
-
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => OpResult;
|
|
484
|
-
deleteText: (id: string, offset: number, length: number) => OpResult;
|
|
485
|
-
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => OpResult;
|
|
486
|
-
clearMarks: (id: string, offset: number, length: number) => OpResult;
|
|
487
|
-
insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => OpResult;
|
|
488
|
-
removeInline: (id: string, inlineId: string) => OpResult;
|
|
489
|
-
setBlockType: (id: string, type: string) => OpResult;
|
|
490
|
-
patchData: (target: DataTarget, patches: readonly DataPatch[]) => OpResult;
|
|
491
|
-
setBlock: (id: string, value: {
|
|
492
|
-
type?: string;
|
|
493
|
-
data?: Record<string, unknown>;
|
|
494
|
-
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
495
|
-
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
496
|
-
}) => OpResult;
|
|
497
|
-
deleteBlock: (id: string, opts?: {
|
|
498
|
-
keepChildren?: boolean;
|
|
499
|
-
} | undefined) => OpResult;
|
|
500
|
-
splitBlock: (id: string, offset: number, newId: string, tail?: SplitTail | undefined) => OpResult;
|
|
501
|
-
mergeBlocks: (fromId: string, intoId: string) => OpResult;
|
|
502
|
-
mergeBackward: (id: string) => OpResult;
|
|
503
|
-
mergeForward: (id: string) => OpResult;
|
|
504
|
-
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => OpResult;
|
|
505
|
-
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => OpResult;
|
|
506
480
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (JSONBlock | import("./index.js").BlockSpec)[]) => OpResult;
|
|
507
481
|
moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => OpResult;
|
|
508
482
|
unNestBlocks: (ids: readonly string[]) => OpResult;
|
|
@@ -512,6 +486,32 @@ export declare const bindDocModel: (Y: EngineApi) => {
|
|
|
512
486
|
after?: readonly import("./index.js").BlockSpec[];
|
|
513
487
|
} | undefined) => OpResult;
|
|
514
488
|
duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => OpResult;
|
|
489
|
+
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => OpResult;
|
|
490
|
+
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => OpResult;
|
|
491
|
+
splitBlock: (id: string, offset: number, newId: string, tail?: SplitTail | undefined) => OpResult;
|
|
492
|
+
mergeBlocks: (fromId: string, intoId: string) => OpResult;
|
|
493
|
+
mergeBackward: (id: string) => OpResult;
|
|
494
|
+
mergeForward: (id: string) => OpResult;
|
|
495
|
+
deleteBlock: (id: string, opts?: {
|
|
496
|
+
keepChildren?: boolean;
|
|
497
|
+
} | undefined) => OpResult;
|
|
498
|
+
setBlockType: (id: string, type: string) => OpResult;
|
|
499
|
+
patchData: (target: DataTarget, patches: readonly DataPatch[]) => OpResult;
|
|
500
|
+
setBlock: (id: string, value: {
|
|
501
|
+
type?: string;
|
|
502
|
+
data?: Record<string, unknown>;
|
|
503
|
+
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
504
|
+
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
505
|
+
}) => OpResult;
|
|
506
|
+
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => OpResult;
|
|
507
|
+
deleteText: (id: string, offset: number, length: number) => OpResult;
|
|
508
|
+
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => OpResult;
|
|
509
|
+
clearMarks: (id: string, offset: number, length: number) => OpResult;
|
|
510
|
+
insertInline: (id: string, offset: number, atom: import("./doc/ops.js").NewInline) => OpResult;
|
|
511
|
+
removeInline: (id: string, inlineId: string) => OpResult;
|
|
512
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => OpResult;
|
|
513
|
+
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
514
|
+
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
515
515
|
project: () => import("./index.js").ProjectedDoc;
|
|
516
516
|
toJSON: (options?: {
|
|
517
517
|
suggestions?: boolean;
|
|
@@ -834,9 +834,6 @@ export declare const bindEdytorDoc: (Y: EngineApi) => {
|
|
|
834
834
|
} & {
|
|
835
835
|
/** Every op prepared: pure, a plan of named steps + its effect, or `refused`. */
|
|
836
836
|
prepare: {
|
|
837
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => Prepared;
|
|
838
|
-
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
839
|
-
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
840
837
|
/**
|
|
841
838
|
* Move `id` to the last position under `parent` — under a container
|
|
842
839
|
* it is no item of, under its last item (`nestParent`: Tab after a list).
|
|
@@ -844,29 +841,6 @@ export declare const bindEdytorDoc: (Y: EngineApi) => {
|
|
|
844
841
|
nestBlock: (id: BlockId, parent: BlockId) => Prepared;
|
|
845
842
|
/** Delete a block selection — one plan; only the members leave (`deleteBlocks` above). */
|
|
846
843
|
deleteBlocks: (ids: readonly BlockId[]) => Prepared;
|
|
847
|
-
insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
|
|
848
|
-
deleteText: (id: BlockId, offset: number, length: number) => Prepared;
|
|
849
|
-
formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
|
|
850
|
-
clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
|
|
851
|
-
insertInline: (id: BlockId, offset: number, atom: import("./doc/content.js").NewInline) => Prepared;
|
|
852
|
-
removeInline: (id: BlockId, inlineId: string) => Prepared;
|
|
853
|
-
setBlockType: (id: BlockId, type: string) => Prepared;
|
|
854
|
-
patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
|
|
855
|
-
setBlock: (id: BlockId, value: {
|
|
856
|
-
type?: string;
|
|
857
|
-
data?: Record<string, unknown>;
|
|
858
|
-
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
859
|
-
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
860
|
-
}) => Prepared;
|
|
861
|
-
deleteBlock: (id: BlockId, opts?: {
|
|
862
|
-
keepChildren?: boolean;
|
|
863
|
-
}) => Prepared;
|
|
864
|
-
splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
|
|
865
|
-
mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
|
|
866
|
-
mergeBackward: (id: BlockId) => Prepared;
|
|
867
|
-
mergeForward: (id: BlockId) => Prepared;
|
|
868
|
-
placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
|
|
869
|
-
wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
|
|
870
844
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | JSONBlock)[]) => Prepared;
|
|
871
845
|
moveBlocks: (ids: readonly BlockId[], dest: import("./index.js").Destination) => Prepared;
|
|
872
846
|
unNestBlocks: (ids: readonly BlockId[]) => Prepared;
|
|
@@ -876,40 +850,40 @@ export declare const bindEdytorDoc: (Y: EngineApi) => {
|
|
|
876
850
|
after?: readonly import("./index.js").BlockSpec[];
|
|
877
851
|
}) => Prepared;
|
|
878
852
|
duplicateBlock: (id: BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => Prepared;
|
|
853
|
+
placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
|
|
854
|
+
wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
|
|
855
|
+
splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
|
|
856
|
+
mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
|
|
857
|
+
mergeBackward: (id: BlockId) => Prepared;
|
|
858
|
+
mergeForward: (id: BlockId) => Prepared;
|
|
859
|
+
deleteBlock: (id: BlockId, opts?: {
|
|
860
|
+
keepChildren?: boolean;
|
|
861
|
+
}) => Prepared;
|
|
862
|
+
setBlockType: (id: BlockId, type: string) => Prepared;
|
|
863
|
+
patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
|
|
864
|
+
setBlock: (id: BlockId, value: {
|
|
865
|
+
type?: string;
|
|
866
|
+
data?: Record<string, unknown>;
|
|
867
|
+
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
868
|
+
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
869
|
+
}) => Prepared;
|
|
870
|
+
insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
|
|
871
|
+
deleteText: (id: BlockId, offset: number, length: number) => Prepared;
|
|
872
|
+
formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
|
|
873
|
+
clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
|
|
874
|
+
insertInline: (id: BlockId, offset: number, atom: import("./doc/ops.js").NewInline) => Prepared;
|
|
875
|
+
removeInline: (id: BlockId, inlineId: string) => Prepared;
|
|
876
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => Prepared;
|
|
877
|
+
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
878
|
+
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView) => Prepared;
|
|
879
879
|
};
|
|
880
880
|
/** Write a prepared plan exactly (refusals pass through). */
|
|
881
881
|
apply: (p: Prepared, quiet?: boolean) => OpResult;
|
|
882
882
|
compose: (...parts: Prepared[]) => Prepared;
|
|
883
883
|
transact: <R>(fn: () => R, origin?: unknown) => R;
|
|
884
884
|
version: number;
|
|
885
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => OpResult;
|
|
886
|
-
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
887
|
-
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
888
885
|
nestBlock: (id: string, parent: string) => OpResult;
|
|
889
886
|
deleteBlocks: (ids: readonly string[]) => OpResult;
|
|
890
|
-
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => OpResult;
|
|
891
|
-
deleteText: (id: string, offset: number, length: number) => OpResult;
|
|
892
|
-
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => OpResult;
|
|
893
|
-
clearMarks: (id: string, offset: number, length: number) => OpResult;
|
|
894
|
-
insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => OpResult;
|
|
895
|
-
removeInline: (id: string, inlineId: string) => OpResult;
|
|
896
|
-
setBlockType: (id: string, type: string) => OpResult;
|
|
897
|
-
patchData: (target: DataTarget, patches: readonly DataPatch[]) => OpResult;
|
|
898
|
-
setBlock: (id: string, value: {
|
|
899
|
-
type?: string;
|
|
900
|
-
data?: Record<string, unknown>;
|
|
901
|
-
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
902
|
-
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
903
|
-
}) => OpResult;
|
|
904
|
-
deleteBlock: (id: string, opts?: {
|
|
905
|
-
keepChildren?: boolean;
|
|
906
|
-
} | undefined) => OpResult;
|
|
907
|
-
splitBlock: (id: string, offset: number, newId: string, tail?: SplitTail | undefined) => OpResult;
|
|
908
|
-
mergeBlocks: (fromId: string, intoId: string) => OpResult;
|
|
909
|
-
mergeBackward: (id: string) => OpResult;
|
|
910
|
-
mergeForward: (id: string) => OpResult;
|
|
911
|
-
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => OpResult;
|
|
912
|
-
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => OpResult;
|
|
913
887
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (JSONBlock | import("./index.js").BlockSpec)[]) => OpResult;
|
|
914
888
|
moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => OpResult;
|
|
915
889
|
unNestBlocks: (ids: readonly string[]) => OpResult;
|
|
@@ -919,6 +893,32 @@ export declare const bindEdytorDoc: (Y: EngineApi) => {
|
|
|
919
893
|
after?: readonly import("./index.js").BlockSpec[];
|
|
920
894
|
} | undefined) => OpResult;
|
|
921
895
|
duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => OpResult;
|
|
896
|
+
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => OpResult;
|
|
897
|
+
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => OpResult;
|
|
898
|
+
splitBlock: (id: string, offset: number, newId: string, tail?: SplitTail | undefined) => OpResult;
|
|
899
|
+
mergeBlocks: (fromId: string, intoId: string) => OpResult;
|
|
900
|
+
mergeBackward: (id: string) => OpResult;
|
|
901
|
+
mergeForward: (id: string) => OpResult;
|
|
902
|
+
deleteBlock: (id: string, opts?: {
|
|
903
|
+
keepChildren?: boolean;
|
|
904
|
+
} | undefined) => OpResult;
|
|
905
|
+
setBlockType: (id: string, type: string) => OpResult;
|
|
906
|
+
patchData: (target: DataTarget, patches: readonly DataPatch[]) => OpResult;
|
|
907
|
+
setBlock: (id: string, value: {
|
|
908
|
+
type?: string;
|
|
909
|
+
data?: Record<string, unknown>;
|
|
910
|
+
content?: (ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
911
|
+
children?: (import("./index.js").BlockSpec | JSONBlock)[];
|
|
912
|
+
}) => OpResult;
|
|
913
|
+
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => OpResult;
|
|
914
|
+
deleteText: (id: string, offset: number, length: number) => OpResult;
|
|
915
|
+
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => OpResult;
|
|
916
|
+
clearMarks: (id: string, offset: number, length: number) => OpResult;
|
|
917
|
+
insertInline: (id: string, offset: number, atom: import("./doc/ops.js").NewInline) => OpResult;
|
|
918
|
+
removeInline: (id: string, inlineId: string) => OpResult;
|
|
919
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => OpResult;
|
|
920
|
+
deleteRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
921
|
+
replaceRange: (from: DocPosition, to: DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => OpResult;
|
|
922
922
|
project: () => import("./index.js").ProjectedDoc;
|
|
923
923
|
toJSON: (options?: {
|
|
924
924
|
suggestions?: boolean;
|
package/dist/crdt/edytor-doc.js
CHANGED
|
@@ -23,18 +23,16 @@
|
|
|
23
23
|
* `doc/types.ts` — the public types; `doc/plan.ts` — op results, a plan's
|
|
24
24
|
* effect, ingress normalization.
|
|
25
25
|
* - `doc/reads.ts` (`DocBase`: the doc, its engine, its index and
|
|
26
|
-
* roles) — the reads, roles and document order
|
|
27
|
-
* structural capability (`canPlace`, `fits`, `canMerge`, the island and
|
|
28
|
-
* void rules).
|
|
26
|
+
* roles) — the reads, roles and document order.
|
|
29
27
|
* - `doc/funnel.ts` — the write funnel (`write`, `apply`, attribution);
|
|
30
28
|
* `doc/events.ts` — `onChange`; `doc/history.ts` —
|
|
31
29
|
* `createUndoManager`; `doc/anchors.ts` — caret anchors.
|
|
32
|
-
* - `doc/
|
|
33
|
-
*
|
|
34
|
-
* (
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `rangeDelete.ts` and `flow.ts
|
|
30
|
+
* - `doc/ops.ts` — one closure over the reads: the structural capability
|
|
31
|
+
* (`canPlace`, `fits`, `canMerge`, the island and void rules), the step
|
|
32
|
+
* writers every op composes (ranks, settle, emptying, dissolving) and the
|
|
33
|
+
* prepared op families (placement, layout, split and merge, delete, type
|
|
34
|
+
* and data, text, atoms and marks), then range deletion and flow placement
|
|
35
|
+
* over them (their types in `rangeDelete.ts` and `flow.ts`).
|
|
38
36
|
*
|
|
39
37
|
* ── Identity discipline ────────────────────────────────────────────────
|
|
40
38
|
*
|
|
@@ -56,24 +54,15 @@ import { bindPurge, readHorizon } from './purge.js';
|
|
|
56
54
|
import { restoreDocument } from './restore.js';
|
|
57
55
|
import { bindRuns, indexOf } from './text/runs.js';
|
|
58
56
|
import { bindBlockAttribution, blockAttributionOf } from './attribution/block.js';
|
|
59
|
-
import { rangeDeleteOps } from './rangeDelete.js';
|
|
60
|
-
import { flowOps } from './flow.js';
|
|
61
57
|
import { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
|
|
62
58
|
import { bindSeed, restore } from './doc/seed.js';
|
|
63
59
|
import { applied, ref } from './doc/plan.js';
|
|
64
60
|
import { docReads } from './doc/reads.js';
|
|
65
|
-
import { docCapability } from './doc/capability.js';
|
|
66
61
|
import { writeFunnel } from './doc/funnel.js';
|
|
67
62
|
import { docEvents } from './doc/events.js';
|
|
68
63
|
import { docHistory } from './doc/history.js';
|
|
69
64
|
import { docAnchors } from './doc/anchors.js';
|
|
70
|
-
import {
|
|
71
|
-
import { moveOps } from './doc/moves.js';
|
|
72
|
-
import { layoutOps } from './doc/layout.js';
|
|
73
|
-
import { splitMergeOps } from './doc/split-merge.js';
|
|
74
|
-
import { deleteOps } from './doc/delete.js';
|
|
75
|
-
import { metaOps } from './doc/meta.js';
|
|
76
|
-
import { contentOps } from './doc/content.js';
|
|
65
|
+
import { docOps } from './doc/ops.js';
|
|
77
66
|
// ── schema manifest and gate (`doc/gate.ts`) ────────────────────────────
|
|
78
67
|
export { SCHEMA };
|
|
79
68
|
export { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
|
|
@@ -165,9 +154,10 @@ export const docFacade = (Y, layers) => {
|
|
|
165
154
|
// The facade's parts, each over the ones before it (`doc/*`).
|
|
166
155
|
const base = { Y, doc, runsView, roles, roleOf, rendersContentOf };
|
|
167
156
|
const reads = { ...base, ...docReads(base) };
|
|
168
|
-
|
|
157
|
+
// The capability, the step writers and the prepared op families (`doc/ops.ts`).
|
|
158
|
+
const ops = { ...reads, ...docOps(reads) };
|
|
169
159
|
const { blockJSON, view, blockTypeOf, blockDataOf, docData, dataItemIds, dataPreview, childrenIds, positionOf, pathOf, ancestorsOf, slotOf, isVoid, isIsland, isLines, islandOf, insideIsland, isLayout, isLayoutItem, order, compare, next, previous, displayLength, contentItems, hasBlock, live } = reads;
|
|
170
|
-
const { canPlace, fits, nestParent, canMerge, defaultChild } =
|
|
160
|
+
const { canPlace, fits, nestParent, canMerge, defaultChild, plan, landingOf, besideAt } = ops;
|
|
171
161
|
const funnel = writeFunnel({ ...reads, BA, config });
|
|
172
162
|
const { write, apply } = funnel;
|
|
173
163
|
const events = docEvents({ runsView });
|
|
@@ -178,37 +168,19 @@ export const docFacade = (Y, layers) => {
|
|
|
178
168
|
};
|
|
179
169
|
const { createUndoManager } = docHistory({ ...base, ...funnel, init });
|
|
180
170
|
const { anchorAt, followUndo, resolveAnchor } = docAnchors(reads);
|
|
181
|
-
const steps = { ...shape, ...planSteps(shape) };
|
|
182
|
-
const { plan } = steps;
|
|
183
|
-
// The prepared op families (`OpsContext`: the reads, capability and step
|
|
184
|
-
// writers): every op they answer is a document write, but for the reads
|
|
185
|
-
// and step writers taken out here.
|
|
186
|
-
const { landingOf, ...moves } = moveOps(steps);
|
|
187
|
-
const { besideAt, ...layouts } = layoutOps(steps);
|
|
188
|
-
const { dataSteps, replaceData, ...metas } = metaOps(steps);
|
|
189
|
-
const deletes = deleteOps(steps);
|
|
190
|
-
/** What range deletion and flow placement compose: the step writers and the ops. */
|
|
191
|
-
const ops = { ...steps, ...moves, ...deletes, dataSteps, replaceData };
|
|
192
171
|
/** Every document op, prepared — `apply(prepare.op(…))` is the op. */
|
|
193
172
|
const prepare = {
|
|
194
|
-
...
|
|
195
|
-
...layouts,
|
|
196
|
-
...splitMergeOps(steps),
|
|
197
|
-
...deletes,
|
|
198
|
-
...metas,
|
|
199
|
-
...contentOps(steps),
|
|
173
|
+
...ops.prepare,
|
|
200
174
|
/**
|
|
201
175
|
* Move `id` to the last position under `parent` — under a container
|
|
202
176
|
* it is no item of, under its last item (`nestParent`: Tab after a list).
|
|
203
177
|
*/
|
|
204
178
|
nestBlock: (id, parent) => {
|
|
205
179
|
const at = nestParent([ref(id)], ref(parent));
|
|
206
|
-
return
|
|
180
|
+
return ops.prepare.moveBlocks([id], { parent: at, index: childrenIds(at).length });
|
|
207
181
|
},
|
|
208
182
|
/** Delete a block selection — one plan; only the members leave (`deleteBlocks` above). */
|
|
209
|
-
deleteBlocks: (ids) =>
|
|
210
|
-
...rangeDeleteOps(ops),
|
|
211
|
-
...flowOps(ops)
|
|
183
|
+
deleteBlocks: (ids) => ops.prepare.deleteBlocks(ids)
|
|
212
184
|
};
|
|
213
185
|
/**
|
|
214
186
|
* What a part built over this document reads beyond the facade (the
|
package/dist/crdt/flow.d.ts
CHANGED
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `docs/editor-delete-contract.md`:
|
|
5
|
-
*
|
|
6
|
-
* - a flow is lines with fresh ids: a kinded block, or an inline run (no
|
|
7
|
-
* `type`); an empty flow changes nothing (`flow.shape`);
|
|
8
|
-
* - one line joins the text at the position; an empty block takes a kinded
|
|
9
|
-
* line's kind (`flow.inline`);
|
|
10
|
-
* - several lines split the block: the first joins the head, the last is the
|
|
11
|
-
* tail's block and takes the text after the position and the block's
|
|
12
|
-
* children, the rest go between (`flow.split`) — children the view
|
|
13
|
-
* hides (a closed toggle's body) stay with the head, as Enter keeps them;
|
|
14
|
-
* - a line that joins no text (a list, a code block, a divider: it renders
|
|
15
|
-
* none of its own, or is a void or an island) is placed as a block, never
|
|
16
|
-
* joined; the text after the position stays in a shown line of the
|
|
17
|
-
* block's kind (`flow.apart`), and the caret ends the last pasted
|
|
18
|
-
* shown line;
|
|
19
|
-
* - in a code line (a `lines` island) the lines, nested ones included, are
|
|
20
|
-
* placed as plain lines (`flow.lines`);
|
|
21
|
-
* - a `whole` flow (a block-selection copy) goes after the block, replacing
|
|
22
|
-
* it when empty (`flow.whole`); over selected blocks the lines take their
|
|
23
|
-
* slot (`flow.slot`), and at a slot they are placed with nothing replaced
|
|
24
|
-
* (`flow.place`: an accepted suggestion), as plain inserts (`insertBlocks`: their order
|
|
25
|
-
* against a peer's split beside them is not claimed); a void
|
|
26
|
-
* takes one run (`flow.void`);
|
|
27
|
-
* - a table's cell is never split: it takes the lines a flow shows, nested
|
|
28
|
-
* ones and a pasted table's cells included, as one text joined by line
|
|
29
|
-
* breaks; a cell outside a row (cells copied out of a table) is a line of
|
|
30
|
-
* text, and a row outside a table its cells (`table.paste`);
|
|
31
|
-
* - a plain line that lands directly in a container takes its item kind
|
|
32
|
-
* (the document's `fitted`: a pasted paragraph in a list is its item),
|
|
33
|
-
* and so does a line of the list's flat item kind (the view's
|
|
34
|
-
* `itemKind`: a pasted numbered item in an `ordered-list`); any
|
|
35
|
-
* other kind keeps its kind and data (a pasted image stays an image, a
|
|
36
|
-
* bulleted item in an `ordered-list` a bulleted item).
|
|
2
|
+
* The types flow placement (`insertFlow`: the `flow.*` rows, prepared in
|
|
3
|
+
* `doc/ops.ts`) reads, and where the caret ends a placed block.
|
|
37
4
|
*/
|
|
38
5
|
import type { BlockId, BlockSpec, Destination } from './placement/model.js';
|
|
39
|
-
import type { Prepared } from './edytor-doc.js';
|
|
40
6
|
import type { DocPosition, RangeView } from './rangeDelete.js';
|
|
41
|
-
import type { OpsContext } from './doc/steps.js';
|
|
42
|
-
import type { MoveOps } from './doc/moves.js';
|
|
43
|
-
import type { DeleteOps } from './doc/delete.js';
|
|
44
|
-
import type { MetaOps } from './doc/meta.js';
|
|
45
7
|
/** One line of a flow: a kinded block, or an inline run when it has no `type`. */
|
|
46
8
|
export type FlowLine = Omit<BlockSpec, 'type'> & {
|
|
47
9
|
type?: string;
|
|
@@ -72,8 +34,8 @@ export type FlowTarget = DocPosition | {
|
|
|
72
34
|
} | {
|
|
73
35
|
slot: Destination;
|
|
74
36
|
};
|
|
75
|
-
/**
|
|
76
|
-
export
|
|
37
|
+
/** The units of a line's content (an atom counts 1). */
|
|
38
|
+
export declare const lengthOf: (l: FlowLine) => number;
|
|
77
39
|
/**
|
|
78
40
|
* Where the caret ends a placed block: its own content's end when it shows a
|
|
79
41
|
* line (renders its content, no void; a toggle's header, never its body),
|
|
@@ -85,7 +47,3 @@ export declare const placedEnd: (roleOf: (kind: string) => {
|
|
|
85
47
|
childless: boolean;
|
|
86
48
|
rendersContent: boolean;
|
|
87
49
|
}) => (s: BlockSpec) => DocPosition | undefined;
|
|
88
|
-
/** `insertFlow`, prepared. */
|
|
89
|
-
export declare const flowOps: (c: FlowContext) => {
|
|
90
|
-
insertFlow: (target: FlowTarget, flow: Flow, view?: FlowView) => Prepared;
|
|
91
|
-
};
|