@dou-ui/editor 0.0.0-stage → 0.1.0-alpha.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 (324) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -2
  3. package/dist/catalog.js +18 -0
  4. package/dist/catalog.js.map +1 -0
  5. package/dist/code/code-editor-block.js +6 -0
  6. package/dist/code/code-editor-block.js.map +1 -0
  7. package/dist/code/code-editor-block.vue_vue_type_script_setup_true_lang.js +116 -0
  8. package/dist/code/code-editor-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  9. package/dist/code/index.js +69 -0
  10. package/dist/code/index.js.map +1 -0
  11. package/dist/code/languages.js +51 -0
  12. package/dist/code/languages.js.map +1 -0
  13. package/dist/code/view.js +255 -0
  14. package/dist/code/view.js.map +1 -0
  15. package/dist/collaboration/binding.js +381 -0
  16. package/dist/collaboration/binding.js.map +1 -0
  17. package/dist/collaboration/cursors.js +150 -0
  18. package/dist/collaboration/cursors.js.map +1 -0
  19. package/dist/collaboration/index.js +108 -0
  20. package/dist/collaboration/index.js.map +1 -0
  21. package/dist/collaboration/order.js +88 -0
  22. package/dist/collaboration/order.js.map +1 -0
  23. package/dist/collaboration/table.js +234 -0
  24. package/dist/collaboration/table.js.map +1 -0
  25. package/dist/collaboration/text.js +91 -0
  26. package/dist/collaboration/text.js.map +1 -0
  27. package/dist/components/block-handle.js +6 -0
  28. package/dist/components/block-handle.js.map +1 -0
  29. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +474 -0
  30. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -0
  31. package/dist/components/bubble-toolbar.js +6 -0
  32. package/dist/components/bubble-toolbar.js.map +1 -0
  33. package/dist/components/bubble-toolbar.vue_vue_type_script_setup_true_lang.js +381 -0
  34. package/dist/components/bubble-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  35. package/dist/components/comment-button.js +6 -0
  36. package/dist/components/comment-button.js.map +1 -0
  37. package/dist/components/comment-button.vue_vue_type_script_setup_true_lang.js +83 -0
  38. package/dist/components/comment-button.vue_vue_type_script_setup_true_lang.js.map +1 -0
  39. package/dist/components/comment-card.js +6 -0
  40. package/dist/components/comment-card.js.map +1 -0
  41. package/dist/components/comment-card.vue_vue_type_script_setup_true_lang.js +104 -0
  42. package/dist/components/comment-card.vue_vue_type_script_setup_true_lang.js.map +1 -0
  43. package/dist/components/menu-escape.js +25 -0
  44. package/dist/components/menu-escape.js.map +1 -0
  45. package/dist/components/search-bar.js +6 -0
  46. package/dist/components/search-bar.js.map +1 -0
  47. package/dist/components/search-bar.vue_vue_type_script_setup_true_lang.js +192 -0
  48. package/dist/components/search-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  49. package/dist/components/slash-menu.js +6 -0
  50. package/dist/components/slash-menu.js.map +1 -0
  51. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +164 -0
  52. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  53. package/dist/core/align.js +94 -0
  54. package/dist/core/align.js.map +1 -0
  55. package/dist/core/block-selection.js +155 -0
  56. package/dist/core/block-selection.js.map +1 -0
  57. package/dist/core/blocks.js +132 -0
  58. package/dist/core/blocks.js.map +1 -0
  59. package/dist/core/changes.js +85 -0
  60. package/dist/core/changes.js.map +1 -0
  61. package/dist/core/colors.js +16 -0
  62. package/dist/core/colors.js.map +1 -0
  63. package/dist/core/commands.js +379 -0
  64. package/dist/core/commands.js.map +1 -0
  65. package/dist/core/comments.js +186 -0
  66. package/dist/core/comments.js.map +1 -0
  67. package/dist/core/compare.js +106 -0
  68. package/dist/core/compare.js.map +1 -0
  69. package/dist/core/convert.js +28 -0
  70. package/dist/core/convert.js.map +1 -0
  71. package/dist/core/diff.js +141 -0
  72. package/dist/core/diff.js.map +1 -0
  73. package/dist/core/editor.js +138 -0
  74. package/dist/core/editor.js.map +1 -0
  75. package/dist/core/extension.js +99 -0
  76. package/dist/core/extension.js.map +1 -0
  77. package/dist/core/file-drop.js +56 -0
  78. package/dist/core/file-drop.js.map +1 -0
  79. package/dist/core/highlight.js +120 -0
  80. package/dist/core/highlight.js.map +1 -0
  81. package/dist/core/input-rules.js +61 -0
  82. package/dist/core/input-rules.js.map +1 -0
  83. package/dist/core/keymap.js +38 -0
  84. package/dist/core/keymap.js.map +1 -0
  85. package/dist/core/model.js +196 -0
  86. package/dist/core/model.js.map +1 -0
  87. package/dist/core/output.js +263 -0
  88. package/dist/core/output.js.map +1 -0
  89. package/dist/core/plugins.js +102 -0
  90. package/dist/core/plugins.js.map +1 -0
  91. package/dist/core/prepare.js +102 -0
  92. package/dist/core/prepare.js.map +1 -0
  93. package/dist/core/schema.js +158 -0
  94. package/dist/core/schema.js.map +1 -0
  95. package/dist/core/search.js +197 -0
  96. package/dist/core/search.js.map +1 -0
  97. package/dist/core/selection.js +16 -0
  98. package/dist/core/selection.js.map +1 -0
  99. package/dist/core/slash.js +83 -0
  100. package/dist/core/slash.js.map +1 -0
  101. package/dist/core/transaction.js +311 -0
  102. package/dist/core/transaction.js.map +1 -0
  103. package/dist/define-block.js +177 -0
  104. package/dist/define-block.js.map +1 -0
  105. package/dist/document.js +157 -0
  106. package/dist/document.js.map +1 -0
  107. package/dist/dom.js +48 -0
  108. package/dist/dom.js.map +1 -0
  109. package/dist/editor.js +33 -0
  110. package/dist/editor.js.map +1 -0
  111. package/dist/editor.vue_vue_type_script_setup_true_lang.js +564 -0
  112. package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -0
  113. package/dist/editor2.js +6 -0
  114. package/dist/editor2.js.map +1 -0
  115. package/dist/extensions/align/align-menu.js +6 -0
  116. package/dist/extensions/align/align-menu.js.map +1 -0
  117. package/dist/extensions/align/align-menu.vue_vue_type_script_setup_true_lang.js +82 -0
  118. package/dist/extensions/align/align-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  119. package/dist/extensions/align/align-sub.js +6 -0
  120. package/dist/extensions/align/align-sub.js.map +1 -0
  121. package/dist/extensions/align/align-sub.vue_vue_type_script_setup_true_lang.js +57 -0
  122. package/dist/extensions/align/align-sub.vue_vue_type_script_setup_true_lang.js.map +1 -0
  123. package/dist/extensions/align/commands.js +40 -0
  124. package/dist/extensions/align/commands.js.map +1 -0
  125. package/dist/extensions/align/index.js +27 -0
  126. package/dist/extensions/align/index.js.map +1 -0
  127. package/dist/extensions/attachment/attachment-block.js +6 -0
  128. package/dist/extensions/attachment/attachment-block.js.map +1 -0
  129. package/dist/extensions/attachment/attachment-block.vue_vue_type_script_setup_true_lang.js +119 -0
  130. package/dist/extensions/attachment/attachment-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  131. package/dist/extensions/attachment/files.js +66 -0
  132. package/dist/extensions/attachment/files.js.map +1 -0
  133. package/dist/extensions/attachment/index.js +132 -0
  134. package/dist/extensions/attachment/index.js.map +1 -0
  135. package/dist/extensions/blocks.js +170 -0
  136. package/dist/extensions/blocks.js.map +1 -0
  137. package/dist/extensions/callout/callout-block.js +6 -0
  138. package/dist/extensions/callout/callout-block.js.map +1 -0
  139. package/dist/extensions/callout/callout-block.vue_vue_type_script_setup_true_lang.js +71 -0
  140. package/dist/extensions/callout/callout-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  141. package/dist/extensions/callout/html.js +61 -0
  142. package/dist/extensions/callout/html.js.map +1 -0
  143. package/dist/extensions/callout/index.js +52 -0
  144. package/dist/extensions/callout/index.js.map +1 -0
  145. package/dist/extensions/callout/tones.js +12 -0
  146. package/dist/extensions/callout/tones.js.map +1 -0
  147. package/dist/extensions/code-block/code-block-view.js +6 -0
  148. package/dist/extensions/code-block/code-block-view.js.map +1 -0
  149. package/dist/extensions/code-block/code-block-view.vue_vue_type_script_setup_true_lang.js +87 -0
  150. package/dist/extensions/code-block/code-block-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
  151. package/dist/extensions/code-block/index.js +98 -0
  152. package/dist/extensions/code-block/index.js.map +1 -0
  153. package/dist/extensions/code-block/languages.js +116 -0
  154. package/dist/extensions/code-block/languages.js.map +1 -0
  155. package/dist/extensions/colors/color-menu.js +6 -0
  156. package/dist/extensions/colors/color-menu.js.map +1 -0
  157. package/dist/extensions/colors/color-menu.vue_vue_type_script_setup_true_lang.js +113 -0
  158. package/dist/extensions/colors/color-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  159. package/dist/extensions/colors/index.js +49 -0
  160. package/dist/extensions/colors/index.js.map +1 -0
  161. package/dist/extensions/colors/palette.js +26 -0
  162. package/dist/extensions/colors/palette.js.map +1 -0
  163. package/dist/extensions/editor-kit.js +35 -0
  164. package/dist/extensions/editor-kit.js.map +1 -0
  165. package/dist/extensions/embed/embed-block.js +6 -0
  166. package/dist/extensions/embed/embed-block.js.map +1 -0
  167. package/dist/extensions/embed/embed-block.vue_vue_type_script_setup_true_lang.js +210 -0
  168. package/dist/extensions/embed/embed-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  169. package/dist/extensions/embed/index.js +118 -0
  170. package/dist/extensions/embed/index.js.map +1 -0
  171. package/dist/extensions/embed/targets.js +79 -0
  172. package/dist/extensions/embed/targets.js.map +1 -0
  173. package/dist/extensions/formatting.js +153 -0
  174. package/dist/extensions/formatting.js.map +1 -0
  175. package/dist/extensions/image/image-block.js +6 -0
  176. package/dist/extensions/image/image-block.js.map +1 -0
  177. package/dist/extensions/image/image-block.vue_vue_type_script_setup_true_lang.js +206 -0
  178. package/dist/extensions/image/image-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  179. package/dist/extensions/image/index.js +125 -0
  180. package/dist/extensions/image/index.js.map +1 -0
  181. package/dist/extensions/image/uploads.js +96 -0
  182. package/dist/extensions/image/uploads.js.map +1 -0
  183. package/dist/extensions/list-html.js +58 -0
  184. package/dist/extensions/list-html.js.map +1 -0
  185. package/dist/extensions/lists.js +182 -0
  186. package/dist/extensions/lists.js.map +1 -0
  187. package/dist/extensions/mention/index.js +56 -0
  188. package/dist/extensions/mention/index.js.map +1 -0
  189. package/dist/extensions/mention/mention-menu.js +6 -0
  190. package/dist/extensions/mention/mention-menu.js.map +1 -0
  191. package/dist/extensions/mention/mention-menu.vue_vue_type_script_setup_true_lang.js +132 -0
  192. package/dist/extensions/mention/mention-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  193. package/dist/extensions/mention/state.js +113 -0
  194. package/dist/extensions/mention/state.js.map +1 -0
  195. package/dist/extensions/table/commands.js +356 -0
  196. package/dist/extensions/table/commands.js.map +1 -0
  197. package/dist/extensions/table/html.js +134 -0
  198. package/dist/extensions/table/html.js.map +1 -0
  199. package/dist/extensions/table/index.js +56 -0
  200. package/dist/extensions/table/index.js.map +1 -0
  201. package/dist/extensions/table/plugin.js +81 -0
  202. package/dist/extensions/table/plugin.js.map +1 -0
  203. package/dist/extensions/table/schema.js +258 -0
  204. package/dist/extensions/table/schema.js.map +1 -0
  205. package/dist/extensions/table/table-controls.js +6 -0
  206. package/dist/extensions/table/table-controls.js.map +1 -0
  207. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +698 -0
  208. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
  209. package/dist/extensions/table/view.js +19 -0
  210. package/dist/extensions/table/view.js.map +1 -0
  211. package/dist/extensions/toggle/index.js +87 -0
  212. package/dist/extensions/toggle/index.js.map +1 -0
  213. package/dist/extensions/toggle/state.js +120 -0
  214. package/dist/extensions/toggle/state.js.map +1 -0
  215. package/dist/extensions/toggle/toggle-block.js +6 -0
  216. package/dist/extensions/toggle/toggle-block.js.map +1 -0
  217. package/dist/extensions/toggle/toggle-block.vue_vue_type_script_setup_true_lang.js +42 -0
  218. package/dist/extensions/toggle/toggle-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  219. package/dist/index.js +49 -0
  220. package/dist/index.js.map +1 -0
  221. package/dist/locale.js +522 -0
  222. package/dist/locale.js.map +1 -0
  223. package/dist/markdown/index.js +24 -0
  224. package/dist/markdown/index.js.map +1 -0
  225. package/dist/style.css +1 -0
  226. package/dist/style.d.ts +1 -0
  227. package/dist/style.js +8 -0
  228. package/dist/types/catalog.d.ts +8 -0
  229. package/dist/types/code/code-editor-block.vue.d.ts +17 -0
  230. package/dist/types/code/index.d.ts +18 -0
  231. package/dist/types/code/languages.d.ts +7 -0
  232. package/dist/types/code/types.d.ts +37 -0
  233. package/dist/types/code/view.d.ts +12 -0
  234. package/dist/types/collaboration/binding.d.ts +32 -0
  235. package/dist/types/collaboration/cursors.d.ts +26 -0
  236. package/dist/types/collaboration/index.d.ts +47 -0
  237. package/dist/types/collaboration/order.d.ts +20 -0
  238. package/dist/types/collaboration/table.d.ts +25 -0
  239. package/dist/types/collaboration/text.d.ts +9 -0
  240. package/dist/types/components/block-handle.vue.d.ts +3 -0
  241. package/dist/types/components/bubble-toolbar.vue.d.ts +7 -0
  242. package/dist/types/components/comment-button.vue.d.ts +3 -0
  243. package/dist/types/components/comment-card.vue.d.ts +3 -0
  244. package/dist/types/components/menu-escape.d.ts +7 -0
  245. package/dist/types/components/search-bar.vue.d.ts +22 -0
  246. package/dist/types/components/slash-menu.vue.d.ts +11 -0
  247. package/dist/types/core/align.d.ts +16 -0
  248. package/dist/types/core/block-selection.d.ts +22 -0
  249. package/dist/types/core/blocks.d.ts +52 -0
  250. package/dist/types/core/changes.d.ts +14 -0
  251. package/dist/types/core/colors.d.ts +4 -0
  252. package/dist/types/core/commands.d.ts +61 -0
  253. package/dist/types/core/comments.d.ts +44 -0
  254. package/dist/types/core/compare.d.ts +10 -0
  255. package/dist/types/core/convert.d.ts +12 -0
  256. package/dist/types/core/diff.d.ts +49 -0
  257. package/dist/types/core/editor.d.ts +64 -0
  258. package/dist/types/core/extension.d.ts +167 -0
  259. package/dist/types/core/file-drop.d.ts +19 -0
  260. package/dist/types/core/highlight.d.ts +32 -0
  261. package/dist/types/core/input-rules.d.ts +21 -0
  262. package/dist/types/core/keymap.d.ts +8 -0
  263. package/dist/types/core/model.d.ts +158 -0
  264. package/dist/types/core/output.d.ts +64 -0
  265. package/dist/types/core/plugins.d.ts +24 -0
  266. package/dist/types/core/prepare.d.ts +23 -0
  267. package/dist/types/core/schema.d.ts +38 -0
  268. package/dist/types/core/search.d.ts +83 -0
  269. package/dist/types/core/selection.d.ts +8 -0
  270. package/dist/types/core/slash.d.ts +21 -0
  271. package/dist/types/core/transaction.d.ts +97 -0
  272. package/dist/types/define-block.d.ts +66 -0
  273. package/dist/types/document.d.ts +46 -0
  274. package/dist/types/dom.d.ts +17 -0
  275. package/dist/types/editor.d.ts +252 -0
  276. package/dist/types/editor.vue.d.ts +210 -0
  277. package/dist/types/extensions/align/align-menu.vue.d.ts +3 -0
  278. package/dist/types/extensions/align/align-sub.vue.d.ts +7 -0
  279. package/dist/types/extensions/align/commands.d.ts +13 -0
  280. package/dist/types/extensions/align/index.d.ts +7 -0
  281. package/dist/types/extensions/attachment/attachment-block.vue.d.ts +17 -0
  282. package/dist/types/extensions/attachment/files.d.ts +6 -0
  283. package/dist/types/extensions/attachment/index.d.ts +20 -0
  284. package/dist/types/extensions/blocks.d.ts +8 -0
  285. package/dist/types/extensions/callout/callout-block.vue.d.ts +14 -0
  286. package/dist/types/extensions/callout/html.d.ts +4 -0
  287. package/dist/types/extensions/callout/index.d.ts +3 -0
  288. package/dist/types/extensions/callout/tones.d.ts +8 -0
  289. package/dist/types/extensions/code-block/code-block-view.vue.d.ts +16 -0
  290. package/dist/types/extensions/code-block/index.d.ts +19 -0
  291. package/dist/types/extensions/code-block/languages.d.ts +9 -0
  292. package/dist/types/extensions/colors/color-menu.vue.d.ts +3 -0
  293. package/dist/types/extensions/colors/index.d.ts +7 -0
  294. package/dist/types/extensions/colors/palette.d.ts +7 -0
  295. package/dist/types/extensions/editor-kit.d.ts +37 -0
  296. package/dist/types/extensions/embed/embed-block.vue.d.ts +16 -0
  297. package/dist/types/extensions/embed/index.d.ts +18 -0
  298. package/dist/types/extensions/embed/targets.d.ts +32 -0
  299. package/dist/types/extensions/formatting.d.ts +8 -0
  300. package/dist/types/extensions/image/image-block.vue.d.ts +16 -0
  301. package/dist/types/extensions/image/index.d.ts +16 -0
  302. package/dist/types/extensions/image/uploads.d.ts +35 -0
  303. package/dist/types/extensions/list-html.d.ts +11 -0
  304. package/dist/types/extensions/lists.d.ts +6 -0
  305. package/dist/types/extensions/mention/index.d.ts +11 -0
  306. package/dist/types/extensions/mention/mention-menu.vue.d.ts +7 -0
  307. package/dist/types/extensions/mention/state.d.ts +28 -0
  308. package/dist/types/extensions/table/commands.d.ts +69 -0
  309. package/dist/types/extensions/table/html.d.ts +4 -0
  310. package/dist/types/extensions/table/index.d.ts +8 -0
  311. package/dist/types/extensions/table/plugin.d.ts +4 -0
  312. package/dist/types/extensions/table/schema.d.ts +23 -0
  313. package/dist/types/extensions/table/table-controls.vue.d.ts +3 -0
  314. package/dist/types/extensions/table/view.d.ts +13 -0
  315. package/dist/types/extensions/toggle/index.d.ts +7 -0
  316. package/dist/types/extensions/toggle/state.d.ts +17 -0
  317. package/dist/types/extensions/toggle/toggle-block.vue.d.ts +14 -0
  318. package/dist/types/index.d.ts +266 -0
  319. package/dist/types/locale.d.ts +195 -0
  320. package/dist/types/markdown/index.d.ts +14 -0
  321. package/dist/types/use-comments.d.ts +17 -0
  322. package/dist/use-comments.js +141 -0
  323. package/dist/use-comments.js.map +1 -0
  324. package/package.json +98 -4
@@ -0,0 +1,61 @@
1
+ import { type Node as PMNode } from 'prosemirror-model';
2
+ import { type Command, type EditorState, type Transaction } from 'prosemirror-state';
3
+ import { type BlockInfo, type SiblingRange } from './blocks';
4
+ import { type BlockProps } from './model';
5
+ import type { ContentType } from './schema';
6
+ /**
7
+ * Turn every block the selection touches into `type`. Text formatting is
8
+ * dropped when it can't be kept (in a code block); a type without text
9
+ * (a divider, an embed) replaces the content and adds an empty paragraph
10
+ * after it to keep typing in.
11
+ */
12
+ export declare function setBlockType(type: ContentType, props?: BlockProps): Command;
13
+ /** Set attributes on the content of the block at `pos`, e.g. tick a to-do. */
14
+ export declare function setContentAttrs(pos: number, attrs: Record<string, unknown>): Command;
15
+ /**
16
+ * Split the block at the cursor. An empty list item turns back into a
17
+ * paragraph, an empty nested paragraph moves up a level, and a block with
18
+ * children gets its new block as the first child.
19
+ */
20
+ export declare const splitBlock: Command;
21
+ /** `Shift+Enter`: a line break, or a newline in code. */
22
+ export declare const insertBreak: Command;
23
+ /** In a code block, `Enter` adds a newline. */
24
+ export declare const newlineInCode: Command;
25
+ /** `Mod+Enter` in a code block: leave it for a new paragraph below. */
26
+ export declare const exitCode: Command;
27
+ /**
28
+ * `Backspace` at the start of a block: first turn it into a paragraph, then
29
+ * move a nested block up a level, then join it with the block above.
30
+ */
31
+ export declare const joinBackward: Command;
32
+ /** `Delete` at the end of a block: pull the next block's text up. */
33
+ export declare const joinForward: Command;
34
+ /** With a divider selected, `Backspace` or `Delete` removes its block. */
35
+ export declare const deleteSelectedAtom: Command;
36
+ /** `Tab`: make the selected blocks children of the block above them. */
37
+ export declare const sinkBlocks: Command;
38
+ /**
39
+ * `Shift+Tab`: move the selected blocks up a level, right after their
40
+ * parent. The siblings that followed them become children of the last one,
41
+ * so nothing changes order.
42
+ */
43
+ export declare const liftBlocks: Command;
44
+ /** `Mod+Shift+↑/↓`: swap the selected blocks with their neighbour. */
45
+ export declare function swapBlocks(direction: -1 | 1): Command;
46
+ /**
47
+ * Drag and drop: move the blocks of `range` to `target`, a position right
48
+ * before or after a block, possibly at another level. Fails when the
49
+ * target is inside the moved blocks. The cursor goes to the first one.
50
+ */
51
+ export declare function moveRangeTo(range: SiblingRange, target: number): Command;
52
+ /** Remove blocks, keeping at least one empty paragraph in the document. */
53
+ export declare function deleteBlocks(tr: Transaction, blocks: BlockInfo[]): Transaction;
54
+ /** Copies of blocks with fresh ids (the id plugin assigns them). */
55
+ export declare function withoutIds(node: PMNode): PMNode;
56
+ /** Insert copies of the selected blocks right after them. */
57
+ export declare const duplicateBlocks: Command;
58
+ /** Insert an empty block of `type` after the block at `pos` and put the cursor in it. */
59
+ export declare function insertBlockAfter(pos: number, type?: ContentType): Command;
60
+ /** The selection's blocks, for menus and the block selection. */
61
+ export declare function selectedBlocks(state: EditorState): BlockInfo[];
@@ -0,0 +1,44 @@
1
+ import { type Node as PMNode } from 'prosemirror-model';
2
+ import { Plugin, PluginKey, type EditorState } from 'prosemirror-state';
3
+ import { DecorationSet, type EditorView } from 'prosemirror-view';
4
+ /** A range of the document, as positions. */
5
+ export interface CommentRange {
6
+ from: number;
7
+ to: number;
8
+ }
9
+ /** Where a thread is anchored: the block and the text it is about. */
10
+ export interface CommentAnchor {
11
+ /** The id of the (first) block holding the text. */
12
+ block: string;
13
+ /** The text the thread is about. */
14
+ text: string;
15
+ from: number;
16
+ to: number;
17
+ }
18
+ export interface CommentPluginState {
19
+ /** The text a thread is being started on, until its first comment is sent. */
20
+ pending: CommentRange | null;
21
+ decorations: DecorationSet;
22
+ }
23
+ export declare const commentKey: PluginKey<CommentPluginState>;
24
+ export interface CommentPluginOptions {
25
+ /** The ids of the threads there are, or `null` when comments are off. */
26
+ known: () => ReadonlySet<string> | null;
27
+ /** A click on text that is in threads, with their ids, innermost first; `[]` elsewhere. */
28
+ onClick: (ids: string[]) => void;
29
+ onPending: (range: CommentRange | null) => void;
30
+ /** Text got selected (a range, not a cursor). */
31
+ onSelect: () => void;
32
+ }
33
+ /** The ids of the threads at `pos`, the shortest (innermost) first. */
34
+ export declare function commentsAt(state: EditorState, pos: number): string[];
35
+ /** Every thread's anchor in the document, by id: the first and last positions of its text. */
36
+ export declare function commentAnchors(doc: PMNode): Map<string, CommentAnchor>;
37
+ /** The text of `id`'s anchor that a thread card points at: its first and last positions. */
38
+ export declare function commentRange(doc: PMNode, id: string): CommentRange | null;
39
+ /** Marks `range` as the text of a new thread. Not undone with the edits around it. */
40
+ export declare function anchorComment(view: EditorView, range: CommentRange, id: string): void;
41
+ /** Takes a removed thread's anchor off the text. */
42
+ export declare function unanchorComment(view: EditorView, id: string): void;
43
+ export declare function setPendingComment(view: EditorView, range: CommentRange | null): void;
44
+ export declare function commentPlugin(options: CommentPluginOptions): Plugin<CommentPluginState>;
@@ -0,0 +1,10 @@
1
+ import { Plugin, PluginKey } from 'prosemirror-state';
2
+ import { DecorationSet } from 'prosemirror-view';
3
+ import { type Block } from './model';
4
+ export declare const compareKey: PluginKey<DecorationSet>;
5
+ /** Draws the changes from `before()`; `null` draws none. */
6
+ export declare function comparePlugin(options: {
7
+ before: () => readonly Block[] | null | undefined;
8
+ /** What to show for a removed block without text, such as a divider. */
9
+ label: (block: Block) => string;
10
+ }): Plugin<DecorationSet>;
@@ -0,0 +1,12 @@
1
+ import { type EditorExtension, type ResolvedEditorExtensions } from './extension';
2
+ import type { Block, PartialBlock } from './model';
3
+ export type EditorExtensionList = readonly (EditorExtension | EditorExtension[])[];
4
+ /** Resolve a list of extensions once; the same array gives the same result. */
5
+ export declare function kitOf(extensions: EditorExtensionList): ResolvedEditorExtensions;
6
+ /**
7
+ * Write blocks as HTML with the given extensions, e.g. to show a document
8
+ * outside the editor. Works without a browser.
9
+ */
10
+ export declare function blocksToHTML(blocks: PartialBlock[], extensions: EditorExtensionList): string;
11
+ /** Read HTML as blocks with the given extensions. Needs `DOMParser` (a browser, or a DOM library). */
12
+ export declare function htmlToBlocks(html: string, extensions: EditorExtensionList): Block[];
@@ -0,0 +1,49 @@
1
+ import type { Block, InlineContent } from './model';
2
+ /** One block that differs between two versions. */
3
+ export type BlockVersionChange = {
4
+ type: 'added';
5
+ id: string;
6
+ after: Block;
7
+ }
8
+ /** `next`: the block of the newer version it stood before; `null` at the end. */
9
+ | {
10
+ type: 'removed';
11
+ id: string;
12
+ before: Block;
13
+ next: string | null;
14
+ }
15
+ /** Its text, type, attributes or rows changed. */
16
+ | {
17
+ type: 'updated';
18
+ id: string;
19
+ before: Block;
20
+ after: Block;
21
+ };
22
+ export interface BlocksDiff {
23
+ /** The changed blocks, in the order of the newer version, removed ones where they were. */
24
+ changes: BlockVersionChange[];
25
+ /** The ids of the blocks added, removed and updated, as the `transaction` event's `changes` has them. */
26
+ added: string[];
27
+ removed: string[];
28
+ updated: string[];
29
+ }
30
+ /** The blocks added, removed and changed from `before` to `after`. */
31
+ export declare function diffBlocks(before: readonly Block[], after: readonly Block[]): BlocksDiff;
32
+ /**
33
+ * A block's inline content as text, one character for each position it
34
+ * takes in the editor: a line break and an inline node (a mention) are
35
+ * one each.
36
+ */
37
+ export declare function inlineText(content: readonly InlineContent[]): string;
38
+ /** A piece of a text diff: kept, only in the newer text, or only in the older one. */
39
+ export interface TextPart {
40
+ type: 'same' | 'added' | 'removed';
41
+ text: string;
42
+ }
43
+ /**
44
+ * The characters `after` added to `before` and those it removed: their
45
+ * longest common subsequence kept, the rest added or removed. Shared
46
+ * starts and ends are taken off first, so a small edit in a long text is
47
+ * cheap.
48
+ */
49
+ export declare function diffText(before: string, after: string): TextPart[];
@@ -0,0 +1,64 @@
1
+ import type { Node as PMNode } from 'prosemirror-model';
2
+ import { EditorState, Plugin, type Command, type Transaction } from 'prosemirror-state';
3
+ import { EditorView, type NodeViewConstructor } from 'prosemirror-view';
4
+ import type { ResolvedEditorExtensions } from './extension';
5
+ import { type KeymapOptions } from './keymap';
6
+ import { type Block, type PartialBlock } from './model';
7
+ import { type PlaceholderOptions } from './plugins';
8
+ export interface CreateEditorOptions {
9
+ /** Where the editor goes. */
10
+ element: HTMLElement;
11
+ /** The resolved extensions: schema, plugins, node views. */
12
+ kit: ResolvedEditorExtensions;
13
+ /** More node views, e.g. ones that render Vue components. */
14
+ nodeViews?: Record<string, NodeViewConstructor>;
15
+ blocks?: PartialBlock[];
16
+ editable?: boolean;
17
+ placeholder: PlaceholderOptions;
18
+ /** Called after each change to the document, with the transaction and the state before it. */
19
+ onChange?: (view: EditorView, tr: Transaction, before: EditorState) => void;
20
+ /** Called after every state change, including the selection. */
21
+ onUpdate?: (view: EditorView, before: EditorState) => void;
22
+ /**
23
+ * Extra plugins, placed before the built-in ones so their keys win.
24
+ * The collaboration extension adds its sync and cursor plugins here.
25
+ */
26
+ plugins?: Plugin[];
27
+ /**
28
+ * Key plugins placed after the extensions' keys, so an extension can
29
+ * take one of their keys, and before the built-in ones.
30
+ */
31
+ keymaps?: Plugin[];
32
+ /** Leave out the built-in undo history (collaboration brings its own). */
33
+ history?: boolean;
34
+ undo?: KeymapOptions['undo'];
35
+ redo?: KeymapOptions['redo'];
36
+ /** Attributes for the editable element, e.g. an accessible name. */
37
+ attributes?: () => Record<string, string>;
38
+ }
39
+ /** The transaction meta that names who made a change, for the `transaction` event. */
40
+ export declare const originKey = "douOrigin";
41
+ /**
42
+ * The undo and redo the editor runs: the built-in history's, or those of
43
+ * the extension or props that replace it. For node views that edit their
44
+ * text themselves, so their undo is the document's.
45
+ */
46
+ export declare function historyCommands(state: EditorState): {
47
+ undo: Command;
48
+ redo: Command;
49
+ };
50
+ export declare function createPlugins(options: Omit<CreateEditorOptions, 'element'>): Plugin[];
51
+ export declare function createState(kit: ResolvedEditorExtensions, blocks: PartialBlock[] | undefined, plugins: Plugin[]): EditorState;
52
+ export declare function createEditorView(options: CreateEditorOptions): EditorView;
53
+ export declare function setEditable(view: EditorView, value: boolean): void;
54
+ /** Replace the whole document, e.g. when `v-model` changes from outside. */
55
+ export declare function replaceBlocks(view: EditorView, blocks: PartialBlock[]): void;
56
+ /**
57
+ * Replace the document with `blocks` as one change undo takes back, e.g.
58
+ * an older version. Only what differs is replaced, so the blocks that stay
59
+ * keep their place, and with collaboration only they are written.
60
+ */
61
+ export declare function restoreBlocks(view: EditorView, blocks: PartialBlock[]): boolean;
62
+ export declare function getBlocks(view: EditorView): Block[];
63
+ export declare function runCommand(view: EditorView, command: Command): boolean;
64
+ export type { PMNode };
@@ -0,0 +1,167 @@
1
+ import type { InputRule } from 'prosemirror-inputrules';
2
+ import type { MarkSpec, NodeSpec, Schema } from 'prosemirror-model';
3
+ import type { Command, Plugin } from 'prosemirror-state';
4
+ import type { NodeViewConstructor } from 'prosemirror-view';
5
+ import { type CommentAction, type CommentThread } from 'dou-ui';
6
+ import type { Component, Ref } from 'vue';
7
+ import type { EditorMessages } from '../locale';
8
+ import type { BlockProps } from './model';
9
+ import type { EditorExtensionOutput } from './output';
10
+ /** Text shown in a menu: fixed, or read from the editor's messages so it follows the locale. */
11
+ export type Label = string | ((messages: EditorMessages) => string);
12
+ export declare const labelOf: (label: Label | undefined, messages: EditorMessages) => string;
13
+ /** An entry of the slash menu and of the “turn into” menus. */
14
+ export interface BlockOption {
15
+ /** Unique among the options. */
16
+ key: string;
17
+ /** The block type it inserts or turns blocks into. */
18
+ type: string;
19
+ props?: BlockProps;
20
+ label: Label;
21
+ /** A short description under the label in the slash menu. */
22
+ hint?: Label;
23
+ icon: Component;
24
+ /** Extra words the slash menu matches, besides the label (pinyin works well). */
25
+ keywords?: string[];
26
+ /** The Markdown shortcut, shown as a hint. */
27
+ shortcut?: string;
28
+ }
29
+ /** A toggle in the formatting toolbar for a mark. */
30
+ export interface FormatOption {
31
+ mark: string;
32
+ label: Label;
33
+ icon: Component;
34
+ /** The shortcut shown in its tooltip, written as in `useHotkey`, e.g. `mod+b`. */
35
+ hotkey?: string;
36
+ }
37
+ /** Where the comment threads live, when not in `v-model:comments`. */
38
+ export interface CommentsProvider {
39
+ /** The threads, kept up to date. */
40
+ threads: Readonly<Ref<readonly CommentThread[]>>;
41
+ /** Make a change this user asked for. */
42
+ apply: (action: CommentAction) => void;
43
+ }
44
+ export interface EditorExtensionContext {
45
+ schema: Schema;
46
+ }
47
+ /** What the extension replacing the undo history provides (e.g. collaboration). */
48
+ export interface HistoryProvider {
49
+ plugins: Plugin[];
50
+ undo: Command;
51
+ redo: Command;
52
+ }
53
+ /**
54
+ * A piece of the editor: block types, marks, behaviour and menu entries.
55
+ * The built-in blocks are extensions too (see `editorKit`).
56
+ */
57
+ export interface EditorExtension {
58
+ name: string;
59
+ /** Higher runs first: its keys, input rules and plugins win. Defaults to 100. */
60
+ priority?: number;
61
+ /**
62
+ * Content node specs for new block types, by type name. They join the
63
+ * `blockContent` group. Extra spec fields the editor reads:
64
+ * `continues` (Enter continues the same type, like a list) and
65
+ * `component` (a Vue component that renders the block).
66
+ */
67
+ blocks?: Record<string, NodeSpec>;
68
+ /**
69
+ * Nodes that only live inside the extension's blocks, e.g. a table's
70
+ * rows and cells. They join no group.
71
+ */
72
+ nodes?: Record<string, NodeSpec>;
73
+ /** Inline nodes, e.g. a mention. */
74
+ inlines?: Record<string, NodeSpec>;
75
+ marks?: Record<string, MarkSpec>;
76
+ nodeViews?: Record<string, NodeViewConstructor>;
77
+ /**
78
+ * Node views that draw Vue components, by node type. Each is made with
79
+ * `mount`, which renders a component into an element inside the editor's
80
+ * app, so it can call `useEditor()` and follows the ConfigProvider.
81
+ */
82
+ componentViews?: Record<string, (mount: MountComponent) => NodeViewConstructor>;
83
+ inputRules?: (context: EditorExtensionContext) => InputRule[];
84
+ /**
85
+ * Keys, written as in `useHotkey` (e.g. `mod+shift+h`, `shift+tab`,
86
+ * `enter`), while the editor has focus. A command returning `false` lets
87
+ * the key through to the next extension.
88
+ */
89
+ keymap?: (context: EditorExtensionContext) => Record<string, Command>;
90
+ plugins?: (context: EditorExtensionContext) => Plugin[];
91
+ /**
92
+ * The document lives outside the editor (e.g. in a Yjs document): the
93
+ * initial `modelValue` and later outside changes to it are ignored, and
94
+ * `v-model` only mirrors the document.
95
+ */
96
+ externalDocument?: boolean;
97
+ /** Replace the built-in undo history. Only one extension may. */
98
+ history?: (context: EditorExtensionContext) => HistoryProvider;
99
+ /**
100
+ * Keep the comment threads somewhere else than `v-model:comments`, e.g.
101
+ * in a shared document. `v-model:comments` then only mirrors them.
102
+ * Only one extension may.
103
+ */
104
+ comments?: (context: EditorExtensionContext) => CommentsProvider;
105
+ /** Entries for the slash menu and the “turn into” menus. */
106
+ blockOptions?: BlockOption[];
107
+ /** Toggles for the formatting toolbar. */
108
+ formats?: FormatOption[];
109
+ /**
110
+ * Components rendered next to the editing area while it is editable,
111
+ * e.g. a popup of suggestions. They can call `useEditor()`.
112
+ */
113
+ overlays?: Component[];
114
+ /**
115
+ * Controls added to the formatting toolbar, after the marks (e.g. a
116
+ * color menu). They can call `useEditor()`.
117
+ */
118
+ toolbar?: Component[];
119
+ /**
120
+ * Entries added to the block menu of the handle, usually a
121
+ * `DouDropdownSub` or `DouDropdownItem`s. Each gets the block the menu is
122
+ * for as the `block` prop (a `Block`) and can call `useEditor()`.
123
+ */
124
+ blockMenu?: Component[];
125
+ /**
126
+ * How the extension's blocks, inline nodes and marks are written as HTML
127
+ * and Markdown (`blocksToHTML`, `blocksToMarkdown`).
128
+ */
129
+ output?: EditorExtensionOutput;
130
+ /**
131
+ * Rewrite HTML before it is read as blocks (when pasting, and in
132
+ * `htmlToBlocks` and `markdownToBlocks`), e.g. turn a `<details>`
133
+ * element into a toggle with its children. `blockElement` and
134
+ * `splitContainer` help build the editor's markup.
135
+ */
136
+ prepareHTML?: (root: HTMLElement) => void;
137
+ }
138
+ /**
139
+ * Renders `component` into `element` with `props` (a reactive object stays
140
+ * live), inside the editor's app. Returns a function that removes it.
141
+ */
142
+ export type MountComponent = (component: Component, props: Record<string, unknown>, element: HTMLElement) => () => void;
143
+ /** Declare an extension; only gives it a type. */
144
+ export declare function defineEditorExtension(extension: EditorExtension): EditorExtension;
145
+ /** Everything the extensions contribute, gathered once per list of extensions. */
146
+ export interface ResolvedEditorExtensions {
147
+ extensions: EditorExtension[];
148
+ schema: Schema;
149
+ context: EditorExtensionContext;
150
+ nodeViews: Record<string, NodeViewConstructor>;
151
+ componentViews: Record<string, (mount: MountComponent) => NodeViewConstructor>;
152
+ blockOptions: BlockOption[];
153
+ formats: FormatOption[];
154
+ overlays: Component[];
155
+ toolbar: Component[];
156
+ blockMenu: Component[];
157
+ inputRules: InputRule[];
158
+ keymaps: Record<string, Command>[];
159
+ plugins: Plugin[];
160
+ history: HistoryProvider | null;
161
+ comments: CommentsProvider | null;
162
+ externalDocument: boolean;
163
+ }
164
+ /** `mod+shift+h` → `Mod-Shift-h`, the way the ProseMirror keymap names keys. */
165
+ export declare function toEditorKey(hotkey: string): string;
166
+ /** Sort the extensions by priority, build the schema and collect what they add. */
167
+ export declare function resolveEditorExtensions(list: readonly (EditorExtension | EditorExtension[])[]): ResolvedEditorExtensions;
@@ -0,0 +1,19 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import type { EditorView } from 'prosemirror-view';
3
+ /** A block type that takes pasted and dropped files, e.g. images or attachments. */
4
+ export interface FileDropTarget {
5
+ /** Whether the target takes this file. */
6
+ accepts: (file: File) => boolean;
7
+ /** Takes files no other target accepts (attachments): asked last. */
8
+ fallback?: boolean;
9
+ /** Insert blocks for the files after the block at `pos`; returns a position in the last one. */
10
+ insert: (view: EditorView, files: File[], pos: number) => number;
11
+ /** Leave a paste to the browser, e.g. an image copied from a page comes with its address. */
12
+ skipPaste?: (event: ClipboardEvent, files: File[]) => boolean;
13
+ }
14
+ /**
15
+ * A plugin that hands pasted and dropped files to the targets. However many
16
+ * extensions take files, the first such plugin sorts all of them out, so
17
+ * an image and a PDF pasted together both arrive.
18
+ */
19
+ export declare function fileDropPlugin(target: FileDropTarget): Plugin;
@@ -0,0 +1,32 @@
1
+ import { Plugin, PluginKey } from 'prosemirror-state';
2
+ import { DecorationSet, type EditorView } from 'prosemirror-view';
3
+ /**
4
+ * Turns code into highlighted HTML, the same function `DouCodeBlock` takes:
5
+ * `(code, lang) => codeToHtml(code, { lang, themes, defaultColor: false })`
6
+ * with shiki works as is.
7
+ */
8
+ export type CodeHighlighter = (code: string, lang: string) => string | Promise<string>;
9
+ /** A highlighted stretch of a code block's text. */
10
+ interface Token {
11
+ from: number;
12
+ to: number;
13
+ style: string;
14
+ className: string;
15
+ }
16
+ interface HighlightState {
17
+ decorations: DecorationSet;
18
+ /** The highlighter the editor falls back on, e.g. one set up in ConfigProvider. */
19
+ fallback: CodeHighlighter | null;
20
+ }
21
+ export declare const highlightKey: PluginKey<HighlightState>;
22
+ /** Read the tokens from highlighted HTML: the text of each `<span>` with its style and class. */
23
+ export declare function readTokens(html: string, code: string): Token[] | null;
24
+ /**
25
+ * Highlights code blocks with a highlighter that returns HTML. It runs
26
+ * after each change (asynchronous highlighters are fine) and the colors
27
+ * are laid over the text as decorations, so the document keeps plain text.
28
+ */
29
+ export declare function highlightPlugin(highlight?: CodeHighlighter): Plugin<HighlightState>;
30
+ /** Set the highlighter used when the code block was not given one. */
31
+ export declare function setFallbackHighlighter(view: EditorView, highlight: CodeHighlighter | null): void;
32
+ export {};
@@ -0,0 +1,21 @@
1
+ import { InputRule } from 'prosemirror-inputrules';
2
+ import { type Plugin } from 'prosemirror-state';
3
+ /**
4
+ * A Markdown-style shortcut typed at the start of a block, e.g. `# ` for a
5
+ * heading. It only applies to paragraphs, so typing `# ` inside a heading
6
+ * or code stays literal. Input rules never run during IME composition.
7
+ */
8
+ export declare function blockInputRule(pattern: RegExp, type: string, attrs?: (match: RegExpMatchArray) => Record<string, unknown>): InputRule;
9
+ /**
10
+ * A shortcut that fills an empty paragraph with a block without text (e.g.
11
+ * `---` for a divider) and opens a paragraph below. The pattern matches the
12
+ * whole paragraph, the character just typed included.
13
+ */
14
+ export declare function atomInputRule(pattern: RegExp, type: string): InputRule;
15
+ /**
16
+ * Formatting typed inline, e.g. `**bold**`. The pattern's first group is
17
+ * the marked text with its markers, the second the text alone. The
18
+ * character just typed (the last marker) is not in the document yet.
19
+ */
20
+ export declare function markInputRule(pattern: RegExp, mark: string): InputRule;
21
+ export declare function editorInputRules(rules: InputRule[]): Plugin;
@@ -0,0 +1,8 @@
1
+ import type { Command, Plugin } from 'prosemirror-state';
2
+ export interface KeymapOptions {
3
+ /** Undo and redo; the collaboration extension swaps in its own. */
4
+ undo?: Command;
5
+ redo?: Command;
6
+ }
7
+ /** The keys every editor has; marks and block types bring their own. */
8
+ export declare function editorKeymap(options?: KeymapOptions): Plugin;
@@ -0,0 +1,158 @@
1
+ import { type NodeType, type Node as PMNode, type Schema } from 'prosemirror-model';
2
+ import { type TextColor } from './colors';
3
+ import type { ContentType, MarkType } from './schema';
4
+ /** A run of text with its formatting. */
5
+ export interface TextContent {
6
+ type: 'text';
7
+ text: string;
8
+ /** Formatting, in a fixed order: bold, italic, underline, strike, code. */
9
+ marks?: MarkType[];
10
+ /** The link target, when the text is a link. */
11
+ link?: string;
12
+ /** The text color, by palette name (e.g. `red`), with the `colors` extension. */
13
+ color?: TextColor;
14
+ /** The background color, by palette name (e.g. `yellow`), with the `colors` extension. */
15
+ highlight?: TextColor;
16
+ /** The ids of the comment threads about this text. */
17
+ comments?: string[];
18
+ }
19
+ /**
20
+ * For the `colors` extension's marks (internal): a mark that carries one
21
+ * color is stored on the text run under this name, e.g.
22
+ * `{ text, color: 'red' }`, and keeps it in its `value` attribute.
23
+ */
24
+ export type MarkField = 'color' | 'highlight';
25
+ /** A line break inside a block (`Shift+Enter`). */
26
+ export interface BreakContent {
27
+ type: 'break';
28
+ }
29
+ /** An inline node an extension adds, e.g. a mention. */
30
+ export interface InlineNodeContent {
31
+ type: 'inline';
32
+ /** The node's name, e.g. `mention`. */
33
+ name: string;
34
+ props: Record<string, unknown>;
35
+ }
36
+ export type InlineContent = TextContent | BreakContent | InlineNodeContent;
37
+ /** A block's attributes: those of the built-in types, and any an extension declares. */
38
+ export interface BlockProps {
39
+ /** Heading level, `1` to `3`. */
40
+ level?: number;
41
+ /** Whether a to-do item is done. */
42
+ checked?: boolean;
43
+ /** The language of a code block. */
44
+ language?: string;
45
+ /** The tone of a callout: `info`, `tip`, `warning` or `danger`. */
46
+ tone?: string;
47
+ /** How a paragraph, heading or quote lines up; left out when it follows the reading direction. */
48
+ align?: 'left' | 'center' | 'right';
49
+ [name: string]: unknown;
50
+ }
51
+ /** A table cell: formatted text, and how far it reaches when merged. */
52
+ export interface TableCell {
53
+ content: InlineContent[];
54
+ /** Columns the cell spans, when more than one. */
55
+ colspan?: number;
56
+ /** Rows the cell spans, when more than one. */
57
+ rowspan?: number;
58
+ }
59
+ /** A table row: one cell for every column, including those a merged cell covers. */
60
+ export interface TableRow {
61
+ /** Stable across edits, like a block's id. */
62
+ id: string;
63
+ cells: TableCell[];
64
+ }
65
+ export interface PartialTableCell {
66
+ content?: InlineContent[] | string;
67
+ colspan?: number;
68
+ rowspan?: number;
69
+ }
70
+ export interface PartialTableRow {
71
+ id?: string;
72
+ cells: (PartialTableCell | string)[];
73
+ }
74
+ /** One block of the document, as `v-model` reads and writes it. */
75
+ export interface Block {
76
+ /** Stable across edits; a random UUID unless you provide your own. */
77
+ id: string;
78
+ type: ContentType;
79
+ props: BlockProps;
80
+ content: InlineContent[];
81
+ /** The rows of a table; other blocks have none. */
82
+ rows?: TableRow[];
83
+ children: Block[];
84
+ }
85
+ /**
86
+ * The document the editor edits, bound with `v-model`: plain JSON to store
87
+ * and send as it is. The editor writes full blocks; it reads partial ones.
88
+ */
89
+ export interface EditorDocument<B extends PartialBlock = Block> {
90
+ /** The version of the format; see `migrateDocument`. */
91
+ version: 1;
92
+ blocks: B[];
93
+ }
94
+ /** A block to insert: everything but the type is optional. */
95
+ export interface PartialBlock {
96
+ id?: string;
97
+ type?: ContentType;
98
+ props?: BlockProps;
99
+ /** Inline content, or plain text. */
100
+ content?: InlineContent[] | string;
101
+ rows?: PartialTableRow[];
102
+ children?: PartialBlock[];
103
+ }
104
+ /**
105
+ * A content node spec field for blocks whose content is rows rather than
106
+ * text (a table): how to read them into a block and build them back.
107
+ */
108
+ export interface RowsSpec {
109
+ read: (node: PMNode) => {
110
+ props: BlockProps;
111
+ rows: TableRow[];
112
+ };
113
+ write: (type: NodeType, props: BlockProps, rows: PartialTableRow[]) => PMNode;
114
+ /** The node as a grid of ids and cell nodes, for collaboration. */
115
+ grid: (node: PMNode) => TableGrid;
116
+ }
117
+ /** A table node laid out by ids. */
118
+ export interface TableGrid {
119
+ /** The props other than `columns`. */
120
+ props: BlockProps;
121
+ /** Each column's id and its other fields (width, alignment). */
122
+ columns: {
123
+ id: string;
124
+ width?: number;
125
+ align?: string;
126
+ }[];
127
+ /** Row ids, top to bottom. */
128
+ rows: string[];
129
+ /** The cells that are shown, merged ones by their top-left place. */
130
+ cells: GridCell[];
131
+ }
132
+ export interface GridCell {
133
+ row: number;
134
+ col: number;
135
+ rowspan: number;
136
+ colspan: number;
137
+ /** The cell node; its content is inline. */
138
+ node: PMNode;
139
+ /** Where the cell starts, counted from the start of the table's content. */
140
+ offset: number;
141
+ }
142
+ /** A random id; UUIDs keep blocks created at the same time on two devices apart. */
143
+ export declare function createId(): string;
144
+ export declare function inlineOf(node: PMNode): InlineContent[];
145
+ /** A block of the document; shared between reads, so frozen. */
146
+ export declare function blockFromNode(node: PMNode): Block;
147
+ export declare function docToBlocks(doc: PMNode): Block[];
148
+ export declare function inlineNodes(schema: Schema, content: PartialBlock['content'], code: boolean): PMNode[];
149
+ /**
150
+ * The attributes a content type declares, taken from `props` where given.
151
+ * A spec's `normalizeProps` can clamp them, e.g. a heading's level.
152
+ */
153
+ export declare function contentAttrs(type: NodeType, props?: BlockProps): Record<string, unknown>;
154
+ export declare function createContentNode(schema: Schema, type: ContentType, props?: BlockProps, content?: PartialBlock['content'], rows?: PartialTableRow[]): PMNode;
155
+ export declare function nodeFromBlock(schema: Schema, block: PartialBlock): PMNode;
156
+ export declare function blocksToDoc(schema: Schema, blocks: PartialBlock[]): PMNode;
157
+ /** A development warning, once per message. */
158
+ export declare function warnOnce(message: string): void;