@dou-ui/editor 0.1.0-alpha.3 → 0.1.0-alpha.30

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 (159) hide show
  1. package/dist/collaboration/binding.js +371 -57
  2. package/dist/collaboration/binding.js.map +1 -1
  3. package/dist/collaboration/cursors.js +42 -10
  4. package/dist/collaboration/cursors.js.map +1 -1
  5. package/dist/collaboration/index.js +61 -11
  6. package/dist/collaboration/index.js.map +1 -1
  7. package/dist/collaboration/inline-diff.js +138 -0
  8. package/dist/collaboration/inline-diff.js.map +1 -0
  9. package/dist/collaboration/merged-props.js +152 -0
  10. package/dist/collaboration/merged-props.js.map +1 -0
  11. package/dist/collaboration/order.js +41 -1
  12. package/dist/collaboration/order.js.map +1 -1
  13. package/dist/collaboration/table.js +64 -25
  14. package/dist/collaboration/table.js.map +1 -1
  15. package/dist/collaboration/text.js +213 -1
  16. package/dist/collaboration/text.js.map +1 -1
  17. package/dist/components/block-handle.js.map +1 -1
  18. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +127 -17
  19. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  20. package/dist/components/slash-choices.js +6 -0
  21. package/dist/components/slash-choices.js.map +1 -0
  22. package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js +56 -0
  23. package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js.map +1 -0
  24. package/dist/components/slash-menu.js.map +1 -1
  25. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +185 -20
  26. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  27. package/dist/core/block-selection.js +32 -4
  28. package/dist/core/block-selection.js.map +1 -1
  29. package/dist/core/blocks.js +21 -3
  30. package/dist/core/blocks.js.map +1 -1
  31. package/dist/core/cjk.js +54 -0
  32. package/dist/core/cjk.js.map +1 -0
  33. package/dist/core/commands.js +125 -13
  34. package/dist/core/commands.js.map +1 -1
  35. package/dist/core/comments.js +85 -3
  36. package/dist/core/comments.js.map +1 -1
  37. package/dist/core/convert.js +3 -3
  38. package/dist/core/convert.js.map +1 -1
  39. package/dist/core/extension.js +6 -2
  40. package/dist/core/extension.js.map +1 -1
  41. package/dist/core/model.js +10 -3
  42. package/dist/core/model.js.map +1 -1
  43. package/dist/core/output.js +26 -10
  44. package/dist/core/output.js.map +1 -1
  45. package/dist/core/prepare.js +12 -5
  46. package/dist/core/prepare.js.map +1 -1
  47. package/dist/core/schema.js.map +1 -1
  48. package/dist/core/transaction.js +19 -4
  49. package/dist/core/transaction.js.map +1 -1
  50. package/dist/define-block.js +8 -4
  51. package/dist/define-block.js.map +1 -1
  52. package/dist/document.js +59 -4
  53. package/dist/document.js.map +1 -1
  54. package/dist/dom.js +109 -13
  55. package/dist/dom.js.map +1 -1
  56. package/dist/editor.js.map +1 -1
  57. package/dist/editor.vue_vue_type_script_setup_true_lang.js +6 -5
  58. package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  59. package/dist/editor2.js.map +1 -1
  60. package/dist/extensions/callout/html.js +5 -4
  61. package/dist/extensions/callout/html.js.map +1 -1
  62. package/dist/extensions/columns/column-picker.js +6 -0
  63. package/dist/extensions/columns/column-picker.js.map +1 -0
  64. package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js +57 -0
  65. package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  66. package/dist/extensions/columns/columns-controls.js +6 -0
  67. package/dist/extensions/columns/columns-controls.js.map +1 -0
  68. package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js +341 -0
  69. package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
  70. package/dist/extensions/columns/html.js +34 -0
  71. package/dist/extensions/columns/html.js.map +1 -0
  72. package/dist/extensions/columns/index.js +57 -0
  73. package/dist/extensions/columns/index.js.map +1 -0
  74. package/dist/extensions/columns/keys.js +53 -0
  75. package/dist/extensions/columns/keys.js.map +1 -0
  76. package/dist/extensions/columns/plugin.js +213 -0
  77. package/dist/extensions/columns/plugin.js.map +1 -0
  78. package/dist/extensions/columns/schema.js +58 -0
  79. package/dist/extensions/columns/schema.js.map +1 -0
  80. package/dist/extensions/columns/select-columns.js +6 -0
  81. package/dist/extensions/columns/select-columns.js.map +1 -0
  82. package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js +71 -0
  83. package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js.map +1 -0
  84. package/dist/extensions/editor-kit.js +3 -1
  85. package/dist/extensions/editor-kit.js.map +1 -1
  86. package/dist/extensions/list-html.js +1 -1
  87. package/dist/extensions/list-html.js.map +1 -1
  88. package/dist/extensions/table/plugin.js +33 -1
  89. package/dist/extensions/table/plugin.js.map +1 -1
  90. package/dist/extensions/table/schema.js +5 -1
  91. package/dist/extensions/table/schema.js.map +1 -1
  92. package/dist/extensions/table/table-controls.js.map +1 -1
  93. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +80 -9
  94. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -1
  95. package/dist/extensions/table/view.js +181 -3
  96. package/dist/extensions/table/view.js.map +1 -1
  97. package/dist/flow/board-block.js +6 -0
  98. package/dist/flow/board-block.js.map +1 -0
  99. package/dist/flow/board-block.vue_vue_type_script_setup_true_lang.js +659 -0
  100. package/dist/flow/board-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
  101. package/dist/flow/board.js +221 -0
  102. package/dist/flow/board.js.map +1 -0
  103. package/dist/flow/index.js +173 -0
  104. package/dist/flow/index.js.map +1 -0
  105. package/dist/index.js +3 -2
  106. package/dist/index.js.map +1 -1
  107. package/dist/locale.js +78 -6
  108. package/dist/locale.js.map +1 -1
  109. package/dist/markdown/cjk-friendly.js +62 -0
  110. package/dist/markdown/cjk-friendly.js.map +1 -0
  111. package/dist/markdown/index.js +4 -3
  112. package/dist/markdown/index.js.map +1 -1
  113. package/dist/style.css +1 -1
  114. package/dist/style.js +2 -0
  115. package/dist/types/collaboration/binding.d.ts +12 -0
  116. package/dist/types/collaboration/cursors.d.ts +29 -1
  117. package/dist/types/collaboration/index.d.ts +53 -6
  118. package/dist/types/collaboration/inline-diff.d.ts +9 -0
  119. package/dist/types/collaboration/merged-props.d.ts +20 -0
  120. package/dist/types/collaboration/order.d.ts +5 -0
  121. package/dist/types/collaboration/table.d.ts +5 -1
  122. package/dist/types/collaboration/text.d.ts +20 -0
  123. package/dist/types/components/slash-choices.vue.d.ts +18 -0
  124. package/dist/types/core/blocks.d.ts +10 -0
  125. package/dist/types/core/cjk.d.ts +23 -0
  126. package/dist/types/core/commands.d.ts +17 -2
  127. package/dist/types/core/comments.d.ts +39 -3
  128. package/dist/types/core/convert.d.ts +10 -2
  129. package/dist/types/core/extension.d.ts +58 -4
  130. package/dist/types/core/model.d.ts +6 -1
  131. package/dist/types/core/prepare.d.ts +16 -2
  132. package/dist/types/core/schema.d.ts +1 -1
  133. package/dist/types/core/transaction.d.ts +6 -0
  134. package/dist/types/define-block.d.ts +16 -4
  135. package/dist/types/document.d.ts +5 -2
  136. package/dist/types/dom.d.ts +41 -4
  137. package/dist/types/editor.d.ts +15 -1
  138. package/dist/types/editor.vue.d.ts +24 -0
  139. package/dist/types/extensions/columns/column-picker.vue.d.ts +10 -0
  140. package/dist/types/extensions/columns/columns-controls.vue.d.ts +3 -0
  141. package/dist/types/extensions/columns/html.d.ts +10 -0
  142. package/dist/types/extensions/columns/index.d.ts +9 -0
  143. package/dist/types/extensions/columns/keys.d.ts +6 -0
  144. package/dist/types/extensions/columns/plugin.d.ts +28 -0
  145. package/dist/types/extensions/columns/schema.d.ts +17 -0
  146. package/dist/types/extensions/columns/select-columns.vue.d.ts +13 -0
  147. package/dist/types/extensions/editor-kit.d.ts +4 -1
  148. package/dist/types/extensions/table/view.d.ts +36 -2
  149. package/dist/types/flow/board-block.vue.d.ts +16 -0
  150. package/dist/types/flow/board.d.ts +53 -0
  151. package/dist/types/flow/index.d.ts +65 -0
  152. package/dist/types/index.d.ts +29 -4
  153. package/dist/types/locale.d.ts +34 -0
  154. package/dist/types/markdown/cjk-friendly.d.ts +6 -0
  155. package/dist/types/markdown/index.d.ts +11 -4
  156. package/dist/types/use-comments.d.ts +1 -0
  157. package/dist/use-comments.js +63 -9
  158. package/dist/use-comments.js.map +1 -1
  159. package/package.json +14 -5
@@ -0,0 +1,57 @@
1
+ import { defineEditorExtension } from "../../core/extension.js";
2
+ import column_picker_default from "./column-picker.js";
3
+ import { columnsPlugin } from "./plugin.js";
4
+ import { columnSpec, columnsSpec } from "./schema.js";
5
+ import columns_controls_default from "./columns-controls.js";
6
+ import { columnsOutput, prepareColumns } from "./html.js";
7
+ import { columnKeys } from "./keys.js";
8
+ import select_columns_default from "./select-columns.js";
9
+ import { LayoutColumnsIcon } from "@dou-ui/icons";
10
+ // src/extensions/columns/index.ts
11
+ var counts = Array.from({ length: 4 }, (_, index) => 2 + index);
12
+ /**
13
+ * Columns: blocks side by side, two to five of them. In the slash menu,
14
+ * “Columns” opens a picker for how many. Each column holds any blocks,
15
+ * which move between columns like anywhere else; dropping blocks between
16
+ * two columns makes a new one there, and dragging the bar between two
17
+ * columns resizes them. On a narrow screen the columns stack.
18
+ */
19
+ var columns = defineEditorExtension({
20
+ name: "columns",
21
+ blocks: {
22
+ columns: columnsSpec,
23
+ column: columnSpec
24
+ },
25
+ keymap: columnKeys,
26
+ plugins: ({ messages }) => [columnsPlugin((index, count) => messages().columns.column.replace("{index}", String(index)).replace("{count}", String(count)))],
27
+ output: { blocks: columnsOutput },
28
+ prepareHTML: prepareColumns,
29
+ overlays: [columns_controls_default],
30
+ blockMenu: [select_columns_default],
31
+ blockOptions: [{
32
+ key: "columns",
33
+ type: "columns",
34
+ props: { count: 2 },
35
+ label: (m) => m.types.columns,
36
+ hint: (m) => m.hints.columns,
37
+ icon: LayoutColumnsIcon,
38
+ keywords: [
39
+ "columns",
40
+ "layout",
41
+ "grid",
42
+ "fl",
43
+ "fenlan"
44
+ ],
45
+ choices: {
46
+ title: (m) => m.columns.pick,
47
+ items: counts.map((count) => ({
48
+ props: { count },
49
+ label: (m) => m.columns.count.replace("{count}", String(count))
50
+ })),
51
+ component: column_picker_default
52
+ }
53
+ }]
54
+ });
55
+ export { columns };
56
+
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ColumnsControls","SelectColumns","ColumnPicker"],"sources":["../../../src/extensions/columns/index.ts"],"sourcesContent":["import { LayoutColumnsIcon } from '@dou-ui/icons'\nimport { defineEditorExtension } from '../../core/extension'\nimport ColumnPicker from './column-picker.vue'\nimport ColumnsControls from './columns-controls.vue'\nimport { columnsOutput, prepareColumns } from './html'\nimport { columnKeys } from './keys'\nimport { columnsPlugin } from './plugin'\nimport { columnSpec, columnsSpec, MAX_COLUMNS, MIN_COLUMNS } from './schema'\nimport SelectColumns from './select-columns.vue'\n\nconst counts = Array.from(\n { length: MAX_COLUMNS - MIN_COLUMNS + 1 },\n (_, index) => MIN_COLUMNS + index,\n)\n\n/**\n * Columns: blocks side by side, two to five of them. In the slash menu,\n * “Columns” opens a picker for how many. Each column holds any blocks,\n * which move between columns like anywhere else; dropping blocks between\n * two columns makes a new one there, and dragging the bar between two\n * columns resizes them. On a narrow screen the columns stack.\n */\nexport const columns = defineEditorExtension({\n name: 'columns',\n blocks: { columns: columnsSpec, column: columnSpec },\n keymap: columnKeys,\n plugins: ({ messages }) => [\n columnsPlugin((index, count) =>\n messages().columns.column.replace('{index}', String(index)).replace('{count}', String(count)),\n ),\n ],\n output: { blocks: columnsOutput },\n prepareHTML: prepareColumns,\n overlays: [ColumnsControls],\n blockMenu: [SelectColumns],\n blockOptions: [\n {\n key: 'columns',\n type: 'columns',\n props: { count: MIN_COLUMNS },\n label: (m) => m.types.columns,\n hint: (m) => m.hints.columns,\n icon: LayoutColumnsIcon,\n keywords: ['columns', 'layout', 'grid', 'fl', 'fenlan'],\n choices: {\n title: (m) => m.columns.pick,\n items: counts.map((count) => ({\n props: { count },\n label: (m) => m.columns.count.replace('{count}', String(count)),\n })),\n component: ColumnPicker,\n },\n },\n ],\n})\n\nexport { MAX_COLUMNS } from './schema'\n"],"mappings":";;;;;;;;;;AAUA,IAAM,SAAS,MAAM,KACnB,EAAE,QAAA,EAAsC,IACvC,GAAG,UAAA,IAAwB,KAC9B;;;;;;;;AASA,IAAa,UAAU,sBAAsB;CAC3C,MAAM;CACN,QAAQ;EAAE,SAAS;EAAa,QAAQ;CAAW;CACnD,QAAQ;CACR,UAAU,EAAE,eAAe,CACzB,eAAe,OAAO,UACpB,SAAS,CAAC,CAAC,QAAQ,OAAO,QAAQ,WAAW,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,WAAW,OAAO,KAAK,CAAC,CAC9F,CACF;CACA,QAAQ,EAAE,QAAQ,cAAc;CAChC,aAAa;CACb,UAAU,CAACA,wBAAe;CAC1B,WAAW,CAACC,sBAAa;CACzB,cAAc,CACZ;EACE,KAAK;EACL,MAAM;EACN,OAAO,EAAE,OAAA,EAAmB;EAC5B,QAAQ,MAAM,EAAE,MAAM;EACtB,OAAO,MAAM,EAAE,MAAM;EACrB,MAAM;EACN,UAAU;GAAC;GAAW;GAAU;GAAQ;GAAM;EAAQ;EACtD,SAAS;GACP,QAAQ,MAAM,EAAE,QAAQ;GACxB,OAAO,OAAO,KAAK,WAAW;IAC5B,OAAO,EAAE,MAAM;IACf,QAAQ,MAAM,EAAE,QAAQ,MAAM,QAAQ,WAAW,OAAO,KAAK,CAAC;GAChE,EAAE;GACF,WAAWC;EACb;CACF,CACF;AACF,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { blockAround, layoutOf, nextInDocument, parentBlock, previousInDocument } from "../../core/blocks.js";
2
+ import { sinkBlocks } from "../../core/commands.js";
3
+ import { Selection } from "prosemirror-state";
4
+ // src/extensions/columns/keys.ts
5
+ /**
6
+ * `↑` on the first line of a column and `↓` on its last: the cursor goes to
7
+ * the block above or below the set of columns, as it looks, instead of
8
+ * into the column beside (the next one in the document).
9
+ */
10
+ function leave(direction) {
11
+ return (state, dispatch, view) => {
12
+ const { selection } = state;
13
+ if (!selection.empty || !view?.endOfTextblock(direction < 0 ? "up" : "down")) return false;
14
+ const doc = state.doc;
15
+ const block = blockAround(selection.$head);
16
+ if (!block) return false;
17
+ if ((direction < 0 ? previousInDocument : nextInDocument)(doc, block)) return false;
18
+ let row = parentBlock(doc, block);
19
+ while (row && layoutOf(row.node) !== "row") row = parentBlock(doc, row);
20
+ if (!row) return false;
21
+ const pos = direction < 0 ? row.pos : row.pos + row.node.nodeSize;
22
+ if (direction < 0 ? pos <= 0 : pos >= doc.content.size) return false;
23
+ const target = Selection.findFrom(doc.resolve(pos), direction, true);
24
+ if (!target) return false;
25
+ if (dispatch) dispatch(state.tr.setSelection(target).scrollIntoView());
26
+ return true;
27
+ };
28
+ }
29
+ /**
30
+ * `Tab` in a column where it can't indent (and not in code): to the bar
31
+ * beside the column, to resize it with `←` `→`.
32
+ */
33
+ var toBar = (state, _dispatch, view) => {
34
+ const { $from } = state.selection;
35
+ if (!view || $from.parent.type.spec.code || sinkBlocks(state)) return false;
36
+ let column = blockAround($from);
37
+ while (column && layoutOf(column.node) !== "column") column = parentBlock(state.doc, column);
38
+ const row = column && parentBlock(state.doc, column);
39
+ if (!column || !row?.group) return false;
40
+ const index = state.doc.resolve(column.pos).index();
41
+ const bar = (view.dom.closest(".dou-editor")?.querySelectorAll(".dou-editor-columns__bar.is-key"))?.[Math.min(index, row.group.childCount - 2)];
42
+ if (!bar) return false;
43
+ bar.focus();
44
+ return true;
45
+ };
46
+ var columnKeys = () => ({
47
+ ArrowUp: leave(-1),
48
+ ArrowDown: leave(1),
49
+ Tab: toBar
50
+ });
51
+ export { columnKeys };
52
+
53
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","names":[],"sources":["../../../src/extensions/columns/keys.ts"],"sourcesContent":["import { Selection, type Command } from 'prosemirror-state'\nimport {\n blockAround,\n layoutOf,\n nextInDocument,\n parentBlock,\n previousInDocument,\n} from '../../core/blocks'\nimport { sinkBlocks } from '../../core/commands'\n\n/**\n * `↑` on the first line of a column and `↓` on its last: the cursor goes to\n * the block above or below the set of columns, as it looks, instead of\n * into the column beside (the next one in the document).\n */\nfunction leave(direction: -1 | 1): Command {\n return (state, dispatch, view) => {\n const { selection } = state\n if (!selection.empty || !view?.endOfTextblock(direction < 0 ? 'up' : 'down')) return false\n const doc = state.doc\n const block = blockAround(selection.$head)\n if (!block) return false\n // only at the first or last block of the column\n if ((direction < 0 ? previousInDocument : nextInDocument)(doc, block)) return false\n let row = parentBlock(doc, block)\n while (row && layoutOf(row.node) !== 'row') row = parentBlock(doc, row)\n if (!row) return false\n const pos = direction < 0 ? row.pos : row.pos + row.node.nodeSize\n if (direction < 0 ? pos <= 0 : pos >= doc.content.size) return false\n const target = Selection.findFrom(doc.resolve(pos), direction, true)\n if (!target) return false\n if (dispatch) dispatch(state.tr.setSelection(target).scrollIntoView())\n return true\n }\n}\n\n/**\n * `Tab` in a column where it can't indent (and not in code): to the bar\n * beside the column, to resize it with `←` `→`.\n */\nconst toBar: Command = (state, _dispatch, view) => {\n const { $from } = state.selection\n if (!view || $from.parent.type.spec.code || sinkBlocks(state)) return false\n let column = blockAround($from)\n while (column && layoutOf(column.node) !== 'column') column = parentBlock(state.doc, column)\n const row = column && parentBlock(state.doc, column)\n if (!column || !row?.group) return false\n const index = state.doc.resolve(column.pos).index()\n const bars = view.dom\n .closest('.dou-editor')\n ?.querySelectorAll<HTMLElement>('.dou-editor-columns__bar.is-key')\n const bar = bars?.[Math.min(index, row.group.childCount - 2)]\n if (!bar) return false\n bar.focus()\n return true\n}\n\nexport const columnKeys = () => ({ ArrowUp: leave(-1), ArrowDown: leave(1), Tab: toBar })\n"],"mappings":";;;;;;;;;AAeA,SAAS,MAAM,WAA4B;CACzC,QAAQ,OAAO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B,iBAA8B,iCAAiC,EAAA,GAChD,KAAK,IAAI,OAAO,IAAI,MAAM,aAAa,CAAC;CAC3D,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI,MAAM;CACV,OAAO;AACT;AAEA,IAAa,oBAAoB;CAAE,SAAS,MAAM,EAAE;CAAG,WAAW,MAAM,CAAC;CAAG,KAAK;AAAM"}
@@ -0,0 +1,213 @@
1
+ import { blockAround, blocksIn, layoutOf, siblingRangeBetween } from "../../core/blocks.js";
2
+ import { getBlockSelection, selectBlocks } from "../../core/block-selection.js";
3
+ import { changesBlockStructure, isRemote } from "../../core/plugins.js";
4
+ import { Plugin, PluginKey, Selection, TextSelection } from "prosemirror-state";
5
+ import { Decoration, DecorationSet } from "prosemirror-view";
6
+ import { AttrStep } from "prosemirror-transform";
7
+ // src/extensions/columns/plugin.ts
8
+ var descends = (node) => node.type.name === "block" || node.type.name === "blockGroup";
9
+ /** Remove the block at `pos`, or its group when it is the only block there (a group may not be empty). */
10
+ function removeBlock(tr, pos) {
11
+ const $pos = tr.doc.resolve(pos);
12
+ const node = tr.doc.nodeAt(pos);
13
+ if ($pos.parent.type.name === "blockGroup" && $pos.parent.childCount === 1) tr.delete($pos.before(), $pos.after());
14
+ else tr.delete(pos, pos + node.nodeSize);
15
+ }
16
+ /** Put the block at `pos` in place of its children. */
17
+ function unwrap(tr, pos, block) {
18
+ const group = block.childCount > 1 ? block.child(1) : null;
19
+ if (group) tr.replaceWith(pos, pos + block.nodeSize, group.content);
20
+ else removeBlock(tr, pos);
21
+ }
22
+ /**
23
+ * Find the first thing wrong with the columns of `tr.doc` and fix it.
24
+ * Fixes only move and remove blocks, never add any: two editors fixing
25
+ * the same remote change both end up with the same document.
26
+ */
27
+ function fixOne(tr) {
28
+ const doc = tr.doc;
29
+ const first = tr.steps.length;
30
+ const map = (pos) => tr.mapping.slice(first).map(pos);
31
+ let fixed = false;
32
+ doc.descendants((node, pos) => {
33
+ if (fixed) return false;
34
+ if (node.type.name !== "block") return descends(node);
35
+ const layout = layoutOf(node);
36
+ if (!layout) return true;
37
+ const $pos = doc.resolve(pos);
38
+ const owner = $pos.depth > 0 ? $pos.node($pos.depth - 1) : null;
39
+ const group = node.childCount > 1 ? node.child(1) : null;
40
+ if (layout === "column") {
41
+ if (layoutOf(owner) !== "row") unwrap(tr, pos, node);
42
+ else if (!group) removeBlock(tr, pos);
43
+ else return true;
44
+ fixed = true;
45
+ return false;
46
+ }
47
+ for (let depth = $pos.depth; depth > 0; depth--) {
48
+ if (layoutOf($pos.node(depth)) !== "column") continue;
49
+ unwrap(tr, pos, node);
50
+ fixed = true;
51
+ return false;
52
+ }
53
+ if (!group) {
54
+ removeBlock(tr, pos);
55
+ fixed = true;
56
+ return false;
57
+ }
58
+ const columns = [];
59
+ const strays = [];
60
+ const start = pos + 1 + node.firstChild.nodeSize + 1;
61
+ group.forEach((child, offset) => {
62
+ const entry = {
63
+ node: child,
64
+ pos: start + offset
65
+ };
66
+ if (layoutOf(child) === "column") columns.push(entry);
67
+ else strays.push(entry);
68
+ });
69
+ const stray = strays[0];
70
+ if (!columns.length || columns.length === 1 && !stray) {
71
+ const only = columns[0];
72
+ if (only) unwrap(tr, only.pos, only.node);
73
+ unwrap(tr, map(pos), tr.doc.nodeAt(map(pos)));
74
+ fixed = true;
75
+ return false;
76
+ }
77
+ if (stray) {
78
+ const before = columns.filter((column) => column.pos < stray.pos).at(-1);
79
+ const target = before ?? columns[0];
80
+ const at = before ? target.pos + target.node.nodeSize - 2 : target.pos + 1 + target.node.firstChild.nodeSize + 1;
81
+ tr.delete(stray.pos, stray.pos + stray.node.nodeSize);
82
+ tr.insert(map(at), stray.node);
83
+ fixed = true;
84
+ return false;
85
+ }
86
+ return true;
87
+ });
88
+ if (fixed && tr.doc.childCount === 0) {
89
+ const schema = tr.doc.type.schema;
90
+ tr.insert(0, schema.nodes.block.create(null, schema.nodes.paragraph.create()));
91
+ }
92
+ return fixed;
93
+ }
94
+ /** Each column's width, as a style on its block, and its name for screen readers. */
95
+ function widths(doc, preview, label) {
96
+ const decorations = [];
97
+ doc.descendants((node, pos) => {
98
+ if (node.type.name !== "block") return descends(node);
99
+ if (layoutOf(node) !== "row") return true;
100
+ const group = node.childCount > 1 ? node.child(1) : null;
101
+ let at = pos + 1 + node.firstChild.nodeSize + 1;
102
+ group?.forEach((column, _offset, index) => {
103
+ const shown = preview?.find((entry) => entry.pos === at);
104
+ const width = shown ? shown.width : column.firstChild.attrs.width;
105
+ if (width && width !== 1) decorations.push(Decoration.node(at, at + column.nodeSize, { style: `--dou-editor-column-width: ${width}` }));
106
+ const inner = at + 1 + column.firstChild.nodeSize;
107
+ if (column.childCount > 1) decorations.push(Decoration.node(inner, inner + column.child(1).nodeSize, { "aria-label": label(index + 1, group.childCount) }));
108
+ at += column.nodeSize;
109
+ });
110
+ return true;
111
+ });
112
+ return DecorationSet.create(doc, decorations);
113
+ }
114
+ var columnsKey = new PluginKey("dou-editor-columns");
115
+ /** Show `preview` widths without changing the document, or stop showing them (`null`). */
116
+ function previewColumns(tr, preview) {
117
+ return tr.setMeta(columnsKey, { preview }).setMeta("addToHistory", false);
118
+ }
119
+ /** Lay the columns out again, e.g. after the locale changed their names. */
120
+ var refreshColumns = (tr) => tr.setMeta(columnsKey, {}).setMeta("addToHistory", false);
121
+ /** The column around a position: the position before its block, or -1 outside columns. */
122
+ function columnAt(state, pos) {
123
+ const $pos = state.doc.resolve(pos);
124
+ for (let depth = $pos.depth; depth > 0; depth--) if (layoutOf($pos.node(depth)) === "column") return $pos.before(depth);
125
+ return -1;
126
+ }
127
+ /**
128
+ * A text selection from one column into another, or between a column and
129
+ * the blocks around the set: the whole blocks instead, so deleting it or
130
+ * typing over it never joins text across columns.
131
+ */
132
+ function selectAcross(state) {
133
+ const { selection } = state;
134
+ if (!(selection instanceof TextSelection) || selection.empty || getBlockSelection(state)) return null;
135
+ const { $from, $to } = selection;
136
+ const doc = state.doc;
137
+ let from = selection.from;
138
+ let to = selection.to;
139
+ if ($to.parentOffset === 0 && $to.parent.isTextblock) {
140
+ const block = blockAround($to);
141
+ const before = block && Selection.findFrom(doc.resolve(block.pos), -1, true);
142
+ if (before && before.from > from) to = before.from;
143
+ }
144
+ if ($from.parentOffset === $from.parent.content.size && $from.parent.isTextblock) {
145
+ const block = blockAround($from);
146
+ const after = block && Selection.findFrom(doc.resolve(block.contentPos + block.content.nodeSize), 1, true);
147
+ if (after && after.from < to) from = after.from;
148
+ }
149
+ if (columnAt(state, from) === columnAt(state, to)) return null;
150
+ const range = siblingRangeBetween(doc, from, to);
151
+ if (!range) return null;
152
+ const blocks = blocksIn(range);
153
+ const [first, last] = [blocks[0].node.attrs.id, blocks.at(-1).node.attrs.id];
154
+ const backwards = selection.head < selection.anchor;
155
+ let result = null;
156
+ selectBlocks(backwards ? last : first, backwards ? first : last)(state, (tr) => {
157
+ result = tr;
158
+ });
159
+ return result;
160
+ }
161
+ /**
162
+ * Keeps columns well formed after every change, also one from another
163
+ * collaborator (the fix is the same everywhere): columns only in a set of
164
+ * columns, at least one block in each, at least two in a set, no set of
165
+ * columns in a column. Lays each column's width on it, and turns a text
166
+ * selection across columns into a selection of the whole blocks.
167
+ */
168
+ function columnsPlugin(label) {
169
+ return new Plugin({
170
+ key: columnsKey,
171
+ state: {
172
+ init: (_config, state) => ({
173
+ decorations: widths(state.doc, null, label),
174
+ preview: null
175
+ }),
176
+ apply: (tr, value, _old, state) => {
177
+ const meta = tr.getMeta(columnsKey);
178
+ let preview = value.preview;
179
+ if (meta?.preview !== void 0) preview = meta.preview;
180
+ else if (preview && tr.docChanged) preview = preview.map((entry) => ({
181
+ ...entry,
182
+ pos: tr.mapping.map(entry.pos)
183
+ }));
184
+ if (meta || tr.docChanged && (changesBlockStructure(tr) || tr.steps.some((step) => step instanceof AttrStep))) return {
185
+ decorations: widths(state.doc, preview, label),
186
+ preview
187
+ };
188
+ if (!tr.docChanged) return value;
189
+ return {
190
+ decorations: value.decorations.map(tr.mapping, tr.doc),
191
+ preview
192
+ };
193
+ }
194
+ },
195
+ appendTransaction(trs, _old, state) {
196
+ if (trs.some((tr) => changesBlockStructure(tr))) {
197
+ const tr = state.tr;
198
+ for (let round = 0; round < 64 && fixOne(tr); round++);
199
+ if (tr.docChanged) {
200
+ if (trs.every(isRemote)) tr.setMeta("addToHistory", false);
201
+ return tr;
202
+ }
203
+ }
204
+ return trs.some((tr) => tr.selectionSet) ? selectAcross(state) : null;
205
+ },
206
+ props: { decorations(state) {
207
+ return this.getState(state)?.decorations;
208
+ } }
209
+ });
210
+ }
211
+ export { columnsKey, columnsPlugin, previewColumns, refreshColumns };
212
+
213
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../../../src/extensions/columns/plugin.ts"],"sourcesContent":["import type { Node as PMNode } from 'prosemirror-model'\nimport {\n Plugin,\n PluginKey,\n Selection,\n TextSelection,\n type EditorState,\n type Transaction,\n} from 'prosemirror-state'\nimport { AttrStep } from 'prosemirror-transform'\nimport { Decoration, DecorationSet } from 'prosemirror-view'\nimport { getBlockSelection, selectBlocks } from '../../core/block-selection'\nimport { blockAround, blocksIn, layoutOf, siblingRangeBetween } from '../../core/blocks'\nimport { changesBlockStructure, isRemote } from '../../core/plugins'\n\nconst descends = (node: PMNode) => node.type.name === 'block' || node.type.name === 'blockGroup'\n\n/** Remove the block at `pos`, or its group when it is the only block there (a group may not be empty). */\nfunction removeBlock(tr: Transaction, pos: number) {\n const $pos = tr.doc.resolve(pos)\n const node = tr.doc.nodeAt(pos)!\n if ($pos.parent.type.name === 'blockGroup' && $pos.parent.childCount === 1)\n tr.delete($pos.before(), $pos.after())\n else tr.delete(pos, pos + node.nodeSize)\n}\n\n/** Put the block at `pos` in place of its children. */\nfunction unwrap(tr: Transaction, pos: number, block: PMNode) {\n const group = block.childCount > 1 ? block.child(1) : null\n if (group) tr.replaceWith(pos, pos + block.nodeSize, group.content)\n else removeBlock(tr, pos)\n}\n\n/**\n * Find the first thing wrong with the columns of `tr.doc` and fix it.\n * Fixes only move and remove blocks, never add any: two editors fixing\n * the same remote change both end up with the same document.\n */\nfunction fixOne(tr: Transaction): boolean {\n const doc = tr.doc\n // positions in `doc`, mapped through this round's steps only\n const first = tr.steps.length\n const map = (pos: number) => tr.mapping.slice(first).map(pos)\n let fixed = false\n doc.descendants((node, pos) => {\n if (fixed) return false\n if (node.type.name !== 'block') return descends(node)\n const layout = layoutOf(node)\n if (!layout) return true\n const $pos = doc.resolve(pos)\n const owner = $pos.depth > 0 ? $pos.node($pos.depth - 1) : null\n const group = node.childCount > 1 ? node.child(1) : null\n if (layout === 'column') {\n // a column outside a set of columns: its blocks take its place\n if (layoutOf(owner) !== 'row') unwrap(tr, pos, node)\n // an empty column goes away\n else if (!group) removeBlock(tr, pos)\n else return true\n fixed = true\n return false\n }\n // a set of columns inside a column: columns don't nest, its columns take its place\n for (let depth = $pos.depth; depth > 0; depth--) {\n if (layoutOf($pos.node(depth)) !== 'column') continue\n unwrap(tr, pos, node)\n fixed = true\n return false\n }\n if (!group) {\n removeBlock(tr, pos)\n fixed = true\n return false\n }\n const columns: { node: PMNode; pos: number }[] = []\n const strays: { node: PMNode; pos: number }[] = []\n const start = pos + 1 + node.firstChild!.nodeSize + 1\n group.forEach((child, offset) => {\n const entry = { node: child, pos: start + offset }\n if (layoutOf(child) === 'column') columns.push(entry)\n else strays.push(entry)\n })\n const stray = strays[0]\n if (!columns.length || (columns.length === 1 && !stray)) {\n // one column (or none) is no set of columns: its blocks take its place\n const only = columns[0]\n if (only) unwrap(tr, only.pos, only.node)\n unwrap(tr, map(pos), tr.doc.nodeAt(map(pos))!)\n fixed = true\n return false\n }\n if (stray) {\n // a block between columns joins the column before it, or the first one\n const before = columns.filter((column) => column.pos < stray.pos).at(-1)\n const target = before ?? columns[0]!\n const at = before\n ? target.pos + target.node.nodeSize - 2\n : target.pos + 1 + target.node.firstChild!.nodeSize + 1\n tr.delete(stray.pos, stray.pos + stray.node.nodeSize)\n tr.insert(map(at), stray.node)\n fixed = true\n return false\n }\n return true\n })\n if (fixed && tr.doc.childCount === 0) {\n const schema = tr.doc.type.schema\n tr.insert(0, schema.nodes.block!.create(null, schema.nodes.paragraph!.create()))\n }\n return fixed\n}\n\n/** A column's width while its bar is dragged: shown, not yet in the document. */\nexport interface ColumnPreview {\n /** The position before the column's block. */\n pos: number\n width: number\n}\n\ninterface ColumnsState {\n decorations: DecorationSet\n preview: ColumnPreview[] | null\n}\n\n/** Each column's width, as a style on its block, and its name for screen readers. */\nfunction widths(doc: PMNode, preview: ColumnPreview[] | null, label: ColumnLabel): DecorationSet {\n const decorations: Decoration[] = []\n doc.descendants((node, pos) => {\n if (node.type.name !== 'block') return descends(node)\n if (layoutOf(node) !== 'row') return true\n const group = node.childCount > 1 ? node.child(1) : null\n let at = pos + 1 + node.firstChild!.nodeSize + 1\n group?.forEach((column, _offset, index) => {\n const shown = preview?.find((entry) => entry.pos === at)\n const width = shown ? shown.width : (column.firstChild!.attrs.width as number | null)\n if (width && width !== 1)\n decorations.push(\n Decoration.node(at, at + column.nodeSize, {\n style: `--dou-editor-column-width: ${width}`,\n }),\n )\n // the column's blocks, named after its place\n const inner = at + 1 + column.firstChild!.nodeSize\n if (column.childCount > 1)\n decorations.push(\n Decoration.node(inner, inner + column.child(1).nodeSize, {\n 'aria-label': label(index + 1, group.childCount),\n }),\n )\n at += column.nodeSize\n })\n return true\n })\n return DecorationSet.create(doc, decorations)\n}\n\n/** The name of a column: its place among the columns of its set. */\nexport type ColumnLabel = (index: number, count: number) => string\n\nexport const columnsKey = new PluginKey<ColumnsState>('dou-editor-columns')\n\n/** Show `preview` widths without changing the document, or stop showing them (`null`). */\nexport function previewColumns(tr: Transaction, preview: ColumnPreview[] | null): Transaction {\n return tr.setMeta(columnsKey, { preview }).setMeta('addToHistory', false)\n}\n\n/** Lay the columns out again, e.g. after the locale changed their names. */\nexport const refreshColumns = (tr: Transaction) =>\n tr.setMeta(columnsKey, {}).setMeta('addToHistory', false)\n\n/** The column around a position: the position before its block, or -1 outside columns. */\nfunction columnAt(state: EditorState, pos: number): number {\n const $pos = state.doc.resolve(pos)\n for (let depth = $pos.depth; depth > 0; depth--)\n if (layoutOf($pos.node(depth)) === 'column') return $pos.before(depth)\n return -1\n}\n\n/**\n * A text selection from one column into another, or between a column and\n * the blocks around the set: the whole blocks instead, so deleting it or\n * typing over it never joins text across columns.\n */\nfunction selectAcross(state: EditorState): Transaction | null {\n const { selection } = state\n if (!(selection instanceof TextSelection) || selection.empty || getBlockSelection(state))\n return null\n // an end at the very start of the next block (or the very end of the one\n // before) is where the browser puts a selection that stops at a line\n // break: that block isn't selected\n const { $from, $to } = selection\n const doc = state.doc\n let from = selection.from\n let to = selection.to\n if ($to.parentOffset === 0 && $to.parent.isTextblock) {\n const block = blockAround($to)\n const before = block && Selection.findFrom(doc.resolve(block.pos), -1, true)\n if (before && before.from > from) to = before.from\n }\n if ($from.parentOffset === $from.parent.content.size && $from.parent.isTextblock) {\n const block = blockAround($from)\n const after =\n block && Selection.findFrom(doc.resolve(block.contentPos + block.content.nodeSize), 1, true)\n if (after && after.from < to) from = after.from\n }\n if (columnAt(state, from) === columnAt(state, to)) return null\n const range = siblingRangeBetween(doc, from, to)\n if (!range) return null\n const blocks = blocksIn(range)\n const [first, last] = [blocks[0]!.node.attrs.id, blocks.at(-1)!.node.attrs.id] as string[]\n const backwards = selection.head < selection.anchor\n let result: Transaction | null = null\n selectBlocks(backwards ? last! : first!, backwards ? first! : last!)(state, (tr) => {\n result = tr\n })\n return result\n}\n\n/**\n * Keeps columns well formed after every change, also one from another\n * collaborator (the fix is the same everywhere): columns only in a set of\n * columns, at least one block in each, at least two in a set, no set of\n * columns in a column. Lays each column's width on it, and turns a text\n * selection across columns into a selection of the whole blocks.\n */\nexport function columnsPlugin(label: ColumnLabel): Plugin<ColumnsState> {\n return new Plugin<ColumnsState>({\n key: columnsKey,\n state: {\n init: (_config, state) => ({ decorations: widths(state.doc, null, label), preview: null }),\n apply: (tr, value, _old, state) => {\n const meta = tr.getMeta(columnsKey) as { preview?: ColumnPreview[] | null } | undefined\n let preview = value.preview\n if (meta?.preview !== undefined) preview = meta.preview\n else if (preview && tr.docChanged)\n preview = preview.map((entry) => ({ ...entry, pos: tr.mapping.map(entry.pos) }))\n if (\n meta ||\n (tr.docChanged &&\n (changesBlockStructure(tr) || tr.steps.some((step) => step instanceof AttrStep)))\n )\n return { decorations: widths(state.doc, preview, label), preview }\n if (!tr.docChanged) return value\n return { decorations: value.decorations.map(tr.mapping, tr.doc), preview }\n },\n },\n appendTransaction(trs, _old, state) {\n if (trs.some((tr) => changesBlockStructure(tr))) {\n const tr = state.tr\n for (let round = 0; round < 64 && fixOne(tr); round++);\n if (tr.docChanged) {\n if (trs.every(isRemote)) tr.setMeta('addToHistory', false)\n return tr\n }\n }\n return trs.some((tr) => tr.selectionSet) ? selectAcross(state) : null\n },\n props: {\n decorations(state) {\n return this.getState(state)?.decorations\n },\n },\n })\n}\n"],"mappings":";;;;;;;AAeA,IAAM,YAAY,SAAiB,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS;;AAGpF,SAAS,YAAY,IAAiB,KAAa;CACjD,MAAM,OAAO,GAAG,IAAI,QAAQ,GAAG;CAC/B,MAAM,OAAO,GAAG,IAAI,OAAO,GAAG;CAC9B,IAAI,KAAK,OAAO,KAAK,SAAS,gBAAgB,KAAK,OAAO,eAAe,GACvE,GAAG,OAAO,KAAK,OAAO,GAAG,KAAK,MAAM,CAAC;MAClC,GAAG,OAAO,KAAK,MAAM,KAAK,QAAQ;AACzC;;AAGA,SAAS,OAAO,IAAiB,KAAa,OAAe;CAC3D,MAAM,QAAQ,MAAM,aAAa,IAAI,MAAM,MAAM,CAAC,IAAI;CACtD,IAAI,OAAO,GAAG,YAAY,KAAK,MAAM,MAAM,UAAU,MAAM,OAAO;MAC7D,YAAY,IAAI,GAAG;AAC1B;;;;;;AAOA,SAAS,OAAO,IAA0B;CACxC,MAAM,MAAM,GAAG;CAEf,MA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W;KAAE,GAAG;KAAO,KAAK,GAAG,QAAQ,IAAI,MAAM,GAAG;IAAE,EAAE;IACjF,IACE,QACC,GAAG,eACD,sBAAsB,EAAE,KAAK,GAAG,MAAM,MAAM,SAAS,gBAAgB,QAAQ,IAEhF,OAAO;KAAE,aAAa,OAAO,MAAM,KAAK,SAAS,KAAK;KAAG;IAAQ;IACnE,IAAI,CAAC,GAAG,YAAY,OAAO;IAC3B,OAAO;KAAE,aAAa,MAAM,YAAY,IAAI,GAAG,SAAS,GAAG,GAAG;KAAG;IAAQ;GAC3E;EACF;EACA,kBAAkB,KAAK,MAAM,OAAO;GAClC,IAAI,IAAI,MAAM,OAAO,sBAAsB,EAAE,CAAC,GAAG;IAC/C,MAAM,KAAK,MAAM;IACjB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,OAAO,EAAE,GAAG;IAC9C,IAAI,GAAG,YAAY;KACjB,IAAI,IAAI,MAAM,QAAQ,GAAG,GAAG,QAAQ,gBAAgB,KAAK;KACzD,OAAO;IACT;GACF;GACA,OAAO,IAAI,MAAM,OAAO,GAAG,YAAY,IAAI,aAAa,KAAK,IAAI;EACnE;EACA,OAAO,EACL,YAAY,OAAO;GACjB,OAAO,KAAK,SAAS,KAAK,CAAC,EAAE;EAC/B,EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,58 @@
1
+ /** A column's width: a positive weight, rounded; anything else is the default (1). */
2
+ function widthOf(value) {
3
+ const width = Number(value);
4
+ if (value === null || value === void 0 || !Number.isFinite(width) || width <= 0) return null;
5
+ return Math.min(100, Math.max(.01, Math.round(width * 1e3) / 1e3));
6
+ }
7
+ var countOf = (props) => {
8
+ const count = Math.round(Number(props.count));
9
+ return Number.isFinite(count) ? Math.min(5, Math.max(2, count)) : 2;
10
+ };
11
+ /**
12
+ * A set of columns. Its content node holds no text and isn't shown; its
13
+ * children are `column` blocks, laid out side by side.
14
+ */
15
+ var columnsSpec = {
16
+ atom: true,
17
+ selectable: false,
18
+ layout: "row",
19
+ maxColumns: 5,
20
+ /** New columns, `props.count` of them (2 by default), each with an empty paragraph. */
21
+ template: (props) => Array.from({ length: countOf(props) }, () => ({
22
+ type: "column",
23
+ children: [{ type: "paragraph" }]
24
+ })),
25
+ parseDOM: [{ tag: "div[data-content-type=\"columns\"]" }],
26
+ toDOM: () => ["div", {
27
+ class: "dou-editor__content dou-editor__content--columns",
28
+ "data-content-type": "columns"
29
+ }]
30
+ };
31
+ /**
32
+ * One column: its children are the blocks shown in it. `props.width` is
33
+ * its share of the row, a weight against the other columns' (1 when left
34
+ * out), so two people resizing different columns at once both keep theirs.
35
+ */
36
+ var columnSpec = {
37
+ atom: true,
38
+ selectable: false,
39
+ layout: "column",
40
+ attrs: { width: { default: null } },
41
+ optionalProps: ["width"],
42
+ normalizeProps: (attrs) => "width" in attrs ? {
43
+ ...attrs,
44
+ width: widthOf(attrs.width)
45
+ } : attrs,
46
+ parseDOM: [{
47
+ tag: "div[data-content-type=\"column\"]",
48
+ getAttrs: (dom) => ({ width: widthOf(dom.dataset.width) })
49
+ }],
50
+ toDOM: (node) => ["div", {
51
+ class: "dou-editor__content dou-editor__content--column",
52
+ "data-content-type": "column",
53
+ ...node.attrs.width ? { "data-width": String(node.attrs.width) } : {}
54
+ }]
55
+ };
56
+ export { columnSpec, columnsSpec, widthOf };
57
+
58
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../../src/extensions/columns/schema.ts"],"sourcesContent":["import type { NodeSpec } from 'prosemirror-model'\nimport type { BlockProps, PartialBlock } from '../../core/model'\n\n/** The most columns a set can have, from the picker or by dropping blocks beside them. */\nexport const MAX_COLUMNS = 5\nexport const MIN_COLUMNS = 2\n\n/** A column's width: a positive weight, rounded; anything else is the default (1). */\nexport function widthOf(value: unknown): number | null {\n const width = Number(value)\n if (value === null || value === undefined || !Number.isFinite(width) || width <= 0) return null\n return Math.min(100, Math.max(0.01, Math.round(width * 1000) / 1000))\n}\n\nconst countOf = (props: BlockProps) => {\n const count = Math.round(Number(props.count))\n return Number.isFinite(count) ? Math.min(MAX_COLUMNS, Math.max(MIN_COLUMNS, count)) : MIN_COLUMNS\n}\n\n/**\n * A set of columns. Its content node holds no text and isn't shown; its\n * children are `column` blocks, laid out side by side.\n */\nexport const columnsSpec: NodeSpec = {\n atom: true,\n selectable: false,\n layout: 'row',\n maxColumns: MAX_COLUMNS,\n /** New columns, `props.count` of them (2 by default), each with an empty paragraph. */\n template: (props: BlockProps): PartialBlock[] =>\n Array.from({ length: countOf(props) }, () => ({\n type: 'column',\n children: [{ type: 'paragraph' }],\n })),\n parseDOM: [{ tag: 'div[data-content-type=\"columns\"]' }],\n toDOM: () => [\n 'div',\n { class: 'dou-editor__content dou-editor__content--columns', 'data-content-type': 'columns' },\n ],\n}\n\n/**\n * One column: its children are the blocks shown in it. `props.width` is\n * its share of the row, a weight against the other columns' (1 when left\n * out), so two people resizing different columns at once both keep theirs.\n */\nexport const columnSpec: NodeSpec = {\n atom: true,\n selectable: false,\n layout: 'column',\n attrs: { width: { default: null } },\n optionalProps: ['width'],\n normalizeProps: (attrs: { width?: unknown }) =>\n 'width' in attrs ? { ...attrs, width: widthOf(attrs.width) } : attrs,\n parseDOM: [\n {\n tag: 'div[data-content-type=\"column\"]',\n getAttrs: (dom) => ({ width: widthOf((dom as HTMLElement).dataset.width) }),\n },\n ],\n toDOM: (node) => [\n 'div',\n {\n class: 'dou-editor__content dou-editor__content--column',\n 'data-content-type': 'column',\n ...(node.attrs.width ? { 'data-width': String(node.attrs.width) } : {}),\n },\n ],\n}\n"],"mappings":";AAQA,SAAgB,QAAQ,OAA+B;CACrD,MAAM,QAAQ,OAAO,KAAK;CAC1B,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GAAG,OAAO;CAC3F,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAM,KAAK,MAAM,QAAQ,GAAI,IAAI,GAAI,CAAC;AACtE;AAEA,IAAM,WAAW,UAAsB;CACrC,MAAM,QAAQ,KAAK,MAAM,OAAO,MAAM,KAAK,CAAC;CAC5C,OAAO,OAAO,SAAS,KAAK,IAAI,KAAK,IAAA,GAAiB,KAAK,IAAA,GAAiB,KAAK,CAAC,IAAA;AACpF;;;;;AAMA,IAAa,cAAwB;CACnC,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,YAAA;;CAEA,WAAW,UACT,MAAM,KAAK,EAAE,QAAQ,QAAQ,KAAK,EAAE,UAAU;EAC5C,MAAM;EACN,UAAU,CAAC,EAAE,MAAM,YAAY,CAAC;CAClC,EAAE;CACJ,UAAU,CAAC,EAAE,KAAK,qCAAmC,CAAC;CACtD,aAAa,CACX,OACA;EAAE,OAAO;EAAoD,qBAAqB;CAAU,CAC9F;AACF;;;;;;AAOA,IAAa,aAAuB;CAClC,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,OAAO,EAAE,OAAO,EAAE,SAAS,KAAK,EAAE;CAClC,eAAe,CAAC,OAAO;CACvB,iBAAiB,UACf,WAAW,QAAQ;EAAE,GAAG;EAAO,OAAO,QAAQ,MAAM,KAAK;CAAE,IAAI;CACjE,UAAU,CACR;EACE,KAAK;EACL,WAAW,SAAS,EAAE,OAAO,QAAS,IAAoB,QAAQ,KAAK,EAAE;CAC3E,CACF;CACA,QAAQ,SAAS,CACf,OACA;EACE,OAAO;EACP,qBAAqB;EACrB,GAAI,KAAK,MAAM,QAAQ,EAAE,cAAc,OAAO,KAAK,MAAM,KAAK,EAAE,IAAI,CAAC;CACvE,CACF;AACF"}
@@ -0,0 +1,6 @@
1
+ import select_columns_vue_vue_type_script_setup_true_lang_default from "./select-columns.vue_vue_type_script_setup_true_lang.js";
2
+ // src/extensions/columns/select-columns.vue
3
+ var select_columns_default = select_columns_vue_vue_type_script_setup_true_lang_default;
4
+ export { select_columns_default as default };
5
+
6
+ //# sourceMappingURL=select-columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-columns.js","names":["_sfc_main"],"sources":["../../../src/extensions/columns/select-columns.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DistributeHorizontalIcon, LayoutColumnsIcon } from '@dou-ui/icons'\nimport { DouDropdownItem } from 'dou-ui'\nimport { computed } from 'vue'\nimport { selectBlocks } from '../../core/block-selection'\nimport { findBlockById, layoutOf, parentBlock } from '../../core/blocks'\nimport type { Block } from '../../core/model'\nimport { useEditor } from '../../editor'\n\n/**\n * In the block menu of a block inside columns: select the whole set of\n * columns, to move, copy or remove it with the handle or the keyboard;\n * and, when the columns differ in width, make them even (where the bar\n * between them can't be dragged, e.g. on a touch screen).\n */\nconst props = defineProps<{ block: Block }>()\nconst { view, state, messages } = useEditor()\n\n/** The set of columns around the block, if any. */\nconst row = computed(() => {\n const doc = state.value?.doc\n if (!doc) return null\n for (let info = findBlockById(doc, props.block.id); info; info = parentBlock(doc, info))\n if (layoutOf(info.node) === 'row') return info\n return null\n})\n\n/** Where the content of each column with a width of its own is. */\nconst uneven = computed(() => {\n const info = row.value\n if (!info?.group) return []\n const list: number[] = []\n let pos = info.contentPos + info.content.nodeSize + 1\n info.group.forEach((column) => {\n if (column.firstChild!.attrs.width != null) list.push(pos + 1)\n pos += column.nodeSize\n })\n return list\n})\n\nfunction select() {\n const current = view.value\n if (!current || !row.value) return\n selectBlocks(row.value.node.attrs.id as string)(current.state, current.dispatch)\n requestAnimationFrame(() => view.value?.focus())\n}\n\nfunction even() {\n const current = view.value\n if (!current || !uneven.value.length) return\n const tr = current.state.tr\n for (const pos of uneven.value) tr.setNodeAttribute(pos, 'width', null)\n current.dispatch(tr)\n requestAnimationFrame(() => view.value?.focus())\n}\n</script>\n\n<template>\n <template v-if=\"row\">\n <DouDropdownItem @click=\"select\">\n <template #prefix><LayoutColumnsIcon /></template>\n {{ messages.columns.select }}\n </DouDropdownItem>\n <DouDropdownItem v-if=\"uneven.length\" @click=\"even\">\n <template #prefix><DistributeHorizontalIcon /></template>\n {{ messages.columns.even }}\n </DouDropdownItem>\n </template>\n</template>\n"],"mappings":""}
@@ -0,0 +1,71 @@
1
+ import { findBlockById, layoutOf, parentBlock } from "../../core/blocks.js";
2
+ import { selectBlocks } from "../../core/block-selection.js";
3
+ import { useEditor } from "../../editor.js";
4
+ import { DouDropdownItem } from "dou-ui";
5
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
6
+ import { DistributeHorizontalIcon, LayoutColumnsIcon } from "@dou-ui/icons";
7
+ // src/extensions/columns/select-columns.vue?vue&type=script&setup=true&lang.ts
8
+ /**
9
+ * In the block menu of a block inside columns: select the whole set of
10
+ * columns, to move, copy or remove it with the handle or the keyboard;
11
+ * and, when the columns differ in width, make them even (where the bar
12
+ * between them can't be dragged, e.g. on a touch screen).
13
+ */
14
+ var select_columns_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
15
+ __name: "select-columns",
16
+ props: { block: {} },
17
+ setup(__props) {
18
+ const props = __props;
19
+ const { view, state, messages } = useEditor();
20
+ /** The set of columns around the block, if any. */
21
+ const row = computed(() => {
22
+ const doc = state.value?.doc;
23
+ if (!doc) return null;
24
+ for (let info = findBlockById(doc, props.block.id); info; info = parentBlock(doc, info)) if (layoutOf(info.node) === "row") return info;
25
+ return null;
26
+ });
27
+ /** Where the content of each column with a width of its own is. */
28
+ const uneven = computed(() => {
29
+ const info = row.value;
30
+ if (!info?.group) return [];
31
+ const list = [];
32
+ let pos = info.contentPos + info.content.nodeSize + 1;
33
+ info.group.forEach((column) => {
34
+ if (column.firstChild.attrs.width != null) list.push(pos + 1);
35
+ pos += column.nodeSize;
36
+ });
37
+ return list;
38
+ });
39
+ function select() {
40
+ const current = view.value;
41
+ if (!current || !row.value) return;
42
+ selectBlocks(row.value.node.attrs.id)(current.state, current.dispatch);
43
+ requestAnimationFrame(() => view.value?.focus());
44
+ }
45
+ function even() {
46
+ const current = view.value;
47
+ if (!current || !uneven.value.length) return;
48
+ const tr = current.state.tr;
49
+ for (const pos of uneven.value) tr.setNodeAttribute(pos, "width", null);
50
+ current.dispatch(tr);
51
+ requestAnimationFrame(() => view.value?.focus());
52
+ }
53
+ return (_ctx, _cache) => {
54
+ return row.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode(unref(DouDropdownItem), { onClick: select }, {
55
+ prefix: withCtx(() => [createVNode(unref(LayoutColumnsIcon))]),
56
+ default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(messages).columns.select), 1)]),
57
+ _: 1
58
+ }), uneven.value.length ? (openBlock(), createBlock(unref(DouDropdownItem), {
59
+ key: 0,
60
+ onClick: even
61
+ }, {
62
+ prefix: withCtx(() => [createVNode(unref(DistributeHorizontalIcon))]),
63
+ default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(messages).columns.even), 1)]),
64
+ _: 1
65
+ })) : createCommentVNode("", true)], 64)) : createCommentVNode("", true);
66
+ };
67
+ }
68
+ });
69
+ export { select_columns_vue_vue_type_script_setup_true_lang_default as default };
70
+
71
+ //# sourceMappingURL=select-columns.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-columns.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createVNode","_unref","_withCtx","_createTextVNode","_toDisplayString","_createBlock","_createCommentVNode"],"sources":["../../../src/extensions/columns/select-columns.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DistributeHorizontalIcon, LayoutColumnsIcon } from '@dou-ui/icons'\nimport { DouDropdownItem } from 'dou-ui'\nimport { computed } from 'vue'\nimport { selectBlocks } from '../../core/block-selection'\nimport { findBlockById, layoutOf, parentBlock } from '../../core/blocks'\nimport type { Block } from '../../core/model'\nimport { useEditor } from '../../editor'\n\n/**\n * In the block menu of a block inside columns: select the whole set of\n * columns, to move, copy or remove it with the handle or the keyboard;\n * and, when the columns differ in width, make them even (where the bar\n * between them can't be dragged, e.g. on a touch screen).\n */\nconst props = defineProps<{ block: Block }>()\nconst { view, state, messages } = useEditor()\n\n/** The set of columns around the block, if any. */\nconst row = computed(() => {\n const doc = state.value?.doc\n if (!doc) return null\n for (let info = findBlockById(doc, props.block.id); info; info = parentBlock(doc, info))\n if (layoutOf(info.node) === 'row') return info\n return null\n})\n\n/** Where the content of each column with a width of its own is. */\nconst uneven = computed(() => {\n const info = row.value\n if (!info?.group) return []\n const list: number[] = []\n let pos = info.contentPos + info.content.nodeSize + 1\n info.group.forEach((column) => {\n if (column.firstChild!.attrs.width != null) list.push(pos + 1)\n pos += column.nodeSize\n })\n return list\n})\n\nfunction select() {\n const current = view.value\n if (!current || !row.value) return\n selectBlocks(row.value.node.attrs.id as string)(current.state, current.dispatch)\n requestAnimationFrame(() => view.value?.focus())\n}\n\nfunction even() {\n const current = view.value\n if (!current || !uneven.value.length) return\n const tr = current.state.tr\n for (const pos of uneven.value) tr.setNodeAttribute(pos, 'width', null)\n current.dispatch(tr)\n requestAnimationFrame(() => view.value?.focus())\n}\n</script>\n\n<template>\n <template v-if=\"row\">\n <DouDropdownItem @click=\"select\">\n <template #prefix><LayoutColumnsIcon /></template>\n {{ messages.columns.select }}\n </DouDropdownItem>\n <DouDropdownItem v-if=\"uneven.length\" @click=\"even\">\n <template #prefix><DistributeHorizontalIcon /></template>\n {{ messages.columns.even }}\n </DouDropdownItem>\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAeA,MAAM,QAAQ;EACd,MAAM,EAAE,MAAM,OAAO,aAAa,UAAU;;EAG5C,MAAM,MAAM,eAAe;GACzB,MAAM,MAAM,MAAM,OAAO;GACzB,IAAI,CAAC,KAAK,OAAO;GACjB,KAAK,IAAI,OAAO,cAAc,KAAK,MAAM,MAAM,EAAE,GAAG,MAAM,OAAO,YAAY,KAAK,IAAI,GACpF,IAAI,SAAS,KAAK,IAAI,MAAM,OAAO,OAAO;GAC5C,OAAO;EACT,CAAC;;EAGD,MAAM,SAAS,eA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CADyDC,gBAAA,MACzDC,gBAAGH,MAAA,QAAA,CAAQ,CAAC,QAAQ,IAAI,GAAA,CAAA,C"}
@@ -3,6 +3,7 @@ import { align } from "./align/index.js";
3
3
  import { callout } from "./callout/index.js";
4
4
  import { colors } from "./colors/index.js";
5
5
  import { codeBlock } from "./code-block/index.js";
6
+ import { columns } from "./columns/index.js";
6
7
  import { formatting, link } from "./formatting.js";
7
8
  import { lists } from "./lists.js";
8
9
  import { table } from "./table/index.js";
@@ -23,6 +24,7 @@ function editorKit(options = {}) {
23
24
  toggle,
24
25
  callout,
25
26
  table,
27
+ columns,
26
28
  formatting,
27
29
  link,
28
30
  colors,
@@ -30,6 +32,6 @@ function editorKit(options = {}) {
30
32
  };
31
33
  return [paragraph, ...Object.entries(parts).filter(([name]) => options[name] !== false).map(([, extension]) => extension)];
32
34
  }
33
- export { align, callout, codeBlock, colors, divider, editorKit, formatting, heading, link, lists, paragraph, quote, table, toggle };
35
+ export { align, callout, codeBlock, colors, columns, divider, editorKit, formatting, heading, link, lists, paragraph, quote, table, toggle };
34
36
 
35
37
  //# sourceMappingURL=editor-kit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-kit.js","names":[],"sources":["../../src/extensions/editor-kit.ts"],"sourcesContent":["import type { EditorExtension } from '../core/extension'\nimport { divider, heading, paragraph, quote } from './blocks'\nimport { align } from './align'\nimport { callout } from './callout'\nimport { colors } from './colors'\nimport { codeBlock, type CodeBlockOptions } from './code-block'\nimport { formatting, link } from './formatting'\nimport { lists } from './lists'\nimport { table } from './table'\nimport { toggle } from './toggle'\n\nexport interface EditorKitOptions {\n heading?: boolean\n lists?: boolean\n quote?: boolean\n /**\n * Options for the code block, e.g. its highlighter, or `false` to leave\n * it out. Another code block extension takes its place, e.g.\n * `codeEditorBlock()` from `@dou-ui/editor/code`.\n */\n codeBlock?: boolean | CodeBlockOptions | EditorExtension\n divider?: boolean\n toggle?: boolean\n callout?: boolean\n table?: boolean\n formatting?: boolean\n link?: boolean\n /** Text and background colors. */\n colors?: boolean\n /** Aligning paragraphs, headings and quotes. */\n align?: boolean\n}\n\n/**\n * The built-in blocks and formatting. Pass `false` for any part to leave\n * it out, e.g. `editorKit({ codeBlock: false })`.\n */\nexport function editorKit(options: EditorKitOptions = {}): EditorExtension[] {\n const code = options.codeBlock\n const parts = {\n heading,\n lists,\n quote,\n codeBlock:\n typeof code === 'object' && 'name' in code\n ? code\n : codeBlock(typeof code === 'object' ? code : {}),\n divider,\n toggle,\n callout,\n table,\n formatting,\n link,\n colors,\n align,\n }\n return [\n paragraph,\n ...Object.entries(parts)\n .filter(([name]) => options[name as keyof EditorKitOptions] !== false)\n .map(([, extension]) => extension),\n ]\n}\n\nexport {\n align,\n callout,\n colors,\n codeBlock,\n divider,\n formatting,\n heading,\n link,\n lists,\n paragraph,\n quote,\n table,\n toggle,\n}\n"],"mappings":";;;;;;;;;;;;;;AAqCA,SAAgB,UAAU,UAA4B,CAAC,GAAsB;CAC3E,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ;EACZ;EACA;EACA;EACA,WACE,OAAO,SAAS,YAAY,UAAU,OAClC,OACA,UAAU,OAAO,SAAS,WAAW,OAAO,CAAC,CAAC;EACpD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,OAAO,CACL,WACA,GAAG,OAAO,QAAQ,KAAK,CAAC,CACrB,QAAQ,CAAC,UAAU,QAAQ,UAAoC,KAAK,CAAC,CACrE,KAAK,GAAG,eAAe,SAAS,CACrC;AACF"}
1
+ {"version":3,"file":"editor-kit.js","names":[],"sources":["../../src/extensions/editor-kit.ts"],"sourcesContent":["import type { EditorExtension } from '../core/extension'\nimport { divider, heading, paragraph, quote } from './blocks'\nimport { align } from './align'\nimport { callout } from './callout'\nimport { colors } from './colors'\nimport { codeBlock, type CodeBlockOptions } from './code-block'\nimport { columns } from './columns'\nimport { formatting, link } from './formatting'\nimport { lists } from './lists'\nimport { table } from './table'\nimport { toggle } from './toggle'\n\nexport interface EditorKitOptions {\n heading?: boolean\n lists?: boolean\n quote?: boolean\n /**\n * Options for the code block, e.g. its highlighter, or `false` to leave\n * it out. Another code block extension takes its place, e.g.\n * `codeEditorBlock()` from `@dou-ui/editor/code`.\n */\n codeBlock?: boolean | CodeBlockOptions | EditorExtension\n divider?: boolean\n toggle?: boolean\n callout?: boolean\n table?: boolean\n /** Blocks side by side in columns. */\n columns?: boolean\n formatting?: boolean\n link?: boolean\n /** Text and background colors. */\n colors?: boolean\n /** Aligning paragraphs, headings and quotes. */\n align?: boolean\n}\n\n/**\n * The built-in blocks and formatting. Pass `false` for any part to leave\n * it out, e.g. `editorKit({ codeBlock: false })`.\n */\nexport function editorKit(options: EditorKitOptions = {}): EditorExtension[] {\n const code = options.codeBlock\n const parts = {\n heading,\n lists,\n quote,\n codeBlock:\n typeof code === 'object' && 'name' in code\n ? code\n : codeBlock(typeof code === 'object' ? code : {}),\n divider,\n toggle,\n callout,\n table,\n columns,\n formatting,\n link,\n colors,\n align,\n }\n return [\n paragraph,\n ...Object.entries(parts)\n .filter(([name]) => options[name as keyof EditorKitOptions] !== false)\n .map(([, extension]) => extension),\n ]\n}\n\nexport {\n align,\n callout,\n colors,\n codeBlock,\n columns,\n divider,\n formatting,\n heading,\n link,\n lists,\n paragraph,\n quote,\n table,\n toggle,\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,SAAgB,UAAU,UAA4B,CAAC,GAAsB;CAC3E,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ;EACZ;EACA;EACA;EACA,WACE,OAAO,SAAS,YAAY,UAAU,OAClC,OACA,UAAU,OAAO,SAAS,WAAW,OAAO,CAAC,CAAC;EACpD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,OAAO,CACL,WACA,GAAG,OAAO,QAAQ,KAAK,CAAC,CACrB,QAAQ,CAAC,UAAU,QAAQ,UAAoC,KAAK,CAAC,CACrE,KAAK,GAAG,eAAe,SAAS,CACrC;AACF"}
@@ -42,7 +42,7 @@ function convertList(list) {
42
42
  return blocks;
43
43
  }
44
44
  function firstText(item) {
45
- const walker = item.ownerDocument.createTreeWalker(item, NodeFilter.SHOW_TEXT);
45
+ const walker = item.ownerDocument.createTreeWalker(item, 4);
46
46
  for (let node = walker.nextNode(); node; node = walker.nextNode()) if (node.textContent?.trim()) return node;
47
47
  return null;
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"list-html.js","names":[],"sources":["../../src/extensions/list-html.ts"],"sourcesContent":["import { indentLines, type BlockOutputContext } from '../core/output'\nimport { blockElement, splitContainer } from '../core/prepare'\n\nconst TASK = /^\\s*\\[( |x|X)\\]\\s/\n\n/**\n * Lists from other apps nest a list inside an item (`<li>text<ul>…</ul></li>`),\n * but a list item here is a block of text with child blocks. Rewrite them\n * into blocks before parsing, so nesting survives. Task lists\n * (`<li><input type=\"checkbox\">`, or `[ ]` / `[x]` before the text as\n * Markdown writes them) become to-do items.\n */\nexport function prepareLists(root: HTMLElement) {\n const outer = Array.from(root.querySelectorAll('ul, ol')).filter(\n (list) => !list.parentElement?.closest('ul, ol'),\n )\n for (const list of outer) list.replaceWith(...convertList(list))\n}\n\nfunction convertList(list: Element): HTMLElement[] {\n const doc = list.ownerDocument\n const numbered = list.tagName === 'OL'\n const blocks: HTMLElement[] = []\n for (const item of Array.from(list.children)) {\n if (item.tagName !== 'LI') continue\n let type = numbered ? 'numberedItem' : 'bulletItem'\n const data: Record<string, string> = {}\n const checkbox = item.querySelector(\n ':scope > input[type=\"checkbox\"], :scope > p > input[type=\"checkbox\"]',\n )\n if (checkbox) {\n type = 'checkItem'\n data.checked = String(\n (checkbox as HTMLInputElement).checked || checkbox.hasAttribute('checked'),\n )\n checkbox.remove()\n } else {\n const text = firstText(item)\n const match = text && TASK.exec(text.data)\n if (text && match) {\n type = 'checkItem'\n data.checked = String(match[1] !== ' ')\n text.data = text.data.slice(match[0].length)\n }\n }\n // the first paragraph is the item's text; what follows becomes its children\n for (const nested of Array.from(item.children))\n if (nested.tagName === 'UL' || nested.tagName === 'OL')\n nested.replaceWith(...convertList(nested))\n const { content, children } = splitContainer(item)\n blocks.push(blockElement(doc, type, content, children, data))\n }\n return blocks\n}\n\nfunction firstText(item: Element): Text | null {\n const walker = item.ownerDocument.createTreeWalker(item, NodeFilter.SHOW_TEXT)\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n if (node.textContent?.trim()) return node as Text\n }\n return null\n}\n\n/** A list item in Markdown: the marker, the text, and the children indented under it. */\nexport function listItemMarkdown(marker: string, { content, children }: BlockOutputContext) {\n // a checkbox marker indents its children like the bullet in front of it\n const width = marker.startsWith('- [') ? 2 : marker.length\n const item = indentLines(content, marker, ' '.repeat(width))\n if (!children) return item\n // a nested list follows right after; other blocks need a blank line, or they join the text\n const gap = /^([-*+]|\\d+[.)])( |$)/.test(children) ? '\\n' : '\\n\\n'\n return `${item}${gap}${indentLines(children, ' '.repeat(width))}`\n}\n"],"mappings":";;;AAGA,IAAM,OAAO;;;;;;;;AASb,SAAgB,aAAa,MAAmB;CAC9C,MAAM,QAAQ,MAAM,KAAK,KAAK,iBAAiB,QAAQ,CAAC,CAAC,CAAC,QACvD,SAAS,CAAC,KAAK,eAAe,QAAQ,QAAQ,CACjD;CACA,KAAK,MAAM,QAAQ,OAAO,KAAK,YAAY,GAAG,YAAY,IAAI,CAAC;AACjE;AAEA,SAAS,YAAY,MAA8B;CACjD,MAAM,MAAM,KAAK;CACjB,MAAM,WAAW,KAAK,YAAY;CAClC,MAAM,SAAwB,CAAC;CAC/B,KAAK,MAAM,QAAQ,MAAM,KAAK,KAAK,QAAQ,GAAG;EAC5C,IAAI,KAAK,YAAY,MAAM;EAC3B,IAAI,OAAO,WAAW,iBAAiB;EACvC,MAAM,OAA+B,CAAC;EACtC,MAAM,WAAW,KAAK,cACpB,0EACF;EACA,IAAI,UAAU;GACZ,OAAO;GACP,KAAK,UAAU,OACZ,SAA8B,WAAW,SAAS,aAAa,SAAS,CAC3E;GACA,SAAS,OAAO;EAClB,OAAO;GACL,MAAM,OAAO,UAAU,IAAI;GAC3B,MAAM,QAAQ,QAAQ,KAAK,KAAK,KAAK,IAAI;GACzC,IAAI,QAAQ,OAAO;IACjB,OAAO;IACP,KAAK,UAAU,OAAO,MAAM,OAAO,GAAG;IACtC,KAAK,OAAO,KAAK,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM;GAC7C;EACF;EAEA,KAAK,MAAM,UAAU,MAAM,KAAK,KAAK,QAAQ,GAC3C,IAAI,OAAO,YAAY,QAAQ,OAAO,YAAY,MAChD,OAAO,YAAY,GAAG,YAAY,MAAM,CAAC;EAC7C,MAAM,EAAE,SAAS,aAAa,eAAe,IAAI;EACjD,OAAO,KAAK,aAAa,KAAK,MAAM,SAAS,UAAU,IAAI,CAAC;CAC9D;CACA,OAAO;AACT;AAEA,SAAS,UAAU,MAA4B;CAC7C,MAAM,SAAS,KAAK,cAAc,iBAAiB,MAAM,WAAW,SAAS;CAC7E,KAAK,IAAI,OAAO,OAAO,SAAS,GAAG,MAAM,OAAO,OAAO,SAAS,GAC9D,IAAI,KAAK,aAAa,KAAK,GAAG,OAAO;CAEvC,OAAO;AACT;;AAGA,SAAgB,iBAAiB,QAAgB,EAAE,SAAS,YAAgC;CAE1F,MAAM,QAAQ,OAAO,WAAW,KAAK,IAAI,IAAI,OAAO;CACpD,MAAM,OAAO,YAAY,SAAS,QAAQ,IAAI,OAAO,KAAK,CAAC;CAC3D,IAAI,CAAC,UAAU,OAAO;CAGtB,OAAO,GAAG,OADE,wBAAwB,KAAK,QAAQ,IAAI,OAAO,SACrC,YAAY,UAAU,IAAI,OAAO,KAAK,CAAC;AAChE"}
1
+ {"version":3,"file":"list-html.js","names":[],"sources":["../../src/extensions/list-html.ts"],"sourcesContent":["import { indentLines, type BlockOutputContext } from '../core/output'\nimport { blockElement, splitContainer } from '../core/prepare'\n\nconst TASK = /^\\s*\\[( |x|X)\\]\\s/\n\n/**\n * Lists from other apps nest a list inside an item (`<li>text<ul>…</ul></li>`),\n * but a list item here is a block of text with child blocks. Rewrite them\n * into blocks before parsing, so nesting survives. Task lists\n * (`<li><input type=\"checkbox\">`, or `[ ]` / `[x]` before the text as\n * Markdown writes them) become to-do items.\n */\nexport function prepareLists(root: HTMLElement) {\n const outer = Array.from(root.querySelectorAll('ul, ol')).filter(\n (list) => !list.parentElement?.closest('ul, ol'),\n )\n for (const list of outer) list.replaceWith(...convertList(list))\n}\n\nfunction convertList(list: Element): HTMLElement[] {\n const doc = list.ownerDocument\n const numbered = list.tagName === 'OL'\n const blocks: HTMLElement[] = []\n for (const item of Array.from(list.children)) {\n if (item.tagName !== 'LI') continue\n let type = numbered ? 'numberedItem' : 'bulletItem'\n const data: Record<string, string> = {}\n const checkbox = item.querySelector(\n ':scope > input[type=\"checkbox\"], :scope > p > input[type=\"checkbox\"]',\n )\n if (checkbox) {\n type = 'checkItem'\n data.checked = String(\n (checkbox as HTMLInputElement).checked || checkbox.hasAttribute('checked'),\n )\n checkbox.remove()\n } else {\n const text = firstText(item)\n const match = text && TASK.exec(text.data)\n if (text && match) {\n type = 'checkItem'\n data.checked = String(match[1] !== ' ')\n text.data = text.data.slice(match[0].length)\n }\n }\n // the first paragraph is the item's text; what follows becomes its children\n for (const nested of Array.from(item.children))\n if (nested.tagName === 'UL' || nested.tagName === 'OL')\n nested.replaceWith(...convertList(nested))\n const { content, children } = splitContainer(item)\n blocks.push(blockElement(doc, type, content, children, data))\n }\n return blocks\n}\n\nfunction firstText(item: Element): Text | null {\n // NodeFilter.SHOW_TEXT, as a number: the DOM may come from a library, without globals\n const walker = item.ownerDocument.createTreeWalker(item, 4)\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n if (node.textContent?.trim()) return node as Text\n }\n return null\n}\n\n/** A list item in Markdown: the marker, the text, and the children indented under it. */\nexport function listItemMarkdown(marker: string, { content, children }: BlockOutputContext) {\n // a checkbox marker indents its children like the bullet in front of it\n const width = marker.startsWith('- [') ? 2 : marker.length\n const item = indentLines(content, marker, ' '.repeat(width))\n if (!children) return item\n // a nested list follows right after; other blocks need a blank line, or they join the text\n const gap = /^([-*+]|\\d+[.)])( |$)/.test(children) ? '\\n' : '\\n\\n'\n return `${item}${gap}${indentLines(children, ' '.repeat(width))}`\n}\n"],"mappings":";;;AAGA,IAAM,OAAO;;;;;;;;AASb,SAAgB,aAAa,MAAmB;CAC9C,MAAM,QAAQ,MAAM,KAAK,KAAK,iBAAiB,QAAQ,CAAC,CAAC,CAAC,QACvD,SAAS,CAAC,KAAK,eAAe,QAAQ,QAAQ,CACjD;CACA,KAAK,MAAM,QAAQ,OAAO,KAAK,YAAY,GAAG,YAAY,IAAI,CAAC;AACjE;AAEA,SAAS,YAAY,MAA8B;CACjD,MAAM,MAAM,KAAK;CACjB,MAAM,WAAW,KAAK,YAAY;CAClC,MAAM,SAAwB,CAAC;CAC/B,KAAK,MAAM,QAAQ,MAAM,KAAK,KAAK,QAAQ,GAAG;EAC5C,IAAI,KAAK,YAAY,MAAM;EAC3B,IAAI,OAAO,WAAW,iBAAiB;EACvC,MAAM,OAA+B,CAAC;EACtC,MAAM,WAAW,KAAK,cACpB,0EACF;EACA,IAAI,UAAU;GACZ,OAAO;GACP,KAAK,UAAU,OACZ,SAA8B,WAAW,SAAS,aAAa,SAAS,CAC3E;GACA,SAAS,OAAO;EAClB,OAAO;GACL,MAAM,OAAO,UAAU,IAAI;GAC3B,MAAM,QAAQ,QAAQ,KAAK,KAAK,KAAK,IAAI;GACzC,IAAI,QAAQ,OAAO;IACjB,OAAO;IACP,KAAK,UAAU,OAAO,MAAM,OAAO,GAAG;IACtC,KAAK,OAAO,KAAK,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM;GAC7C;EACF;EAEA,KAAK,MAAM,UAAU,MAAM,KAAK,KAAK,QAAQ,GAC3C,IAAI,OAAO,YAAY,QAAQ,OAAO,YAAY,MAChD,OAAO,YAAY,GAAG,YAAY,MAAM,CAAC;EAC7C,MAAM,EAAE,SAAS,aAAa,eAAe,IAAI;E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