markloom 0.5.1 → 0.7.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 (73) hide show
  1. package/PACKAGES.md +26 -0
  2. package/README.md +20 -2
  3. package/collab.md +60 -13
  4. package/dist/ai/index.cjs +5 -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 +4 -3
  8. package/dist/ai/theme.css +66 -102
  9. package/dist/{chunk-ZMTLSFLO.js → chunk-4Q7PAR2T.js} +5746 -1341
  10. package/dist/chunk-75EJ4ARB.cjs +642 -0
  11. package/dist/{chunk-JS527FDV.cjs → chunk-BMPCVT3B.cjs} +47 -39
  12. package/dist/{chunk-RLTHVQNQ.js → chunk-EFYT2223.js} +47 -39
  13. package/dist/chunk-HXABDVLZ.cjs +297 -0
  14. package/dist/{chunk-YIFOGP2D.cjs → chunk-I2LDEVLA.cjs} +499 -102
  15. package/dist/chunk-MQLRZQZL.js +642 -0
  16. package/dist/chunk-OVHASRID.cjs +4279 -0
  17. package/dist/chunk-PCSVBPOR.cjs +40 -0
  18. package/dist/{chunk-FCH7LZFI.js → chunk-PSAXWBNM.js} +450 -53
  19. package/dist/chunk-PZRWTLLB.cjs +858 -0
  20. package/dist/chunk-QO7JEZDB.js +4279 -0
  21. package/dist/chunk-WSJUXPAG.js +40 -0
  22. package/dist/{chunk-VXM7Q6P5.cjs → chunk-Y4IXQFWL.cjs} +6026 -1621
  23. package/dist/chunk-YLVSMDIO.js +858 -0
  24. package/dist/chunk-ZL6WT6OY.js +297 -0
  25. package/dist/client-BvvyHjhh.d.ts +250 -0
  26. package/dist/client-Ciy7Fa_k.d.cts +250 -0
  27. package/dist/collab/index.cjs +17 -4
  28. package/dist/collab/index.d.cts +18 -7
  29. package/dist/collab/index.d.ts +18 -7
  30. package/dist/collab/index.js +19 -6
  31. package/dist/{controller-DQITsFhy.d.cts → controller-CHznEhAR.d.cts} +277 -26
  32. package/dist/{controller-BNuuUM3E.d.ts → controller-DLqI8_jm.d.ts} +277 -26
  33. package/dist/index.cjs +119 -7
  34. package/dist/index.d.cts +138 -6
  35. package/dist/index.d.ts +138 -6
  36. package/dist/index.js +130 -18
  37. package/dist/io/index.cjs +1412 -0
  38. package/dist/io/index.d.cts +33 -0
  39. package/dist/io/index.d.ts +33 -0
  40. package/dist/io/index.js +1412 -0
  41. package/dist/react/index.cjs +9 -8
  42. package/dist/react/index.d.cts +5 -4
  43. package/dist/react/index.d.ts +5 -4
  44. package/dist/react/index.js +8 -7
  45. package/dist/{rebase-batch-8rL_aXEE.d.ts → rebase-batch-CSnv8FKp.d.ts} +11 -9
  46. package/dist/{rebase-batch-bYnBJpRO.d.cts → rebase-batch-DO1ygkx9.d.cts} +11 -9
  47. package/dist/types-BkHlmUFL.d.cts +34 -0
  48. package/dist/types-BkHlmUFL.d.ts +34 -0
  49. package/dist/versions-DNFf8zVz.d.cts +51 -0
  50. package/dist/versions-DOkOyh2J.d.ts +51 -0
  51. package/dist/view/index.cjs +259 -17
  52. package/dist/view/index.d.cts +277 -12
  53. package/dist/view/index.d.ts +277 -12
  54. package/dist/view/index.js +256 -14
  55. package/dist/view/theme.css +2093 -1577
  56. package/dist/word-count-BPw9G2Bg.d.ts +130 -0
  57. package/dist/word-count-DNLn1h_t.d.cts +130 -0
  58. package/io.md +38 -0
  59. package/package.json +25 -4
  60. package/dist/chunk-4JSJAHTB.js +0 -255
  61. package/dist/chunk-4TMHVNL6.cjs +0 -2297
  62. package/dist/chunk-ALZ3A5CS.cjs +0 -255
  63. package/dist/chunk-GQ2HHRGI.cjs +0 -16
  64. package/dist/chunk-LA5SBCGQ.js +0 -16
  65. package/dist/chunk-LEYAQNJA.js +0 -220
  66. package/dist/chunk-MFYF2A6U.js +0 -2297
  67. package/dist/chunk-YXQDCW4Y.cjs +0 -220
  68. package/dist/client-6KiH4kGK.d.ts +0 -144
  69. package/dist/client-ZRZj2nkq.d.cts +0 -144
  70. package/dist/comments-DlExS6f-.d.cts +0 -43
  71. package/dist/comments-PhnR7Gkn.d.ts +0 -43
  72. package/dist/step-BrvHIK7O.d.cts +0 -65
  73. package/dist/step-BrvHIK7O.d.ts +0 -65
package/dist/index.cjs CHANGED
@@ -9,7 +9,6 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
13
12
 
14
13
 
15
14
 
@@ -38,6 +37,7 @@ var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
38
37
 
39
38
 
40
39
 
40
+ var _chunkPZRWTLLBcjs = require('./chunk-PZRWTLLB.cjs');
41
41
 
42
42
 
43
43
 
@@ -70,7 +70,6 @@ var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
70
70
 
71
71
 
72
72
 
73
- var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
74
73
 
75
74
 
76
75
 
@@ -81,21 +80,79 @@ var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
81
80
 
82
81
 
83
82
 
84
- var _chunkJS527FDVcjs = require('./chunk-JS527FDV.cjs');
85
83
 
86
84
 
87
85
 
88
86
 
89
- var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ var _chunkOVHASRIDcjs = require('./chunk-OVHASRID.cjs');
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ var _chunkBMPCVT3Bcjs = require('./chunk-BMPCVT3B.cjs');
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ var _chunkHXABDVLZcjs = require('./chunk-HXABDVLZ.cjs');
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+ var _chunkPCSVBPORcjs = require('./chunk-PCSVBPOR.cjs');
90
147
 
91
148
  // src/tree/stats.ts
92
149
  function rawText(node) {
93
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
150
+ if (_chunkPCSVBPORcjs.isText.call(void 0, node))
94
151
  return node.text;
95
152
  return node.children.map(rawText).join("");
96
153
  }
97
154
  function spacedText(node) {
98
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
155
+ if (_chunkPCSVBPORcjs.isText.call(void 0, node))
99
156
  return node.text;
100
157
  return node.children.map(spacedText).join("\n");
101
158
  }
@@ -199,4 +256,59 @@ function docStats(doc) {
199
256
 
200
257
 
201
258
 
202
- exports.amend = _chunkYXQDCW4Ycjs.amend; exports.appendText = _chunk4TMHVNL6cjs.appendText; exports.apply = _chunk4TMHVNL6cjs.apply; exports.applyAll = _chunk4TMHVNL6cjs.applyAll; exports.arrowCell = _chunk4TMHVNL6cjs.arrowCell; exports.basicSchema = _chunk4TMHVNL6cjs.basicSchema; exports.buildGrid = _chunk4TMHVNL6cjs.buildGrid; exports.buildIdIndex = _chunk4TMHVNL6cjs.buildIdIndex; exports.calloutToHtml = _chunk4TMHVNL6cjs.calloutToHtml; exports.caretCell = _chunk4TMHVNL6cjs.caretCell; exports.cellCaret = _chunk4TMHVNL6cjs.cellCaret; exports.cellText = _chunk4TMHVNL6cjs.cellText; exports.checkSchema = _chunk4TMHVNL6cjs.checkSchema; exports.checkTable = _chunk4TMHVNL6cjs.checkTable; exports.clearCells = _chunk4TMHVNL6cjs.clearCells; exports.colspanOf = _chunk4TMHVNL6cjs.colspanOf; exports.commentIdsInDoc = _chunkYXQDCW4Ycjs.commentIdsInDoc; exports.commit = _chunkYXQDCW4Ycjs.commit; exports.deleteCol = _chunk4TMHVNL6cjs.deleteCol; exports.deleteRow = _chunk4TMHVNL6cjs.deleteRow; exports.deleteTableBlock = _chunk4TMHVNL6cjs.deleteTableBlock; exports.diffById = _chunk4TMHVNL6cjs.diffById; exports.docStats = docStats; exports.docToMd = _chunk4TMHVNL6cjs.docToMd; exports.embedHtml = _chunk4TMHVNL6cjs.embedHtml; exports.firstLeafPath = _chunk4TMHVNL6cjs.firstLeafPath; exports.firstViolation = _chunkYXQDCW4Ycjs.firstViolation; exports.hasSpan = _chunk4TMHVNL6cjs.hasSpan; exports.htmlToBlocks = _chunk4TMHVNL6cjs.htmlToBlocks; exports.init = _chunkYXQDCW4Ycjs.init; exports.insertAfter = _chunk4TMHVNL6cjs.insertAfter; exports.insertCol = _chunk4TMHVNL6cjs.insertCol; exports.insertRow = _chunk4TMHVNL6cjs.insertRow; exports.invariants = _chunkYXQDCW4Ycjs.invariants; exports.invert = _chunk4TMHVNL6cjs.invert; exports.invertAll = _chunk4TMHVNL6cjs.invertAll; exports.isElement = _chunkGQ2HHRGIcjs.isElement; exports.isInlineAtom = _chunkGQ2HHRGIcjs.isInlineAtom; exports.isRichHtmlBlocks = _chunk4TMHVNL6cjs.isRichHtmlBlocks; exports.isText = _chunkGQ2HHRGIcjs.isText; exports.lastLeafEnd = _chunk4TMHVNL6cjs.lastLeafEnd; exports.makeBias = _chunkJS527FDVcjs.makeBias; exports.makeTable = _chunk4TMHVNL6cjs.makeTable; exports.mapPosition = _chunkJS527FDVcjs.mapPosition; exports.mapSelection = _chunkJS527FDVcjs.mapSelection; exports.mdToDoc = _chunk4TMHVNL6cjs.mdToDoc; exports.mergeCells = _chunk4TMHVNL6cjs.mergeCells; exports.moveBlock = _chunk4TMHVNL6cjs.moveBlock; exports.moveCol = _chunk4TMHVNL6cjs.moveCol; exports.moveRow = _chunk4TMHVNL6cjs.moveRow; exports.nextCell = _chunk4TMHVNL6cjs.nextCell; exports.nodeAt = _chunk4TMHVNL6cjs.nodeAt; exports.normalizePosition = _chunkJS527FDVcjs.normalizePosition; exports.normalizeToLeaf = _chunk4TMHVNL6cjs.normalizeToLeaf; exports.outline = _chunkYXQDCW4Ycjs.outline; exports.pathOfId = _chunk4TMHVNL6cjs.pathOfId; exports.rebase = _chunkJS527FDVcjs.rebase; exports.rebaseBatchOver = _chunkJS527FDVcjs.rebaseBatchOver; exports.rebaseOne = _chunkJS527FDVcjs.rebaseOne; exports.rebaseStepsThrough = _chunkJS527FDVcjs.rebaseStepsThrough; exports.redo = _chunkYXQDCW4Ycjs.redo; exports.replaceAt = _chunk4TMHVNL6cjs.replaceAt; exports.resolve = _chunk4TMHVNL6cjs.resolve; exports.rewriteNode = _chunk4TMHVNL6cjs.rewriteNode; exports.rowspanOf = _chunk4TMHVNL6cjs.rowspanOf; exports.setAlign = _chunk4TMHVNL6cjs.setAlign; exports.setCellStyle = _chunk4TMHVNL6cjs.setCellStyle; exports.setColWidths = _chunk4TMHVNL6cjs.setColWidths; exports.setFreeze = _chunk4TMHVNL6cjs.setFreeze; exports.spliceAt = _chunk4TMHVNL6cjs.spliceAt; exports.splitCell = _chunk4TMHVNL6cjs.splitCell; exports.stripCommentMarks = _chunkYXQDCW4Ycjs.stripCommentMarks; exports.tableAt = _chunk4TMHVNL6cjs.tableAt; exports.tableColWidths = _chunk4TMHVNL6cjs.tableColWidths; exports.tableHasExtras = _chunk4TMHVNL6cjs.tableHasExtras; exports.tableSchema = _chunk4TMHVNL6cjs.tableSchema; exports.tableShape = _chunk4TMHVNL6cjs.tableShape; exports.tableToHtml = _chunk4TMHVNL6cjs.tableToHtml; exports.transformRemoteAgainstPending = _chunkJS527FDVcjs.transformRemoteAgainstPending; exports.undo = _chunkYXQDCW4Ycjs.undo; exports.validate = _chunk4TMHVNL6cjs.validate; exports.validateAll = _chunk4TMHVNL6cjs.validateAll;
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+ exports.CELL_BLOCK_TYPES = _chunkOVHASRIDcjs.CELL_BLOCK_TYPES; exports.CELL_EXCLUDED_FROM_BODY = _chunkOVHASRIDcjs.CELL_EXCLUDED_FROM_BODY; exports.DEFAULT_COL_WIDTH = _chunkOVHASRIDcjs.DEFAULT_COL_WIDTH; exports.FRONT_MATTER = _chunkOVHASRIDcjs.FRONT_MATTER; exports.acceptSuggestion = _chunkPZRWTLLBcjs.acceptSuggestion; exports.amend = _chunkPZRWTLLBcjs.amend; exports.appendText = _chunkOVHASRIDcjs.appendText; exports.apply = _chunkHXABDVLZcjs.apply; exports.applyAll = _chunkHXABDVLZcjs.applyAll; exports.applyForeign = _chunkPZRWTLLBcjs.applyForeign; exports.applyReplaceAll = _chunkPZRWTLLBcjs.applyReplaceAll; exports.arrowCell = _chunkOVHASRIDcjs.arrowCell; exports.basicSchema = _chunkOVHASRIDcjs.basicSchema; exports.bodyBlockTypes = _chunkOVHASRIDcjs.bodyBlockTypes; exports.buildGrid = _chunkOVHASRIDcjs.buildGrid; exports.buildIdIndex = _chunkOVHASRIDcjs.buildIdIndex; exports.calloutToHtml = _chunkOVHASRIDcjs.calloutToHtml; exports.caretCell = _chunkOVHASRIDcjs.caretCell; exports.cellBlockTypes = _chunkOVHASRIDcjs.cellBlockTypes; exports.cellCaret = _chunkOVHASRIDcjs.cellCaret; exports.cellRectTable = _chunkOVHASRIDcjs.cellRectTable; exports.cellText = _chunkOVHASRIDcjs.cellText; exports.checkSchema = _chunkOVHASRIDcjs.checkSchema; exports.checkTable = _chunkOVHASRIDcjs.checkTable; exports.clearCells = _chunkOVHASRIDcjs.clearCells; exports.colspanOf = _chunkOVHASRIDcjs.colspanOf; exports.commentIdsInDoc = _chunkPZRWTLLBcjs.commentIdsInDoc; exports.commit = _chunkPZRWTLLBcjs.commit; exports.deleteCol = _chunkOVHASRIDcjs.deleteCol; exports.deleteRow = _chunkOVHASRIDcjs.deleteRow; exports.deleteTableBlock = _chunkOVHASRIDcjs.deleteTableBlock; exports.diffById = _chunkOVHASRIDcjs.diffById; exports.docStats = docStats; exports.docToMd = _chunkOVHASRIDcjs.docToMd; exports.dropMarkedLeaves = _chunkPZRWTLLBcjs.dropMarkedLeaves; exports.dropSuggestText = _chunkPZRWTLLBcjs.dropSuggestText; exports.embedHtml = _chunkOVHASRIDcjs.embedHtml; exports.findText = _chunkPZRWTLLBcjs.findText; exports.firstLeafPath = _chunkHXABDVLZcjs.firstLeafPath; exports.firstViolation = _chunkPZRWTLLBcjs.firstViolation; exports.footnoteIndex = _chunkPZRWTLLBcjs.footnoteIndex; exports.footnoteKey = _chunkPCSVBPORcjs.footnoteKey; exports.footnoteText = _chunkPZRWTLLBcjs.footnoteText; exports.frontMatterEnd = _chunkOVHASRIDcjs.frontMatterEnd; exports.gapToTextPath = _chunkHXABDVLZcjs.gapToTextPath; exports.getVersion = _chunkPZRWTLLBcjs.getVersion; exports.hasFootnotes = _chunkPZRWTLLBcjs.hasFootnotes; exports.hasSpan = _chunkOVHASRIDcjs.hasSpan; exports.htmlToBlocks = _chunkOVHASRIDcjs.htmlToBlocks; exports.init = _chunkPZRWTLLBcjs.init; exports.insertAfter = _chunkOVHASRIDcjs.insertAfter; exports.insertCol = _chunkOVHASRIDcjs.insertCol; exports.insertRow = _chunkOVHASRIDcjs.insertRow; exports.invariants = _chunkPZRWTLLBcjs.invariants; exports.invert = _chunkHXABDVLZcjs.invert; exports.invertAll = _chunkHXABDVLZcjs.invertAll; exports.isAiCompose = _chunkPCSVBPORcjs.isAiCompose; exports.isBodyBlockType = _chunkOVHASRIDcjs.isBodyBlockType; exports.isCallout = _chunkPCSVBPORcjs.isCallout; exports.isCellBlockType = _chunkOVHASRIDcjs.isCellBlockType; exports.isCellBlockTypeInSpace = _chunkOVHASRIDcjs.isCellBlockTypeInSpace; exports.isElement = _chunkPCSVBPORcjs.isElement; exports.isFootnoteDef = _chunkPCSVBPORcjs.isFootnoteDef; exports.isFrontMatter = _chunkOVHASRIDcjs.isFrontMatter; exports.isInlineAtom = _chunkPCSVBPORcjs.isInlineAtom; exports.isLastCell = _chunkOVHASRIDcjs.isLastCell; exports.isPlainTransportHtml = _chunkOVHASRIDcjs.isPlainTransportHtml; exports.isRichHtmlBlocks = _chunkOVHASRIDcjs.isRichHtmlBlocks; exports.isSuggestMark = _chunkPZRWTLLBcjs.isSuggestMark; exports.isText = _chunkPCSVBPORcjs.isText; exports.lastLeafEnd = _chunkHXABDVLZcjs.lastLeafEnd; exports.listSuggestions = _chunkPZRWTLLBcjs.listSuggestions; exports.makeBias = _chunkBMPCVT3Bcjs.makeBias; exports.makeTable = _chunkOVHASRIDcjs.makeTable; exports.mapLeafBlocks = _chunkPZRWTLLBcjs.mapLeafBlocks; exports.mapPosition = _chunkBMPCVT3Bcjs.mapPosition; exports.mapSelection = _chunkBMPCVT3Bcjs.mapSelection; exports.mapSelectionThrough = _chunkBMPCVT3Bcjs.mapSelectionThrough; exports.markIdsInDoc = _chunkPZRWTLLBcjs.markIdsInDoc; exports.markSuggestRange = _chunkPZRWTLLBcjs.markSuggestRange; exports.mdStructureBeatsTransport = _chunkOVHASRIDcjs.mdStructureBeatsTransport; exports.mdToDoc = _chunkOVHASRIDcjs.mdToDoc; exports.mdToDocAsync = _chunkOVHASRIDcjs.mdToDocAsync; exports.mergeCells = _chunkOVHASRIDcjs.mergeCells; exports.moveBlock = _chunkHXABDVLZcjs.moveBlock; exports.moveCol = _chunkOVHASRIDcjs.moveCol; exports.moveRow = _chunkOVHASRIDcjs.moveRow; exports.nextCell = _chunkOVHASRIDcjs.nextCell; exports.nodeAt = _chunkHXABDVLZcjs.nodeAt; exports.normalizePosition = _chunkBMPCVT3Bcjs.normalizePosition; exports.normalizeToLeaf = _chunkHXABDVLZcjs.normalizeToLeaf; exports.outline = _chunkPZRWTLLBcjs.outline; exports.pathOfId = _chunkOVHASRIDcjs.pathOfId; exports.preferMarkdownPaste = _chunkOVHASRIDcjs.preferMarkdownPaste; exports.pushVersion = _chunkPZRWTLLBcjs.pushVersion; exports.rangeForDelete = _chunkPZRWTLLBcjs.rangeForDelete; exports.rangeIsSuggestInsert = _chunkPZRWTLLBcjs.rangeIsSuggestInsert; exports.rebase = _chunkBMPCVT3Bcjs.rebase; exports.rebaseBatchOver = _chunkBMPCVT3Bcjs.rebaseBatchOver; exports.rebaseOne = _chunkBMPCVT3Bcjs.rebaseOne; exports.rebaseStepsThrough = _chunkBMPCVT3Bcjs.rebaseStepsThrough; exports.redo = _chunkPZRWTLLBcjs.redo; exports.rejectSuggestion = _chunkPZRWTLLBcjs.rejectSuggestion; exports.removeVersion = _chunkPZRWTLLBcjs.removeVersion; exports.replaceAll = _chunkPZRWTLLBcjs.replaceAll; exports.replaceAt = _chunkHXABDVLZcjs.replaceAt; exports.replaceMatch = _chunkPZRWTLLBcjs.replaceMatch; exports.resolve = _chunkHXABDVLZcjs.resolve; exports.resolveTxAfter = _chunkBMPCVT3Bcjs.resolveTxAfter; exports.resolvedColWidths = _chunkOVHASRIDcjs.resolvedColWidths; exports.rewriteNode = _chunkOVHASRIDcjs.rewriteNode; exports.rowspanOf = _chunkOVHASRIDcjs.rowspanOf; exports.setAlign = _chunkOVHASRIDcjs.setAlign; exports.setCellStyle = _chunkOVHASRIDcjs.setCellStyle; exports.setColWidths = _chunkOVHASRIDcjs.setColWidths; exports.setFreeze = _chunkOVHASRIDcjs.setFreeze; exports.setHeaderCol = _chunkOVHASRIDcjs.setHeaderCol; exports.setMathSyntax = _chunkOVHASRIDcjs.setMathSyntax; exports.snapshotDoc = _chunkPZRWTLLBcjs.snapshotDoc; exports.spliceAt = _chunkHXABDVLZcjs.spliceAt; exports.splitCell = _chunkOVHASRIDcjs.splitCell; exports.stripCommentMarks = _chunkPZRWTLLBcjs.stripCommentMarks; exports.stripMarks = _chunkPZRWTLLBcjs.stripMarks; exports.stripSuggestMarks = _chunkPZRWTLLBcjs.stripSuggestMarks; exports.suggestIdsInDoc = _chunkPZRWTLLBcjs.suggestIdsInDoc; exports.suggestMark = _chunkPZRWTLLBcjs.suggestMark; exports.tableAt = _chunkOVHASRIDcjs.tableAt; exports.tableColWidths = _chunkOVHASRIDcjs.tableColWidths; exports.tableHasExtras = _chunkOVHASRIDcjs.tableHasExtras; exports.tableSchema = _chunkOVHASRIDcjs.tableSchema; exports.tableShape = _chunkOVHASRIDcjs.tableShape; exports.tableToHtml = _chunkOVHASRIDcjs.tableToHtml; exports.transformRemoteAgainstPending = _chunkBMPCVT3Bcjs.transformRemoteAgainstPending; exports.undo = _chunkPZRWTLLBcjs.undo; exports.validate = _chunkOVHASRIDcjs.validate; exports.validateAll = _chunkOVHASRIDcjs.validateAll; exports.wordCount = _chunkPZRWTLLBcjs.wordCount;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
- import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './step-BrvHIK7O.cjs';
2
- export { D as DeleteText, b as Doc, I as InsertText, M as Mark, R as ReplaceNode, c as Selection, d as SpliceChildren, T as TextNode, e as apply, f as applyAll, i as invert, g as invertAll, h as isElement, j as isInlineAtom, k as isText, m as moveBlock } from './step-BrvHIK7O.cjs';
3
- export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, e as amend, f as commentIdsInDoc, g as commit, i as init, r as redo, s as stripCommentMarks, u as undo } from './comments-DlExS6f-.cjs';
4
- export { B as Bias, m as makeBias, c as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-bYnBJpRO.cjs';
1
+ import { S as Step } from './versions-DNFf8zVz.cjs';
2
+ export { D as DeleteText, a as DocVersion, I as InsertText, R as ReplaceNode, b as SpliceChildren, c as apply, d as applyAll, g as getVersion, i as invert, e as invertAll, m as moveBlock, p as pushVersion, r as removeVersion, s as snapshotDoc } from './versions-DNFf8zVz.cjs';
3
+ import { E as ElementNode, P as Path, N as Node, a as Position, T as TextNode, M as Mark } from './types-BkHlmUFL.cjs';
4
+ export { D as Doc, S as Selection, f as footnoteKey, i as isAiCompose, b as isCallout, c as isElement, d as isFootnoteDef, e as isInlineAtom, g as isText } from './types-BkHlmUFL.cjs';
5
+ export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, S as SearchOpts, e as SuggestAuthor, f as SuggestHit, g as SuggestKind, T as TextMatch, W as WordCount, h as acceptSuggestion, i as amend, j as applyForeign, k as applyReplaceAll, l as commentIdsInDoc, m as commit, n as dropSuggestText, o as findText, p as init, q as isSuggestMark, r as listSuggestions, s as markSuggestRange, t as rangeForDelete, u as rangeIsSuggestInsert, v as redo, w as rejectSuggestion, x as replaceAll, y as replaceMatch, z as stripCommentMarks, A as stripSuggestMarks, B as suggestIdsInDoc, D as suggestMark, E as undo, F as wordCount } from './word-count-DNLn1h_t.cjs';
6
+ export { B as Bias, m as makeBias, d as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-DO1ygkx9.cjs';
5
7
 
6
8
  interface TableShape {
7
9
  rows: number;
@@ -28,12 +30,14 @@ declare function caretCell(tablePath: Path, table: ElementNode, caret: Path): {
28
30
  r: number;
29
31
  c: number;
30
32
  } | null;
33
+ declare const DEFAULT_COL_WIDTH = 120;
31
34
  declare function makeTable(id: string, rows: number, cols: number): ElementNode;
32
35
  declare function cellText(table: ElementNode, r: number, c: number): string;
33
36
  declare function nextCell(table: ElementNode, r: number, c: number, dir: 1 | -1): {
34
37
  r: number;
35
38
  c: number;
36
39
  };
40
+ declare function isLastCell(table: ElementNode, r: number, c: number): boolean;
37
41
  declare function arrowCell(table: ElementNode, r: number, c: number, dir: 'up' | 'down' | 'left' | 'right'): {
38
42
  r: number;
39
43
  c: number;
@@ -45,7 +49,9 @@ declare function deleteCol(table: ElementNode, tablePath: Path, c: number, doc?:
45
49
  declare function hasSpan(table: ElementNode): boolean;
46
50
  declare function moveRow(table: ElementNode, tablePath: Path, from: number, to: number): Step;
47
51
  declare function moveCol(table: ElementNode, tablePath: Path, from: number, to: number): Step;
52
+ declare function cellRectTable(table: ElementNode, r1: number, c1: number, r2: number, c2: number): ElementNode;
48
53
  declare function tableColWidths(table: ElementNode): number[] | null;
54
+ declare function resolvedColWidths(table: ElementNode): number[];
49
55
  declare function setColWidths(table: ElementNode, tablePath: Path, widths: number[]): Step;
50
56
  declare function setAlign(table: ElementNode, tablePath: Path, col: number, value: 'left' | 'center' | 'right' | null): Step;
51
57
  declare function mergeCells(table: ElementNode, tablePath: Path, r1: number, c1: number, r2: number, c2: number): Step;
@@ -64,9 +70,14 @@ declare function setFreeze(table: ElementNode, tablePath: Path, freeze: {
64
70
  rows?: number;
65
71
  cols?: number;
66
72
  }): Step;
73
+ declare function setHeaderCol(table: ElementNode, tablePath: Path, on: boolean): Step;
67
74
  declare function deleteTableBlock(tablePath: Path, doc?: ElementNode): Step;
68
75
  declare function tableAt(doc: ElementNode, tablePath: Path): ElementNode | null;
69
76
  declare function checkTable(table: ElementNode): string[];
77
+ /** 名保留兼容;定义 = cellBlockTypes() */
78
+ declare const CELL_BLOCK_TYPES: readonly string[];
79
+ type CellBlockType = string;
80
+ declare function isCellBlockType(type: string): boolean;
70
81
  declare const tableSchema: {
71
82
  marks: string[];
72
83
  nodes: {
@@ -81,12 +92,73 @@ declare const tableSchema: {
81
92
  content: string[];
82
93
  inline: boolean;
83
94
  };
95
+ list: {
96
+ content: string[];
97
+ };
98
+ list_item: {
99
+ content: string[];
100
+ };
101
+ quote: {
102
+ content: string[];
103
+ };
104
+ callout: {
105
+ content: string[];
106
+ };
107
+ code: {
108
+ content: string[];
109
+ inline: boolean;
110
+ marks: never[];
111
+ };
112
+ image: {
113
+ content: never[];
114
+ atom: boolean;
115
+ };
116
+ embed: {
117
+ content: never[];
118
+ atom: boolean;
119
+ };
120
+ raw: {
121
+ content: string[];
122
+ inline: boolean;
123
+ marks: never[];
124
+ };
84
125
  };
85
126
  };
86
127
 
87
- declare function mdToDoc(md: string): ElementNode;
128
+ /**
129
+ * 公式怎么写进 Markdown。
130
+ * - `'html'`(默认):`<span data-math data-latex=…>$x$</span>`,`$x$` 不当公式读(README 里的 `$HOME/$USER` 还是字)。
131
+ * - `'dollar'`:读写 `$x$`、`$$x$$`(pandoc 的规则,见 md-math.ts),Typora、Obsidian、GitHub 都读得懂。
132
+ * 旧的 span 照读;没改过的块逐字节不变,改过的块里的公式写成 `$`;写不成 `$` 的(公式里有空行、开头是空格)仍写 span。
133
+ * 这是这个页面的文件格式,不是某一个编辑器的:在打开任何文档之前设一次。
134
+ */
135
+ declare function setMathSyntax(syntax: 'html' | 'dollar'): void;
136
+ interface MdToDocAsyncOptions {
137
+ chunkBytes?: number;
138
+ /** 每一片最多占主线程这么久(毫秒,默认 6)。片与片之间把线程还给浏览器,输入、滚动、绘制不被 3 秒的解析冻住。 */
139
+ budgetMs?: number;
140
+ /** 解出至少这么多个块后,调用一次 onHead,给一份「文档开头」的预览树(默认 200 块,约一屏多)。 */
141
+ headBlocks?: number;
142
+ /**
143
+ * 开头预览。**只能看,不能编辑、不能存盘**:它只是整篇的前缀,结尾处的 callout 若还没等到 `</div>` 会按普通块降级,
144
+ * 且它没有后面的块——拿它当文档存回去就丢了全文。真正的文档是 promise 的结果。
145
+ * 预览的块 id 与最终文档里同位置的块相同(都是 b0、b1…),所以换成完整文档时块能原地对上。
146
+ */
147
+ onHead?: (head: ElementNode) => void;
148
+ signal?: AbortSignal;
149
+ }
150
+ /**
151
+ * mdToDoc 的非阻塞版:同一份解析代码(生成器),每解完一块看一眼用掉了多少时间,超了预算就把主线程还出去再继续。
152
+ * 结果与 mdToDoc(md) 逐字节相同(同一个生成器,只是中间多了让出)。总耗时比同步版略长(让出的间隙),但没有一次超过预算的阻塞。
153
+ * 块的粒度见 md-chunk.ts:单块一般 1–3 ms,个别切不开的大表/大代码块更长,那一块里没法再让。
154
+ */
155
+ declare function mdToDocAsync(md: string, opts?: MdToDocAsyncOptions): Promise<ElementNode>;
156
+ declare function mdToDoc(md: string, chunkBytes?: number): ElementNode;
88
157
  declare function htmlToBlocks(html: string): ElementNode[] | null;
89
158
  declare function isRichHtmlBlocks(blocks: ElementNode[]): boolean;
159
+ declare function isPlainTransportHtml(blocks: ElementNode[]): boolean;
160
+ declare function mdStructureBeatsTransport(plain: string): boolean;
161
+ declare function preferMarkdownPaste(plain: string, htmlBlocks: ElementNode[]): boolean;
90
162
  declare function embedHtml(n: ElementNode): string;
91
163
  declare function tableHasExtras(n: ElementNode): boolean;
92
164
  declare function tableToHtml(n: ElementNode): string;
@@ -101,6 +173,12 @@ interface Resolved {
101
173
  }
102
174
  declare function resolve(doc: ElementNode, path: Path): Resolved;
103
175
  declare function firstLeafPath(block: ElementNode): Path;
176
+ /**
177
+ * 元素内 child 缝 at → 最近可落文本叶。
178
+ * 空 atom(image/embed/hard_break/math)从缝上跳过,吸到后侧文本首;
179
+ * mention 不跳,归前叶尾。再无文本才扫另一侧。
180
+ */
181
+ declare function gapToTextPath(parent: ElementNode, at: number, prefix?: Path): Path;
104
182
  declare function normalizeToLeaf(doc: ElementNode, path: Path): Path;
105
183
  declare function lastLeafEnd(block: ElementNode): Path;
106
184
  declare function nodeAt(doc: ElementNode, path: Path): Node;
@@ -162,8 +240,34 @@ declare function mapSelection(step: Step, sel: {
162
240
  anchor: Position;
163
241
  head: Position;
164
242
  };
243
+ declare function mapSelectionThrough<S extends {
244
+ anchor: Position;
245
+ head: Position;
246
+ }>(sel: S | null | undefined, steps: readonly Step[]): S | undefined;
247
+ declare function resolveTxAfter<S extends {
248
+ anchor: Position;
249
+ head: Position;
250
+ }>(before: S | null | undefined, after: S | null | undefined, steps: readonly Step[], gaps?: readonly Step[]): S | undefined;
165
251
  declare function normalizePosition(doc: ElementNode, pos: Position): Position;
166
252
 
253
+ /**
254
+ * Content spaces — composable finite block sets (runtime + domain share).
255
+ *
256
+ * bodyBlocks = doc.content
257
+ * cellBlocks = bodyBlocks − { heading, table, ai }
258
+ *
259
+ * Definition is set algebra, not a second hand-written list.
260
+ */
261
+
262
+ /** Types in body but not admitted as table-cell children. */
263
+ declare const CELL_EXCLUDED_FROM_BODY: readonly ["heading", "table"];
264
+ /** Top-level block types under doc (paste/transform palette). */
265
+ declare function bodyBlockTypes(schema?: Schema): readonly string[];
266
+ /** Table-cell admit set = body − CELL_EXCLUDED_FROM_BODY. */
267
+ declare function cellBlockTypes(schema?: Schema): readonly string[];
268
+ declare function isBodyBlockType(type: string, schema?: Schema): boolean;
269
+ declare function isCellBlockTypeInSpace(type: string, schema?: Schema): boolean;
270
+
167
271
  interface DocStats {
168
272
  chars: number;
169
273
  words: number;
@@ -171,6 +275,15 @@ interface DocStats {
171
275
  }
172
276
  declare function docStats(doc: ElementNode): DocStats;
173
277
 
278
+ declare const FRONT_MATTER = "frontmatter";
279
+ declare function isFrontMatter(n: Node | null | undefined): boolean;
280
+ /**
281
+ * md 开头是 front matter 时,返回闭合栅栏文字的结束偏移(不含其后的空白和换行);不是则 -1。
282
+ * 判据:首行只有 `---`(行尾空白不算);往下第一条只有 `---` / `...` 的行闭合;两条栅栏之间至少有一行非空白
283
+ * (`---\n---` 是两条分隔线,不是空的 front matter)。CRLF 照常认。
284
+ */
285
+ declare function frontMatterEnd(md: string): number;
286
+
174
287
  interface TocEntry {
175
288
  level: number;
176
289
  text: string;
@@ -179,4 +292,23 @@ interface TocEntry {
179
292
  }
180
293
  declare function outline(doc: ElementNode): TocEntry[];
181
294
 
182
- export { 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, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
295
+ declare function markIdsInDoc(doc: ElementNode, name: string): Set<string>;
296
+ declare function mapLeafBlocks(doc: ElementNode, fn: (node: ElementNode, path: Path) => ElementNode | null): Step[];
297
+ declare function stripMarks(doc: ElementNode, pred: (m: Mark) => boolean): Step[];
298
+ declare function dropMarkedLeaves(doc: ElementNode, pred: (leaf: TextNode) => boolean): Step[];
299
+
300
+ interface FootnoteIndex {
301
+ /** 引用首次出现的顺序(规范化键);编号 = 下标 + 1。 */
302
+ order: string[];
303
+ /** 键 → 定义块(同一键多个定义时取第一个,同 CommonMark 引用定义)。 */
304
+ defs: Map<string, ElementNode>;
305
+ /** 键 → 引用次数。 */
306
+ refs: Map<string, number>;
307
+ }
308
+ declare function footnoteIndex(doc: ElementNode): FootnoteIndex;
309
+ /** 一个块的纯文本(块间换行),悬停卡显示用。 */
310
+ declare function footnoteText(def: ElementNode): string;
311
+ /** 文档里有没有任何脚注(引用或定义):没有就不必为编号付任何代价。 */
312
+ declare function hasFootnotes(doc: ElementNode): boolean;
313
+
314
+ export { CELL_BLOCK_TYPES, CELL_EXCLUDED_FROM_BODY, type CellBlockType, DEFAULT_COL_WIDTH, type DocStats, ElementNode, FRONT_MATTER, type FootnoteIndex, type Grid, type IdIndex, Mark, type MdToDocAsyncOptions, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, TextNode, type TocEntry, type Violation, appendText, arrowCell, basicSchema, bodyBlockTypes, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellBlockTypes, cellCaret, cellRectTable, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, dropMarkedLeaves, embedHtml, firstLeafPath, firstViolation, footnoteIndex, footnoteText, frontMatterEnd, gapToTextPath, hasFootnotes, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isBodyBlockType, isCellBlockType, isCellBlockTypeInSpace, isFrontMatter, isLastCell, isPlainTransportHtml, isRichHtmlBlocks, lastLeafEnd, makeTable, mapLeafBlocks, mapPosition, mapSelection, mapSelectionThrough, markIdsInDoc, mdStructureBeatsTransport, mdToDoc, mdToDocAsync, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, preferMarkdownPaste, replaceAt, resolve, resolveTxAfter, resolvedColWidths, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, setHeaderCol, setMathSyntax, spliceAt, splitCell, stripMarks, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './step-BrvHIK7O.js';
2
- export { D as DeleteText, b as Doc, I as InsertText, M as Mark, R as ReplaceNode, c as Selection, d as SpliceChildren, T as TextNode, e as apply, f as applyAll, i as invert, g as invertAll, h as isElement, j as isInlineAtom, k as isText, m as moveBlock } from './step-BrvHIK7O.js';
3
- export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, e as amend, f as commentIdsInDoc, g as commit, i as init, r as redo, s as stripCommentMarks, u as undo } from './comments-PhnR7Gkn.js';
4
- export { B as Bias, m as makeBias, c as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-8rL_aXEE.js';
1
+ import { S as Step } from './versions-DOkOyh2J.js';
2
+ export { D as DeleteText, a as DocVersion, I as InsertText, R as ReplaceNode, b as SpliceChildren, c as apply, d as applyAll, g as getVersion, i as invert, e as invertAll, m as moveBlock, p as pushVersion, r as removeVersion, s as snapshotDoc } from './versions-DOkOyh2J.js';
3
+ import { E as ElementNode, P as Path, N as Node, a as Position, T as TextNode, M as Mark } from './types-BkHlmUFL.js';
4
+ export { D as Doc, S as Selection, f as footnoteKey, i as isAiCompose, b as isCallout, c as isElement, d as isFootnoteDef, e as isInlineAtom, g as isText } from './types-BkHlmUFL.js';
5
+ export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, S as SearchOpts, e as SuggestAuthor, f as SuggestHit, g as SuggestKind, T as TextMatch, W as WordCount, h as acceptSuggestion, i as amend, j as applyForeign, k as applyReplaceAll, l as commentIdsInDoc, m as commit, n as dropSuggestText, o as findText, p as init, q as isSuggestMark, r as listSuggestions, s as markSuggestRange, t as rangeForDelete, u as rangeIsSuggestInsert, v as redo, w as rejectSuggestion, x as replaceAll, y as replaceMatch, z as stripCommentMarks, A as stripSuggestMarks, B as suggestIdsInDoc, D as suggestMark, E as undo, F as wordCount } from './word-count-BPw9G2Bg.js';
6
+ export { B as Bias, m as makeBias, d as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-CSnv8FKp.js';
5
7
 
6
8
  interface TableShape {
7
9
  rows: number;
@@ -28,12 +30,14 @@ declare function caretCell(tablePath: Path, table: ElementNode, caret: Path): {
28
30
  r: number;
29
31
  c: number;
30
32
  } | null;
33
+ declare const DEFAULT_COL_WIDTH = 120;
31
34
  declare function makeTable(id: string, rows: number, cols: number): ElementNode;
32
35
  declare function cellText(table: ElementNode, r: number, c: number): string;
33
36
  declare function nextCell(table: ElementNode, r: number, c: number, dir: 1 | -1): {
34
37
  r: number;
35
38
  c: number;
36
39
  };
40
+ declare function isLastCell(table: ElementNode, r: number, c: number): boolean;
37
41
  declare function arrowCell(table: ElementNode, r: number, c: number, dir: 'up' | 'down' | 'left' | 'right'): {
38
42
  r: number;
39
43
  c: number;
@@ -45,7 +49,9 @@ declare function deleteCol(table: ElementNode, tablePath: Path, c: number, doc?:
45
49
  declare function hasSpan(table: ElementNode): boolean;
46
50
  declare function moveRow(table: ElementNode, tablePath: Path, from: number, to: number): Step;
47
51
  declare function moveCol(table: ElementNode, tablePath: Path, from: number, to: number): Step;
52
+ declare function cellRectTable(table: ElementNode, r1: number, c1: number, r2: number, c2: number): ElementNode;
48
53
  declare function tableColWidths(table: ElementNode): number[] | null;
54
+ declare function resolvedColWidths(table: ElementNode): number[];
49
55
  declare function setColWidths(table: ElementNode, tablePath: Path, widths: number[]): Step;
50
56
  declare function setAlign(table: ElementNode, tablePath: Path, col: number, value: 'left' | 'center' | 'right' | null): Step;
51
57
  declare function mergeCells(table: ElementNode, tablePath: Path, r1: number, c1: number, r2: number, c2: number): Step;
@@ -64,9 +70,14 @@ declare function setFreeze(table: ElementNode, tablePath: Path, freeze: {
64
70
  rows?: number;
65
71
  cols?: number;
66
72
  }): Step;
73
+ declare function setHeaderCol(table: ElementNode, tablePath: Path, on: boolean): Step;
67
74
  declare function deleteTableBlock(tablePath: Path, doc?: ElementNode): Step;
68
75
  declare function tableAt(doc: ElementNode, tablePath: Path): ElementNode | null;
69
76
  declare function checkTable(table: ElementNode): string[];
77
+ /** 名保留兼容;定义 = cellBlockTypes() */
78
+ declare const CELL_BLOCK_TYPES: readonly string[];
79
+ type CellBlockType = string;
80
+ declare function isCellBlockType(type: string): boolean;
70
81
  declare const tableSchema: {
71
82
  marks: string[];
72
83
  nodes: {
@@ -81,12 +92,73 @@ declare const tableSchema: {
81
92
  content: string[];
82
93
  inline: boolean;
83
94
  };
95
+ list: {
96
+ content: string[];
97
+ };
98
+ list_item: {
99
+ content: string[];
100
+ };
101
+ quote: {
102
+ content: string[];
103
+ };
104
+ callout: {
105
+ content: string[];
106
+ };
107
+ code: {
108
+ content: string[];
109
+ inline: boolean;
110
+ marks: never[];
111
+ };
112
+ image: {
113
+ content: never[];
114
+ atom: boolean;
115
+ };
116
+ embed: {
117
+ content: never[];
118
+ atom: boolean;
119
+ };
120
+ raw: {
121
+ content: string[];
122
+ inline: boolean;
123
+ marks: never[];
124
+ };
84
125
  };
85
126
  };
86
127
 
87
- declare function mdToDoc(md: string): ElementNode;
128
+ /**
129
+ * 公式怎么写进 Markdown。
130
+ * - `'html'`(默认):`<span data-math data-latex=…>$x$</span>`,`$x$` 不当公式读(README 里的 `$HOME/$USER` 还是字)。
131
+ * - `'dollar'`:读写 `$x$`、`$$x$$`(pandoc 的规则,见 md-math.ts),Typora、Obsidian、GitHub 都读得懂。
132
+ * 旧的 span 照读;没改过的块逐字节不变,改过的块里的公式写成 `$`;写不成 `$` 的(公式里有空行、开头是空格)仍写 span。
133
+ * 这是这个页面的文件格式,不是某一个编辑器的:在打开任何文档之前设一次。
134
+ */
135
+ declare function setMathSyntax(syntax: 'html' | 'dollar'): void;
136
+ interface MdToDocAsyncOptions {
137
+ chunkBytes?: number;
138
+ /** 每一片最多占主线程这么久(毫秒,默认 6)。片与片之间把线程还给浏览器,输入、滚动、绘制不被 3 秒的解析冻住。 */
139
+ budgetMs?: number;
140
+ /** 解出至少这么多个块后,调用一次 onHead,给一份「文档开头」的预览树(默认 200 块,约一屏多)。 */
141
+ headBlocks?: number;
142
+ /**
143
+ * 开头预览。**只能看,不能编辑、不能存盘**:它只是整篇的前缀,结尾处的 callout 若还没等到 `</div>` 会按普通块降级,
144
+ * 且它没有后面的块——拿它当文档存回去就丢了全文。真正的文档是 promise 的结果。
145
+ * 预览的块 id 与最终文档里同位置的块相同(都是 b0、b1…),所以换成完整文档时块能原地对上。
146
+ */
147
+ onHead?: (head: ElementNode) => void;
148
+ signal?: AbortSignal;
149
+ }
150
+ /**
151
+ * mdToDoc 的非阻塞版:同一份解析代码(生成器),每解完一块看一眼用掉了多少时间,超了预算就把主线程还出去再继续。
152
+ * 结果与 mdToDoc(md) 逐字节相同(同一个生成器,只是中间多了让出)。总耗时比同步版略长(让出的间隙),但没有一次超过预算的阻塞。
153
+ * 块的粒度见 md-chunk.ts:单块一般 1–3 ms,个别切不开的大表/大代码块更长,那一块里没法再让。
154
+ */
155
+ declare function mdToDocAsync(md: string, opts?: MdToDocAsyncOptions): Promise<ElementNode>;
156
+ declare function mdToDoc(md: string, chunkBytes?: number): ElementNode;
88
157
  declare function htmlToBlocks(html: string): ElementNode[] | null;
89
158
  declare function isRichHtmlBlocks(blocks: ElementNode[]): boolean;
159
+ declare function isPlainTransportHtml(blocks: ElementNode[]): boolean;
160
+ declare function mdStructureBeatsTransport(plain: string): boolean;
161
+ declare function preferMarkdownPaste(plain: string, htmlBlocks: ElementNode[]): boolean;
90
162
  declare function embedHtml(n: ElementNode): string;
91
163
  declare function tableHasExtras(n: ElementNode): boolean;
92
164
  declare function tableToHtml(n: ElementNode): string;
@@ -101,6 +173,12 @@ interface Resolved {
101
173
  }
102
174
  declare function resolve(doc: ElementNode, path: Path): Resolved;
103
175
  declare function firstLeafPath(block: ElementNode): Path;
176
+ /**
177
+ * 元素内 child 缝 at → 最近可落文本叶。
178
+ * 空 atom(image/embed/hard_break/math)从缝上跳过,吸到后侧文本首;
179
+ * mention 不跳,归前叶尾。再无文本才扫另一侧。
180
+ */
181
+ declare function gapToTextPath(parent: ElementNode, at: number, prefix?: Path): Path;
104
182
  declare function normalizeToLeaf(doc: ElementNode, path: Path): Path;
105
183
  declare function lastLeafEnd(block: ElementNode): Path;
106
184
  declare function nodeAt(doc: ElementNode, path: Path): Node;
@@ -162,8 +240,34 @@ declare function mapSelection(step: Step, sel: {
162
240
  anchor: Position;
163
241
  head: Position;
164
242
  };
243
+ declare function mapSelectionThrough<S extends {
244
+ anchor: Position;
245
+ head: Position;
246
+ }>(sel: S | null | undefined, steps: readonly Step[]): S | undefined;
247
+ declare function resolveTxAfter<S extends {
248
+ anchor: Position;
249
+ head: Position;
250
+ }>(before: S | null | undefined, after: S | null | undefined, steps: readonly Step[], gaps?: readonly Step[]): S | undefined;
165
251
  declare function normalizePosition(doc: ElementNode, pos: Position): Position;
166
252
 
253
+ /**
254
+ * Content spaces — composable finite block sets (runtime + domain share).
255
+ *
256
+ * bodyBlocks = doc.content
257
+ * cellBlocks = bodyBlocks − { heading, table, ai }
258
+ *
259
+ * Definition is set algebra, not a second hand-written list.
260
+ */
261
+
262
+ /** Types in body but not admitted as table-cell children. */
263
+ declare const CELL_EXCLUDED_FROM_BODY: readonly ["heading", "table"];
264
+ /** Top-level block types under doc (paste/transform palette). */
265
+ declare function bodyBlockTypes(schema?: Schema): readonly string[];
266
+ /** Table-cell admit set = body − CELL_EXCLUDED_FROM_BODY. */
267
+ declare function cellBlockTypes(schema?: Schema): readonly string[];
268
+ declare function isBodyBlockType(type: string, schema?: Schema): boolean;
269
+ declare function isCellBlockTypeInSpace(type: string, schema?: Schema): boolean;
270
+
167
271
  interface DocStats {
168
272
  chars: number;
169
273
  words: number;
@@ -171,6 +275,15 @@ interface DocStats {
171
275
  }
172
276
  declare function docStats(doc: ElementNode): DocStats;
173
277
 
278
+ declare const FRONT_MATTER = "frontmatter";
279
+ declare function isFrontMatter(n: Node | null | undefined): boolean;
280
+ /**
281
+ * md 开头是 front matter 时,返回闭合栅栏文字的结束偏移(不含其后的空白和换行);不是则 -1。
282
+ * 判据:首行只有 `---`(行尾空白不算);往下第一条只有 `---` / `...` 的行闭合;两条栅栏之间至少有一行非空白
283
+ * (`---\n---` 是两条分隔线,不是空的 front matter)。CRLF 照常认。
284
+ */
285
+ declare function frontMatterEnd(md: string): number;
286
+
174
287
  interface TocEntry {
175
288
  level: number;
176
289
  text: string;
@@ -179,4 +292,23 @@ interface TocEntry {
179
292
  }
180
293
  declare function outline(doc: ElementNode): TocEntry[];
181
294
 
182
- export { 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, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
295
+ declare function markIdsInDoc(doc: ElementNode, name: string): Set<string>;
296
+ declare function mapLeafBlocks(doc: ElementNode, fn: (node: ElementNode, path: Path) => ElementNode | null): Step[];
297
+ declare function stripMarks(doc: ElementNode, pred: (m: Mark) => boolean): Step[];
298
+ declare function dropMarkedLeaves(doc: ElementNode, pred: (leaf: TextNode) => boolean): Step[];
299
+
300
+ interface FootnoteIndex {
301
+ /** 引用首次出现的顺序(规范化键);编号 = 下标 + 1。 */
302
+ order: string[];
303
+ /** 键 → 定义块(同一键多个定义时取第一个,同 CommonMark 引用定义)。 */
304
+ defs: Map<string, ElementNode>;
305
+ /** 键 → 引用次数。 */
306
+ refs: Map<string, number>;
307
+ }
308
+ declare function footnoteIndex(doc: ElementNode): FootnoteIndex;
309
+ /** 一个块的纯文本(块间换行),悬停卡显示用。 */
310
+ declare function footnoteText(def: ElementNode): string;
311
+ /** 文档里有没有任何脚注(引用或定义):没有就不必为编号付任何代价。 */
312
+ declare function hasFootnotes(doc: ElementNode): boolean;
313
+
314
+ export { CELL_BLOCK_TYPES, CELL_EXCLUDED_FROM_BODY, type CellBlockType, DEFAULT_COL_WIDTH, type DocStats, ElementNode, FRONT_MATTER, type FootnoteIndex, type Grid, type IdIndex, Mark, type MdToDocAsyncOptions, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, TextNode, type TocEntry, type Violation, appendText, arrowCell, basicSchema, bodyBlockTypes, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellBlockTypes, cellCaret, cellRectTable, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, dropMarkedLeaves, embedHtml, firstLeafPath, firstViolation, footnoteIndex, footnoteText, frontMatterEnd, gapToTextPath, hasFootnotes, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isBodyBlockType, isCellBlockType, isCellBlockTypeInSpace, isFrontMatter, isLastCell, isPlainTransportHtml, isRichHtmlBlocks, lastLeafEnd, makeTable, mapLeafBlocks, mapPosition, mapSelection, mapSelectionThrough, markIdsInDoc, mdStructureBeatsTransport, mdToDoc, mdToDocAsync, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, preferMarkdownPaste, replaceAt, resolve, resolveTxAfter, resolvedColWidths, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, setHeaderCol, setMathSyntax, spliceAt, splitCell, stripMarks, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };