@milkdown/preset-gfm 6.5.2 → 6.5.3

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 (94) hide show
  1. package/lib/footnote/definition.d.ts +1 -1
  2. package/lib/footnote/definition.d.ts.map +1 -1
  3. package/lib/footnote/index.d.ts.map +1 -1
  4. package/lib/footnote/reference.d.ts +1 -1
  5. package/lib/footnote/reference.d.ts.map +1 -1
  6. package/lib/footnote/utils.d.ts.map +1 -1
  7. package/lib/index.d.ts +1 -1
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/index.es.js +649 -607
  10. package/lib/index.es.js.map +1 -1
  11. package/lib/strike-through.d.ts +1 -1
  12. package/lib/strike-through.d.ts.map +1 -1
  13. package/lib/supported-keys.d.ts +1 -1
  14. package/lib/supported-keys.d.ts.map +1 -1
  15. package/lib/table/command.d.ts +2 -2
  16. package/lib/table/command.d.ts.map +1 -1
  17. package/lib/table/index.d.ts +1 -1
  18. package/lib/table/index.d.ts.map +1 -1
  19. package/lib/table/nodes/index.d.ts +1 -1
  20. package/lib/table/nodes/index.d.ts.map +1 -1
  21. package/lib/table/operator-plugin/actions.d.ts +5 -5
  22. package/lib/table/operator-plugin/actions.d.ts.map +1 -1
  23. package/lib/table/operator-plugin/calc-pos.d.ts +1 -1
  24. package/lib/table/operator-plugin/calc-pos.d.ts.map +1 -1
  25. package/lib/table/operator-plugin/constant.d.ts.map +1 -1
  26. package/lib/table/operator-plugin/helper.d.ts +3 -3
  27. package/lib/table/operator-plugin/helper.d.ts.map +1 -1
  28. package/lib/table/operator-plugin/index.d.ts +2 -2
  29. package/lib/table/operator-plugin/index.d.ts.map +1 -1
  30. package/lib/table/operator-plugin/style.d.ts +1 -1
  31. package/lib/table/operator-plugin/style.d.ts.map +1 -1
  32. package/lib/table/operator-plugin/widget.d.ts +2 -2
  33. package/lib/table/operator-plugin/widget.d.ts.map +1 -1
  34. package/lib/table/plugin/auto-insert-zero-space.d.ts.map +1 -1
  35. package/lib/table/plugin/cell-selection.d.ts +5 -3
  36. package/lib/table/plugin/cell-selection.d.ts.map +1 -1
  37. package/lib/table/plugin/column-resizing.d.ts +2 -1
  38. package/lib/table/plugin/column-resizing.d.ts.map +1 -1
  39. package/lib/table/plugin/commands.d.ts +2 -2
  40. package/lib/table/plugin/commands.d.ts.map +1 -1
  41. package/lib/table/plugin/copy-paste.d.ts +6 -5
  42. package/lib/table/plugin/copy-paste.d.ts.map +1 -1
  43. package/lib/table/plugin/fix-tables.d.ts +3 -2
  44. package/lib/table/plugin/fix-tables.d.ts.map +1 -1
  45. package/lib/table/plugin/index.d.ts.map +1 -1
  46. package/lib/table/plugin/schema.d.ts +1 -1
  47. package/lib/table/plugin/schema.d.ts.map +1 -1
  48. package/lib/table/plugin/table-editing.d.ts +1 -1
  49. package/lib/table/plugin/table-editing.d.ts.map +1 -1
  50. package/lib/table/plugin/table-map.d.ts +2 -2
  51. package/lib/table/plugin/table-map.d.ts.map +1 -1
  52. package/lib/table/plugin/table-view.d.ts +2 -2
  53. package/lib/table/plugin/table-view.d.ts.map +1 -1
  54. package/lib/table/plugin/types.d.ts +2 -2
  55. package/lib/table/plugin/types.d.ts.map +1 -1
  56. package/lib/table/plugin/util.d.ts +2 -2
  57. package/lib/table/plugin/util.d.ts.map +1 -1
  58. package/lib/table/utils.d.ts +5 -5
  59. package/lib/table/utils.d.ts.map +1 -1
  60. package/lib/task-list-item.d.ts +2 -2
  61. package/lib/task-list-item.d.ts.map +1 -1
  62. package/package.json +17 -17
  63. package/src/footnote/definition.ts +172 -166
  64. package/src/footnote/index.ts +2 -2
  65. package/src/footnote/reference.ts +166 -162
  66. package/src/footnote/utils.ts +2 -2
  67. package/src/index.ts +83 -83
  68. package/src/strike-through.ts +36 -36
  69. package/src/supported-keys.ts +9 -8
  70. package/src/table/command.ts +17 -16
  71. package/src/table/index.ts +9 -9
  72. package/src/table/nodes/index.ts +177 -174
  73. package/src/table/operator-plugin/actions.ts +103 -102
  74. package/src/table/operator-plugin/calc-pos.ts +31 -34
  75. package/src/table/operator-plugin/constant.ts +3 -3
  76. package/src/table/operator-plugin/helper.ts +31 -32
  77. package/src/table/operator-plugin/index.ts +104 -95
  78. package/src/table/operator-plugin/style.ts +10 -9
  79. package/src/table/operator-plugin/widget.ts +47 -45
  80. package/src/table/plugin/auto-insert-zero-space.ts +41 -41
  81. package/src/table/plugin/cell-selection.ts +325 -296
  82. package/src/table/plugin/column-resizing.ts +226 -198
  83. package/src/table/plugin/commands.ts +464 -421
  84. package/src/table/plugin/copy-paste.ts +256 -240
  85. package/src/table/plugin/fix-tables.ts +103 -88
  86. package/src/table/plugin/index.ts +3 -3
  87. package/src/table/plugin/schema.ts +100 -94
  88. package/src/table/plugin/table-editing.ts +324 -230
  89. package/src/table/plugin/table-map.ts +294 -229
  90. package/src/table/plugin/table-view.ts +66 -62
  91. package/src/table/plugin/types.ts +8 -8
  92. package/src/table/plugin/util.ts +78 -66
  93. package/src/table/utils.ts +141 -138
  94. package/src/task-list-item.ts +151 -146
@@ -1,34 +1,39 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
 
3
- import { Node } from '@milkdown/prose/model';
4
- import { EditorState, PluginKey, Transaction } from '@milkdown/prose/state';
3
+ import type { Node } from '@milkdown/prose/model'
4
+ import type { EditorState, Transaction } from '@milkdown/prose/state'
5
+ import { PluginKey } from '@milkdown/prose/state'
5
6
 
6
- import { tableNodeTypes } from './schema';
7
- import { Problem, TableMap } from './table-map';
8
- import { removeColSpan, setAttr } from './util';
7
+ import { tableNodeTypes } from './schema'
8
+ import type { Problem } from './table-map'
9
+ import { TableMap } from './table-map'
10
+ import { removeColSpan, setAttr } from './util'
9
11
 
10
- export const fixTablesKey = new PluginKey('fix-tables');
12
+ export const fixTablesKey = new PluginKey('fix-tables')
11
13
 
12
14
  // Helper for iterating through the nodes in a document that changed
13
15
  // compared to the given previous document. Useful for avoiding
14
16
  // duplicate work on each transaction.
15
17
  function changedDescendants(old: Node, cur: Node, offset: number, f: (node: Node, pos: number) => void | boolean) {
16
- const oldSize = old.childCount,
17
- curSize = cur.childCount;
18
- outer: for (let i = 0, j = 0; i < curSize; i++) {
19
- const child = cur.child(i);
20
- for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {
21
- if (old.child(scan) == child) {
22
- j = scan + 1;
23
- offset += child.nodeSize;
24
- continue outer;
25
- }
26
- }
27
- f(child, offset);
28
- if (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child, offset + 1, f);
29
- else child.nodesBetween(0, child.content.size, f, offset + 1);
30
- offset += child.nodeSize;
18
+ const oldSize = old.childCount
19
+ const curSize = cur.childCount
20
+ // eslint-disable-next-line no-restricted-syntax, no-labels
21
+ outer: for (let i = 0, j = 0; i < curSize; i++) {
22
+ const child = cur.child(i)
23
+ for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {
24
+ if (old.child(scan) == child) {
25
+ j = scan + 1
26
+ offset += child.nodeSize
27
+ // eslint-disable-next-line no-labels
28
+ continue outer
29
+ }
31
30
  }
31
+ f(child, offset)
32
+ if (j < oldSize && old.child(j).sameMarkup(child))
33
+ changedDescendants(old.child(j), child, offset + 1, f)
34
+ else child.nodesBetween(0, child.content.size, f, offset + 1)
35
+ offset += child.nodeSize
36
+ }
32
37
  }
33
38
 
34
39
  // :: (EditorState, ?EditorState) → ?Transaction
@@ -38,80 +43,90 @@ function changedDescendants(old: Node, cur: Node, offset: number, f: (node: Node
38
43
  // which will be used to avoid re-scanning unchanged parts of the
39
44
  // document.
40
45
  export function fixTables(state: EditorState, oldState: EditorState) {
41
- let tr: undefined | Transaction;
42
- const check = (node: Node, pos: number) => {
43
- if (node.type.spec['tableRole'] == 'table') tr = fixTable(state, node, pos, tr);
44
- };
45
- if (!oldState) state.doc.descendants(check);
46
- else if (oldState.doc != state.doc) changedDescendants(oldState.doc, state.doc, 0, check);
47
- return tr;
46
+ let tr: undefined | Transaction
47
+ const check = (node: Node, pos: number) => {
48
+ if (node.type.spec.tableRole == 'table')
49
+ tr = fixTable(state, node, pos, tr)
50
+ }
51
+ if (!oldState)
52
+ state.doc.descendants(check)
53
+ else if (oldState.doc != state.doc)
54
+ changedDescendants(oldState.doc, state.doc, 0, check)
55
+ return tr
48
56
  }
49
57
 
50
58
  // : (EditorState, Node, number, ?Transaction) → ?Transaction
51
59
  // Fix the given table, if necessary. Will append to the transaction
52
60
  // it was given, if non-null, or create a new one if necessary.
53
61
  export function fixTable(state: EditorState, table: Node, tablePos: number, tr?: Transaction) {
54
- const map = TableMap.get(table);
55
- if (!map.problems) return tr;
56
- if (!tr) tr = state.tr;
62
+ const map = TableMap.get(table)
63
+ if (!map.problems)
64
+ return tr
65
+ if (!tr)
66
+ tr = state.tr
57
67
 
58
- // Track which rows we must add cells to, so that we can adjust that
59
- // when fixing collisions.
60
- const mustAdd = [];
61
- for (let i = 0; i < map.height; i++) mustAdd.push(0);
62
- for (let i = 0; i < map.problems.length; i++) {
63
- const prob = map.problems[i] as Problem;
64
- if (prob.type == 'collision') {
65
- const cell = table.nodeAt(prob.pos) as Node;
66
- for (let j = 0; j < cell.attrs['rowspan']; j++) mustAdd[prob.row + j] += prob.n;
67
- tr.setNodeMarkup(
68
- tr.mapping.map(tablePos + 1 + prob.pos),
69
- null,
70
- removeColSpan(cell.attrs, cell.attrs['colspan'] - prob.n, prob.n),
71
- );
72
- } else if (prob.type == 'missing') {
73
- mustAdd[prob.row] += prob.n;
74
- } else if (prob.type == 'overlong_rowspan') {
75
- const cell = table.nodeAt(prob.pos) as Node;
76
- tr.setNodeMarkup(
77
- tr.mapping.map(tablePos + 1 + prob.pos),
78
- null,
79
- setAttr(cell.attrs, 'rowspan', cell.attrs['rowspan'] - prob.n),
80
- );
81
- } else if (prob.type == 'colwidth mismatch') {
82
- const cell = table.nodeAt(prob.pos) as Node;
83
- tr.setNodeMarkup(
84
- tr.mapping.map(tablePos + 1 + prob.pos),
85
- null,
86
- setAttr(cell.attrs, 'colwidth', prob.colwidth),
87
- );
88
- }
68
+ // Track which rows we must add cells to, so that we can adjust that
69
+ // when fixing collisions.
70
+ const mustAdd = []
71
+ for (let i = 0; i < map.height; i++) mustAdd.push(0)
72
+ for (let i = 0; i < map.problems.length; i++) {
73
+ const prob = map.problems[i] as Problem
74
+ if (prob.type == 'collision') {
75
+ const cell = table.nodeAt(prob.pos) as Node
76
+ for (let j = 0; j < cell.attrs.rowspan; j++) mustAdd[prob.row + j] += prob.n
77
+ tr.setNodeMarkup(
78
+ tr.mapping.map(tablePos + 1 + prob.pos),
79
+ null,
80
+ removeColSpan(cell.attrs, cell.attrs.colspan - prob.n, prob.n),
81
+ )
89
82
  }
90
- let first, last;
91
- for (let i = 0; i < mustAdd.length; i++)
92
- if (mustAdd[i]) {
93
- if (first == null) first = i;
94
- last = i;
95
- }
96
- // Add the necessary cells, using a heuristic for whether to add the
97
- // cells at the start or end of the rows (if it looks like a 'bite'
98
- // was taken out of the table, add cells at the start of the row
99
- // after the bite. Otherwise add them at the end).
100
- for (let i = 0, pos = tablePos + 1; i < map.height; i++) {
101
- const row = table.child(i);
102
- const end = pos + row.nodeSize;
103
- const add = mustAdd[i] as number;
104
- if (add > 0) {
105
- let tableNodeType = 'cell';
106
- if (row.firstChild) {
107
- tableNodeType = row.firstChild.type.spec['tableRole'];
108
- }
109
- const nodes = [];
110
- for (let j = 0; j < add; j++) nodes.push(tableNodeTypes(state.schema)[tableNodeType].createAndFill());
111
- const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;
112
- tr.insert(tr.mapping.map(side), nodes);
113
- }
114
- pos = end;
83
+ else if (prob.type == 'missing') {
84
+ mustAdd[prob.row] += prob.n
115
85
  }
116
- return tr.setMeta(fixTablesKey, { fixTables: true });
86
+ else if (prob.type == 'overlong_rowspan') {
87
+ const cell = table.nodeAt(prob.pos) as Node
88
+ tr.setNodeMarkup(
89
+ tr.mapping.map(tablePos + 1 + prob.pos),
90
+ null,
91
+ setAttr(cell.attrs, 'rowspan', cell.attrs.rowspan - prob.n),
92
+ )
93
+ }
94
+ else if (prob.type == 'colwidth mismatch') {
95
+ const cell = table.nodeAt(prob.pos) as Node
96
+ tr.setNodeMarkup(
97
+ tr.mapping.map(tablePos + 1 + prob.pos),
98
+ null,
99
+ setAttr(cell.attrs, 'colwidth', prob.colwidth),
100
+ )
101
+ }
102
+ }
103
+ let first, last
104
+ for (let i = 0; i < mustAdd.length; i++) {
105
+ if (mustAdd[i]) {
106
+ if (first == null)
107
+ first = i
108
+ last = i
109
+ }
110
+ }
111
+ // Add the necessary cells, using a heuristic for whether to add the
112
+ // cells at the start or end of the rows (if it looks like a 'bite'
113
+ // was taken out of the table, add cells at the start of the row
114
+ // after the bite. Otherwise add them at the end).
115
+ for (let i = 0, pos = tablePos + 1; i < map.height; i++) {
116
+ const row = table.child(i)
117
+ const end = pos + row.nodeSize
118
+ const add = mustAdd[i] as number
119
+ if (add > 0) {
120
+ let tableNodeType = 'cell'
121
+ if (row.firstChild)
122
+ tableNodeType = row.firstChild.type.spec.tableRole
123
+
124
+ const nodes = []
125
+ for (let j = 0; j < add; j++) nodes.push(tableNodeTypes(state.schema)[tableNodeType].createAndFill())
126
+ const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1
127
+ tr.insert(tr.mapping.map(side), nodes)
128
+ }
129
+ pos = end
130
+ }
131
+ return tr.setMeta(fixTablesKey, { fixTables: true })
117
132
  }
@@ -1,4 +1,4 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
- export * from './cell-selection';
3
- export * from './commands';
4
- export * from './util';
2
+ export * from './cell-selection'
3
+ export * from './commands'
4
+ export * from './util'
@@ -1,114 +1,120 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
- import { Attrs, Node, NodeSpec, Schema } from '@milkdown/prose/model';
2
+ import type { Attrs, Node, NodeSpec, Schema } from '@milkdown/prose/model'
3
3
 
4
- import { TableNodesOptions } from './types';
4
+ import type { TableNodesOptions } from './types'
5
5
 
6
6
  function getCellAttrs(dom: HTMLElement, extraAttrs: Attrs) {
7
- const widthAttr = dom.getAttribute('data-colwidth');
8
- const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(',').map((s) => Number(s)) : null;
9
- const colspan = Number(dom.getAttribute('colspan') || 1);
10
- const result = {
11
- colspan,
12
- rowspan: Number(dom.getAttribute('rowspan') || 1),
13
- colwidth: widths && widths.length == colspan ? widths : null,
14
- };
15
- for (const prop in extraAttrs) {
16
- const getter = extraAttrs[prop].getFromDOM;
17
- const value = getter && getter(dom);
18
- if (value != null) result[prop as keyof typeof result] = value;
19
- }
20
- return result;
7
+ const widthAttr = dom.getAttribute('data-colwidth')
8
+ const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(',').map(s => Number(s)) : null
9
+ const colspan = Number(dom.getAttribute('colspan') || 1)
10
+ const result = {
11
+ colspan,
12
+ rowspan: Number(dom.getAttribute('rowspan') || 1),
13
+ colwidth: widths && widths.length == colspan ? widths : null,
14
+ }
15
+ for (const prop in extraAttrs) {
16
+ const getter = extraAttrs[prop].getFromDOM
17
+ const value = getter && getter(dom)
18
+ if (value != null)
19
+ result[prop as keyof typeof result] = value
20
+ }
21
+ return result
21
22
  }
22
23
 
23
24
  function setCellAttrs(node: Node, extraAttrs: Attrs) {
24
- const attrs: Record<string, unknown> = {};
25
- if (node.attrs['colspan'] != 1) attrs['colspan'] = node.attrs['colspan'];
26
- if (node.attrs['rowspan'] != 1) attrs['rowspan'] = node.attrs['rowspan'];
27
- if (node.attrs['colwidth']) attrs['data-colwidth'] = node.attrs['colwidth'].join(',');
28
- for (const prop in extraAttrs) {
29
- const setter = extraAttrs[prop].setDOMAttr;
30
- if (setter) setter(node.attrs[prop], attrs);
31
- }
32
- return attrs;
25
+ const attrs: Record<string, unknown> = {}
26
+ if (node.attrs.colspan != 1)
27
+ attrs.colspan = node.attrs.colspan
28
+ if (node.attrs.rowspan != 1)
29
+ attrs.rowspan = node.attrs.rowspan
30
+ if (node.attrs.colwidth)
31
+ attrs['data-colwidth'] = node.attrs.colwidth.join(',')
32
+ for (const prop in extraAttrs) {
33
+ const setter = extraAttrs[prop].setDOMAttr
34
+ if (setter)
35
+ setter(node.attrs[prop], attrs)
36
+ }
37
+ return attrs
33
38
  }
34
39
 
35
40
  function tableNodesSpecCreator(options: TableNodesOptions) {
36
- const extraAttrs: Attrs = options.cellAttributes || {};
37
- const cellAttrs: Record<string, unknown> = {
38
- colspan: { default: 1 },
39
- rowspan: { default: 1 },
40
- colwidth: { default: null },
41
- };
42
- for (const prop in extraAttrs) cellAttrs[prop] = { default: extraAttrs[prop].default };
43
- const finalAttrs = cellAttrs as Attrs;
41
+ const extraAttrs: Attrs = options.cellAttributes || {}
42
+ const cellAttrs: Record<string, unknown> = {
43
+ colspan: { default: 1 },
44
+ rowspan: { default: 1 },
45
+ colwidth: { default: null },
46
+ }
47
+ for (const prop in extraAttrs) cellAttrs[prop] = { default: extraAttrs[prop].default }
48
+ const finalAttrs = cellAttrs as Attrs
44
49
 
45
- const schema: Record<'table' | 'table_row' | 'table_cell' | 'table_header', NodeSpec> = {
46
- table: {
47
- content: 'table_row+',
48
- tableRole: 'table',
49
- isolating: true,
50
- group: options.tableGroup,
51
- parseDOM: [{ tag: 'table' }],
52
- toDOM() {
53
- return ['table', ['tbody', 0]];
54
- },
55
- },
56
- table_row: {
57
- content: '(table_cell | table_header)*',
58
- tableRole: 'row',
59
- parseDOM: [{ tag: 'tr' }],
60
- toDOM() {
61
- return ['tr', 0];
62
- },
63
- },
64
- table_cell: {
65
- content: options.cellContent,
66
- attrs: finalAttrs,
67
- tableRole: 'cell',
68
- isolating: true,
69
- parseDOM: [{ tag: 'td', getAttrs: (dom) => getCellAttrs(dom as HTMLElement, extraAttrs) }],
70
- toDOM(node) {
71
- return ['td', setCellAttrs(node, extraAttrs), 0];
72
- },
73
- },
74
- table_header: {
75
- content: options.cellContent,
76
- attrs: finalAttrs,
77
- tableRole: 'header_cell',
78
- isolating: true,
79
- parseDOM: [{ tag: 'th', getAttrs: (dom) => getCellAttrs(dom as HTMLElement, extraAttrs) }],
80
- toDOM(node) {
81
- return ['th', setCellAttrs(node, extraAttrs), 0];
82
- },
83
- },
84
- };
50
+ const schema: Record<'table' | 'table_row' | 'table_cell' | 'table_header', NodeSpec> = {
51
+ table: {
52
+ content: 'table_row+',
53
+ tableRole: 'table',
54
+ isolating: true,
55
+ group: options.tableGroup,
56
+ parseDOM: [{ tag: 'table' }],
57
+ toDOM() {
58
+ return ['table', ['tbody', 0]]
59
+ },
60
+ },
61
+ table_row: {
62
+ content: '(table_cell | table_header)*',
63
+ tableRole: 'row',
64
+ parseDOM: [{ tag: 'tr' }],
65
+ toDOM() {
66
+ return ['tr', 0]
67
+ },
68
+ },
69
+ table_cell: {
70
+ content: options.cellContent,
71
+ attrs: finalAttrs,
72
+ tableRole: 'cell',
73
+ isolating: true,
74
+ parseDOM: [{ tag: 'td', getAttrs: dom => getCellAttrs(dom as HTMLElement, extraAttrs) }],
75
+ toDOM(node) {
76
+ return ['td', setCellAttrs(node, extraAttrs), 0]
77
+ },
78
+ },
79
+ table_header: {
80
+ content: options.cellContent,
81
+ attrs: finalAttrs,
82
+ tableRole: 'header_cell',
83
+ isolating: true,
84
+ parseDOM: [{ tag: 'th', getAttrs: dom => getCellAttrs(dom as HTMLElement, extraAttrs) }],
85
+ toDOM(node) {
86
+ return ['th', setCellAttrs(node, extraAttrs), 0]
87
+ },
88
+ },
89
+ }
85
90
 
86
- return schema;
91
+ return schema
87
92
  }
88
93
 
89
94
  export function tableNodeTypes(schema: Schema) {
90
- let result = schema.cached['tableNodeTypes'];
91
- if (!result) {
92
- result = schema.cached['tableNodeTypes'] = {};
93
- for (const name in schema.nodes) {
94
- const type = schema.nodes[name],
95
- role = type?.spec['tableRole'];
96
- if (role) result[role] = type;
97
- }
95
+ let result = schema.cached.tableNodeTypes
96
+ if (!result) {
97
+ result = schema.cached.tableNodeTypes = {}
98
+ for (const name in schema.nodes) {
99
+ const type = schema.nodes[name]
100
+ const role = type?.spec.tableRole
101
+ if (role)
102
+ result[role] = type
98
103
  }
99
- return result;
104
+ }
105
+ return result
100
106
  }
101
107
 
102
108
  export const schema = tableNodesSpecCreator({
103
- tableGroup: 'block',
104
- cellContent: 'paragraph',
105
- cellAttributes: {
106
- alignment: {
107
- default: 'left',
108
- getFromDOM: (dom) => (dom as HTMLElement).style.textAlign || 'left',
109
- setDOMAttr: (value, attrs) => {
110
- attrs['style'] = `text-align: ${value || 'left'}`;
111
- },
112
- },
109
+ tableGroup: 'block',
110
+ cellContent: 'paragraph',
111
+ cellAttributes: {
112
+ alignment: {
113
+ default: 'left',
114
+ getFromDOM: dom => (dom as HTMLElement).style.textAlign || 'left',
115
+ setDOMAttr: (value, attrs) => {
116
+ attrs.style = `text-align: ${value || 'left'}`
117
+ },
113
118
  },
114
- });
119
+ },
120
+ })