markloom 0.3.0 → 0.5.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 +29 -16
- package/ai.md +160 -0
- package/collab.md +68 -0
- package/dist/ai/index.cjs +4 -3
- package/dist/ai/index.d.cts +4 -2
- package/dist/ai/index.d.ts +4 -2
- package/dist/ai/index.js +5 -4
- package/dist/ai/theme.css +63 -63
- package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
- package/dist/chunk-6DCI7AL3.js +208 -0
- package/dist/chunk-AC5E42NH.cjs +208 -0
- package/dist/chunk-GQ2HHRGI.cjs +16 -0
- package/dist/{chunk-GUPMZI6Q.js → chunk-JMOJU5EU.js} +7 -5
- package/dist/chunk-JS527FDV.cjs +294 -0
- package/dist/chunk-LA5SBCGQ.js +16 -0
- package/dist/{chunk-ITVAR2UM.js → chunk-LEYAQNJA.js} +5 -3
- package/dist/{chunk-J3QWW6CN.js → chunk-MFYF2A6U.js} +5 -13
- package/dist/chunk-RLTHVQNQ.js +294 -0
- package/dist/{chunk-7Q6AXLF2.cjs → chunk-SLRD6FMP.cjs} +30 -28
- package/dist/{chunk-UCNEQGMY.js → chunk-WUHTCCAE.js} +391 -332
- package/dist/{chunk-2X6AF7XH.cjs → chunk-YJAWPRJW.cjs} +722 -663
- package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
- package/dist/client-A0ZQJnyR.d.ts +137 -0
- package/dist/client-BNams4wv.d.cts +137 -0
- package/dist/collab/index.cjs +19 -0
- package/dist/collab/index.d.cts +3 -0
- package/dist/collab/index.d.ts +3 -0
- package/dist/collab/index.js +19 -0
- package/dist/comments-DlExS6f-.d.cts +43 -0
- package/dist/comments-PhnR7Gkn.d.ts +43 -0
- package/dist/{controller-Dm4uLD3I.d.ts → controller-BkY1VPzc.d.ts} +24 -8
- package/dist/{controller-cE9iEYp3.d.cts → controller-CVIZI--A.d.cts} +24 -8
- package/dist/index.cjs +21 -243
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +22 -244
- package/dist/react/index.cjs +12 -9
- package/dist/react/index.d.cts +7 -5
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +12 -9
- package/dist/rebase-batch-8rL_aXEE.d.ts +38 -0
- package/dist/rebase-batch-bYnBJpRO.d.cts +38 -0
- package/dist/step-BrvHIK7O.d.cts +65 -0
- package/dist/step-BrvHIK7O.d.ts +65 -0
- package/dist/view/index.cjs +11 -8
- package/dist/view/index.d.cts +7 -5
- package/dist/view/index.d.ts +7 -5
- package/dist/view/index.js +9 -6
- package/dist/view/theme.css +507 -507
- package/package.json +10 -3
- package/dist/comments-USjT1wYN.d.cts +0 -105
- package/dist/comments-USjT1wYN.d.ts +0 -105
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
|
|
10
12
|
|
|
11
13
|
// src/tree/history.ts
|
|
12
14
|
function init(doc, validate) {
|
|
@@ -18,8 +20,8 @@ function gate(h, next) {
|
|
|
18
20
|
throw new Error(`[invariant] \u63D0\u4EA4\u4EA7\u751F\u975E\u6CD5 doc: ${v}`);
|
|
19
21
|
}
|
|
20
22
|
function commit(h, steps) {
|
|
21
|
-
const inverse =
|
|
22
|
-
const next =
|
|
23
|
+
const inverse = _chunk4TMHVNL6cjs.invertAll.call(void 0, h.doc, steps);
|
|
24
|
+
const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, steps);
|
|
23
25
|
gate(h, next);
|
|
24
26
|
return { ...h, doc: next, past: h.past.concat({ steps, inverse }), future: [] };
|
|
25
27
|
}
|
|
@@ -29,10 +31,10 @@ function amend(h, more) {
|
|
|
29
31
|
if (h.past.length === 0)
|
|
30
32
|
return commit(h, more);
|
|
31
33
|
const last = h.past[h.past.length - 1];
|
|
32
|
-
const before =
|
|
34
|
+
const before = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, last.inverse);
|
|
33
35
|
const steps = last.steps.concat(more);
|
|
34
|
-
const inverse =
|
|
35
|
-
const next =
|
|
36
|
+
const inverse = _chunk4TMHVNL6cjs.invertAll.call(void 0, before, steps);
|
|
37
|
+
const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, before, steps);
|
|
36
38
|
gate(h, next);
|
|
37
39
|
return {
|
|
38
40
|
...h,
|
|
@@ -45,7 +47,7 @@ function undo(h) {
|
|
|
45
47
|
const last = h.past[h.past.length - 1];
|
|
46
48
|
if (!last)
|
|
47
49
|
return h;
|
|
48
|
-
const next =
|
|
50
|
+
const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, last.inverse);
|
|
49
51
|
gate(h, next);
|
|
50
52
|
return { ...h, doc: next, past: h.past.slice(0, -1), future: [last, ...h.future] };
|
|
51
53
|
}
|
|
@@ -53,7 +55,7 @@ function redo(h) {
|
|
|
53
55
|
const next = h.future[0];
|
|
54
56
|
if (!next)
|
|
55
57
|
return h;
|
|
56
|
-
const doc =
|
|
58
|
+
const doc = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, next.steps);
|
|
57
59
|
gate(h, doc);
|
|
58
60
|
return { ...h, doc, past: h.past.concat(next), future: h.future.slice(1) };
|
|
59
61
|
}
|
|
@@ -61,13 +63,13 @@ function redo(h) {
|
|
|
61
63
|
// src/tree/invariants.ts
|
|
62
64
|
function invariants(schema, doc) {
|
|
63
65
|
const out = [];
|
|
64
|
-
out.push(...
|
|
66
|
+
out.push(..._chunk4TMHVNL6cjs.validateAll.call(void 0, schema, doc));
|
|
65
67
|
const ids = /* @__PURE__ */ new Map();
|
|
66
68
|
walk(doc, [], schema, out, ids);
|
|
67
69
|
return out;
|
|
68
70
|
}
|
|
69
71
|
function walk(node, path, schema, out, ids) {
|
|
70
|
-
if (
|
|
72
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node)) {
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
if (node.id !== void 0) {
|
|
@@ -100,7 +102,7 @@ function walk(node, path, schema, out, ids) {
|
|
|
100
102
|
out.push({ path, reason: `[embed] \u7F3A src` });
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
103
|
-
for (const reason of
|
|
105
|
+
for (const reason of _chunk4TMHVNL6cjs.checkTable.call(void 0, node)) {
|
|
104
106
|
out.push({ path, reason: `[table] ${reason}` });
|
|
105
107
|
}
|
|
106
108
|
return;
|
|
@@ -108,7 +110,7 @@ function walk(node, path, schema, out, ids) {
|
|
|
108
110
|
if (_optionalChain([spec, 'optionalAccess', _14 => _14.marks])) {
|
|
109
111
|
for (let i = 0; i < node.children.length; i++) {
|
|
110
112
|
const child = node.children[i];
|
|
111
|
-
if (
|
|
113
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, child) && child.marks) {
|
|
112
114
|
for (const m of child.marks) {
|
|
113
115
|
if (!spec.marks.includes(m.name)) {
|
|
114
116
|
out.push({ path: path.concat(i), reason: `${node.type} \u4E0D\u5141\u8BB8 mark "${m.name}"` });
|
|
@@ -133,7 +135,7 @@ function firstViolation(vs) {
|
|
|
133
135
|
function headingText(node) {
|
|
134
136
|
let out = "";
|
|
135
137
|
for (const c of node.children) {
|
|
136
|
-
if (
|
|
138
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
|
|
137
139
|
out += c.text;
|
|
138
140
|
}
|
|
139
141
|
return out;
|
|
@@ -141,7 +143,7 @@ function headingText(node) {
|
|
|
141
143
|
function outline(doc) {
|
|
142
144
|
const out = [];
|
|
143
145
|
const walk2 = (node, path) => {
|
|
144
|
-
if (
|
|
146
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
|
|
145
147
|
return;
|
|
146
148
|
if (node.type === "heading") {
|
|
147
149
|
const level = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([node, 'access', _15 => _15.attrs, 'optionalAccess', _16 => _16.depth]), () => ( 1))), 1), 6);
|
|
@@ -159,14 +161,14 @@ function outline(doc) {
|
|
|
159
161
|
function commentIdsInDoc(doc) {
|
|
160
162
|
const ids = /* @__PURE__ */ new Set();
|
|
161
163
|
const walk2 = (n) => {
|
|
162
|
-
if (
|
|
164
|
+
if (_chunkGQ2HHRGIcjs.isText.call(void 0, n)) {
|
|
163
165
|
for (const m of _nullishCoalesce(n.marks, () => ( []))) {
|
|
164
166
|
if (m.name === "comment" && _optionalChain([m, 'access', _17 => _17.attrs, 'optionalAccess', _18 => _18.id]) != null)
|
|
165
167
|
ids.add(String(m.attrs.id));
|
|
166
168
|
}
|
|
167
169
|
return;
|
|
168
170
|
}
|
|
169
|
-
if (
|
|
171
|
+
if (_chunkGQ2HHRGIcjs.isElement.call(void 0, n))
|
|
170
172
|
for (const c of n.children)
|
|
171
173
|
walk2(c);
|
|
172
174
|
};
|
|
@@ -180,10 +182,10 @@ function stripLeaf(leaf, id) {
|
|
|
180
182
|
function stripCommentMarks(doc, id) {
|
|
181
183
|
const steps = [];
|
|
182
184
|
const walk2 = (node, path) => {
|
|
183
|
-
if (node.children.every((c) =>
|
|
185
|
+
if (node.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) || _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c))) {
|
|
184
186
|
let changed = false;
|
|
185
187
|
const children = node.children.map((c) => {
|
|
186
|
-
if (!
|
|
188
|
+
if (!_chunkGQ2HHRGIcjs.isText.call(void 0, c) || !_optionalChain([c, 'access', _21 => _21.marks, 'optionalAccess', _22 => _22.some, 'call', _23 => _23((m) => m.name === "comment" && String(_optionalChain([m, 'access', _24 => _24.attrs, 'optionalAccess', _25 => _25.id])) === id)]))
|
|
187
189
|
return c;
|
|
188
190
|
changed = true;
|
|
189
191
|
return stripLeaf(c, id);
|
|
@@ -193,12 +195,12 @@ function stripCommentMarks(doc, id) {
|
|
|
193
195
|
return;
|
|
194
196
|
}
|
|
195
197
|
node.children.forEach((c, i) => {
|
|
196
|
-
if (
|
|
198
|
+
if (_chunkGQ2HHRGIcjs.isElement.call(void 0, c))
|
|
197
199
|
walk2(c, path.concat(i));
|
|
198
200
|
});
|
|
199
201
|
};
|
|
200
202
|
doc.children.forEach((c, i) => {
|
|
201
|
-
if (
|
|
203
|
+
if (_chunkGQ2HHRGIcjs.isElement.call(void 0, c))
|
|
202
204
|
walk2(c, [i]);
|
|
203
205
|
});
|
|
204
206
|
return steps;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { P as Path, E as ElementNode, S as Step } from './step-BrvHIK7O.js';
|
|
2
|
+
|
|
3
|
+
/** 光标/选区在协议里的轻量形态(path + offset,无 assoc) */
|
|
4
|
+
type WireSel = {
|
|
5
|
+
anchor: {
|
|
6
|
+
path: Path;
|
|
7
|
+
offset: number;
|
|
8
|
+
};
|
|
9
|
+
head: {
|
|
10
|
+
path: Path;
|
|
11
|
+
offset: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type PeerInfo = {
|
|
15
|
+
siteId: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
sel?: WireSel | null;
|
|
19
|
+
};
|
|
20
|
+
type ClientJoin = {
|
|
21
|
+
type: 'join';
|
|
22
|
+
room: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
color?: string;
|
|
25
|
+
/** 空房时用客户端 doc 初始化 */
|
|
26
|
+
seed?: ElementNode;
|
|
27
|
+
};
|
|
28
|
+
type ClientOp = {
|
|
29
|
+
type: 'op';
|
|
30
|
+
baseVersion: number;
|
|
31
|
+
clientSeq: number;
|
|
32
|
+
steps: Step[];
|
|
33
|
+
};
|
|
34
|
+
type ClientPresence = {
|
|
35
|
+
type: 'presence';
|
|
36
|
+
name?: string;
|
|
37
|
+
color?: string;
|
|
38
|
+
sel?: WireSel | null;
|
|
39
|
+
};
|
|
40
|
+
type ClientPing = {
|
|
41
|
+
type: 'ping';
|
|
42
|
+
};
|
|
43
|
+
type ClientMsg = ClientJoin | ClientOp | ClientPresence | ClientPing;
|
|
44
|
+
type ServerWelcome = {
|
|
45
|
+
type: 'welcome';
|
|
46
|
+
siteId: number;
|
|
47
|
+
version: number;
|
|
48
|
+
doc: ElementNode;
|
|
49
|
+
peers: PeerInfo[];
|
|
50
|
+
};
|
|
51
|
+
type ServerOp = {
|
|
52
|
+
type: 'op';
|
|
53
|
+
version: number;
|
|
54
|
+
siteId: number;
|
|
55
|
+
clientSeq?: number;
|
|
56
|
+
steps: Step[];
|
|
57
|
+
};
|
|
58
|
+
type ServerPresence = {
|
|
59
|
+
type: 'presence';
|
|
60
|
+
siteId: number;
|
|
61
|
+
name?: string;
|
|
62
|
+
color?: string;
|
|
63
|
+
sel?: WireSel | null;
|
|
64
|
+
};
|
|
65
|
+
type ServerPeerJoin = {
|
|
66
|
+
type: 'peer-join';
|
|
67
|
+
siteId: number;
|
|
68
|
+
name?: string;
|
|
69
|
+
color?: string;
|
|
70
|
+
};
|
|
71
|
+
type ServerPeerLeave = {
|
|
72
|
+
type: 'peer-leave';
|
|
73
|
+
siteId: number;
|
|
74
|
+
};
|
|
75
|
+
type ServerResync = {
|
|
76
|
+
type: 'resync';
|
|
77
|
+
version: number;
|
|
78
|
+
doc: ElementNode;
|
|
79
|
+
};
|
|
80
|
+
type ServerError = {
|
|
81
|
+
type: 'error';
|
|
82
|
+
message: string;
|
|
83
|
+
};
|
|
84
|
+
type ServerPong = {
|
|
85
|
+
type: 'pong';
|
|
86
|
+
};
|
|
87
|
+
type ServerMsg = ServerWelcome | ServerOp | ServerPresence | ServerPeerJoin | ServerPeerLeave | ServerResync | ServerError | ServerPong;
|
|
88
|
+
|
|
89
|
+
type CollabConfig = {
|
|
90
|
+
/** ws(s)://host 或 http(s)://host(自动改 scheme) */
|
|
91
|
+
url: string;
|
|
92
|
+
room: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
color?: string;
|
|
95
|
+
/** 空房初始化文档;默认由 Editor 传入当前 doc */
|
|
96
|
+
seed?: ElementNode;
|
|
97
|
+
};
|
|
98
|
+
type CollabHandlers = {
|
|
99
|
+
/** 权威快照(welcome / resync) */
|
|
100
|
+
onDoc: (doc: ElementNode, version: number) => void;
|
|
101
|
+
/** 已变换的远端 steps,应 applyRemote */
|
|
102
|
+
onRemote: (steps: Step[]) => void;
|
|
103
|
+
onPeers?: (peers: PeerInfo[]) => void;
|
|
104
|
+
onStatus?: (s: 'connecting' | 'open' | 'closed') => void;
|
|
105
|
+
onError?: (message: string) => void;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 协作会话:WS + pending OT。
|
|
109
|
+
* Editor 调 push(localSteps);远端经 onRemote / onDoc。
|
|
110
|
+
*/
|
|
111
|
+
declare class CollabClient {
|
|
112
|
+
private cfg;
|
|
113
|
+
private handlers;
|
|
114
|
+
private ws;
|
|
115
|
+
private closed;
|
|
116
|
+
private retry;
|
|
117
|
+
private reconnectTimer;
|
|
118
|
+
siteId: number;
|
|
119
|
+
version: number;
|
|
120
|
+
private clientSeq;
|
|
121
|
+
private pending;
|
|
122
|
+
private peers;
|
|
123
|
+
private joined;
|
|
124
|
+
constructor(cfg: CollabConfig, handlers: CollabHandlers);
|
|
125
|
+
get peersList(): PeerInfo[];
|
|
126
|
+
private connect;
|
|
127
|
+
private scheduleReconnect;
|
|
128
|
+
private send;
|
|
129
|
+
private onServer;
|
|
130
|
+
/** 本地已 apply 的 steps 推上服务器 */
|
|
131
|
+
push(steps: Step[]): void;
|
|
132
|
+
presence(sel: WireSel | null): void;
|
|
133
|
+
close(): void;
|
|
134
|
+
}
|
|
135
|
+
declare function connectCollab(cfg: CollabConfig, handlers: CollabHandlers): CollabClient;
|
|
136
|
+
|
|
137
|
+
export { type ClientJoin as C, type PeerInfo as P, type ServerMsg as S, type WireSel as W, type ClientMsg as a, type ClientOp as b, CollabClient as c, type CollabConfig as d, type CollabHandlers as e, type ServerOp as f, type ServerWelcome as g, connectCollab as h };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { P as Path, E as ElementNode, S as Step } from './step-BrvHIK7O.cjs';
|
|
2
|
+
|
|
3
|
+
/** 光标/选区在协议里的轻量形态(path + offset,无 assoc) */
|
|
4
|
+
type WireSel = {
|
|
5
|
+
anchor: {
|
|
6
|
+
path: Path;
|
|
7
|
+
offset: number;
|
|
8
|
+
};
|
|
9
|
+
head: {
|
|
10
|
+
path: Path;
|
|
11
|
+
offset: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type PeerInfo = {
|
|
15
|
+
siteId: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
sel?: WireSel | null;
|
|
19
|
+
};
|
|
20
|
+
type ClientJoin = {
|
|
21
|
+
type: 'join';
|
|
22
|
+
room: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
color?: string;
|
|
25
|
+
/** 空房时用客户端 doc 初始化 */
|
|
26
|
+
seed?: ElementNode;
|
|
27
|
+
};
|
|
28
|
+
type ClientOp = {
|
|
29
|
+
type: 'op';
|
|
30
|
+
baseVersion: number;
|
|
31
|
+
clientSeq: number;
|
|
32
|
+
steps: Step[];
|
|
33
|
+
};
|
|
34
|
+
type ClientPresence = {
|
|
35
|
+
type: 'presence';
|
|
36
|
+
name?: string;
|
|
37
|
+
color?: string;
|
|
38
|
+
sel?: WireSel | null;
|
|
39
|
+
};
|
|
40
|
+
type ClientPing = {
|
|
41
|
+
type: 'ping';
|
|
42
|
+
};
|
|
43
|
+
type ClientMsg = ClientJoin | ClientOp | ClientPresence | ClientPing;
|
|
44
|
+
type ServerWelcome = {
|
|
45
|
+
type: 'welcome';
|
|
46
|
+
siteId: number;
|
|
47
|
+
version: number;
|
|
48
|
+
doc: ElementNode;
|
|
49
|
+
peers: PeerInfo[];
|
|
50
|
+
};
|
|
51
|
+
type ServerOp = {
|
|
52
|
+
type: 'op';
|
|
53
|
+
version: number;
|
|
54
|
+
siteId: number;
|
|
55
|
+
clientSeq?: number;
|
|
56
|
+
steps: Step[];
|
|
57
|
+
};
|
|
58
|
+
type ServerPresence = {
|
|
59
|
+
type: 'presence';
|
|
60
|
+
siteId: number;
|
|
61
|
+
name?: string;
|
|
62
|
+
color?: string;
|
|
63
|
+
sel?: WireSel | null;
|
|
64
|
+
};
|
|
65
|
+
type ServerPeerJoin = {
|
|
66
|
+
type: 'peer-join';
|
|
67
|
+
siteId: number;
|
|
68
|
+
name?: string;
|
|
69
|
+
color?: string;
|
|
70
|
+
};
|
|
71
|
+
type ServerPeerLeave = {
|
|
72
|
+
type: 'peer-leave';
|
|
73
|
+
siteId: number;
|
|
74
|
+
};
|
|
75
|
+
type ServerResync = {
|
|
76
|
+
type: 'resync';
|
|
77
|
+
version: number;
|
|
78
|
+
doc: ElementNode;
|
|
79
|
+
};
|
|
80
|
+
type ServerError = {
|
|
81
|
+
type: 'error';
|
|
82
|
+
message: string;
|
|
83
|
+
};
|
|
84
|
+
type ServerPong = {
|
|
85
|
+
type: 'pong';
|
|
86
|
+
};
|
|
87
|
+
type ServerMsg = ServerWelcome | ServerOp | ServerPresence | ServerPeerJoin | ServerPeerLeave | ServerResync | ServerError | ServerPong;
|
|
88
|
+
|
|
89
|
+
type CollabConfig = {
|
|
90
|
+
/** ws(s)://host 或 http(s)://host(自动改 scheme) */
|
|
91
|
+
url: string;
|
|
92
|
+
room: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
color?: string;
|
|
95
|
+
/** 空房初始化文档;默认由 Editor 传入当前 doc */
|
|
96
|
+
seed?: ElementNode;
|
|
97
|
+
};
|
|
98
|
+
type CollabHandlers = {
|
|
99
|
+
/** 权威快照(welcome / resync) */
|
|
100
|
+
onDoc: (doc: ElementNode, version: number) => void;
|
|
101
|
+
/** 已变换的远端 steps,应 applyRemote */
|
|
102
|
+
onRemote: (steps: Step[]) => void;
|
|
103
|
+
onPeers?: (peers: PeerInfo[]) => void;
|
|
104
|
+
onStatus?: (s: 'connecting' | 'open' | 'closed') => void;
|
|
105
|
+
onError?: (message: string) => void;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 协作会话:WS + pending OT。
|
|
109
|
+
* Editor 调 push(localSteps);远端经 onRemote / onDoc。
|
|
110
|
+
*/
|
|
111
|
+
declare class CollabClient {
|
|
112
|
+
private cfg;
|
|
113
|
+
private handlers;
|
|
114
|
+
private ws;
|
|
115
|
+
private closed;
|
|
116
|
+
private retry;
|
|
117
|
+
private reconnectTimer;
|
|
118
|
+
siteId: number;
|
|
119
|
+
version: number;
|
|
120
|
+
private clientSeq;
|
|
121
|
+
private pending;
|
|
122
|
+
private peers;
|
|
123
|
+
private joined;
|
|
124
|
+
constructor(cfg: CollabConfig, handlers: CollabHandlers);
|
|
125
|
+
get peersList(): PeerInfo[];
|
|
126
|
+
private connect;
|
|
127
|
+
private scheduleReconnect;
|
|
128
|
+
private send;
|
|
129
|
+
private onServer;
|
|
130
|
+
/** 本地已 apply 的 steps 推上服务器 */
|
|
131
|
+
push(steps: Step[]): void;
|
|
132
|
+
presence(sel: WireSel | null): void;
|
|
133
|
+
close(): void;
|
|
134
|
+
}
|
|
135
|
+
declare function connectCollab(cfg: CollabConfig, handlers: CollabHandlers): CollabClient;
|
|
136
|
+
|
|
137
|
+
export { type ClientJoin as C, type PeerInfo as P, type ServerMsg as S, type WireSel as W, type ClientMsg as a, type ClientOp as b, CollabClient as c, type CollabConfig as d, type CollabHandlers as e, type ServerOp as f, type ServerWelcome as g, connectCollab as h };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkAC5E42NHcjs = require('../chunk-AC5E42NH.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkJS527FDVcjs = require('../chunk-JS527FDV.cjs');
|
|
11
|
+
require('../chunk-GQ2HHRGI.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.CollabClient = _chunkAC5E42NHcjs.CollabClient; exports.connectCollab = _chunkAC5E42NHcjs.connectCollab; exports.rebaseBatchOver = _chunkJS527FDVcjs.rebaseBatchOver; exports.rebaseOne = _chunkJS527FDVcjs.rebaseOne; exports.rebaseStepsThrough = _chunkJS527FDVcjs.rebaseStepsThrough; exports.transformRemoteAgainstPending = _chunkJS527FDVcjs.transformRemoteAgainstPending;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { C as ClientJoin, a as ClientMsg, b as ClientOp, c as CollabClient, d as CollabConfig, e as CollabHandlers, P as PeerInfo, S as ServerMsg, f as ServerOp, g as ServerWelcome, W as WireSel, h as connectCollab } from '../client-BNams4wv.cjs';
|
|
2
|
+
export { r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from '../rebase-batch-bYnBJpRO.cjs';
|
|
3
|
+
import '../step-BrvHIK7O.cjs';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { C as ClientJoin, a as ClientMsg, b as ClientOp, c as CollabClient, d as CollabConfig, e as CollabHandlers, P as PeerInfo, S as ServerMsg, f as ServerOp, g as ServerWelcome, W as WireSel, h as connectCollab } from '../client-A0ZQJnyR.js';
|
|
2
|
+
export { r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from '../rebase-batch-8rL_aXEE.js';
|
|
3
|
+
import '../step-BrvHIK7O.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CollabClient,
|
|
3
|
+
connectCollab
|
|
4
|
+
} from "../chunk-6DCI7AL3.js";
|
|
5
|
+
import {
|
|
6
|
+
rebaseBatchOver,
|
|
7
|
+
rebaseOne,
|
|
8
|
+
rebaseStepsThrough,
|
|
9
|
+
transformRemoteAgainstPending
|
|
10
|
+
} from "../chunk-RLTHVQNQ.js";
|
|
11
|
+
import "../chunk-LA5SBCGQ.js";
|
|
12
|
+
export {
|
|
13
|
+
CollabClient,
|
|
14
|
+
connectCollab,
|
|
15
|
+
rebaseBatchOver,
|
|
16
|
+
rebaseOne,
|
|
17
|
+
rebaseStepsThrough,
|
|
18
|
+
transformRemoteAgainstPending
|
|
19
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { E as ElementNode, S as Step } from './step-BrvHIK7O.cjs';
|
|
2
|
+
|
|
3
|
+
interface Commit {
|
|
4
|
+
steps: Step[];
|
|
5
|
+
inverse: Step[];
|
|
6
|
+
}
|
|
7
|
+
interface History {
|
|
8
|
+
doc: ElementNode;
|
|
9
|
+
past: Commit[];
|
|
10
|
+
future: Commit[];
|
|
11
|
+
validate?: (doc: ElementNode) => string | null;
|
|
12
|
+
}
|
|
13
|
+
declare function init(doc: ElementNode, validate?: (doc: ElementNode) => string | null): History;
|
|
14
|
+
declare function commit(h: History, steps: Step[]): History;
|
|
15
|
+
declare function amend(h: History, more: Step[]): History;
|
|
16
|
+
declare function undo(h: History): History;
|
|
17
|
+
declare function redo(h: History): History;
|
|
18
|
+
|
|
19
|
+
interface CommentAuthor {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
avatar?: string;
|
|
23
|
+
}
|
|
24
|
+
interface CommentMessage {
|
|
25
|
+
id: string;
|
|
26
|
+
author: CommentAuthor;
|
|
27
|
+
body: string;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
interface CommentThread {
|
|
31
|
+
id: string;
|
|
32
|
+
resolved: boolean;
|
|
33
|
+
quote?: string;
|
|
34
|
+
messages: CommentMessage[];
|
|
35
|
+
}
|
|
36
|
+
interface CommentRenderState {
|
|
37
|
+
resolved: Set<string>;
|
|
38
|
+
activeId: string | null;
|
|
39
|
+
}
|
|
40
|
+
declare function commentIdsInDoc(doc: ElementNode): Set<string>;
|
|
41
|
+
declare function stripCommentMarks(doc: ElementNode, id: string): Step[];
|
|
42
|
+
|
|
43
|
+
export { type CommentAuthor as C, type History as H, type CommentMessage as a, type CommentRenderState as b, type CommentThread as c, type Commit as d, amend as e, commentIdsInDoc as f, commit as g, init as i, redo as r, stripCommentMarks as s, undo as u };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { E as ElementNode, S as Step } from './step-BrvHIK7O.js';
|
|
2
|
+
|
|
3
|
+
interface Commit {
|
|
4
|
+
steps: Step[];
|
|
5
|
+
inverse: Step[];
|
|
6
|
+
}
|
|
7
|
+
interface History {
|
|
8
|
+
doc: ElementNode;
|
|
9
|
+
past: Commit[];
|
|
10
|
+
future: Commit[];
|
|
11
|
+
validate?: (doc: ElementNode) => string | null;
|
|
12
|
+
}
|
|
13
|
+
declare function init(doc: ElementNode, validate?: (doc: ElementNode) => string | null): History;
|
|
14
|
+
declare function commit(h: History, steps: Step[]): History;
|
|
15
|
+
declare function amend(h: History, more: Step[]): History;
|
|
16
|
+
declare function undo(h: History): History;
|
|
17
|
+
declare function redo(h: History): History;
|
|
18
|
+
|
|
19
|
+
interface CommentAuthor {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
avatar?: string;
|
|
23
|
+
}
|
|
24
|
+
interface CommentMessage {
|
|
25
|
+
id: string;
|
|
26
|
+
author: CommentAuthor;
|
|
27
|
+
body: string;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
interface CommentThread {
|
|
31
|
+
id: string;
|
|
32
|
+
resolved: boolean;
|
|
33
|
+
quote?: string;
|
|
34
|
+
messages: CommentMessage[];
|
|
35
|
+
}
|
|
36
|
+
interface CommentRenderState {
|
|
37
|
+
resolved: Set<string>;
|
|
38
|
+
activeId: string | null;
|
|
39
|
+
}
|
|
40
|
+
declare function commentIdsInDoc(doc: ElementNode): Set<string>;
|
|
41
|
+
declare function stripCommentMarks(doc: ElementNode, id: string): Step[];
|
|
42
|
+
|
|
43
|
+
export { type CommentAuthor as C, type History as H, type CommentMessage as a, type CommentRenderState as b, type CommentThread as c, type Commit as d, amend as e, commentIdsInDoc as f, commit as g, init as i, redo as r, stripCommentMarks as s, undo as u };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { E as ElementNode, S as Step,
|
|
1
|
+
import { E as ElementNode, S as Step, c as Selection, M as Mark, P as Path, N as Node } from './step-BrvHIK7O.js';
|
|
2
2
|
import * as preact from 'preact';
|
|
3
3
|
import { ComponentChild } from 'preact';
|
|
4
|
+
import { H as History, c as CommentThread, C as CommentAuthor } from './comments-PhnR7Gkn.js';
|
|
5
|
+
import { d as CollabConfig, c as CollabClient } from './client-A0ZQJnyR.js';
|
|
4
6
|
|
|
5
7
|
interface MentionCandidate {
|
|
6
8
|
id: string;
|
|
@@ -78,7 +80,7 @@ declare function renderHr(spec: ElementNode, key: number | string, ctx: BlockRen
|
|
|
78
80
|
declare const defaultBlockRenderers: Record<string, BlockRenderer>;
|
|
79
81
|
declare function renderDoc(doc: ElementNode, opts?: RenderOpts): preact.VNode<preact.ClassAttributes<HTMLElement> & {
|
|
80
82
|
class: string;
|
|
81
|
-
'data-
|
|
83
|
+
'data-markloom': boolean;
|
|
82
84
|
}>;
|
|
83
85
|
declare function renderToHtml(doc: ElementNode, opts?: RenderOpts): string;
|
|
84
86
|
|
|
@@ -336,6 +338,11 @@ interface EditorOptions {
|
|
|
336
338
|
* 应用只配 provider / endpoint。
|
|
337
339
|
*/
|
|
338
340
|
ai?: boolean | AiConfig;
|
|
341
|
+
/**
|
|
342
|
+
* 实时协作(中心化 OT + WebSocket)。传 { url, room } 即连 Cloudflare worker 房间。
|
|
343
|
+
* 本地 dispatch 自动上行;远端 applyRemote。见 collab.md。
|
|
344
|
+
*/
|
|
345
|
+
collab?: CollabConfig;
|
|
339
346
|
}
|
|
340
347
|
declare class Editor {
|
|
341
348
|
root: HTMLElement;
|
|
@@ -354,10 +361,15 @@ declare class Editor {
|
|
|
354
361
|
private decorations;
|
|
355
362
|
/** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
|
|
356
363
|
private aiCtl;
|
|
364
|
+
/** 协作会话;applyingRemote 期间本地 steps 不上行 */
|
|
365
|
+
private collabCtl;
|
|
366
|
+
private applyingRemote;
|
|
357
367
|
constructor(root: HTMLElement, doc: ElementNode, opts?: EditorOptions);
|
|
358
368
|
destroy(): void;
|
|
359
369
|
/** AI 控制器(opts.ai 启用时);应用工具栏可 ed.ai?.openAtFocus / stop */
|
|
360
|
-
get ai():
|
|
370
|
+
get ai(): MarkloomAi | null;
|
|
371
|
+
/** 协作客户端(opts.collab 启用时) */
|
|
372
|
+
get collab(): CollabClient | null;
|
|
361
373
|
openAi(mode: 'continue' | 'rewrite'): void;
|
|
362
374
|
stopAi(): void;
|
|
363
375
|
get doc(): ElementNode;
|
|
@@ -371,6 +383,10 @@ declare class Editor {
|
|
|
371
383
|
private syncPlaceholder;
|
|
372
384
|
dispatch(steps: Step[], selectionAfter?: Selection): void;
|
|
373
385
|
dispatchStream(steps: Step[], selectionAfter?: Selection): void;
|
|
386
|
+
/** 远端协作 op:写入 model 但不上行 */
|
|
387
|
+
applyRemote(steps: Step[], selectionAfter?: Selection): void;
|
|
388
|
+
/** 权威快照替换(welcome/resync);清空本地 undo 栈 */
|
|
389
|
+
replaceDoc(doc: ElementNode): void;
|
|
374
390
|
/** 回退一笔 history(AI 事务 discard = undo 整笔) */
|
|
375
391
|
undo(): boolean;
|
|
376
392
|
redo(): boolean;
|
|
@@ -438,7 +454,7 @@ type AiStreamInput = {
|
|
|
438
454
|
signal?: AbortSignal;
|
|
439
455
|
};
|
|
440
456
|
type AiStreamFn = (input: AiStreamInput, onToken: (text: string) => void) => Promise<void>;
|
|
441
|
-
type
|
|
457
|
+
type MarkloomAiOpts = {
|
|
442
458
|
stream: AiStreamFn;
|
|
443
459
|
onError?: (message: string) => void;
|
|
444
460
|
onBusy?: (busy: boolean) => void;
|
|
@@ -446,7 +462,7 @@ type LoomAiOpts = {
|
|
|
446
462
|
type AiPromptMode = 'continue' | 'rewrite';
|
|
447
463
|
|
|
448
464
|
/**
|
|
449
|
-
*
|
|
465
|
+
* markloom/ai — 一笔完整事务:
|
|
450
466
|
*
|
|
451
467
|
* begin (dispatch) 插入真·顶层段落(aiDraft) + loading
|
|
452
468
|
* stream (amend) token 追加到真段落,随时可见
|
|
@@ -455,7 +471,7 @@ type AiPromptMode = 'continue' | 'rewrite';
|
|
|
455
471
|
*
|
|
456
472
|
* 段落从第一 pen 起就在 doc 里,不是影子预览;淡化只是事务未提交的视觉态。
|
|
457
473
|
*/
|
|
458
|
-
declare class
|
|
474
|
+
declare class MarkloomAi {
|
|
459
475
|
private getEditor;
|
|
460
476
|
private opts;
|
|
461
477
|
private abort;
|
|
@@ -466,7 +482,7 @@ declare class LoomAi {
|
|
|
466
482
|
private raf;
|
|
467
483
|
/** 流式累积的 Markdown 源(每帧物化成真·富文本块做预览) */
|
|
468
484
|
private pendingMd;
|
|
469
|
-
constructor(getEditor: () => Editor | null, opts:
|
|
485
|
+
constructor(getEditor: () => Editor | null, opts: MarkloomAiOpts);
|
|
470
486
|
destroy(): void;
|
|
471
487
|
/**
|
|
472
488
|
* 停止生成:
|
|
@@ -504,4 +520,4 @@ declare class LoomAi {
|
|
|
504
520
|
private paintMd;
|
|
505
521
|
}
|
|
506
522
|
|
|
507
|
-
export { diffSpan as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E,
|
|
523
|
+
export { diffSpan as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E, MentionPopovers as F, type MentionPopoversHost as G, type MentionProfile as H, type InputResult as I, type NodeViewCtx as J, type KeymapCommand as K, type Resolved as L, MarkloomAi as M, type NodeView as N, atomIsSelected as O, type PasteRule as P, blockTransform as Q, type RenderOpts as R, type SlashCommand as S, type TextStylePatch as T, calloutVariantFromQuery as U, caret as V, chord as W, cycleCalloutVariant as X, defaultBlockRenderers as Y, defaultBlockTag as Z, defaultMarkTag as _, type AiPromptMode as a, indentItem as a0, isAtom as a1, isOpaque as a2, leafText as a3, lineBoundaryBack as a4, lineBoundaryFwd as a5, mapInput as a6, mapPaste as a7, mapPasteBlocks as a8, marksAtCaret as a9, mergeTextStyleAttrs as aa, outdentItem as ab, renderCode as ac, renderDoc as ad, renderEmbed as ae, renderHr as af, renderImage as ag, renderTable as ah, renderToHtml as ai, resolve as aj, safeCssValue as ak, serializeSelection as al, setAlign as am, setCalloutVariant as an, setTextStyle as ao, textStyleCss as ap, toggleMark as aq, toggleMarkList as ar, twitchChannel as as, wordBoundaryBack as at, wordBoundaryFwd as au, wrapList as av, youtubeId as aw, type AiProvider as b, type AiStreamFn as c, type AiStreamInput as d, type AiWriteMode as e, type AiWriteSession as f, type MarkloomAiOpts as g, blockPlainText as h, createAiStream as i, focusBlockId as j, Editor as k, type Extension as l, type AtomSelectCtx as m, type BlockKind as n, type BlockRenderCtx as o, type BlockRenderer as p, type CalloutVariant as q, type DecorationHost as r, startAiWrite as s, type InputRuleCtx as t, type Intent as u, type KeymapCtx as v, type KeymapResult as w, type MentionCandidate as x, type MentionHost as y, MentionMenu as z };
|