markloom 0.3.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 +125 -0
- package/dist/ai/index.cjs +19 -0
- package/dist/ai/index.d.cts +10 -0
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.js +19 -0
- package/dist/ai/theme.css +304 -0
- package/dist/chunk-2X6AF7XH.cjs +9030 -0
- package/dist/chunk-7Q6AXLF2.cjs +1076 -0
- package/dist/chunk-GUPMZI6Q.js +1076 -0
- package/dist/chunk-HA6XHJUD.cjs +218 -0
- package/dist/chunk-ITVAR2UM.js +218 -0
- package/dist/chunk-J3QWW6CN.js +2305 -0
- package/dist/chunk-UCNEQGMY.js +9030 -0
- package/dist/chunk-VVFIQLVR.cjs +2305 -0
- package/dist/comments-USjT1wYN.d.cts +105 -0
- package/dist/comments-USjT1wYN.d.ts +105 -0
- package/dist/controller-Dm4uLD3I.d.ts +507 -0
- package/dist/controller-cE9iEYp3.d.cts +507 -0
- package/dist/index.cjs +424 -0
- package/dist/index.d.cts +184 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.js +424 -0
- package/dist/react/index.cjs +45 -0
- package/dist/react/index.d.cts +22 -0
- package/dist/react/index.d.ts +22 -0
- package/dist/react/index.js +45 -0
- package/dist/view/index.cjs +368 -0
- package/dist/view/index.d.cts +155 -0
- package/dist/view/index.d.ts +155 -0
- package/dist/view/index.js +368 -0
- package/dist/view/theme.css +2627 -0
- package/package.json +89 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkHA6XHJUDcjs = require('./chunk-HA6XHJUD.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
var _chunkVVFIQLVRcjs = require('./chunk-VVFIQLVR.cjs');
|
|
77
|
+
|
|
78
|
+
// src/tree/map.ts
|
|
79
|
+
function mapPosition(step, pos) {
|
|
80
|
+
const p = pos.path;
|
|
81
|
+
switch (step.kind) {
|
|
82
|
+
case "insertText":
|
|
83
|
+
return mapText(step.path, step.offset, step.text.length, p, pos);
|
|
84
|
+
case "deleteText":
|
|
85
|
+
return mapText(step.path, step.offset, -step.length, p, pos);
|
|
86
|
+
case "spliceChildren":
|
|
87
|
+
return mapSplice(step.path, step.at, step.remove, step.insert.length, p, pos);
|
|
88
|
+
case "replaceNode":
|
|
89
|
+
return underPrefix(step.path, p) ? withPath(step.path.concat(0), pos) : pos;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function mapSelection(step, sel) {
|
|
93
|
+
return { anchor: mapPosition(step, sel.anchor), head: mapPosition(step, sel.head) };
|
|
94
|
+
}
|
|
95
|
+
function mapText(stepPath, at, delta, p, pos) {
|
|
96
|
+
if (p.length !== stepPath.length + 1 || !isPrefix(stepPath, p))
|
|
97
|
+
return pos;
|
|
98
|
+
const off = p[p.length - 1];
|
|
99
|
+
if (off < at)
|
|
100
|
+
return pos;
|
|
101
|
+
if (off === at) {
|
|
102
|
+
if (delta > 0 && (_nullishCoalesce(pos.assoc, () => ( 1))) === 1)
|
|
103
|
+
return withLast(p, off + delta, pos);
|
|
104
|
+
return pos;
|
|
105
|
+
}
|
|
106
|
+
if (delta < 0 && off < at - delta)
|
|
107
|
+
return withLast(p, at, pos);
|
|
108
|
+
return withLast(p, off + delta, pos);
|
|
109
|
+
}
|
|
110
|
+
function mapSplice(parentPath, at, remove, insertCount, p, pos) {
|
|
111
|
+
const d = parentPath.length;
|
|
112
|
+
if (!isPrefix(parentPath, p) || p.length <= d)
|
|
113
|
+
return pos;
|
|
114
|
+
const idx = p[d];
|
|
115
|
+
const delta = insertCount - remove;
|
|
116
|
+
if (idx < at)
|
|
117
|
+
return pos;
|
|
118
|
+
if (idx < at + remove)
|
|
119
|
+
return withPath(parentPath.concat(at), pos);
|
|
120
|
+
if (idx === at) {
|
|
121
|
+
if (insertCount > 0 && (_nullishCoalesce(pos.assoc, () => ( 1))) === 1)
|
|
122
|
+
return withSeg(p, d, idx + insertCount, pos);
|
|
123
|
+
return pos;
|
|
124
|
+
}
|
|
125
|
+
return withSeg(p, d, idx + delta, pos);
|
|
126
|
+
}
|
|
127
|
+
function withPath(path, src) {
|
|
128
|
+
return src.assoc === void 0 ? { path } : { path, assoc: src.assoc };
|
|
129
|
+
}
|
|
130
|
+
function withLast(path, last, src) {
|
|
131
|
+
return withPath(path.slice(0, -1).concat(last), src);
|
|
132
|
+
}
|
|
133
|
+
function withSeg(path, d, seg, src) {
|
|
134
|
+
const next = path.slice();
|
|
135
|
+
next[d] = seg;
|
|
136
|
+
return withPath(next, src);
|
|
137
|
+
}
|
|
138
|
+
function isPrefix(a, b) {
|
|
139
|
+
if (a.length > b.length)
|
|
140
|
+
return false;
|
|
141
|
+
for (let i = 0; i < a.length; i++) {
|
|
142
|
+
if (a[i] !== b[i])
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
function underPrefix(a, b) {
|
|
148
|
+
return b.length > a.length && isPrefix(a, b);
|
|
149
|
+
}
|
|
150
|
+
function normalizePosition(doc, pos) {
|
|
151
|
+
let cur = doc;
|
|
152
|
+
for (let i = 0; i < pos.path.length - 1; i++) {
|
|
153
|
+
if (!_chunkVVFIQLVRcjs.isElement.call(void 0, cur))
|
|
154
|
+
break;
|
|
155
|
+
const next = cur.children[pos.path[i]];
|
|
156
|
+
if (!next)
|
|
157
|
+
return pos;
|
|
158
|
+
cur = next;
|
|
159
|
+
}
|
|
160
|
+
if (_chunkVVFIQLVRcjs.isText.call(void 0, cur))
|
|
161
|
+
return pos;
|
|
162
|
+
const at = _nullishCoalesce(pos.path[pos.path.length - 1], () => ( 0));
|
|
163
|
+
const prefix = pos.path.slice(0, -1);
|
|
164
|
+
return withPath(descendToText(cur, at, prefix), pos);
|
|
165
|
+
}
|
|
166
|
+
function descendToText(parent, at, prefix) {
|
|
167
|
+
const kids = parent.children;
|
|
168
|
+
if (kids.length === 0)
|
|
169
|
+
return prefix.concat(0);
|
|
170
|
+
const leftIdx = at > 0 ? at - 1 : 0;
|
|
171
|
+
const toEnd = at > 0;
|
|
172
|
+
let path = prefix.concat(leftIdx);
|
|
173
|
+
let node = kids[Math.min(leftIdx, kids.length - 1)];
|
|
174
|
+
while (_chunkVVFIQLVRcjs.isElement.call(void 0, node)) {
|
|
175
|
+
const cs = node.children;
|
|
176
|
+
if (cs.length === 0)
|
|
177
|
+
return path.concat(0);
|
|
178
|
+
const idx = toEnd ? cs.length - 1 : 0;
|
|
179
|
+
path = path.concat(idx);
|
|
180
|
+
node = cs[idx];
|
|
181
|
+
}
|
|
182
|
+
return path.concat(toEnd ? node.text.length : 0);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/tree/rebase.ts
|
|
186
|
+
function makeBias(thisSite, overSite) {
|
|
187
|
+
return thisSite > overSite ? 1 : -1;
|
|
188
|
+
}
|
|
189
|
+
function rebase(over, step, bias) {
|
|
190
|
+
switch (step.kind) {
|
|
191
|
+
case "insertText":
|
|
192
|
+
case "deleteText": {
|
|
193
|
+
if ((over.kind === "insertText" || over.kind === "deleteText") && samePath(over.path, step.path))
|
|
194
|
+
return textVsText(over, step, bias);
|
|
195
|
+
const want = step.path.length + 1;
|
|
196
|
+
const mlo = movePoint(over, step.path.concat(step.offset), bias);
|
|
197
|
+
if (mlo.length < want)
|
|
198
|
+
return null;
|
|
199
|
+
if (step.kind === "insertText")
|
|
200
|
+
return { ...step, path: mlo.slice(0, -1), offset: mlo[mlo.length - 1] };
|
|
201
|
+
const mhi = movePoint(over, step.path.concat(step.offset + step.length), bias);
|
|
202
|
+
if (mhi.length < want)
|
|
203
|
+
return null;
|
|
204
|
+
const a = mlo[mlo.length - 1];
|
|
205
|
+
const b = mhi[mhi.length - 1];
|
|
206
|
+
return { ...step, path: mlo.slice(0, -1), offset: a, length: Math.max(0, b - a) };
|
|
207
|
+
}
|
|
208
|
+
case "spliceChildren": {
|
|
209
|
+
if (over.kind === "spliceChildren" && samePath(over.path, step.path))
|
|
210
|
+
return spliceVsSplice(over, step, bias);
|
|
211
|
+
const want = step.path.length + 1;
|
|
212
|
+
const moved = movePoint(over, step.path.concat(step.at), bias);
|
|
213
|
+
if (moved.length < want)
|
|
214
|
+
return null;
|
|
215
|
+
return { ...step, path: moved.slice(0, -1), at: moved[moved.length - 1] };
|
|
216
|
+
}
|
|
217
|
+
case "replaceNode": {
|
|
218
|
+
if (removesTarget(over, step.path, bias))
|
|
219
|
+
return null;
|
|
220
|
+
return { ...step, path: movePoint(over, step.path, 1) };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function removesTarget(over, targetPath, bias) {
|
|
225
|
+
if (over.kind === "spliceChildren") {
|
|
226
|
+
const d = over.path.length;
|
|
227
|
+
if (targetPath.length <= d || !isPrefix2(over.path, targetPath))
|
|
228
|
+
return false;
|
|
229
|
+
const idx = targetPath[d];
|
|
230
|
+
return idx >= over.at && idx < over.at + over.remove;
|
|
231
|
+
}
|
|
232
|
+
if (over.kind === "replaceNode") {
|
|
233
|
+
if (isPrefix2(over.path, targetPath)) {
|
|
234
|
+
const sameNode = targetPath.length === over.path.length;
|
|
235
|
+
return sameNode ? bias === 1 : true;
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
function textVsText(over, step, bias) {
|
|
242
|
+
if (over.kind === "insertText") {
|
|
243
|
+
const o = over.offset;
|
|
244
|
+
const ins = over.text.length;
|
|
245
|
+
if (step.kind === "insertText") {
|
|
246
|
+
const x = step.offset;
|
|
247
|
+
const off = x < o ? x : x > o ? x + ins : bias === 1 ? x + ins : x;
|
|
248
|
+
return { ...step, offset: off };
|
|
249
|
+
}
|
|
250
|
+
const s2 = step.offset;
|
|
251
|
+
const e2 = step.offset + step.length;
|
|
252
|
+
if (o <= s2)
|
|
253
|
+
return { ...step, offset: s2 + ins, length: step.length };
|
|
254
|
+
if (o >= e2)
|
|
255
|
+
return { ...step, offset: s2, length: step.length };
|
|
256
|
+
return { ...step, offset: s2, length: step.length + ins };
|
|
257
|
+
}
|
|
258
|
+
const d = over.offset;
|
|
259
|
+
const oLen = over.length;
|
|
260
|
+
if (step.kind === "insertText") {
|
|
261
|
+
const x = step.offset;
|
|
262
|
+
if (x > d && x < d + oLen)
|
|
263
|
+
return null;
|
|
264
|
+
return { ...step, offset: x <= d ? x : x - oLen };
|
|
265
|
+
}
|
|
266
|
+
const s0 = step.offset;
|
|
267
|
+
const e0 = step.offset + step.length;
|
|
268
|
+
const s = s0 <= d ? s0 : s0 >= d + oLen ? s0 - oLen : d;
|
|
269
|
+
const e = e0 <= d ? e0 : e0 >= d + oLen ? e0 - oLen : d;
|
|
270
|
+
const len = Math.max(0, e - s);
|
|
271
|
+
if (len === 0)
|
|
272
|
+
return null;
|
|
273
|
+
return { ...step, offset: s, length: len };
|
|
274
|
+
}
|
|
275
|
+
function spliceVsSplice(over, step, bias) {
|
|
276
|
+
const oa = over.at;
|
|
277
|
+
const oe = over.at + over.remove;
|
|
278
|
+
const oN = over.insert.length;
|
|
279
|
+
const delta = oN - over.remove;
|
|
280
|
+
const sa = step.at;
|
|
281
|
+
const se = step.at + step.remove;
|
|
282
|
+
const out = [];
|
|
283
|
+
const leftRem = Math.max(0, Math.min(se, oa) - sa);
|
|
284
|
+
const rightRem = Math.max(0, se - Math.max(sa, oe));
|
|
285
|
+
if (rightRem > 0)
|
|
286
|
+
out.push({ kind: "spliceChildren", path: step.path, at: Math.max(sa, oe) + delta, remove: rightRem, insert: [] });
|
|
287
|
+
if (leftRem > 0)
|
|
288
|
+
out.push({ kind: "spliceChildren", path: step.path, at: sa, remove: leftRem, insert: [] });
|
|
289
|
+
if (step.insert.length > 0) {
|
|
290
|
+
const insAt = sa === oa ? bias === 1 ? oa + oN : oa : sa < oa ? sa : sa >= oe ? sa + delta : oa + oN;
|
|
291
|
+
out.push({ kind: "spliceChildren", path: step.path, at: insAt, remove: 0, insert: step.insert });
|
|
292
|
+
}
|
|
293
|
+
if (out.length === 0)
|
|
294
|
+
return null;
|
|
295
|
+
if (out.length === 1)
|
|
296
|
+
return out[0];
|
|
297
|
+
out.sort((x, y) => y.at - x.at || x.insert.length - y.insert.length);
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
function samePath(a, b) {
|
|
301
|
+
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
302
|
+
}
|
|
303
|
+
function isPrefix2(a, b) {
|
|
304
|
+
if (a.length > b.length)
|
|
305
|
+
return false;
|
|
306
|
+
for (let i = 0; i < a.length; i++) {
|
|
307
|
+
if (a[i] !== b[i])
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
function movePoint(over, path, bias) {
|
|
313
|
+
const pos = { path, assoc: bias };
|
|
314
|
+
return mapPosition(over, pos).path;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// src/tree/stats.ts
|
|
318
|
+
function rawText(node) {
|
|
319
|
+
if (_chunkVVFIQLVRcjs.isText.call(void 0, node))
|
|
320
|
+
return node.text;
|
|
321
|
+
return node.children.map(rawText).join("");
|
|
322
|
+
}
|
|
323
|
+
function spacedText(node) {
|
|
324
|
+
if (_chunkVVFIQLVRcjs.isText.call(void 0, node))
|
|
325
|
+
return node.text;
|
|
326
|
+
return node.children.map(spacedText).join("\n");
|
|
327
|
+
}
|
|
328
|
+
function countWords(s) {
|
|
329
|
+
let n = 0;
|
|
330
|
+
let inWord = false;
|
|
331
|
+
for (const ch of s) {
|
|
332
|
+
const ws = ch === " " || ch === "\n" || ch === " " || ch === "\r" || ch === "\f" || ch === "\v";
|
|
333
|
+
if (ws) {
|
|
334
|
+
inWord = false;
|
|
335
|
+
} else if (!inWord) {
|
|
336
|
+
inWord = true;
|
|
337
|
+
n++;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return n;
|
|
341
|
+
}
|
|
342
|
+
function docStats(doc) {
|
|
343
|
+
return { chars: [...rawText(doc)].length, words: countWords(spacedText(doc)), blocks: doc.children.length };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
exports.amend = _chunkHA6XHJUDcjs.amend; exports.appendText = _chunkVVFIQLVRcjs.appendText; exports.apply = _chunkVVFIQLVRcjs.apply; exports.applyAll = _chunkVVFIQLVRcjs.applyAll; exports.arrowCell = _chunkVVFIQLVRcjs.arrowCell; exports.basicSchema = _chunkVVFIQLVRcjs.basicSchema; exports.buildGrid = _chunkVVFIQLVRcjs.buildGrid; exports.buildIdIndex = _chunkVVFIQLVRcjs.buildIdIndex; exports.calloutToHtml = _chunkVVFIQLVRcjs.calloutToHtml; exports.caretCell = _chunkVVFIQLVRcjs.caretCell; exports.cellCaret = _chunkVVFIQLVRcjs.cellCaret; exports.cellText = _chunkVVFIQLVRcjs.cellText; exports.checkSchema = _chunkVVFIQLVRcjs.checkSchema; exports.checkTable = _chunkVVFIQLVRcjs.checkTable; exports.clearCells = _chunkVVFIQLVRcjs.clearCells; exports.colspanOf = _chunkVVFIQLVRcjs.colspanOf; exports.commentIdsInDoc = _chunkHA6XHJUDcjs.commentIdsInDoc; exports.commit = _chunkHA6XHJUDcjs.commit; exports.deleteCol = _chunkVVFIQLVRcjs.deleteCol; exports.deleteRow = _chunkVVFIQLVRcjs.deleteRow; exports.deleteTableBlock = _chunkVVFIQLVRcjs.deleteTableBlock; exports.diffById = _chunkVVFIQLVRcjs.diffById; exports.docStats = docStats; exports.docToMd = _chunkVVFIQLVRcjs.docToMd; exports.embedHtml = _chunkVVFIQLVRcjs.embedHtml; exports.firstLeafPath = _chunkVVFIQLVRcjs.firstLeafPath; exports.firstViolation = _chunkHA6XHJUDcjs.firstViolation; exports.hasSpan = _chunkVVFIQLVRcjs.hasSpan; exports.htmlToBlocks = _chunkVVFIQLVRcjs.htmlToBlocks; exports.init = _chunkHA6XHJUDcjs.init; exports.insertAfter = _chunkVVFIQLVRcjs.insertAfter; exports.insertCol = _chunkVVFIQLVRcjs.insertCol; exports.insertRow = _chunkVVFIQLVRcjs.insertRow; exports.invariants = _chunkHA6XHJUDcjs.invariants; exports.invert = _chunkVVFIQLVRcjs.invert; exports.invertAll = _chunkVVFIQLVRcjs.invertAll; exports.isElement = _chunkVVFIQLVRcjs.isElement; exports.isInlineAtom = _chunkVVFIQLVRcjs.isInlineAtom; exports.isRichHtmlBlocks = _chunkVVFIQLVRcjs.isRichHtmlBlocks; exports.isText = _chunkVVFIQLVRcjs.isText; exports.lastLeafEnd = _chunkVVFIQLVRcjs.lastLeafEnd; exports.makeBias = makeBias; exports.makeTable = _chunkVVFIQLVRcjs.makeTable; exports.mapPosition = mapPosition; exports.mapSelection = mapSelection; exports.mdToDoc = _chunkVVFIQLVRcjs.mdToDoc; exports.mergeCells = _chunkVVFIQLVRcjs.mergeCells; exports.moveBlock = _chunkVVFIQLVRcjs.moveBlock; exports.moveCol = _chunkVVFIQLVRcjs.moveCol; exports.moveRow = _chunkVVFIQLVRcjs.moveRow; exports.nextCell = _chunkVVFIQLVRcjs.nextCell; exports.nodeAt = _chunkVVFIQLVRcjs.nodeAt; exports.normalizePosition = normalizePosition; exports.normalizeToLeaf = _chunkVVFIQLVRcjs.normalizeToLeaf; exports.outline = _chunkHA6XHJUDcjs.outline; exports.pathOfId = _chunkVVFIQLVRcjs.pathOfId; exports.rebase = rebase; exports.redo = _chunkHA6XHJUDcjs.redo; exports.replaceAt = _chunkVVFIQLVRcjs.replaceAt; exports.resolve = _chunkVVFIQLVRcjs.resolve; exports.rewriteNode = _chunkVVFIQLVRcjs.rewriteNode; exports.rowspanOf = _chunkVVFIQLVRcjs.rowspanOf; exports.setAlign = _chunkVVFIQLVRcjs.setAlign; exports.setCellStyle = _chunkVVFIQLVRcjs.setCellStyle; exports.setColWidths = _chunkVVFIQLVRcjs.setColWidths; exports.setFreeze = _chunkVVFIQLVRcjs.setFreeze; exports.spliceAt = _chunkVVFIQLVRcjs.spliceAt; exports.splitCell = _chunkVVFIQLVRcjs.splitCell; exports.stripCommentMarks = _chunkHA6XHJUDcjs.stripCommentMarks; exports.tableAt = _chunkVVFIQLVRcjs.tableAt; exports.tableColWidths = _chunkVVFIQLVRcjs.tableColWidths; exports.tableHasExtras = _chunkVVFIQLVRcjs.tableHasExtras; exports.tableSchema = _chunkVVFIQLVRcjs.tableSchema; exports.tableShape = _chunkVVFIQLVRcjs.tableShape; exports.tableToHtml = _chunkVVFIQLVRcjs.tableToHtml; exports.undo = _chunkHA6XHJUDcjs.undo; exports.validate = _chunkVVFIQLVRcjs.validate; exports.validateAll = _chunkVVFIQLVRcjs.validateAll;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './comments-USjT1wYN.cjs';
|
|
2
|
+
export { C as CommentAuthor, b as CommentMessage, c as CommentRenderState, d as CommentThread, e as Commit, D as DeleteText, f as Doc, H as History, I as InsertText, M as Mark, R as ReplaceNode, g as Selection, h as SpliceChildren, T as TextNode, i as amend, j as apply, k as applyAll, l as commentIdsInDoc, m as commit, n as init, o as invert, p as invertAll, q as isElement, r as isInlineAtom, s as isText, t as moveBlock, u as redo, v as stripCommentMarks, w as undo } from './comments-USjT1wYN.cjs';
|
|
3
|
+
|
|
4
|
+
interface TableShape {
|
|
5
|
+
rows: number;
|
|
6
|
+
cols: number;
|
|
7
|
+
}
|
|
8
|
+
declare function tableShape(table: ElementNode): TableShape;
|
|
9
|
+
declare function colspanOf(cell: Node): number;
|
|
10
|
+
declare function rowspanOf(cell: Node): number;
|
|
11
|
+
interface Grid {
|
|
12
|
+
rows: number;
|
|
13
|
+
cols: number;
|
|
14
|
+
at: (r: number, c: number) => number;
|
|
15
|
+
cellOf: (idx: number) => {
|
|
16
|
+
r: number;
|
|
17
|
+
c: number;
|
|
18
|
+
colspan: number;
|
|
19
|
+
rowspan: number;
|
|
20
|
+
};
|
|
21
|
+
anchors: number[];
|
|
22
|
+
}
|
|
23
|
+
declare function buildGrid(table: ElementNode): Grid;
|
|
24
|
+
declare function cellCaret(tablePath: Path, table: ElementNode, r: number, c: number, off?: number): Path;
|
|
25
|
+
declare function caretCell(tablePath: Path, table: ElementNode, caret: Path): {
|
|
26
|
+
r: number;
|
|
27
|
+
c: number;
|
|
28
|
+
} | null;
|
|
29
|
+
declare function makeTable(id: string, rows: number, cols: number): ElementNode;
|
|
30
|
+
declare function cellText(table: ElementNode, r: number, c: number): string;
|
|
31
|
+
declare function nextCell(table: ElementNode, r: number, c: number, dir: 1 | -1): {
|
|
32
|
+
r: number;
|
|
33
|
+
c: number;
|
|
34
|
+
};
|
|
35
|
+
declare function arrowCell(table: ElementNode, r: number, c: number, dir: 'up' | 'down' | 'left' | 'right'): {
|
|
36
|
+
r: number;
|
|
37
|
+
c: number;
|
|
38
|
+
} | null;
|
|
39
|
+
declare function insertRow(table: ElementNode, tablePath: Path, at: number): Step;
|
|
40
|
+
declare function deleteRow(table: ElementNode, tablePath: Path, r: number, doc?: ElementNode): Step;
|
|
41
|
+
declare function insertCol(table: ElementNode, tablePath: Path, at: number): Step;
|
|
42
|
+
declare function deleteCol(table: ElementNode, tablePath: Path, c: number, doc?: ElementNode): Step;
|
|
43
|
+
declare function hasSpan(table: ElementNode): boolean;
|
|
44
|
+
declare function moveRow(table: ElementNode, tablePath: Path, from: number, to: number): Step;
|
|
45
|
+
declare function moveCol(table: ElementNode, tablePath: Path, from: number, to: number): Step;
|
|
46
|
+
declare function tableColWidths(table: ElementNode): number[] | null;
|
|
47
|
+
declare function setColWidths(table: ElementNode, tablePath: Path, widths: number[]): Step;
|
|
48
|
+
declare function setAlign(table: ElementNode, tablePath: Path, col: number, value: 'left' | 'center' | 'right' | null): Step;
|
|
49
|
+
declare function mergeCells(table: ElementNode, tablePath: Path, r1: number, c1: number, r2: number, c2: number): Step;
|
|
50
|
+
declare function splitCell(table: ElementNode, tablePath: Path, r: number, c: number): Step;
|
|
51
|
+
declare function setCellStyle(table: ElementNode, tablePath: Path, r: number, c: number, style: {
|
|
52
|
+
bg?: string | null;
|
|
53
|
+
border?: string | null;
|
|
54
|
+
}): Step;
|
|
55
|
+
declare function clearCells(table: ElementNode, tablePath: Path, rect: {
|
|
56
|
+
r1: number;
|
|
57
|
+
c1: number;
|
|
58
|
+
r2: number;
|
|
59
|
+
c2: number;
|
|
60
|
+
}): Step;
|
|
61
|
+
declare function setFreeze(table: ElementNode, tablePath: Path, freeze: {
|
|
62
|
+
rows?: number;
|
|
63
|
+
cols?: number;
|
|
64
|
+
}): Step;
|
|
65
|
+
declare function deleteTableBlock(tablePath: Path, doc?: ElementNode): Step;
|
|
66
|
+
declare function tableAt(doc: ElementNode, tablePath: Path): ElementNode | null;
|
|
67
|
+
declare function checkTable(table: ElementNode): string[];
|
|
68
|
+
declare const tableSchema: {
|
|
69
|
+
marks: string[];
|
|
70
|
+
nodes: {
|
|
71
|
+
table: {
|
|
72
|
+
content: string[];
|
|
73
|
+
atom: boolean;
|
|
74
|
+
};
|
|
75
|
+
table_cell: {
|
|
76
|
+
content: string[];
|
|
77
|
+
};
|
|
78
|
+
paragraph: {
|
|
79
|
+
content: string[];
|
|
80
|
+
inline: boolean;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
declare function mdToDoc(md: string): ElementNode;
|
|
86
|
+
declare function htmlToBlocks(html: string): ElementNode[] | null;
|
|
87
|
+
declare function isRichHtmlBlocks(blocks: ElementNode[]): boolean;
|
|
88
|
+
declare function embedHtml(n: ElementNode): string;
|
|
89
|
+
declare function tableHasExtras(n: ElementNode): boolean;
|
|
90
|
+
declare function tableToHtml(n: ElementNode): string;
|
|
91
|
+
declare function calloutToHtml(n: ElementNode): string;
|
|
92
|
+
declare function docToMd(doc: ElementNode, srcMd: string): string;
|
|
93
|
+
|
|
94
|
+
interface Resolved {
|
|
95
|
+
node: Node;
|
|
96
|
+
offset: number;
|
|
97
|
+
parents: ElementNode[];
|
|
98
|
+
indexInParent: number[];
|
|
99
|
+
}
|
|
100
|
+
declare function resolve(doc: ElementNode, path: Path): Resolved;
|
|
101
|
+
declare function firstLeafPath(block: ElementNode): Path;
|
|
102
|
+
declare function normalizeToLeaf(doc: ElementNode, path: Path): Path;
|
|
103
|
+
declare function lastLeafEnd(block: ElementNode): Path;
|
|
104
|
+
declare function nodeAt(doc: ElementNode, path: Path): Node;
|
|
105
|
+
declare function replaceAt(doc: ElementNode, path: Path, next: Node): ElementNode;
|
|
106
|
+
declare function spliceAt(doc: ElementNode, path: Path, at: number, remove: number, insert: Node[]): ElementNode;
|
|
107
|
+
|
|
108
|
+
interface NodeSpec {
|
|
109
|
+
content: string[];
|
|
110
|
+
inline?: boolean;
|
|
111
|
+
atom?: boolean;
|
|
112
|
+
marks?: string[];
|
|
113
|
+
}
|
|
114
|
+
interface Schema {
|
|
115
|
+
nodes: Record<string, NodeSpec>;
|
|
116
|
+
marks: string[];
|
|
117
|
+
}
|
|
118
|
+
declare function checkSchema(schema: Schema): void;
|
|
119
|
+
declare function validate(schema: Schema, doc: ElementNode): true | string;
|
|
120
|
+
interface Violation {
|
|
121
|
+
path: Path;
|
|
122
|
+
reason: string;
|
|
123
|
+
}
|
|
124
|
+
declare function validateAll(schema: Schema, doc: ElementNode): Violation[];
|
|
125
|
+
declare const basicSchema: Schema;
|
|
126
|
+
|
|
127
|
+
declare function pathOfId(doc: ElementNode, id: string): Path | null;
|
|
128
|
+
type IdIndex = Map<string, Path>;
|
|
129
|
+
declare function buildIdIndex(doc: ElementNode): IdIndex;
|
|
130
|
+
declare function appendText(doc: ElementNode, blockId: string, text: string, index?: IdIndex): Step;
|
|
131
|
+
declare function rewriteNode(doc: ElementNode, blockId: string, node: ElementNode, index?: IdIndex, schema?: Schema): Step;
|
|
132
|
+
declare function insertAfter(doc: ElementNode, afterId: string, nodes: ElementNode[], index?: IdIndex, schema?: Schema): Step;
|
|
133
|
+
type NodeChange = {
|
|
134
|
+
type: 'same';
|
|
135
|
+
id: string;
|
|
136
|
+
} | {
|
|
137
|
+
type: 'changed';
|
|
138
|
+
id: string;
|
|
139
|
+
before: ElementNode;
|
|
140
|
+
after: ElementNode;
|
|
141
|
+
} | {
|
|
142
|
+
type: 'added';
|
|
143
|
+
id: string;
|
|
144
|
+
after: ElementNode;
|
|
145
|
+
} | {
|
|
146
|
+
type: 'removed';
|
|
147
|
+
id: string;
|
|
148
|
+
before: ElementNode;
|
|
149
|
+
};
|
|
150
|
+
declare function diffById(before: ElementNode, after: ElementNode): NodeChange[];
|
|
151
|
+
|
|
152
|
+
declare function invariants(schema: Schema, doc: ElementNode): Violation[];
|
|
153
|
+
declare function firstViolation(vs: Violation[]): string | null;
|
|
154
|
+
|
|
155
|
+
declare function mapPosition(step: Step, pos: Position): Position;
|
|
156
|
+
declare function mapSelection(step: Step, sel: {
|
|
157
|
+
anchor: Position;
|
|
158
|
+
head: Position;
|
|
159
|
+
}): {
|
|
160
|
+
anchor: Position;
|
|
161
|
+
head: Position;
|
|
162
|
+
};
|
|
163
|
+
declare function normalizePosition(doc: ElementNode, pos: Position): Position;
|
|
164
|
+
|
|
165
|
+
type Bias = -1 | 1;
|
|
166
|
+
declare function makeBias(thisSite: number, overSite: number): Bias;
|
|
167
|
+
declare function rebase(over: Step, step: Step, bias: Bias): Step | Step[] | null;
|
|
168
|
+
|
|
169
|
+
interface DocStats {
|
|
170
|
+
chars: number;
|
|
171
|
+
words: number;
|
|
172
|
+
blocks: number;
|
|
173
|
+
}
|
|
174
|
+
declare function docStats(doc: ElementNode): DocStats;
|
|
175
|
+
|
|
176
|
+
interface TocEntry {
|
|
177
|
+
level: number;
|
|
178
|
+
text: string;
|
|
179
|
+
path: Path;
|
|
180
|
+
id?: string;
|
|
181
|
+
}
|
|
182
|
+
declare function outline(doc: ElementNode): TocEntry[];
|
|
183
|
+
|
|
184
|
+
export { type Bias, type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isRichHtmlBlocks, lastLeafEnd, makeBias, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, rebase, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
|