markloom 0.5.0 → 0.6.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.
Files changed (67) hide show
  1. package/PACKAGES.md +26 -0
  2. package/README.md +20 -2
  3. package/collab.md +44 -7
  4. package/dist/ai/index.cjs +4 -4
  5. package/dist/ai/index.d.cts +5 -4
  6. package/dist/ai/index.d.ts +5 -4
  7. package/dist/ai/index.js +3 -3
  8. package/dist/ai/theme.css +66 -102
  9. package/dist/{chunk-YJAWPRJW.cjs → chunk-ACFYBYZJ.cjs} +2817 -903
  10. package/dist/chunk-CGYCJORO.js +759 -0
  11. package/dist/chunk-EADZKEU4.cjs +498 -0
  12. package/dist/chunk-EJSFZHGT.js +24 -0
  13. package/dist/{chunk-SLRD6FMP.cjs → chunk-I5VK4U7J.cjs} +122 -73
  14. package/dist/{chunk-WUHTCCAE.js → chunk-KYZJIOOL.js} +2403 -489
  15. package/dist/chunk-QEVME6ZU.cjs +759 -0
  16. package/dist/{chunk-MFYF2A6U.js → chunk-SNFF6X45.js} +51 -1
  17. package/dist/{chunk-JMOJU5EU.js → chunk-TB2OY3D4.js} +69 -20
  18. package/dist/{chunk-4TMHVNL6.cjs → chunk-TWD5T4YC.cjs} +155 -105
  19. package/dist/{chunk-JS527FDV.cjs → chunk-U3JZDFL4.cjs} +49 -9
  20. package/dist/{chunk-RLTHVQNQ.js → chunk-VSBIMMI7.js} +45 -5
  21. package/dist/chunk-YBAT343I.js +498 -0
  22. package/dist/chunk-ZKQSQSSM.cjs +24 -0
  23. package/dist/{client-BNams4wv.d.cts → client-CLYq17SW.d.ts} +70 -7
  24. package/dist/{client-A0ZQJnyR.d.ts → client-DAth8pPq.d.cts} +70 -7
  25. package/dist/collab/index.cjs +22 -4
  26. package/dist/collab/index.d.cts +24 -3
  27. package/dist/collab/index.d.ts +24 -3
  28. package/dist/collab/index.js +24 -6
  29. package/dist/{controller-BkY1VPzc.d.ts → controller-6AJ36G52.d.ts} +108 -8
  30. package/dist/{controller-CVIZI--A.d.cts → controller-BIOO_XKJ.d.cts} +108 -8
  31. package/dist/index.cjs +57 -7
  32. package/dist/index.d.cts +18 -5
  33. package/dist/index.d.ts +18 -5
  34. package/dist/index.js +54 -4
  35. package/dist/io/index.cjs +1413 -0
  36. package/dist/io/index.d.cts +33 -0
  37. package/dist/io/index.d.ts +33 -0
  38. package/dist/io/index.js +1413 -0
  39. package/dist/react/index.cjs +8 -8
  40. package/dist/react/index.d.cts +5 -4
  41. package/dist/react/index.d.ts +5 -4
  42. package/dist/react/index.js +7 -7
  43. package/dist/{rebase-batch-8rL_aXEE.d.ts → rebase-batch-DlerAcFN.d.ts} +11 -9
  44. package/dist/{rebase-batch-bYnBJpRO.d.cts → rebase-batch-PjENQ742.d.cts} +11 -9
  45. package/dist/suggest-Bk4zLzuv.d.ts +120 -0
  46. package/dist/suggest-BkGGiPKA.d.cts +120 -0
  47. package/dist/types-COUweEav.d.cts +30 -0
  48. package/dist/types-COUweEav.d.ts +30 -0
  49. package/dist/versions-9mG1epfB.d.cts +51 -0
  50. package/dist/versions-Bubyo4pt.d.ts +51 -0
  51. package/dist/view/index.cjs +56 -12
  52. package/dist/view/index.d.cts +203 -11
  53. package/dist/view/index.d.ts +203 -11
  54. package/dist/view/index.js +52 -8
  55. package/dist/view/theme.css +1840 -1526
  56. package/io.md +38 -0
  57. package/package.json +21 -5
  58. package/dist/chunk-6DCI7AL3.js +0 -208
  59. package/dist/chunk-AC5E42NH.cjs +0 -208
  60. package/dist/chunk-GQ2HHRGI.cjs +0 -16
  61. package/dist/chunk-LA5SBCGQ.js +0 -16
  62. package/dist/chunk-LEYAQNJA.js +0 -220
  63. package/dist/chunk-YXQDCW4Y.cjs +0 -220
  64. package/dist/comments-DlExS6f-.d.cts +0 -43
  65. package/dist/comments-PhnR7Gkn.d.ts +0 -43
  66. package/dist/step-BrvHIK7O.d.cts +0 -65
  67. package/dist/step-BrvHIK7O.d.ts +0 -65
@@ -1,220 +0,0 @@
1
- import {
2
- applyAll,
3
- checkTable,
4
- invertAll,
5
- validateAll
6
- } from "./chunk-MFYF2A6U.js";
7
- import {
8
- isElement,
9
- isInlineAtom,
10
- isText
11
- } from "./chunk-LA5SBCGQ.js";
12
-
13
- // src/tree/history.ts
14
- function init(doc, validate) {
15
- return { doc, past: [], future: [], validate };
16
- }
17
- function gate(h, next) {
18
- const v = h.validate?.(next);
19
- if (v)
20
- throw new Error(`[invariant] \u63D0\u4EA4\u4EA7\u751F\u975E\u6CD5 doc: ${v}`);
21
- }
22
- function commit(h, steps) {
23
- const inverse = invertAll(h.doc, steps);
24
- const next = applyAll(h.doc, steps);
25
- gate(h, next);
26
- return { ...h, doc: next, past: h.past.concat({ steps, inverse }), future: [] };
27
- }
28
- function amend(h, more) {
29
- if (more.length === 0)
30
- return h;
31
- if (h.past.length === 0)
32
- return commit(h, more);
33
- const last = h.past[h.past.length - 1];
34
- const before = applyAll(h.doc, last.inverse);
35
- const steps = last.steps.concat(more);
36
- const inverse = invertAll(before, steps);
37
- const next = applyAll(before, steps);
38
- gate(h, next);
39
- return {
40
- ...h,
41
- doc: next,
42
- past: h.past.slice(0, -1).concat({ steps, inverse }),
43
- future: []
44
- };
45
- }
46
- function undo(h) {
47
- const last = h.past[h.past.length - 1];
48
- if (!last)
49
- return h;
50
- const next = applyAll(h.doc, last.inverse);
51
- gate(h, next);
52
- return { ...h, doc: next, past: h.past.slice(0, -1), future: [last, ...h.future] };
53
- }
54
- function redo(h) {
55
- const next = h.future[0];
56
- if (!next)
57
- return h;
58
- const doc = applyAll(h.doc, next.steps);
59
- gate(h, doc);
60
- return { ...h, doc, past: h.past.concat(next), future: h.future.slice(1) };
61
- }
62
-
63
- // src/tree/invariants.ts
64
- function invariants(schema, doc) {
65
- const out = [];
66
- out.push(...validateAll(schema, doc));
67
- const ids = /* @__PURE__ */ new Map();
68
- walk(doc, [], schema, out, ids);
69
- return out;
70
- }
71
- function walk(node, path, schema, out, ids) {
72
- if (isText(node)) {
73
- return;
74
- }
75
- if (node.id !== void 0) {
76
- ids.set(node.id, (ids.get(node.id) ?? 0) + 1);
77
- if (ids.get(node.id) === 2) {
78
- out.push({ path, reason: `\u91CD\u590D id "${node.id}"` });
79
- }
80
- }
81
- const spec = schema.nodes[node.type];
82
- if (spec?.atom) {
83
- if (node.type === "image") {
84
- if (!node.attrs?.url)
85
- out.push({ path, reason: `[image] \u7F3A url` });
86
- return;
87
- }
88
- if (node.type === "mention") {
89
- if (!node.attrs?.id)
90
- out.push({ path, reason: `[mention] \u7F3A id` });
91
- return;
92
- }
93
- if (node.type === "math") {
94
- if (typeof node.attrs?.latex !== "string")
95
- out.push({ path, reason: `[math] \u7F3A latex` });
96
- return;
97
- }
98
- if (node.type === "embed") {
99
- if (!node.attrs?.kind)
100
- out.push({ path, reason: `[embed] \u7F3A kind` });
101
- if (!node.attrs?.src)
102
- out.push({ path, reason: `[embed] \u7F3A src` });
103
- return;
104
- }
105
- for (const reason of checkTable(node)) {
106
- out.push({ path, reason: `[table] ${reason}` });
107
- }
108
- return;
109
- }
110
- if (spec?.marks) {
111
- for (let i = 0; i < node.children.length; i++) {
112
- const child = node.children[i];
113
- if (isText(child) && child.marks) {
114
- for (const m of child.marks) {
115
- if (!spec.marks.includes(m.name)) {
116
- out.push({ path: path.concat(i), reason: `${node.type} \u4E0D\u5141\u8BB8 mark "${m.name}"` });
117
- }
118
- }
119
- }
120
- }
121
- }
122
- for (let i = 0; i < node.children.length; i++) {
123
- walk(node.children[i], path.concat(i), schema, out, ids);
124
- }
125
- }
126
- function firstViolation(vs) {
127
- if (vs.length === 0) {
128
- return null;
129
- }
130
- const v = vs[0];
131
- return `${v.path.join(",")}: ${v.reason}`;
132
- }
133
-
134
- // src/tree/toc.ts
135
- function headingText(node) {
136
- let out = "";
137
- for (const c of node.children) {
138
- if (isText(c))
139
- out += c.text;
140
- }
141
- return out;
142
- }
143
- function outline(doc) {
144
- const out = [];
145
- const walk2 = (node, path) => {
146
- if (isText(node))
147
- return;
148
- if (node.type === "heading") {
149
- const level = Math.min(Math.max(Number(node.attrs?.depth ?? 1), 1), 6);
150
- out.push({ level, text: headingText(node), path, id: node.id });
151
- return;
152
- }
153
- for (let i = 0; i < node.children.length; i++)
154
- walk2(node.children[i], path.concat(i));
155
- };
156
- walk2(doc, []);
157
- return out;
158
- }
159
-
160
- // src/tree/comments.ts
161
- function commentIdsInDoc(doc) {
162
- const ids = /* @__PURE__ */ new Set();
163
- const walk2 = (n) => {
164
- if (isText(n)) {
165
- for (const m of n.marks ?? []) {
166
- if (m.name === "comment" && m.attrs?.id != null)
167
- ids.add(String(m.attrs.id));
168
- }
169
- return;
170
- }
171
- if (isElement(n))
172
- for (const c of n.children)
173
- walk2(c);
174
- };
175
- walk2(doc);
176
- return ids;
177
- }
178
- function stripLeaf(leaf, id) {
179
- const rest = (leaf.marks ?? []).filter((m) => !(m.name === "comment" && String(m.attrs?.id) === id));
180
- return rest.length ? { ...leaf, marks: rest } : { text: leaf.text };
181
- }
182
- function stripCommentMarks(doc, id) {
183
- const steps = [];
184
- const walk2 = (node, path) => {
185
- if (node.children.every((c) => isText(c) || isInlineAtom(c))) {
186
- let changed = false;
187
- const children = node.children.map((c) => {
188
- if (!isText(c) || !c.marks?.some((m) => m.name === "comment" && String(m.attrs?.id) === id))
189
- return c;
190
- changed = true;
191
- return stripLeaf(c, id);
192
- });
193
- if (changed)
194
- steps.push({ kind: "replaceNode", path, node: { ...node, children } });
195
- return;
196
- }
197
- node.children.forEach((c, i) => {
198
- if (isElement(c))
199
- walk2(c, path.concat(i));
200
- });
201
- };
202
- doc.children.forEach((c, i) => {
203
- if (isElement(c))
204
- walk2(c, [i]);
205
- });
206
- return steps;
207
- }
208
-
209
- export {
210
- init,
211
- commit,
212
- amend,
213
- undo,
214
- redo,
215
- invariants,
216
- firstViolation,
217
- outline,
218
- commentIdsInDoc,
219
- stripCommentMarks
220
- };
@@ -1,220 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
- var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
7
-
8
-
9
-
10
-
11
- var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
12
-
13
- // src/tree/history.ts
14
- function init(doc, validate) {
15
- return { doc, past: [], future: [], validate };
16
- }
17
- function gate(h, next) {
18
- const v = _optionalChain([h, 'access', _ => _.validate, 'optionalCall', _2 => _2(next)]);
19
- if (v)
20
- throw new Error(`[invariant] \u63D0\u4EA4\u4EA7\u751F\u975E\u6CD5 doc: ${v}`);
21
- }
22
- function commit(h, steps) {
23
- const inverse = _chunk4TMHVNL6cjs.invertAll.call(void 0, h.doc, steps);
24
- const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, steps);
25
- gate(h, next);
26
- return { ...h, doc: next, past: h.past.concat({ steps, inverse }), future: [] };
27
- }
28
- function amend(h, more) {
29
- if (more.length === 0)
30
- return h;
31
- if (h.past.length === 0)
32
- return commit(h, more);
33
- const last = h.past[h.past.length - 1];
34
- const before = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, last.inverse);
35
- const steps = last.steps.concat(more);
36
- const inverse = _chunk4TMHVNL6cjs.invertAll.call(void 0, before, steps);
37
- const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, before, steps);
38
- gate(h, next);
39
- return {
40
- ...h,
41
- doc: next,
42
- past: h.past.slice(0, -1).concat({ steps, inverse }),
43
- future: []
44
- };
45
- }
46
- function undo(h) {
47
- const last = h.past[h.past.length - 1];
48
- if (!last)
49
- return h;
50
- const next = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, last.inverse);
51
- gate(h, next);
52
- return { ...h, doc: next, past: h.past.slice(0, -1), future: [last, ...h.future] };
53
- }
54
- function redo(h) {
55
- const next = h.future[0];
56
- if (!next)
57
- return h;
58
- const doc = _chunk4TMHVNL6cjs.applyAll.call(void 0, h.doc, next.steps);
59
- gate(h, doc);
60
- return { ...h, doc, past: h.past.concat(next), future: h.future.slice(1) };
61
- }
62
-
63
- // src/tree/invariants.ts
64
- function invariants(schema, doc) {
65
- const out = [];
66
- out.push(..._chunk4TMHVNL6cjs.validateAll.call(void 0, schema, doc));
67
- const ids = /* @__PURE__ */ new Map();
68
- walk(doc, [], schema, out, ids);
69
- return out;
70
- }
71
- function walk(node, path, schema, out, ids) {
72
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, node)) {
73
- return;
74
- }
75
- if (node.id !== void 0) {
76
- ids.set(node.id, (_nullishCoalesce(ids.get(node.id), () => ( 0))) + 1);
77
- if (ids.get(node.id) === 2) {
78
- out.push({ path, reason: `\u91CD\u590D id "${node.id}"` });
79
- }
80
- }
81
- const spec = schema.nodes[node.type];
82
- if (_optionalChain([spec, 'optionalAccess', _3 => _3.atom])) {
83
- if (node.type === "image") {
84
- if (!_optionalChain([node, 'access', _4 => _4.attrs, 'optionalAccess', _5 => _5.url]))
85
- out.push({ path, reason: `[image] \u7F3A url` });
86
- return;
87
- }
88
- if (node.type === "mention") {
89
- if (!_optionalChain([node, 'access', _6 => _6.attrs, 'optionalAccess', _7 => _7.id]))
90
- out.push({ path, reason: `[mention] \u7F3A id` });
91
- return;
92
- }
93
- if (node.type === "math") {
94
- if (typeof _optionalChain([node, 'access', _8 => _8.attrs, 'optionalAccess', _9 => _9.latex]) !== "string")
95
- out.push({ path, reason: `[math] \u7F3A latex` });
96
- return;
97
- }
98
- if (node.type === "embed") {
99
- if (!_optionalChain([node, 'access', _10 => _10.attrs, 'optionalAccess', _11 => _11.kind]))
100
- out.push({ path, reason: `[embed] \u7F3A kind` });
101
- if (!_optionalChain([node, 'access', _12 => _12.attrs, 'optionalAccess', _13 => _13.src]))
102
- out.push({ path, reason: `[embed] \u7F3A src` });
103
- return;
104
- }
105
- for (const reason of _chunk4TMHVNL6cjs.checkTable.call(void 0, node)) {
106
- out.push({ path, reason: `[table] ${reason}` });
107
- }
108
- return;
109
- }
110
- if (_optionalChain([spec, 'optionalAccess', _14 => _14.marks])) {
111
- for (let i = 0; i < node.children.length; i++) {
112
- const child = node.children[i];
113
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, child) && child.marks) {
114
- for (const m of child.marks) {
115
- if (!spec.marks.includes(m.name)) {
116
- out.push({ path: path.concat(i), reason: `${node.type} \u4E0D\u5141\u8BB8 mark "${m.name}"` });
117
- }
118
- }
119
- }
120
- }
121
- }
122
- for (let i = 0; i < node.children.length; i++) {
123
- walk(node.children[i], path.concat(i), schema, out, ids);
124
- }
125
- }
126
- function firstViolation(vs) {
127
- if (vs.length === 0) {
128
- return null;
129
- }
130
- const v = vs[0];
131
- return `${v.path.join(",")}: ${v.reason}`;
132
- }
133
-
134
- // src/tree/toc.ts
135
- function headingText(node) {
136
- let out = "";
137
- for (const c of node.children) {
138
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, c))
139
- out += c.text;
140
- }
141
- return out;
142
- }
143
- function outline(doc) {
144
- const out = [];
145
- const walk2 = (node, path) => {
146
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
147
- return;
148
- if (node.type === "heading") {
149
- const level = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([node, 'access', _15 => _15.attrs, 'optionalAccess', _16 => _16.depth]), () => ( 1))), 1), 6);
150
- out.push({ level, text: headingText(node), path, id: node.id });
151
- return;
152
- }
153
- for (let i = 0; i < node.children.length; i++)
154
- walk2(node.children[i], path.concat(i));
155
- };
156
- walk2(doc, []);
157
- return out;
158
- }
159
-
160
- // src/tree/comments.ts
161
- function commentIdsInDoc(doc) {
162
- const ids = /* @__PURE__ */ new Set();
163
- const walk2 = (n) => {
164
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, n)) {
165
- for (const m of _nullishCoalesce(n.marks, () => ( []))) {
166
- if (m.name === "comment" && _optionalChain([m, 'access', _17 => _17.attrs, 'optionalAccess', _18 => _18.id]) != null)
167
- ids.add(String(m.attrs.id));
168
- }
169
- return;
170
- }
171
- if (_chunkGQ2HHRGIcjs.isElement.call(void 0, n))
172
- for (const c of n.children)
173
- walk2(c);
174
- };
175
- walk2(doc);
176
- return ids;
177
- }
178
- function stripLeaf(leaf, id) {
179
- const rest = (_nullishCoalesce(leaf.marks, () => ( []))).filter((m) => !(m.name === "comment" && String(_optionalChain([m, 'access', _19 => _19.attrs, 'optionalAccess', _20 => _20.id])) === id));
180
- return rest.length ? { ...leaf, marks: rest } : { text: leaf.text };
181
- }
182
- function stripCommentMarks(doc, id) {
183
- const steps = [];
184
- const walk2 = (node, path) => {
185
- if (node.children.every((c) => _chunkGQ2HHRGIcjs.isText.call(void 0, c) || _chunkGQ2HHRGIcjs.isInlineAtom.call(void 0, c))) {
186
- let changed = false;
187
- const children = node.children.map((c) => {
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)]))
189
- return c;
190
- changed = true;
191
- return stripLeaf(c, id);
192
- });
193
- if (changed)
194
- steps.push({ kind: "replaceNode", path, node: { ...node, children } });
195
- return;
196
- }
197
- node.children.forEach((c, i) => {
198
- if (_chunkGQ2HHRGIcjs.isElement.call(void 0, c))
199
- walk2(c, path.concat(i));
200
- });
201
- };
202
- doc.children.forEach((c, i) => {
203
- if (_chunkGQ2HHRGIcjs.isElement.call(void 0, c))
204
- walk2(c, [i]);
205
- });
206
- return steps;
207
- }
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
- exports.init = init; exports.commit = commit; exports.amend = amend; exports.undo = undo; exports.redo = redo; exports.invariants = invariants; exports.firstViolation = firstViolation; exports.outline = outline; exports.commentIdsInDoc = commentIdsInDoc; exports.stripCommentMarks = stripCommentMarks;
@@ -1,43 +0,0 @@
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 };
@@ -1,43 +0,0 @@
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,65 +0,0 @@
1
- interface TextNode {
2
- text: string;
3
- marks?: Mark[];
4
- }
5
- interface ElementNode {
6
- type: string;
7
- attrs?: Record<string, unknown>;
8
- children: Node[];
9
- id?: string;
10
- }
11
- type Node = TextNode | ElementNode;
12
- interface Mark {
13
- name: string;
14
- attrs?: Record<string, unknown>;
15
- }
16
- declare function isText(n: Node): n is TextNode;
17
- declare function isElement(n: Node): n is ElementNode;
18
- declare function isInlineAtom(n: Node): boolean;
19
- type Path = number[];
20
- interface Position {
21
- path: Path;
22
- assoc?: -1 | 1;
23
- }
24
- interface Selection {
25
- anchor: Position;
26
- head: Position;
27
- }
28
- type Doc = ElementNode;
29
-
30
- interface InsertText {
31
- kind: 'insertText';
32
- path: Path;
33
- offset: number;
34
- text: string;
35
- marks?: {
36
- name: string;
37
- attrs?: Record<string, unknown>;
38
- }[];
39
- }
40
- interface DeleteText {
41
- kind: 'deleteText';
42
- path: Path;
43
- offset: number;
44
- length: number;
45
- }
46
- interface ReplaceNode {
47
- kind: 'replaceNode';
48
- path: Path;
49
- node: Node;
50
- }
51
- interface SpliceChildren {
52
- kind: 'spliceChildren';
53
- path: Path;
54
- at: number;
55
- remove: number;
56
- insert: Node[];
57
- }
58
- type Step = InsertText | DeleteText | ReplaceNode | SpliceChildren;
59
- declare function apply(doc: ElementNode, step: Step): ElementNode;
60
- declare function invert(doc: ElementNode, step: Step): Step;
61
- declare function applyAll(doc: ElementNode, steps: Step[]): ElementNode;
62
- declare function moveBlock(doc: ElementNode, fromIdx: number, toGap: number): Step[];
63
- declare function invertAll(doc: ElementNode, steps: Step[]): Step[];
64
-
65
- export { type DeleteText as D, type ElementNode as E, type InsertText as I, type Mark as M, type Node as N, type Path as P, type ReplaceNode as R, type Step as S, type TextNode as T, type Position as a, type Doc as b, type Selection as c, type SpliceChildren as d, apply as e, applyAll as f, invertAll as g, isElement as h, invert as i, isInlineAtom as j, isText as k, moveBlock as m };
@@ -1,65 +0,0 @@
1
- interface TextNode {
2
- text: string;
3
- marks?: Mark[];
4
- }
5
- interface ElementNode {
6
- type: string;
7
- attrs?: Record<string, unknown>;
8
- children: Node[];
9
- id?: string;
10
- }
11
- type Node = TextNode | ElementNode;
12
- interface Mark {
13
- name: string;
14
- attrs?: Record<string, unknown>;
15
- }
16
- declare function isText(n: Node): n is TextNode;
17
- declare function isElement(n: Node): n is ElementNode;
18
- declare function isInlineAtom(n: Node): boolean;
19
- type Path = number[];
20
- interface Position {
21
- path: Path;
22
- assoc?: -1 | 1;
23
- }
24
- interface Selection {
25
- anchor: Position;
26
- head: Position;
27
- }
28
- type Doc = ElementNode;
29
-
30
- interface InsertText {
31
- kind: 'insertText';
32
- path: Path;
33
- offset: number;
34
- text: string;
35
- marks?: {
36
- name: string;
37
- attrs?: Record<string, unknown>;
38
- }[];
39
- }
40
- interface DeleteText {
41
- kind: 'deleteText';
42
- path: Path;
43
- offset: number;
44
- length: number;
45
- }
46
- interface ReplaceNode {
47
- kind: 'replaceNode';
48
- path: Path;
49
- node: Node;
50
- }
51
- interface SpliceChildren {
52
- kind: 'spliceChildren';
53
- path: Path;
54
- at: number;
55
- remove: number;
56
- insert: Node[];
57
- }
58
- type Step = InsertText | DeleteText | ReplaceNode | SpliceChildren;
59
- declare function apply(doc: ElementNode, step: Step): ElementNode;
60
- declare function invert(doc: ElementNode, step: Step): Step;
61
- declare function applyAll(doc: ElementNode, steps: Step[]): ElementNode;
62
- declare function moveBlock(doc: ElementNode, fromIdx: number, toGap: number): Step[];
63
- declare function invertAll(doc: ElementNode, steps: Step[]): Step[];
64
-
65
- export { type DeleteText as D, type ElementNode as E, type InsertText as I, type Mark as M, type Node as N, type Path as P, type ReplaceNode as R, type Step as S, type TextNode as T, type Position as a, type Doc as b, type Selection as c, type SpliceChildren as d, apply as e, applyAll as f, invertAll as g, isElement as h, invert as i, isInlineAtom as j, isText as k, moveBlock as m };