@articollab/prosemirror 0.0.0-stage → 0.12.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/prosemirror
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
+ ProseMirror bindings for Articollab Text.
4
+
5
+ [Read the ProseMirror guide](https://eastsun5566.github.io/articollab/#/prosemirror).
6
+
7
+ MIT.
@@ -0,0 +1,36 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ import { DecorationSet, type EditorView } from "prosemirror-view";
3
+ import { type CursorSelection } from "./sync.ts";
4
+ /** Another writer's selection, as shared through presence. */
5
+ export interface RemoteSelection {
6
+ /** Shown on the caret, and used to tell the writers apart. */
7
+ readonly label: string;
8
+ readonly selection: CursorSelection;
9
+ }
10
+ /** Whether a remote selection could be shown: false while its text has not reached this writer. */
11
+ export interface RemoteSelectionStatus {
12
+ readonly label: string;
13
+ readonly resolved: boolean;
14
+ }
15
+ export interface RemoteSelectionsOptions {
16
+ /** The class of a selected range; "articollab-selection" by default. */
17
+ readonly selectionClass?: string;
18
+ /** Makes the caret element; a `span.articollab-caret` with `data-label` by default. */
19
+ readonly caret?: (label: string) => HTMLElement;
20
+ }
21
+ interface RemoteState {
22
+ readonly selections: readonly RemoteSelection[];
23
+ readonly decorations: DecorationSet;
24
+ }
25
+ /**
26
+ * A plugin that draws other writers' selections, placed from their cursors whenever the editor shows
27
+ * a change from the Text, and moved with local edits in between. Needs `textSync` before it.
28
+ */
29
+ export declare function remoteSelections(options?: RemoteSelectionsOptions): Plugin<RemoteState>;
30
+ /**
31
+ * Replaces the other writers' selections the editor shows. Returns whether each could be placed;
32
+ * one whose text has not reached this writer yet is left out until it can be.
33
+ */
34
+ export declare function setRemoteSelections(view: EditorView, selections: readonly RemoteSelection[]): RemoteSelectionStatus[];
35
+ export {};
36
+ //# sourceMappingURL=cursors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursors.d.ts","sourceRoot":"","sources":["../src/cursors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiD,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAc,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAExE,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;CACrC;AAED,mGAAmG;AACnG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,uFAAuF;IACvF,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;CACjD;AAED,UAAU,WAAW;IACnB,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;CACrC;AAYD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAAC,WAAW,CAAC,CA4B3F;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,eAAe,EAAE,GAAG,qBAAqB,EAAE,CAMrH"}
@@ -0,0 +1,60 @@
1
+ import { Plugin, PluginKey } from "prosemirror-state";
2
+ import { Decoration, DecorationSet } from "prosemirror-view";
3
+ import { bindingOf, isFromText } from "./sync.js";
4
+ const remoteKey = new PluginKey("articollab-remote-selections");
5
+ function defaultCaret(label) {
6
+ const caret = document.createElement("span");
7
+ caret.className = "articollab-caret";
8
+ caret.dataset.label = label;
9
+ caret.setAttribute("aria-hidden", "true");
10
+ return caret;
11
+ }
12
+ /**
13
+ * A plugin that draws other writers' selections, placed from their cursors whenever the editor shows
14
+ * a change from the Text, and moved with local edits in between. Needs `textSync` before it.
15
+ */
16
+ export function remoteSelections(options = {}) {
17
+ const selectionClass = options.selectionClass ?? "articollab-selection", caret = options.caret ?? defaultCaret;
18
+ const draw = (state, from, selections) => {
19
+ const binding = bindingOf(from);
20
+ if (binding === undefined || binding.composing)
21
+ return DecorationSet.empty;
22
+ const decorations = [];
23
+ for (const { label, selection } of selections) {
24
+ const range = binding.resolve(selection, state.doc);
25
+ if (range === undefined)
26
+ continue;
27
+ if (range.from < range.to)
28
+ decorations.push(Decoration.inline(range.from, range.to, { class: selectionClass, title: label }));
29
+ decorations.push(Decoration.widget(range.to, () => caret(label), { key: `${label}:${String(range.to)}`, side: range.from < range.to ? 1 : -1 }));
30
+ }
31
+ return DecorationSet.create(state.doc, decorations);
32
+ };
33
+ return new Plugin({
34
+ key: remoteKey,
35
+ state: {
36
+ init: () => ({ selections: [], decorations: DecorationSet.empty }),
37
+ apply(tr, value, oldState) {
38
+ const next = tr.getMeta(remoteKey);
39
+ const selections = Array.isArray(next) ? next : value.selections;
40
+ // Cursors match the Text, and the editor shows it again only after a change from it.
41
+ if (next !== undefined || isFromText(tr))
42
+ return { selections, decorations: draw(tr, oldState, selections) };
43
+ return tr.docChanged ? { selections, decorations: value.decorations.map(tr.mapping, tr.doc) } : value;
44
+ },
45
+ },
46
+ props: { decorations: (state) => remoteKey.getState(state)?.decorations },
47
+ });
48
+ }
49
+ /**
50
+ * Replaces the other writers' selections the editor shows. Returns whether each could be placed;
51
+ * one whose text has not reached this writer yet is left out until it can be.
52
+ */
53
+ export function setRemoteSelections(view, selections) {
54
+ view.dispatch(view.state.tr.setMeta(remoteKey, selections));
55
+ const binding = bindingOf(view.state);
56
+ return selections.map(({ label, selection }) => ({
57
+ label, resolved: binding !== undefined && !binding.composing && binding.resolve(selection, view.state.doc) !== undefined,
58
+ }));
59
+ }
60
+ //# sourceMappingURL=cursors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursors.js","sourceRoot":"","sources":["../src/cursors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAsC,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAwB,MAAM,WAAW,CAAC;AA2BxE,MAAM,SAAS,GAAG,IAAI,SAAS,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G,CAAC;SACF;QACD,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE;KAC1E,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAgB,EAAE,UAAsC;IAC1F,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QAC/C,KAAK,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS;KACzH,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { remoteSelections, setRemoteSelections, type RemoteSelection, type RemoteSelectionsOptions, type RemoteSelectionStatus, } from "./cursors.ts";
2
+ export { basicMapping, type MarkMapping, type TextMapping } from "./mapping.ts";
3
+ export { isComposing, redo, resolveSelection, selectionCursors, textSync, textToDoc, undo, type CursorSelection, type TextPath, type TextSyncOptions, } from "./sync.ts";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { remoteSelections, setRemoteSelections, } from "./cursors.js";
2
+ export { basicMapping } from "./mapping.js";
3
+ export { isComposing, redo, resolveSelection, selectionCursors, textSync, textToDoc, undo, } from "./sync.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GAIpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAsC,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,IAAI,GAIL,MAAM,WAAW,CAAC"}
@@ -0,0 +1,164 @@
1
+ import { Mark, type Attrs, type Node, type Schema } from "prosemirror-model";
2
+ import type { JsonValue } from "@articollab/core";
3
+ /** One Text mark key's ProseMirror mark. */
4
+ export interface MarkMapping {
5
+ /** The ProseMirror mark's name. */
6
+ readonly mark: string;
7
+ /** The Text mark's value for a ProseMirror mark; `true` by default. */
8
+ readonly value?: (mark: Mark) => JsonValue;
9
+ /** The ProseMirror mark's attributes for a Text mark value; none by default. */
10
+ readonly attrs?: (value: JsonValue) => Attrs | null;
11
+ }
12
+ /**
13
+ * Which ProseMirror nodes and marks stand for a Text's lines, marks and paragraph attributes. A
14
+ * paragraph's attributes use fixed keys: `heading` (a level), `code` (`true`, or a code block's
15
+ * language), `quote` (`true`), `list` (`"bullet"` or `"ordered"`) and `indent` (a list depth from 1).
16
+ * Nodes and marks that are not listed are left out.
17
+ */
18
+ export interface TextMapping {
19
+ /** The document node; `"doc"` by default. */
20
+ readonly doc?: string;
21
+ readonly paragraph: string;
22
+ /** ProseMirror marks by Text mark key. */
23
+ readonly marks: Readonly<Record<string, MarkMapping>>;
24
+ /** A heading node with a `level` attribute, for the `heading` attribute, kept within `levels`. */
25
+ readonly heading?: {
26
+ readonly node: string;
27
+ readonly levels: readonly number[];
28
+ };
29
+ /**
30
+ * A code block, one line per `"\n"` in it, for the `code` attribute. Its text has no marks. With
31
+ * `language`, the name of its language attribute, a block with a language stores it as the value of
32
+ * `code`; otherwise every value of `code` is a code block, and writing leaves the value as it is.
33
+ */
34
+ readonly codeBlock?: {
35
+ readonly node: string;
36
+ readonly language?: string;
37
+ };
38
+ /** A quote around paragraphs, for the `quote` attribute. */
39
+ readonly blockquote?: {
40
+ readonly node: string;
41
+ };
42
+ /**
43
+ * List nodes, for the `list` and `indent` attributes. Each item holds one paragraph and nested
44
+ * lists. Lists nested deeper than `maxIndent` levels below the first are flattened to it.
45
+ */
46
+ readonly lists?: {
47
+ readonly item: string;
48
+ readonly bullet: string;
49
+ readonly ordered: string;
50
+ readonly maxIndent?: number;
51
+ };
52
+ /** An inline node that breaks a line, such as a hard break: it starts another line with the same attributes. */
53
+ readonly lineBreak?: {
54
+ readonly node: string;
55
+ };
56
+ }
57
+ /** The nodes and marks of `prosemirror-schema-basic` with `prosemirror-schema-list`'s lists. */
58
+ export declare const basicMapping: TextMapping;
59
+ /** Paragraph attributes or marks: JSON values by key, keys sorted. */
60
+ export type Attributes = Readonly<Record<string, JsonValue>>;
61
+ /** A run of equally marked text in one line. */
62
+ interface Run {
63
+ readonly text: string;
64
+ readonly marks: Attributes;
65
+ }
66
+ /** One paragraph of the Text: its text as runs, and its paragraph attributes. */
67
+ export interface Line {
68
+ readonly runs: readonly Run[];
69
+ readonly attributes: Attributes;
70
+ }
71
+ /** Whether two JSON values are equal; object key order does not matter. */
72
+ export declare function sameJson(a: unknown, b: unknown): boolean;
73
+ /** A line's length in Text elements. */
74
+ export declare function lineLength(line: Line): number;
75
+ /** The Text lines of `count` elements from `index`, which must start and end at line boundaries. */
76
+ export declare function textLines(body: {
77
+ toDelta(index?: number, count?: number): readonly {
78
+ readonly insert: string;
79
+ readonly attributes?: Attributes;
80
+ }[];
81
+ blocks(index?: number, count?: number): readonly {
82
+ readonly attributes: Attributes;
83
+ }[];
84
+ }, index?: number, count?: number): Line[];
85
+ /** One top-level node's lines, where each line's text starts in it, and its length in Text elements. */
86
+ interface NodeInfo {
87
+ readonly lines: readonly Line[];
88
+ /** Each line's text start, counted from the node's own start. */
89
+ readonly starts: readonly number[];
90
+ /** Each line's length in Text elements. */
91
+ readonly lengths: readonly number[];
92
+ /** The node's length in Text elements, with a line break between its lines. */
93
+ readonly length: number;
94
+ }
95
+ /**
96
+ * Where each top-level node of a document starts, in Text elements and as a ProseMirror position,
97
+ * by child index. A node without lines, such as one the mapping leaves out, takes no elements.
98
+ */
99
+ export interface Layout {
100
+ readonly elements: readonly number[];
101
+ readonly positions: readonly number[];
102
+ /** The child indices of the nodes that have lines, in order. */
103
+ readonly lined: readonly number[];
104
+ /** The text's length in elements. */
105
+ readonly length: number;
106
+ }
107
+ /**
108
+ * Converts between a Text's lines and ProseMirror nodes for one mapping. The nodes are always in one
109
+ * standard shape: consecutive quoted lines are one quote, consecutive code lines one code block
110
+ * without marks, list lines nested lists with one paragraph per item, and a list item never a
111
+ * heading. A line's list depth is its `indent`, but at most one deeper than the line before.
112
+ */
113
+ export declare class TextShape {
114
+ readonly schema: Schema;
115
+ readonly mapping: TextMapping;
116
+ private readonly cache;
117
+ private readonly layouts;
118
+ constructor(schema: Schema, mapping: TextMapping);
119
+ private node;
120
+ /** The Text mark and paragraph attribute keys this mapping writes. */
121
+ keys(): {
122
+ marks: readonly string[];
123
+ blocks: readonly string[];
124
+ };
125
+ /**
126
+ * Whether two values of a paragraph attribute show the same: for `code` without a language
127
+ * attribute, any two values make a code block.
128
+ */
129
+ sameAttribute(key: string, a: JsonValue | undefined, b: JsonValue | undefined): boolean;
130
+ private marksFor;
131
+ private inline;
132
+ private textblock;
133
+ private buildLists;
134
+ private buildBlocks;
135
+ /** The top-level nodes for some lines, in the standard shape. */
136
+ nodes(lines: readonly Line[]): Node[];
137
+ /** The document for some lines, in the standard shape; no lines make one empty paragraph. */
138
+ doc(lines: readonly Line[]): Node;
139
+ private textMarks;
140
+ /** Collects the lines under `parent`, whose content starts at position `offset`, and where each line's text starts. */
141
+ private walk;
142
+ /**
143
+ * The lines of one top-level node, and where each line's text starts, counted from the node's own
144
+ * start. Cached: ProseMirror nodes never change.
145
+ */
146
+ nodeInfo(node: Node): NodeInfo;
147
+ /**
148
+ * Where each top-level node starts, in Text elements and positions. Linear in the number of
149
+ * top-level nodes, not in the text: each node's length is cached.
150
+ */
151
+ layout(doc: Node): Layout;
152
+ /** The child index of the node with lines that holds Text element gap `element`. */
153
+ childAtElement(doc: Node, element: number): number;
154
+ /** The document position of Text element gap `element`. */
155
+ positionAt(doc: Node, element: number): number;
156
+ /** The Text element gap nearest document position `position`; between blocks, the end of the line before. */
157
+ elementAt(doc: Node, position: number): number;
158
+ /** The lines of one top-level node. */
159
+ nodeLines(node: Node): readonly Line[];
160
+ /** The lines of a document: every top-level node's, and one empty line for a document with none. */
161
+ lines(doc: Node): Line[];
162
+ }
163
+ export {};
164
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAiB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,C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