@openleaf-editor/plugins-table 0.1.0-beta.0 → 0.1.0-beta.2

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.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Table commands that are not already in `prosemirror-tables`.
3
+ *
4
+ * Property edits, caption/colgroup, nested insert and vertical alignment live
5
+ * here so a test can apply them without standing up a toolbar.
6
+ */
7
+ import type { Node, ResolvedPos } from 'prosemirror-model';
8
+ import type { Command, EditorState } from 'prosemirror-state';
9
+ import { Plugin } from 'prosemirror-state';
10
+ export declare function inTable(state: EditorState): boolean;
11
+ export declare function findRole($pos: ResolvedPos, role: 'table' | 'row' | 'cell' | 'header_cell'): {
12
+ node: Node;
13
+ pos: number;
14
+ depth: number;
15
+ } | null;
16
+ export declare function findTable($pos: ResolvedPos): {
17
+ node: Node;
18
+ pos: number;
19
+ depth: number;
20
+ } | null;
21
+ export declare function findRow($pos: ResolvedPos): {
22
+ node: Node;
23
+ pos: number;
24
+ depth: number;
25
+ } | null;
26
+ export declare function findCell($pos: ResolvedPos): {
27
+ node: Node;
28
+ pos: number;
29
+ depth: number;
30
+ } | null;
31
+ export declare function insertTable(rows?: number, cols?: number): Command;
32
+ export declare function withCellScope(command: Command): Command;
33
+ export declare const addColumnAfter: Command;
34
+ export declare const addColumnBefore: Command;
35
+ export declare const addRowAfter: Command;
36
+ export declare const addRowBefore: Command;
37
+ export declare const toggleHeaderRow: Command;
38
+ export declare function selectedCellPositions(state: EditorState): number[];
39
+ /**
40
+ * Patch declarations onto a style attribute, validating every value written.
41
+ *
42
+ * The validation is here rather than in each caller because this is the choke
43
+ * point: a value reaches the stored style attribute only through this function,
44
+ * and `serializeDeclarations` joins on `;`, so an unchecked value carrying one
45
+ * becomes extra declarations. `padding: 0;position:fixed;inset:0` is a
46
+ * page-covering overlay, written from a property dialog and saved.
47
+ *
48
+ * `safeTableStyleValue` is core's own parse-path validator, so a dialog cannot
49
+ * disagree with the schema about what an acceptable value is.
50
+ */
51
+ export declare function mergeStyle(existing: string | null | undefined, patch: Record<string, string | null>): string | null;
52
+ /** A style value the schema will keep, or null. For a dialog's commit step. */
53
+ export declare function styleValueOrNull(property: string, value: string | undefined): string | null;
54
+ export declare function setTableAttrs(attrs: Record<string, unknown>): Command;
55
+ export declare function setRowAttrs(attrs: Record<string, unknown>): Command;
56
+ export declare function setCellAttrs(attrs: Record<string, unknown>): Command;
57
+ export declare function setCellVerticalAlign(value: string | null): Command;
58
+ export declare function captionTextFromHtml(html: string | null | undefined): string;
59
+ export declare function captionHtmlFromText(text: string, previous: string | null | undefined): string | null;
60
+ export declare function setTableCaption(text: string): Command;
61
+ export declare function colgroupHtmlFromWidths(widths: Array<string | null | undefined>): string | null;
62
+ /**
63
+ * Column widths, one per column.
64
+ *
65
+ * `span` is honoured: `<col span="2" width="120">` sets two columns to 120, not
66
+ * one. Reading the elements positionally would report the second column as
67
+ * having no width, and then saving would write that back.
68
+ */
69
+ export declare function widthsFromColgroup(html: string | null | undefined, columns: number): string[];
70
+ /**
71
+ * Write widths into an existing colgroup rather than replacing it.
72
+ *
73
+ * Inherited markup carries more than widths -- `<colgroup class="layout">`,
74
+ * `<col span="2">`, whatever else a previous CMS wrote -- and the table
75
+ * properties dialog saves the whole table, so rebuilding the colgroup from
76
+ * widths alone dropped all of it on a save that changed nothing else.
77
+ *
78
+ * An unchanged set of widths returns the stored markup untouched, so saving the
79
+ * dialog is genuinely a no-op. When a width does change, the existing elements
80
+ * are patched: a spanned `<col>` keeps its span while its columns still agree,
81
+ * and is split into one `<col>` per column -- carrying its other attributes --
82
+ * only when they no longer do.
83
+ */
84
+ export declare function colgroupHtmlWithWidths(existing: string | null | undefined, widths: Array<string | null | undefined>): string | null;
85
+ export declare function setTableColgroup(widths: Array<string | null | undefined>): Command;
86
+ /**
87
+ * Keep `<colgroup>` in lockstep with column resizing.
88
+ *
89
+ * `prosemirror-tables` writes `colwidth` onto cells. That is enough for the
90
+ * editor; it is not enough for stored HTML, whose column widths live on
91
+ * `<col>`. Updating the furniture attribute after a resize is what makes
92
+ * colgroup a first-class editing feature rather than a round-trip souvenir.
93
+ *
94
+ * Authored colgroups that are not the product of a resize are left alone:
95
+ * inventing `<col>` elements for a table that never had widths would change
96
+ * markup we had no reason to touch.
97
+ */
98
+ export declare function colgroupSyncPlugin(): Plugin;
99
+ export declare function emptyToNull(value: string | undefined): string | null;
100
+ export declare function colorOrNull(value: string | undefined): string | null;
101
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAiB,MAAM,mBAAmB,CAAA;AAWzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAEnD;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,aAAa,GAC7C;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUnD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW;UAZhC,IAAI;SAAO,MAAM;WAAS,MAAM;SAc1C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW;UAhB9B,IAAI;SAAO,MAAM;WAAS,MAAM;SAkB1C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW;UApB/B,IAAI;SAAO,MAAM;WAAS,MAAM;SAsB1C;AAED,wBAAgB,WAAW,CAAC,IAAI,SAAI,EAAE,IAAI,SAA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G;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOrD;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,CAa9F;AAmBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAa7F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACvC,MAAM,GAAG,IAAI,CAyCf;AAOD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAElF;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAiB3C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGpE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGpE"}
@@ -0,0 +1,445 @@
1
+ /**
2
+ * Table commands that are not already in `prosemirror-tables`.
3
+ *
4
+ * Property edits, caption/colgroup, nested insert and vertical alignment live
5
+ * here so a test can apply them without standing up a toolbar.
6
+ */
7
+ import { canInsert, isNodeActive, parseDeclarations, safeColor, safeTableStyleValue, serializeDeclarations, } from '@openleaf-editor/core';
8
+ import { Plugin, TextSelection } from 'prosemirror-state';
9
+ import { addColumnAfter as addColumnAfterRaw, addColumnBefore as addColumnBeforeRaw, addRowAfter as addRowAfterRaw, addRowBefore as addRowBeforeRaw, CellSelection, TableMap, toggleHeaderRow as toggleHeaderRowRaw, } from 'prosemirror-tables';
10
+ export function inTable(state) {
11
+ return isNodeActive(state, 'table');
12
+ }
13
+ export function findRole($pos, role) {
14
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
15
+ const node = $pos.node(depth);
16
+ const found = node.type.spec['tableRole'];
17
+ if (role === 'cell') {
18
+ if (found !== 'cell' && found !== 'header_cell')
19
+ continue;
20
+ }
21
+ else if (found !== role)
22
+ continue;
23
+ return { node, pos: $pos.before(depth), depth };
24
+ }
25
+ return null;
26
+ }
27
+ export function findTable($pos) {
28
+ return findRole($pos, 'table');
29
+ }
30
+ export function findRow($pos) {
31
+ return findRole($pos, 'row');
32
+ }
33
+ export function findCell($pos) {
34
+ return findRole($pos, 'cell');
35
+ }
36
+ export function insertTable(rows = 3, cols = 3) {
37
+ return (state, dispatch) => {
38
+ if (!canInsert(state, 'table'))
39
+ return false;
40
+ if (dispatch) {
41
+ const cell = state.schema.nodes['table_cell'];
42
+ const header = state.schema.nodes['table_header'];
43
+ const row = state.schema.nodes['table_row'];
44
+ const tableType = state.schema.nodes['table'];
45
+ if (!cell || !header || !row || !tableType)
46
+ return false;
47
+ const headerCells = Array.from({ length: cols }, () => header.createAndFill({ scope: 'col' })).filter((n) => n !== null);
48
+ const bodyRows = Array.from({ length: Math.max(0, rows - 1) }, () => row.create(null, Array.from({ length: cols }, () => cell.createAndFill()).filter((n) => n !== null)));
49
+ const table = tableType.create(null, [row.create(null, headerCells), ...bodyRows]);
50
+ dispatch(state.tr.replaceSelectionWith(table).scrollIntoView());
51
+ }
52
+ return true;
53
+ };
54
+ }
55
+ /**
56
+ * Rewrite header cell `scope` for the table the selection is in.
57
+ *
58
+ * The selection is captured and restored around the rewrite. Every change here
59
+ * is a `setNodeMarkup`, which replaces the cell node, and mapping a text
60
+ * selection through a replacement can drag it to the node boundary. The symptom
61
+ * was not a broken caret but a broken command: inserting a row moved the caret
62
+ * out of the cell the author was editing, so the next table command found no
63
+ * cell and did nothing at all.
64
+ */
65
+ function applyCellScope(tr) {
66
+ const header = tr.doc.type.schema.nodes['table_header'];
67
+ const cell = tr.doc.type.schema.nodes['table_cell'];
68
+ if (!header || !cell)
69
+ return tr;
70
+ let tablePos = -1;
71
+ for (let depth = tr.selection.$from.depth; depth > 0; depth -= 1) {
72
+ if (tr.selection.$from.node(depth).type.spec['tableRole'] === 'table') {
73
+ tablePos = tr.selection.$from.before(depth);
74
+ break;
75
+ }
76
+ }
77
+ if (tablePos < 0)
78
+ return tr;
79
+ const table = tr.doc.nodeAt(tablePos);
80
+ if (!table)
81
+ return tr;
82
+ // Only a plain text selection needs restoring: CellSelection maps itself and
83
+ // stays a CellSelection, which is what multi-cell commands act on.
84
+ const restore = tr.selection instanceof TextSelection ? tr.selection.from : null;
85
+ const stepsBefore = tr.steps.length;
86
+ table.forEach((row, rowOffset, rowIndex) => {
87
+ const rowPos = tablePos + 1 + rowOffset;
88
+ row.forEach((cellNode, cellOffset, cellIndex) => {
89
+ const pos = rowPos + 1 + cellOffset;
90
+ if (cellNode.type === cell && cellNode.attrs['scope']) {
91
+ tr.setNodeMarkup(pos, undefined, { ...cellNode.attrs, scope: null });
92
+ return;
93
+ }
94
+ if (cellNode.type !== header)
95
+ return;
96
+ const scope = cellNode.attrs['scope'];
97
+ if (scope !== null && scope !== undefined && scope !== '')
98
+ return;
99
+ tr.setNodeMarkup(pos, undefined, {
100
+ ...cellNode.attrs,
101
+ scope: rowIndex === 0 || cellIndex > 0 ? 'col' : 'row',
102
+ });
103
+ });
104
+ });
105
+ // Mapped through only the steps this pass added, so the caret lands where it
106
+ // was rather than where the last replacement pushed it.
107
+ if (restore !== null && tr.steps.length > stepsBefore) {
108
+ const at = tr.mapping.slice(stepsBefore).map(restore);
109
+ tr.setSelection(TextSelection.near(tr.doc.resolve(at)));
110
+ }
111
+ return tr;
112
+ }
113
+ export function withCellScope(command) {
114
+ return (state, dispatch, view) => {
115
+ if (!dispatch)
116
+ return command(state, undefined, view);
117
+ return command(state, (tr) => {
118
+ dispatch(applyCellScope(tr));
119
+ }, view);
120
+ };
121
+ }
122
+ export const addColumnAfter = withCellScope(addColumnAfterRaw);
123
+ export const addColumnBefore = withCellScope(addColumnBeforeRaw);
124
+ export const addRowAfter = withCellScope(addRowAfterRaw);
125
+ export const addRowBefore = withCellScope(addRowBeforeRaw);
126
+ export const toggleHeaderRow = withCellScope(toggleHeaderRowRaw);
127
+ export function selectedCellPositions(state) {
128
+ const { selection } = state;
129
+ if (selection instanceof CellSelection) {
130
+ const positions = [];
131
+ selection.forEachCell((_node, pos) => {
132
+ positions.push(pos);
133
+ });
134
+ return positions;
135
+ }
136
+ const cell = findCell(selection.$from);
137
+ return cell ? [cell.pos] : [];
138
+ }
139
+ /**
140
+ * Patch declarations onto a style attribute, validating every value written.
141
+ *
142
+ * The validation is here rather than in each caller because this is the choke
143
+ * point: a value reaches the stored style attribute only through this function,
144
+ * and `serializeDeclarations` joins on `;`, so an unchecked value carrying one
145
+ * becomes extra declarations. `padding: 0;position:fixed;inset:0` is a
146
+ * page-covering overlay, written from a property dialog and saved.
147
+ *
148
+ * `safeTableStyleValue` is core's own parse-path validator, so a dialog cannot
149
+ * disagree with the schema about what an acceptable value is.
150
+ */
151
+ export function mergeStyle(existing, patch) {
152
+ const declarations = parseDeclarations(existing);
153
+ for (const [name, value] of Object.entries(patch)) {
154
+ const safe = value ? safeTableStyleValue(name, value) : null;
155
+ if (!safe)
156
+ declarations.delete(name);
157
+ else
158
+ declarations.set(name, safe);
159
+ }
160
+ return serializeDeclarations(declarations);
161
+ }
162
+ /** A style value the schema will keep, or null. For a dialog's commit step. */
163
+ export function styleValueOrNull(property, value) {
164
+ const trimmed = emptyToNull(value);
165
+ return trimmed ? safeTableStyleValue(property, trimmed) : null;
166
+ }
167
+ export function setTableAttrs(attrs) {
168
+ return (state, dispatch) => {
169
+ const table = findTable(state.selection.$from);
170
+ if (!table)
171
+ return false;
172
+ if (dispatch) {
173
+ dispatch(state.tr.setNodeMarkup(table.pos, undefined, { ...table.node.attrs, ...attrs }));
174
+ }
175
+ return true;
176
+ };
177
+ }
178
+ export function setRowAttrs(attrs) {
179
+ return (state, dispatch) => {
180
+ const row = findRow(state.selection.$from);
181
+ if (!row)
182
+ return false;
183
+ if (dispatch) {
184
+ dispatch(state.tr.setNodeMarkup(row.pos, undefined, { ...row.node.attrs, ...attrs }));
185
+ }
186
+ return true;
187
+ };
188
+ }
189
+ export function setCellAttrs(attrs) {
190
+ return (state, dispatch) => {
191
+ const positions = selectedCellPositions(state);
192
+ if (positions.length === 0)
193
+ return false;
194
+ if (dispatch) {
195
+ const tr = state.tr;
196
+ for (const pos of positions) {
197
+ const node = tr.doc.nodeAt(pos);
198
+ if (!node)
199
+ continue;
200
+ const next = { ...node.attrs, ...attrs };
201
+ tr.setNodeMarkup(pos, undefined, next);
202
+ }
203
+ dispatch(tr);
204
+ }
205
+ return true;
206
+ };
207
+ }
208
+ export function setCellVerticalAlign(value) {
209
+ return setCellAttrs({ valign: value });
210
+ }
211
+ export function captionTextFromHtml(html) {
212
+ if (!html || typeof document === 'undefined')
213
+ return html?.replace(/<[^>]+>/g, '') ?? '';
214
+ const tpl = document.createElement('template');
215
+ tpl.innerHTML = html;
216
+ return tpl.content.querySelector('caption')?.textContent ?? '';
217
+ }
218
+ export function captionHtmlFromText(text, previous) {
219
+ const trimmed = text.trim();
220
+ if (!trimmed)
221
+ return null;
222
+ if (previous && captionTextFromHtml(previous) === trimmed)
223
+ return previous;
224
+ if (typeof document === 'undefined') {
225
+ return `<caption>${escapeText(trimmed)}</caption>`;
226
+ }
227
+ const caption = document.createElement('caption');
228
+ caption.textContent = trimmed;
229
+ return caption.outerHTML;
230
+ }
231
+ export function setTableCaption(text) {
232
+ return (state, dispatch) => {
233
+ const table = findTable(state.selection.$from);
234
+ if (!table)
235
+ return false;
236
+ const caption = captionHtmlFromText(text, table.node.attrs['caption']);
237
+ return setTableAttrs({ caption })(state, dispatch);
238
+ };
239
+ }
240
+ export function colgroupHtmlFromWidths(widths) {
241
+ if (widths.every((width) => !width))
242
+ return null;
243
+ if (typeof document === 'undefined') {
244
+ const cols = widths.map((width) => (width ? `<col width="${escapeAttr(width)}">` : '<col>')).join('');
245
+ return `<colgroup>${cols}</colgroup>`;
246
+ }
247
+ const group = document.createElement('colgroup');
248
+ for (const width of widths) {
249
+ const col = document.createElement('col');
250
+ if (width)
251
+ col.setAttribute('width', width);
252
+ group.appendChild(col);
253
+ }
254
+ return group.outerHTML;
255
+ }
256
+ /** The `<col>` elements of a stored colgroup, or null when there is no DOM. */
257
+ function colsOf(html) {
258
+ if (!html)
259
+ return null;
260
+ if (typeof document === 'undefined')
261
+ return null;
262
+ const tpl = document.createElement('template');
263
+ tpl.innerHTML = html;
264
+ const group = tpl.content.querySelector('colgroup');
265
+ if (!group)
266
+ return null;
267
+ return { group, cols: [...group.querySelectorAll('col')] };
268
+ }
269
+ /** `span` as a count of columns covered, defaulting to 1. */
270
+ function spanOf(col) {
271
+ const raw = Number(col.getAttribute('span') ?? '1');
272
+ return Number.isInteger(raw) && raw > 0 ? raw : 1;
273
+ }
274
+ /**
275
+ * Column widths, one per column.
276
+ *
277
+ * `span` is honoured: `<col span="2" width="120">` sets two columns to 120, not
278
+ * one. Reading the elements positionally would report the second column as
279
+ * having no width, and then saving would write that back.
280
+ */
281
+ export function widthsFromColgroup(html, columns) {
282
+ const widths = Array.from({ length: columns }, () => '');
283
+ const parsed = colsOf(html);
284
+ if (!parsed)
285
+ return widths;
286
+ let column = 0;
287
+ for (const col of parsed.cols) {
288
+ const width = col.getAttribute('width') ?? '';
289
+ for (let i = 0; i < spanOf(col); i += 1) {
290
+ if (column < columns)
291
+ widths[column] = width;
292
+ column += 1;
293
+ }
294
+ }
295
+ return widths;
296
+ }
297
+ /**
298
+ * Write widths into an existing colgroup rather than replacing it.
299
+ *
300
+ * Inherited markup carries more than widths -- `<colgroup class="layout">`,
301
+ * `<col span="2">`, whatever else a previous CMS wrote -- and the table
302
+ * properties dialog saves the whole table, so rebuilding the colgroup from
303
+ * widths alone dropped all of it on a save that changed nothing else.
304
+ *
305
+ * An unchanged set of widths returns the stored markup untouched, so saving the
306
+ * dialog is genuinely a no-op. When a width does change, the existing elements
307
+ * are patched: a spanned `<col>` keeps its span while its columns still agree,
308
+ * and is split into one `<col>` per column -- carrying its other attributes --
309
+ * only when they no longer do.
310
+ */
311
+ export function colgroupHtmlWithWidths(existing, widths) {
312
+ const parsed = colsOf(existing);
313
+ if (!parsed)
314
+ return colgroupHtmlFromWidths(widths);
315
+ const wanted = widths.map((width) => width ?? '');
316
+ const current = widthsFromColgroup(existing, wanted.length);
317
+ if (current.every((width, i) => width === wanted[i]))
318
+ return existing ?? null;
319
+ let column = 0;
320
+ for (const col of parsed.cols) {
321
+ const span = spanOf(col);
322
+ const covered = wanted.slice(column, column + span);
323
+ column += span;
324
+ if (covered.length === 0)
325
+ continue;
326
+ if (covered.every((width) => width === covered[0])) {
327
+ setWidth(col, covered[0] ?? '');
328
+ continue;
329
+ }
330
+ // The columns this element covers no longer share a width, so it has to
331
+ // become one element per column. Its other attributes come along; `span`
332
+ // cannot, because each replacement now covers exactly one column.
333
+ const parent = col.parentNode;
334
+ if (!parent)
335
+ continue;
336
+ for (const width of covered) {
337
+ const clone = col.cloneNode(false);
338
+ clone.removeAttribute('span');
339
+ setWidth(clone, width);
340
+ parent.insertBefore(clone, col);
341
+ }
342
+ parent.removeChild(col);
343
+ }
344
+ // More columns than the stored colgroup described. Bare `<col>` for each, so
345
+ // the widths that follow land on the right column.
346
+ for (; column < wanted.length; column += 1) {
347
+ const col = parsed.group.ownerDocument.createElement('col');
348
+ setWidth(col, wanted[column] ?? '');
349
+ parsed.group.appendChild(col);
350
+ }
351
+ return parsed.group.outerHTML;
352
+ }
353
+ function setWidth(col, width) {
354
+ if (width)
355
+ col.setAttribute('width', width);
356
+ else
357
+ col.removeAttribute('width');
358
+ }
359
+ export function setTableColgroup(widths) {
360
+ return setTableAttrs({ colgroup: colgroupHtmlFromWidths(widths) });
361
+ }
362
+ function colgroupFromCellWidths(table) {
363
+ const map = TableMap.get(table);
364
+ const widths = [];
365
+ let any = false;
366
+ // A cell spanning several columns appears in the map once per column it
367
+ // covers, and its `colwidth` holds one entry per covered column. `offset`
368
+ // tracks how far into that run this column is: reading entry 0 every time
369
+ // wrote the first column's width to every <col> the cell spans, so resizing a
370
+ // later column of a merged cell corrupted the stored colgroup.
371
+ let previous = -1;
372
+ let offset = 0;
373
+ for (let col = 0; col < map.width; col += 1) {
374
+ const pos = map.map[col] ?? 0;
375
+ if (pos === previous)
376
+ offset += 1;
377
+ else {
378
+ previous = pos;
379
+ offset = 0;
380
+ }
381
+ const cell = table.nodeAt(pos);
382
+ const colwidth = cell?.attrs['colwidth'];
383
+ const width = colwidth?.[offset];
384
+ if (width) {
385
+ widths.push(String(width));
386
+ any = true;
387
+ }
388
+ else {
389
+ widths.push('');
390
+ }
391
+ }
392
+ // Patched onto whatever the table already stored, for the same reason the
393
+ // properties dialog patches: a column resize must not cost an inherited
394
+ // colgroup its class or its other attributes.
395
+ return any ? colgroupHtmlWithWidths(table.attrs['colgroup'], widths) : null;
396
+ }
397
+ /**
398
+ * Keep `<colgroup>` in lockstep with column resizing.
399
+ *
400
+ * `prosemirror-tables` writes `colwidth` onto cells. That is enough for the
401
+ * editor; it is not enough for stored HTML, whose column widths live on
402
+ * `<col>`. Updating the furniture attribute after a resize is what makes
403
+ * colgroup a first-class editing feature rather than a round-trip souvenir.
404
+ *
405
+ * Authored colgroups that are not the product of a resize are left alone:
406
+ * inventing `<col>` elements for a table that never had widths would change
407
+ * markup we had no reason to touch.
408
+ */
409
+ export function colgroupSyncPlugin() {
410
+ return new Plugin({
411
+ appendTransaction(transactions, _old, state) {
412
+ if (!transactions.some((tr) => tr.docChanged))
413
+ return null;
414
+ let tr = null;
415
+ state.doc.descendants((node, pos) => {
416
+ if (node.type.spec['tableRole'] !== 'table')
417
+ return true;
418
+ const next = colgroupFromCellWidths(node);
419
+ if (next === null)
420
+ return false;
421
+ if (next === node.attrs['colgroup'])
422
+ return false;
423
+ tr ??= state.tr;
424
+ tr.setNodeMarkup(pos, undefined, { ...node.attrs, colgroup: next });
425
+ return false;
426
+ });
427
+ return tr;
428
+ },
429
+ });
430
+ }
431
+ export function emptyToNull(value) {
432
+ const trimmed = value?.trim() ?? '';
433
+ return trimmed === '' ? null : trimmed;
434
+ }
435
+ export function colorOrNull(value) {
436
+ const trimmed = emptyToNull(value);
437
+ return trimmed ? safeColor(trimmed) : null;
438
+ }
439
+ function escapeText(value) {
440
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
441
+ }
442
+ function escapeAttr(value) {
443
+ return escapeText(value).replace(/"/g, '&quot;');
444
+ }
445
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EACL,cAAc,IAAI,iBAAiB,EACnC,eAAe,IAAI,kBAAkB,EACrC,WAAW,IAAI,cAAc,EAC7B,YAAY,IAAI,eAAe,EAC/B,aAAa,EACb,QAAQ,EACR,eAAe,IAAI,kBAAkB,GACtC,MAAM,oBAAoB,CAAA;AAE3B,MAAM,UAAU,OAAO,CAAC,KAAkB;IACxC,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,IAAiB,EACjB,IAA8C;IAE9C,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACnD,MAAM,I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AyB;IACnD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AACjF,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAClD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Table, row and cell property dialogs.
3
+ *
4
+ * These are the editing surface for attributes the schema already stores:
5
+ * border, padding, background, alignment, caption and column widths. A caption
6
+ * is still an attribute rather than a child node -- see tables.ts -- so this
7
+ * dialog is how an author changes it without an upstream cell-map fix.
8
+ */
9
+ import type { EditorView } from 'prosemirror-view';
10
+ export declare function openTableProperties(view: EditorView, host: HTMLElement): Promise<void>;
11
+ export declare function openRowProperties(view: EditorView, host: HTMLElement): Promise<void>;
12
+ export declare function openCellProperties(view: EditorView, host: HTMLElement): Promise<void>;
13
+ export declare function openCaptionDialog(view: EditorView, host: HTMLElement): Promise<void>;
14
+ //# sourceMappingURL=dialogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogs.d.ts","sourceRoot":"","sources":["../src/dialogs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAoDlD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5F;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B1F;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC3F;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB1F"}