@articollab/codemirror 0.0.0-stage → 0.13.0-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # @articollab/codemirror
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ CodeMirror bindings for Articollab Text.
4
+
5
+ [Read the CodeMirror guide](https://eastsun5566.github.io/articollab/#/codemirror).
6
+
7
+ MIT.
@@ -0,0 +1,21 @@
1
+ import type { Extension } from "@codemirror/state";
2
+ import { EditorView } from "@codemirror/view";
3
+ import { type RemoteSelection, type RemoteSelectionStatus } from "./sync.ts";
4
+ export interface RemoteSelectionsOptions {
5
+ /** The class of a selected range. Default `"articollab-selection"`. */
6
+ readonly selectionClass?: string;
7
+ /** Draws the caret at a selection's end; by default a `<span class="articollab-caret">` with `data-label`. */
8
+ readonly caret?: (label: string) => HTMLElement;
9
+ }
10
+ /**
11
+ * An extension that draws other writers' selections, placed from their cursors when they are set
12
+ * and after each change, and moved with edits in between. Needs `textSync`. While an input method
13
+ * composes it draws none; they come back when the composition ends.
14
+ */
15
+ export declare function remoteSelections(options?: RemoteSelectionsOptions): Extension;
16
+ /**
17
+ * Replaces the other writers' selections the editor shows. Returns whether each could be placed;
18
+ * one whose text has not reached this writer yet is left out until it can be.
19
+ */
20
+ export declare function setRemoteSelections(view: EditorView, selections: readonly RemoteSelection[]): RemoteSelectionStatus[];
21
+ //# sourceMappingURL=cursors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../src/cursors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAc,UAAU,EAAkC,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAwC,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEnH,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,8GAA8G;IAC9G,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;CACjD;AA0BD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,SAAS,CAajF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,eAAe,EAAE,GAAG,qBAAqB,EAAE,CAOrH"}
@@ -0,0 +1,55 @@
1
+ import { Decoration, EditorView, WidgetType } from "@codemirror/view";
2
+ import { bindingOf, isComposing, remoteRanges } from "./sync.js";
3
+ class Caret extends WidgetType {
4
+ label;
5
+ draw;
6
+ constructor(label, draw) {
7
+ super();
8
+ this.label = label;
9
+ this.draw = draw;
10
+ }
11
+ eq(other) { return other.label === this.label && other.draw === this.draw; }
12
+ toDOM() {
13
+ if (this.draw !== undefined)
14
+ return this.draw(this.label);
15
+ const caret = document.createElement("span");
16
+ caret.className = "articollab-caret";
17
+ caret.setAttribute("aria-hidden", "true");
18
+ caret.dataset.label = this.label;
19
+ return caret;
20
+ }
21
+ ignoreEvent() { return true; }
22
+ }
23
+ /**
24
+ * An extension that draws other writers' selections, placed from their cursors when they are set
25
+ * and after each change, and moved with edits in between. Needs `textSync`. While an input method
26
+ * composes it draws none; they come back when the composition ends.
27
+ */
28
+ export function remoteSelections(options = {}) {
29
+ const selectionClass = options.selectionClass ?? "articollab-selection";
30
+ return [
31
+ remoteRanges,
32
+ EditorView.decorations.of((view) => {
33
+ const ranges = view.state.field(remoteRanges);
34
+ if (ranges.length === 0 || isComposing(view))
35
+ return Decoration.none;
36
+ return Decoration.set(ranges.flatMap(({ label, from, to }) => [
37
+ ...(from < to ? [Decoration.mark({ class: selectionClass, attributes: { title: label } }).range(from, to)] : []),
38
+ Decoration.widget({ widget: new Caret(label, options.caret), side: from < to ? 1 : -1 }).range(to),
39
+ ]), true);
40
+ }),
41
+ ];
42
+ }
43
+ /**
44
+ * Replaces the other writers' selections the editor shows. Returns whether each could be placed;
45
+ * one whose text has not reached this writer yet is left out until it can be.
46
+ */
47
+ export function setRemoteSelections(view, selections) {
48
+ const binding = bindingOf(view.state);
49
+ if (binding === undefined || view.state.field(remoteRanges, false) === undefined) {
50
+ throw new TypeError("setRemoteSelections needs the textSync and remoteSelections extensions");
51
+ }
52
+ binding.remote = selections;
53
+ return binding.resolveRemote(view);
54
+ }
55
+ //# sourceMappingURL=cursors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursors.js","sourceRoot":"","sources":["../src/cursors.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Aa,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { remoteSelections, setRemoteSelections, type RemoteSelectionsOptions } from "./cursors.ts";
2
+ export { isComposing, redo, resolveSelection, selectionCursors, selectionIndices, textFormatting, textSync, undo, type Attributes, type CursorSelection, type Embed, type EmbedAt, type LineAttributes, type MarkRange, type RemoteSelection, type RemoteSelectionStatus, type TextDecorations, type TextFormatting, type TextPath, type TextSyncOptions, } from "./sync.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACnG,OAAO,EACL,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { remoteSelections, setRemoteSelections } from "./cursors.js";
2
+ export { isComposing, redo, resolveSelection, selectionCursors, selectionIndices, textFormatting, textSync, undo, } from "./sync.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAgC,MAAM,cAAc,CAAC;AACnG,OAAO,EACL,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,IAAI,GAaL,MAAM,WAAW,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { TextChangeEvent } from "@articollab/core";
2
+ import type { Transaction } from "@codemirror/state";
3
+ /**
4
+ * Text counts code points; CodeMirror counts UTF-16 units. They differ only at elements two units
5
+ * long, such as most emoji, so the mirror keeps just those elements' indices, sorted.
6
+ */
7
+ export interface TextMirror {
8
+ readonly length: number;
9
+ readonly wide: readonly number[];
10
+ }
11
+ /** One replacement in Text element indices. */
12
+ export interface ElementEdit {
13
+ readonly index: number;
14
+ readonly deleteCount: number;
15
+ readonly insert: string;
16
+ }
17
+ export declare function createMirror(elements: Iterable<string>): TextMirror;
18
+ /** The UTF-16 offset of an element gap. */
19
+ export declare function editorOffset(mirror: TextMirror, index: number): number;
20
+ /** The element gap at or before a UTF-16 offset; an offset inside a surrogate pair maps to the gap before it. */
21
+ export declare function elementIndexAt(mirror: TextMirror, offset: number): number;
22
+ /**
23
+ * A transaction's changes as Text edits, in descending element order so that each applies in the
24
+ * coordinates the earlier ones left. A change inside a wide element replaces the whole element, and
25
+ * a region whose text is the same afterwards is left out.
26
+ */
27
+ export declare function editorEdits(mirror: TextMirror, transaction: Transaction): ElementEdit[];
28
+ /**
29
+ * A Text change event as editor changes in the event's pre-event UTF-16 offsets, and the mirror
30
+ * after it. Throws if the event does not start from the mirror's length.
31
+ */
32
+ export declare function textEdits(mirror: TextMirror, event: TextChangeEvent): {
33
+ readonly changes: {
34
+ readonly from: number;
35
+ readonly to: number;
36
+ readonly insert: string;
37
+ }[];
38
+ readonly mirror: TextMirror;
39
+ };
40
+ //# sourceMappingURL=mirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mirror.d.ts","sourceRoot":"","sources":["../src/mirror.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,+CAA+C;AAC/C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,UAAU,CAQnE;AAcD,2CAA2C;AAC3C,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtE;AAoBD,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,EAAE,CAsBvF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG;IACrE,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5F,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,CAwBA"}
package/dist/mirror.js ADDED
@@ -0,0 +1,119 @@
1
+ export function createMirror(elements) {
2
+ const wide = [];
3
+ let length = 0;
4
+ for (const element of elements) {
5
+ if (element.length === 2)
6
+ wide.push(length);
7
+ length++;
8
+ }
9
+ return { length, wide };
10
+ }
11
+ /** Number of entries in sorted `values` that are less than `limit`. */
12
+ function countBelow(values, limit) {
13
+ let low = 0, high = values.length;
14
+ while (low < high) {
15
+ const middle = (low + high) >>> 1;
16
+ const value = values[middle];
17
+ if (value !== undefined && value < limit)
18
+ low = middle + 1;
19
+ else
20
+ high = middle;
21
+ }
22
+ return low;
23
+ }
24
+ /** The UTF-16 offset of an element gap. */
25
+ export function editorOffset(mirror, index) {
26
+ if (!Number.isSafeInteger(index) || index < 0 || index > mirror.length) {
27
+ throw new Error("Position is outside the Text mirror");
28
+ }
29
+ return mirror.wide.length === 0 ? index : index + countBelow(mirror.wide, index);
30
+ }
31
+ /** The element gap at or before a UTF-16 offset, and whether the offset splits a wide element. */
32
+ function elementAt(mirror, offset) {
33
+ const { wide } = mirror;
34
+ // Wide element k ends at wide[k] + k + 2, which increases strictly with k.
35
+ let low = 0, high = wide.length;
36
+ while (low < high) {
37
+ const middle = (low + high) >>> 1;
38
+ const start = wide[middle];
39
+ if (start !== undefined && start + middle + 2 <= offset)
40
+ low = middle + 1;
41
+ else
42
+ high = middle;
43
+ }
44
+ const next = wide[low];
45
+ if (next !== undefined && next + low + 1 === offset)
46
+ return { index: next, inside: true };
47
+ const index = offset - low;
48
+ if (index < 0 || index > mirror.length)
49
+ throw new Error("Position is outside the Text mirror");
50
+ return { index, inside: false };
51
+ }
52
+ /** The element gap at or before a UTF-16 offset; an offset inside a surrogate pair maps to the gap before it. */
53
+ export function elementIndexAt(mirror, offset) {
54
+ return elementAt(mirror, offset).index;
55
+ }
56
+ /**
57
+ * A transaction's changes as Text edits, in descending element order so that each applies in the
58
+ * coordinates the earlier ones left. A change inside a wide element replaces the whole element, and
59
+ * a region whose text is the same afterwards is left out.
60
+ */
61
+ export function editorEdits(mirror, transaction) {
62
+ if (editorOffset(mirror, mirror.length) !== transaction.startState.doc.length) {
63
+ throw new Error("Editor and Text mirror lengths differ");
64
+ }
65
+ const regions = [];
66
+ transaction.changes.iterChanges((from, to) => {
67
+ const start = elementAt(mirror, from).index;
68
+ const last = elementAt(mirror, to);
69
+ const end = last.inside ? last.index + 1 : last.index;
70
+ const previous = regions.at(-1);
71
+ if (previous !== undefined && start <= previous.end)
72
+ previous.end = Math.max(previous.end, end);
73
+ else
74
+ regions.push({ start, end });
75
+ });
76
+ return regions.flatMap(({ start, end }) => {
77
+ const oldFrom = editorOffset(mirror, start), oldTo = editorOffset(mirror, end);
78
+ const from = transaction.changes.mapPos(oldFrom, -1);
79
+ const to = transaction.changes.mapPos(oldTo, 1);
80
+ const insert = transaction.newDoc.sliceString(from, to, "\n");
81
+ return transaction.startState.doc.sliceString(oldFrom, oldTo, "\n") === insert ? [] : [{
82
+ index: start, deleteCount: end - start, insert,
83
+ }];
84
+ }).toReversed();
85
+ }
86
+ /**
87
+ * A Text change event as editor changes in the event's pre-event UTF-16 offsets, and the mirror
88
+ * after it. Throws if the event does not start from the mirror's length.
89
+ */
90
+ export function textEdits(mirror, event) {
91
+ if (mirror.length !== event.beforeLength)
92
+ throw new Error("Text observer baseline differs");
93
+ const changes = event.changes.map(({ index, deleteCount, insert }) => ({
94
+ from: editorOffset(mirror, index), to: editorOffset(mirror, index + deleteCount), insert: insert.join(""),
95
+ })).toReversed();
96
+ const wide = [...mirror.wide];
97
+ let length = mirror.length;
98
+ // Changes arrive in descending order, so each leaves the indices of the next ones alone.
99
+ for (const { index, deleteCount, insert } of event.changes) {
100
+ const first = countBelow(wide, index), last = countBelow(wide, index + deleteCount);
101
+ const inserted = [];
102
+ insert.forEach((element, offset) => { if (element.length === 2)
103
+ inserted.push(index + offset); });
104
+ wide.splice(first, last - first, ...inserted);
105
+ const shift = insert.length - deleteCount;
106
+ if (shift !== 0) {
107
+ for (let position = first + inserted.length; position < wide.length; position++) {
108
+ const value = wide[position];
109
+ if (value !== undefined)
110
+ wide[position] = value + shift;
111
+ }
112
+ }
113
+ length += shift;
114
+ }
115
+ if (length !== event.afterLength)
116
+ throw new Error("Text observer result length differs");
117
+ return { changes, mirror: { length, wide } };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Field, type Extension } from "@codemirror/state";
2
+ import { Decoration, EditorView, type Command, type ViewUpdate } from "@codemirror/view";
3
+ import type { ClientDocument, Cursor, JsonValue, SchemaShape, TextChangeEvent, TextSchema, UndoManager } from "@articollab/core";
4
+ /** A selection as two cursors; `from === to` is a caret. */
5
+ export interface CursorSelection {
6
+ readonly from: Cursor;
7
+ readonly to: Cursor;
8
+ }
9
+ /** Marks or paragraph attributes, by key. */
10
+ export type Attributes = Readonly<Record<string, JsonValue>>;
11
+ /** An embed as the Text reads it: its kind as the only key, with its value. */
12
+ export type Embed = Readonly<Record<string, JsonValue>>;
13
+ /** Formatted text from `from` to `to`, in UTF-16 offsets. */
14
+ export interface MarkRange {
15
+ readonly from: number;
16
+ readonly to: number;
17
+ readonly attributes: Attributes;
18
+ }
19
+ /** The paragraph attributes of the line that starts at `from`. */
20
+ export interface LineAttributes {
21
+ readonly from: number;
22
+ readonly attributes: Attributes;
23
+ }
24
+ /** An embed shown as the U+FFFC at `from`. */
25
+ export interface EmbedAt {
26
+ readonly from: number;
27
+ readonly embed: Embed;
28
+ }
29
+ /** The Text's formatting in the editor's offsets: only runs with marks, lines with attributes, and embeds. */
30
+ export interface TextFormatting {
31
+ readonly marks: readonly MarkRange[];
32
+ readonly lines: readonly LineAttributes[];
33
+ readonly embeds: readonly EmbedAt[];
34
+ }
35
+ /** Decorations for the Text's formatting; return null to draw nothing. */
36
+ export interface TextDecorations {
37
+ readonly mark?: (attributes: Attributes) => Decoration | null;
38
+ readonly line?: (attributes: Attributes) => Decoration | null;
39
+ readonly embed?: (embed: Embed) => Decoration | null;
40
+ }
41
+ export interface TextSyncOptions {
42
+ /** Ends an undo step around a confirmed input method composition, so it is a step of its own. */
43
+ readonly history?: UndoManager;
44
+ /** Whether local edits may be written now; an edit is refused while it returns false. */
45
+ readonly canEdit?: () => boolean;
46
+ /** Called with an error that stopped the binding; local edits are refused from then on. */
47
+ readonly onError?: (error: unknown) => void;
48
+ /** Called with the text of a composition that could not be written, for the user to copy. */
49
+ readonly onUnsentComposition?: (text: string) => void;
50
+ /** How to draw marks, paragraph attributes and embeds. Without it the formatting is only kept in state. */
51
+ readonly decorate?: TextDecorations;
52
+ }
53
+ /** Paths of a schema whose collection is a Text. */
54
+ export type TextPath<S extends SchemaShape> = {
55
+ [K in keyof S & string]: S[K] extends TextSchema ? K : never;
56
+ }[keyof S & string];
57
+ /** The part of a Text the binding reads and writes. */
58
+ interface SyncedText extends Iterable<string> {
59
+ readonly length: number;
60
+ insert(index: number, value: string): void;
61
+ delete(index: number, count?: number): void;
62
+ toString(): string;
63
+ toDelta(index?: number, count?: number): readonly {
64
+ readonly insert: string | Embed;
65
+ readonly attributes?: Attributes;
66
+ }[];
67
+ blocks(index?: number, count?: number): readonly {
68
+ readonly index: number;
69
+ readonly attributes: Attributes;
70
+ }[];
71
+ cursorAt(index: number, bind?: "left" | "right"): Cursor;
72
+ cursorIndex(cursor: Cursor): number | undefined;
73
+ embedAt(index: number): Embed | undefined;
74
+ observe(listener: (event: TextChangeEvent) => void): () => void;
75
+ }
76
+ /** The document a binding writes through: its Text, transactions and replay state. */
77
+ interface SyncedDocument {
78
+ readonly state: Readonly<Record<string, unknown>>;
79
+ transact(callback: () => void): void;
80
+ readonly replayConflict: unknown;
81
+ }
82
+ /** A selection in UTF-16 offsets, as the editor draws it. */
83
+ interface RemoteRange {
84
+ readonly label: string;
85
+ readonly from: number;
86
+ readonly to: number;
87
+ }
88
+ /**
89
+ * Other writers' selections, resolved from their cursors when they are set and after the document
90
+ * changes. In between, a range start stays after text inserted at it, and an end or a caret before.
91
+ */
92
+ export declare const remoteRanges: StateField<readonly RemoteRange[]>;
93
+ /** A selection whose cursors resolved here or not, by label. */
94
+ export interface RemoteSelectionStatus {
95
+ readonly label: string;
96
+ readonly resolved: boolean;
97
+ }
98
+ /** Another writer's selection, with the label its caret shows. */
99
+ export interface RemoteSelection {
100
+ readonly label: string;
101
+ readonly selection: CursorSelection;
102
+ }
103
+ /** Keeps one editor and one Text in step. */
104
+ export declare class TextBinding {
105
+ private mirror;
106
+ private view;
107
+ private unsubscribe;
108
+ private local;
109
+ private localMarks;
110
+ private localLines;
111
+ private localEmbeds;
112
+ private flushScheduled;
113
+ private remoteScheduled;
114
+ private composition;
115
+ private failure;
116
+ /** The editor did not start from the Text's content and waits to be replaced with it. */
117
+ private resetting;
118
+ /** Selections from `setRemoteSelections`, resolved again after each change. */
119
+ remote: readonly RemoteSelection[];
120
+ private readonly doc;
121
+ private readonly text;
122
+ private readonly options;
123
+ constructor(doc: SyncedDocument, text: SyncedText, options: TextSyncOptions);
124
+ get composing(): boolean;
125
+ get failed(): boolean;
126
+ /** Whether a local edit may be written now. */
127
+ canWrite(): boolean;
128
+ /** The Text's formatting in UTF-16 offsets, for a new editor state. */
129
+ initialFormatting(): TextFormatting;
130
+ /** Starts following `view`; after `detach`, such as for `view.setState()`, it can attach again. */
131
+ attach(view: EditorView): void;
132
+ detach(view: EditorView): void;
133
+ private stop;
134
+ /** Runs `work`, stopping the binding if it throws; an error that already stopped it is not reported again. */
135
+ private guard;
136
+ private reset;
137
+ private writeEdits;
138
+ /** The formatting the Text gave this writer's own edits, as effects; the pending lists empty. */
139
+ private takeLocalFormatting;
140
+ private get hasLocalFormatting();
141
+ /** A change to the Text: from this editor, from another writer, or from undo. */
142
+ private received;
143
+ /**
144
+ * The formatting an event changed, as effects in the editor's offsets after it. Inserted text can
145
+ * be text that is not new, such as text a rebase removed and put back with its marks, an embed or
146
+ * a "\n" that starts a paragraph with attributes. So the marks of inserted runs, each inserted
147
+ * U+FFFC and each paragraph after an inserted "\n" are read from the Text, along with what the
148
+ * event lists as changed.
149
+ */
150
+ private formattingOf;
151
+ /** Writes the local edits of a view update to the Text; called from the plugin's update. */
152
+ updated(update: ViewUpdate): void;
153
+ private mapLocalFormatting;
154
+ /** Applies the formatting of this writer's own edits once the editor's update has ended. */
155
+ private scheduleFlush;
156
+ /** Places the remote selections again from their cursors, once the editor's update has ended. */
157
+ scheduleRemote(): void;
158
+ /** Resolves the remote selections and, unless a composition is open, shows them. */
159
+ resolveRemote(view: EditorView): RemoteSelectionStatus[];
160
+ startComposition(state: EditorState): void;
161
+ /** Writes a finished composition once, or none if `cancelled`, and shows what arrived meanwhile. */
162
+ finishComposition(cancelled: boolean): void;
163
+ /** The main selection in Text element indices; undefined while a composition is open. */
164
+ indicesOf(state: EditorState): {
165
+ readonly start: number;
166
+ readonly end: number;
167
+ } | undefined;
168
+ cursorsOf(state: EditorState): CursorSelection | undefined;
169
+ resolve(cursors: CursorSelection): {
170
+ from: number;
171
+ to: number;
172
+ } | undefined;
173
+ }
174
+ /** The binding of an editor with the `textSync` extension. Internal, for the remote selections extension. */
175
+ export declare function bindingOf(state: EditorState): TextBinding | undefined;
176
+ /**
177
+ * An extension that keeps the editor and the Text at `path` in step. Local edits are written to the
178
+ * Text, all of a transaction's changes in one batch, and changes from elsewhere are shown in the
179
+ * editor. Offsets are converted between the Text's code points and CodeMirror's UTF-16 units. An
180
+ * input method composition is written once confirmed, and not at all when Escape cancels it. Create
181
+ * the editor with the Text's string as its document; one extension serves one editor.
182
+ */
183
+ export declare function textSync<S extends SchemaShape>(doc: ClientDocument<S>, path: TextPath<S>, options?: TextSyncOptions): Extension;
184
+ /** The Text's marks, paragraph attributes and embeds in the editor's offsets; empty without `textSync`. */
185
+ export declare function textFormatting(state: EditorState): TextFormatting;
186
+ /** The main selection in Text element indices, for formatting the Text; undefined while composing or without `textSync`. */
187
+ export declare function selectionIndices(state: EditorState): {
188
+ readonly start: number;
189
+ readonly end: number;
190
+ } | undefined;
191
+ /** The editor's selection as cursors, for sharing as presence; undefined while composing or without `textSync`. */
192
+ export declare function selectionCursors(state: EditorState): CursorSelection | undefined;
193
+ /** Another writer's selection in this editor's offsets, or undefined while its text is unknown here. */
194
+ export declare function resolveSelection(state: EditorState, cursors: CursorSelection): {
195
+ from: number;
196
+ to: number;
197
+ } | undefined;
198
+ /** Whether an input method composition is open in the editor; commands and keys should wait for it. */
199
+ export declare function isComposing(view: EditorView): boolean;
200
+ /** A command that undoes this writer's latest change; false when there is nothing to undo or undo is not possible now. */
201
+ export declare function undo(history: UndoManager): Command;
202
+ /** A command that redoes the latest undone change. */
203
+ export declare function redo(history: UndoManager): Command;
204
+ export {};
205
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EACkB,WAAW,EAA+B,UAAU,EAC1D,KAAK,SAAS,EAChC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGjI,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC7D,+EAA+E;AAC/E,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAExD,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AACD,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,C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