@quillmark/svelte 0.29.3 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/core/address.d.ts +3 -3
- package/dist/core/address.js +1 -1
- package/dist/core/codec/decode.d.ts +1 -3
- package/dist/core/codec/decode.js +145 -206
- package/dist/core/codec/encode.d.ts +13 -35
- package/dist/core/codec/encode.js +127 -408
- package/dist/core/codec/field.d.ts +9 -9
- package/dist/core/codec/field.js +85 -76
- package/dist/core/codec/index.d.ts +2 -2
- package/dist/core/codec/index.js +4 -4
- package/dist/core/codec/islands.d.ts +13 -9
- package/dist/core/codec/islands.js +54 -49
- package/dist/core/codec/marks.d.ts +12 -18
- package/dist/core/codec/marks.js +16 -26
- package/dist/core/codec/positions.d.ts +14 -7
- package/dist/core/codec/positions.js +43 -50
- package/dist/core/codec/schema.d.ts +1 -1
- package/dist/core/codec/schema.js +26 -8
- package/dist/core/codec/slash.js +2 -2
- package/dist/core/codec/table-copy.d.ts +3 -3
- package/dist/core/codec/table-copy.js +6 -4
- package/dist/core/codec/table-paste.js +13 -9
- package/dist/core/codec/table-view.js +19 -12
- package/dist/core/codec/table.d.ts +77 -43
- package/dist/core/codec/table.js +157 -48
- package/dist/visual/ArrayField.svelte +1 -1
- package/dist/visual/FormatPopover.svelte +1 -1
- package/dist/visual/ProseValue.svelte +8 -8
- package/dist/visual/VisualEditorInner.svelte +17 -11
- package/dist/visual/leaves.d.ts +1 -1
- package/dist/visual/leaves.js +1 -1
- package/dist/visual/structure.js +1 -10
- package/package.json +2 -2
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { DOMSerializer } from 'prosemirror-model';
|
|
7
7
|
import { Plugin } from 'prosemirror-state';
|
|
8
8
|
import { decode } from './decode.js';
|
|
9
|
-
import {
|
|
9
|
+
import { HARD_BREAK } from './islands.js';
|
|
10
|
+
import { tableOfNode } from './table.js';
|
|
10
11
|
import { blockSchema, cellSchema } from './schema.js';
|
|
11
12
|
import { anchorAt, cellAt, cellContent, columnCount, headRows, rowCount, spanGrid } from './table.js';
|
|
12
13
|
const whole = (props) => ({
|
|
@@ -58,7 +59,8 @@ export function tableElement(props, range = whole(props)) {
|
|
|
58
59
|
}
|
|
59
60
|
/** A cell holding a tab, a line end or a quote goes in quotes with its quotes doubled,
|
|
60
61
|
* as Excel and Sheets write one. */
|
|
61
|
-
function tsvCell(
|
|
62
|
+
function tsvCell(cell) {
|
|
63
|
+
const text = cell.replaceAll(HARD_BREAK, '\n');
|
|
62
64
|
return /[\t\n"]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text;
|
|
63
65
|
}
|
|
64
66
|
/** The cells of `range` as tab-separated text, a line a row. */
|
|
@@ -78,7 +80,7 @@ const base = DOMSerializer.fromSchema(blockSchema);
|
|
|
78
80
|
const islandSerializer = new DOMSerializer({
|
|
79
81
|
...base.nodes,
|
|
80
82
|
island_block: (node) => {
|
|
81
|
-
const props =
|
|
83
|
+
const props = tableOfNode(node);
|
|
82
84
|
const dom = DOMSerializer.renderSpec(document, blockSchema.nodes.island_block.spec.toDOM(node)).dom;
|
|
83
85
|
if (props)
|
|
84
86
|
dom.replaceChildren(tableElement(props));
|
|
@@ -86,7 +88,7 @@ const islandSerializer = new DOMSerializer({
|
|
|
86
88
|
}
|
|
87
89
|
}, base.marks);
|
|
88
90
|
function leafText(node) {
|
|
89
|
-
const props = node.type === blockSchema.nodes.island_block ?
|
|
91
|
+
const props = node.type === blockSchema.nodes.island_block ? tableOfNode(node) : undefined;
|
|
90
92
|
if (props)
|
|
91
93
|
return tableText(props);
|
|
92
94
|
return node.type.spec.leafText?.(node) ?? '';
|
|
@@ -6,23 +6,24 @@
|
|
|
6
6
|
// here, so a pasted table takes the document's face.
|
|
7
7
|
import { DOMParser, Fragment, Slice } from 'prosemirror-model';
|
|
8
8
|
import { Plugin } from 'prosemirror-state';
|
|
9
|
-
import { usvLength } from './decode.js';
|
|
10
9
|
import { pmToContent } from './encode.js';
|
|
11
10
|
import { blockSchema } from './schema.js';
|
|
12
|
-
import {
|
|
11
|
+
import { HARD_BREAK } from './islands.js';
|
|
12
|
+
import { emptyCell, islandOf, normalizeTable } from './table.js';
|
|
13
13
|
const schemaRules = DOMParser.fromSchema(blockSchema).rules;
|
|
14
14
|
/** What a cell's markup is read with: the schema's rules less the islands', so an island
|
|
15
15
|
* element inside a cell is the text it holds. */
|
|
16
16
|
const cellParser = new DOMParser(blockSchema, schemaRules.filter((rule) => !('node' in rule && rule.node?.startsWith('island_'))));
|
|
17
|
-
/** A `<td>` or `<th>` as a cell: its blocks
|
|
17
|
+
/** A `<td>` or `<th>` as a cell: its blocks and each `<br>` are a break, one `U+2028`
|
|
18
18
|
* in the text (`cellContent`), and its marks the ones the schema's rules read. Whitespace
|
|
19
19
|
* at the cell's edges is dropped, which is where a source's empty paragraph lands. */
|
|
20
20
|
function cellFromDOM(el) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const parsed = pmToContent(cellParser.parse(el));
|
|
22
|
+
const text = parsed.text.replaceAll('\n', HARD_BREAK);
|
|
23
|
+
const marks = parsed.marks ?? [];
|
|
23
24
|
const lead = text.length - text.trimStart().length;
|
|
24
25
|
const kept = text.trim();
|
|
25
|
-
const end =
|
|
26
|
+
const end = kept.length;
|
|
26
27
|
return {
|
|
27
28
|
text: kept,
|
|
28
29
|
marks: marks.flatMap((m) => {
|
|
@@ -77,7 +78,7 @@ function tableFromText(text) {
|
|
|
77
78
|
QUOTED.lastIndex = BARE.lastIndex = at;
|
|
78
79
|
const quoted = QUOTED.exec(body);
|
|
79
80
|
const cell = quoted
|
|
80
|
-
? quoted[1].replace(/""/g, '"').replace(/\r\n
|
|
81
|
+
? quoted[1].replace(/""/g, '"').replace(/\r\n?|\n/g, HARD_BREAK)
|
|
81
82
|
: BARE.exec(body)[0];
|
|
82
83
|
lines.at(-1).push(cell);
|
|
83
84
|
at = quoted ? QUOTED.lastIndex : BARE.lastIndex;
|
|
@@ -104,7 +105,7 @@ const clipboardParser = new DOMParser(blockSchema, [
|
|
|
104
105
|
node: 'island_block',
|
|
105
106
|
getAttrs: (el) => {
|
|
106
107
|
const props = tableFromDOM(el);
|
|
107
|
-
return props ? { islandType: 'table', props } : false;
|
|
108
|
+
return props ? { islandType: 'table', ...islandOf(props) } : false;
|
|
108
109
|
}
|
|
109
110
|
},
|
|
110
111
|
...schemaRules
|
|
@@ -124,7 +125,10 @@ export function tablePastePlugin() {
|
|
|
124
125
|
const props = plain ? null : tableFromText(text);
|
|
125
126
|
if (!props)
|
|
126
127
|
return null;
|
|
127
|
-
const island = blockSchema.nodes.island_block.create({
|
|
128
|
+
const island = blockSchema.nodes.island_block.create({
|
|
129
|
+
islandType: 'table',
|
|
130
|
+
...islandOf(props)
|
|
131
|
+
});
|
|
128
132
|
return new Slice(Fragment.from(island), 0, 0);
|
|
129
133
|
})
|
|
130
134
|
}
|
|
@@ -17,12 +17,12 @@ import { EditorView } from 'prosemirror-view';
|
|
|
17
17
|
import { decode } from './decode.js';
|
|
18
18
|
import { inputRulesPlugin, undoRuleKeymap } from './inputrules.js';
|
|
19
19
|
import { linkPastePlugin } from './link-paste.js';
|
|
20
|
-
import {
|
|
20
|
+
import { tableOfNode } from './table.js';
|
|
21
21
|
import { tableElement, tableText } from './table-copy.js';
|
|
22
22
|
import { breakKeymap } from './breaks.js';
|
|
23
23
|
import { cellSchema } from './schema.js';
|
|
24
24
|
import { revealProps } from './reveal.js';
|
|
25
|
-
import { ALIGNS, canMerge, cellAt, closeBlock, cellContent, cellEqual, cellFromDoc, clearCells, columnCount, deleteColumn, deleteRow, insertColumn, insertRow, mergeCells, moveColumn, moveRow, normalizeTable, rowCells, rowCount, rowEmpty, setAlign, setHead, headRows, columnShares, setWidths, shapeEqual, spanGrid, splitCell, withCell } from './table.js';
|
|
25
|
+
import { ALIGNS, canMerge, cellAt, closeBlock, cellContent, cellEqual, cellFromDoc, clearCells, columnCount, deleteColumn, deleteRow, insertColumn, insertRow, mergeCells, moveColumn, moveRow, normalizeTable, rowCells, rowCount, rowEmpty, setAlign, setHead, headRows, columnShares, setWidths, shapeEqual, spanGrid, splitCell, withCell, islandOf } from './table.js';
|
|
26
26
|
/**
|
|
27
27
|
* The package's English for the island chrome. It lives beside the surface that draws it so a
|
|
28
28
|
* consumer reaching `createField` directly gets wording; the visual `strings` set extends it.
|
|
@@ -174,11 +174,16 @@ const spanCells = (a, b) => ({
|
|
|
174
174
|
*/
|
|
175
175
|
const mounted = new WeakMap();
|
|
176
176
|
/**
|
|
177
|
-
* Where the caret stood as each table value was written over, keyed by that value
|
|
178
|
-
* back the
|
|
179
|
-
* from.
|
|
177
|
+
* Where the caret stood as each table value was written over, keyed by that value's `slots`, which
|
|
178
|
+
* every write replaces: an undo hands back the object the edit replaced, so the seat held against
|
|
179
|
+
* it is where the edit was made from.
|
|
180
180
|
*/
|
|
181
181
|
const departures = new WeakMap();
|
|
182
|
+
/** The key {@link departures} holds a node's value under. */
|
|
183
|
+
const valueKey = (node) => {
|
|
184
|
+
const slots = node.attrs.slots;
|
|
185
|
+
return slots ?? undefined;
|
|
186
|
+
};
|
|
182
187
|
class TableIslandView {
|
|
183
188
|
node;
|
|
184
189
|
outer;
|
|
@@ -238,7 +243,7 @@ class TableIslandView {
|
|
|
238
243
|
return false;
|
|
239
244
|
const before = this.rendered;
|
|
240
245
|
this.node = node;
|
|
241
|
-
const props =
|
|
246
|
+
const props = tableOfNode(node);
|
|
242
247
|
if (!props || !before || !shapeEqual(before, props)) {
|
|
243
248
|
this.render();
|
|
244
249
|
return true;
|
|
@@ -248,7 +253,8 @@ class TableIslandView {
|
|
|
248
253
|
// re-hydrate takes fresh state. Compared against `shown`, not a doc projection: this runs
|
|
249
254
|
// every keystroke and projecting costs a `mapMarks` across WASM per anchored cell.
|
|
250
255
|
this.rendered = props;
|
|
251
|
-
const
|
|
256
|
+
const key = valueKey(node);
|
|
257
|
+
const departure = key && departures.get(key);
|
|
252
258
|
for (const mounted of this.cells) {
|
|
253
259
|
const stored = cellAt(props, mounted.r, mounted.c);
|
|
254
260
|
if (cellEqual(stored, mounted.shown))
|
|
@@ -1055,8 +1061,9 @@ class TableIslandView {
|
|
|
1055
1061
|
this.cellCluster = undefined;
|
|
1056
1062
|
this.rails = [];
|
|
1057
1063
|
this.dom.textContent = '';
|
|
1058
|
-
const props =
|
|
1059
|
-
const
|
|
1064
|
+
const props = tableOfNode(this.node);
|
|
1065
|
+
const key = valueKey(this.node);
|
|
1066
|
+
const departure = props && key && departures.get(key);
|
|
1060
1067
|
this.rendered = props;
|
|
1061
1068
|
if (props)
|
|
1062
1069
|
mounted.set(this.dom, this);
|
|
@@ -1376,7 +1383,7 @@ class TableIslandView {
|
|
|
1376
1383
|
// ── Ops ───────────────────────────────────────────────────────────────────
|
|
1377
1384
|
/** The table this view is currently showing; the zero table if the node stopped being one. */
|
|
1378
1385
|
props() {
|
|
1379
|
-
return
|
|
1386
|
+
return tableOfNode(this.node) ?? normalizeTable({ header: [], rows: [], aligns: [] });
|
|
1380
1387
|
}
|
|
1381
1388
|
/**
|
|
1382
1389
|
* Commit a new rectangle onto the node. `setNodeMarkup` is an ordinary PM transaction, so the
|
|
@@ -1390,12 +1397,12 @@ class TableIslandView {
|
|
|
1390
1397
|
const node = this.outer.state.doc.nodeAt(pos);
|
|
1391
1398
|
if (!node || node.type !== this.node.type)
|
|
1392
1399
|
return;
|
|
1393
|
-
const left =
|
|
1400
|
+
const left = valueKey(node);
|
|
1394
1401
|
if (left && from)
|
|
1395
1402
|
departures.set(left, from);
|
|
1396
1403
|
this.outer.dispatch(this.outer.state.tr.setNodeMarkup(pos, undefined, {
|
|
1397
1404
|
...node.attrs,
|
|
1398
|
-
|
|
1405
|
+
...islandOf(next)
|
|
1399
1406
|
}));
|
|
1400
1407
|
if (focus)
|
|
1401
1408
|
this.focusCell(focus.r, focus.c);
|
|
@@ -1,44 +1,80 @@
|
|
|
1
|
-
import type { Content,
|
|
1
|
+
import type { Content, ContentAnchor, ContentMark, TableProps } from '@quillmark/wasm';
|
|
2
2
|
import type { Node as PMNode } from 'prosemirror-model';
|
|
3
|
-
/** One column's alignment,
|
|
4
|
-
export type TableAlign = TableProps['
|
|
3
|
+
/** One column's alignment, `none` where the store keys none. */
|
|
4
|
+
export type TableAlign = 'none' | NonNullable<TableProps['align']>;
|
|
5
5
|
/** The alignments a column can take: the four the content declares, `none` first
|
|
6
6
|
* because it is what a column arrives at and what a set is cleared back to. */
|
|
7
7
|
export declare const ALIGNS: readonly TableAlign[];
|
|
8
|
+
/** A cell's own layout, as the store keys it by slot. */
|
|
9
|
+
type CellAttrs = NonNullable<TableProps['cell_attrs']>[string];
|
|
10
|
+
/** The ids a cell arrived under. */
|
|
11
|
+
export interface CellIds {
|
|
12
|
+
row: string;
|
|
13
|
+
column: string;
|
|
14
|
+
slot: string;
|
|
15
|
+
block: string;
|
|
16
|
+
}
|
|
17
|
+
/** One cell of the grid: its slot's text, marks and anchors, its own layout, its ids. */
|
|
18
|
+
export interface GridCell extends CellAttrs {
|
|
19
|
+
text: string;
|
|
20
|
+
marks: ContentMark[];
|
|
21
|
+
anchors?: ContentAnchor[];
|
|
22
|
+
ids?: CellIds;
|
|
23
|
+
}
|
|
24
|
+
/** A table by place: row 0 the header, `aligns` and `widths` one per column. */
|
|
25
|
+
export interface TableGrid {
|
|
26
|
+
header: GridCell[];
|
|
27
|
+
rows: GridCell[][];
|
|
28
|
+
aligns: TableAlign[];
|
|
29
|
+
widths?: (number | null)[];
|
|
30
|
+
align?: TableProps['align'];
|
|
31
|
+
head?: number;
|
|
32
|
+
/** The props keys the table names none of, riding through. */
|
|
33
|
+
extra?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/** The grid a table island spells, each cell its slot's content and its ids. */
|
|
36
|
+
export declare function gridOf(props: TableProps, slots: Record<string, Content> | null): TableGrid;
|
|
37
|
+
/** A node's grid, or `undefined` for any other island and for a payload of the wrong shape. */
|
|
38
|
+
export declare function tableOfNode(node: PMNode): TableGrid | undefined;
|
|
39
|
+
/** The island a grid spells: its props and slots, each rank's id the first its cells carry. */
|
|
40
|
+
export declare function islandOf(grid: TableGrid): {
|
|
41
|
+
props: TableProps;
|
|
42
|
+
slots: Record<string, Content>;
|
|
43
|
+
};
|
|
8
44
|
/** The zero cell: empty text, no marks. */
|
|
9
|
-
export declare function emptyCell():
|
|
45
|
+
export declare function emptyCell(): GridCell;
|
|
10
46
|
/**
|
|
11
47
|
* The row index space the chrome and the ops share: **0 is the header**, 1…n the body rows. A row
|
|
12
48
|
* op works {@link allRows}, and whichever row lands at index 0 is the header afterwards. The one
|
|
13
49
|
* row the model refuses is the last, there being no table under it.
|
|
14
50
|
*/
|
|
15
|
-
export declare function rowCount(props:
|
|
51
|
+
export declare function rowCount(props: TableGrid): number;
|
|
16
52
|
/** The cells of row `r` in that space. */
|
|
17
|
-
export declare function rowCells(props:
|
|
53
|
+
export declare function rowCells(props: TableGrid, r: number): GridCell[];
|
|
18
54
|
/**
|
|
19
55
|
* Whether a row holds no text, telling a row on offer from one taken up (`table-view.ts` §`step`).
|
|
20
56
|
* Text alone: a mark over none is invisible.
|
|
21
57
|
*/
|
|
22
|
-
export declare function rowEmpty(props:
|
|
58
|
+
export declare function rowEmpty(props: TableGrid, r: number): boolean;
|
|
23
59
|
/** The cell at `(row, column)`, or the zero cell where the rectangle does not reach. */
|
|
24
|
-
export declare function cellAt(props:
|
|
60
|
+
export declare function cellAt(props: TableGrid, r: number, c: number): GridCell;
|
|
25
61
|
/** The table's column count: the one number `header`, every row and `aligns` share. */
|
|
26
|
-
export declare function columnCount(props:
|
|
62
|
+
export declare function columnCount(props: TableGrid): number;
|
|
27
63
|
/**
|
|
28
64
|
* The rectangularizing constructor: one column count (the widest thing present, at least one)
|
|
29
65
|
* across `header`, every row, `aligns` and `widths`, padding with empty cells, `none` and auto-fit.
|
|
30
66
|
* The layout keys ride through, each absent at its default as the store writes it.
|
|
31
67
|
*/
|
|
32
|
-
export declare function normalizeTable(props:
|
|
68
|
+
export declare function normalizeTable(props: TableGrid): TableGrid;
|
|
33
69
|
/** How many rows from the top draw as header rows, absent being one. */
|
|
34
|
-
export declare function headRows(props:
|
|
70
|
+
export declare function headRows(props: TableGrid): number;
|
|
35
71
|
/** The columns and rows a drawn cell spans. */
|
|
36
72
|
export interface Span {
|
|
37
73
|
colspan: number;
|
|
38
74
|
rowspan: number;
|
|
39
75
|
}
|
|
40
76
|
/** {@link spansOf} over a table's rows, header first. */
|
|
41
|
-
export declare function spanGrid(props:
|
|
77
|
+
export declare function spanGrid(props: TableGrid): (Span | null)[][];
|
|
42
78
|
/**
|
|
43
79
|
* The drawn cell whose span covers `(r, c)`; the slot itself where nothing covers it or it lies
|
|
44
80
|
* outside the grid.
|
|
@@ -49,43 +85,43 @@ export declare function anchorAt(grid: (Span | null)[][], r: number, c: number):
|
|
|
49
85
|
span: Span;
|
|
50
86
|
};
|
|
51
87
|
/** A fresh table: a header plus `bodyRows` empty rows, every column unaligned. */
|
|
52
|
-
export declare function newTable(cols?: number, bodyRows?: number):
|
|
88
|
+
export declare function newTable(cols?: number, bodyRows?: number): TableGrid;
|
|
53
89
|
/** `props` with the cell at `(r, c)` replaced. */
|
|
54
|
-
export declare function withCell(props:
|
|
90
|
+
export declare function withCell(props: TableGrid, r: number, c: number, cell: GridCell): TableGrid;
|
|
55
91
|
/** A new empty body row below row `r` (row 0, the header, opens the first body row). */
|
|
56
|
-
export declare function insertRow(props:
|
|
92
|
+
export declare function insertRow(props: TableGrid, r: number): TableGrid;
|
|
57
93
|
/**
|
|
58
94
|
* Drop row `r`, the header included: the row left at index 0 becomes the header. A no-op at the
|
|
59
95
|
* last row, which is the removal of the table and the island's to answer.
|
|
60
96
|
*/
|
|
61
|
-
export declare function deleteRow(props:
|
|
97
|
+
export declare function deleteRow(props: TableGrid, r: number): TableGrid;
|
|
62
98
|
/** A new empty column after column `c`. */
|
|
63
|
-
export declare function insertColumn(props:
|
|
99
|
+
export declare function insertColumn(props: TableGrid, c: number): TableGrid;
|
|
64
100
|
/** Drop column `c`; a no-op at one column (a table has at least one). */
|
|
65
|
-
export declare function deleteColumn(props:
|
|
101
|
+
export declare function deleteColumn(props: TableGrid, c: number): TableGrid;
|
|
66
102
|
/**
|
|
67
103
|
* Row `r` moved by `by` places, clamped: a drag past the rectangle is a no-op, not an error. The
|
|
68
104
|
* header travels like any other row; being the header is holding index 0.
|
|
69
105
|
*/
|
|
70
|
-
export declare function moveRow(props:
|
|
106
|
+
export declare function moveRow(props: TableGrid, r: number, by: number): TableGrid;
|
|
71
107
|
/**
|
|
72
108
|
* Column `c` moved by `by` places, clamped. `aligns` and `widths` travel with the column, being its
|
|
73
109
|
* properties.
|
|
74
110
|
*/
|
|
75
|
-
export declare function moveColumn(props:
|
|
111
|
+
export declare function moveColumn(props: TableGrid, c: number, by: number): TableGrid;
|
|
76
112
|
/**
|
|
77
113
|
* Every cell in the inclusive rectangle emptied, alignment kept (a cell its own, a column its
|
|
78
114
|
* alignment and width): a delete over a block covering no whole rank. A rectangle spanning one axis
|
|
79
115
|
* deletes ranks and one spanning both is the table, so what reaches here is a proper sub-rectangle.
|
|
80
116
|
*/
|
|
81
|
-
export declare function clearCells(props:
|
|
117
|
+
export declare function clearCells(props: TableGrid, r0: number, c0: number, r1: number, c1: number): TableGrid;
|
|
82
118
|
/**
|
|
83
119
|
* Set column `c`'s alignment and clear its cells' own `align`, which would outrank it
|
|
84
120
|
* (`table-view.ts`).
|
|
85
121
|
*/
|
|
86
|
-
export declare function setAlign(props:
|
|
122
|
+
export declare function setAlign(props: TableGrid, c: number, align: TableAlign): TableGrid;
|
|
87
123
|
/** Draw the top `head` rows as header rows (`table-view.ts`). */
|
|
88
|
-
export declare function setHead(props:
|
|
124
|
+
export declare function setHead(props: TableGrid, head: number): TableGrid;
|
|
89
125
|
/** An inclusive block of cells, in the row space {@link rowCount} names. */
|
|
90
126
|
export interface CellBlock {
|
|
91
127
|
r0: number;
|
|
@@ -94,52 +130,50 @@ export interface CellBlock {
|
|
|
94
130
|
c1: number;
|
|
95
131
|
}
|
|
96
132
|
/** `block` grown until every drawn cell it touches lies wholly inside it. */
|
|
97
|
-
export declare function closeBlock(props:
|
|
133
|
+
export declare function closeBlock(props: TableGrid, block: CellBlock): CellBlock;
|
|
98
134
|
/**
|
|
99
135
|
* Whether `block` can be one cell: more than one drawn cell, inside the header rows or the body.
|
|
100
136
|
*/
|
|
101
|
-
export declare function canMerge(props:
|
|
137
|
+
export declare function canMerge(props: TableGrid, block: CellBlock): boolean;
|
|
102
138
|
/**
|
|
103
139
|
* The block's cells as one, at its top-left: the text of each drawn cell holding any, in reading
|
|
104
140
|
* order, a line apiece, every other slot an empty one the span covers, alignment kept. The top-left
|
|
105
141
|
* cell's alignment is the merged cell's. A block {@link canMerge} refuses comes back as it was.
|
|
106
142
|
*/
|
|
107
|
-
export declare function mergeCells(props:
|
|
143
|
+
export declare function mergeCells(props: TableGrid, block: CellBlock): TableGrid;
|
|
108
144
|
/**
|
|
109
145
|
* The merged cell covering `(r, c)` back to the cells under it: its text stays top-left, the rest
|
|
110
146
|
* are the empty cells it covered.
|
|
111
147
|
*/
|
|
112
|
-
export declare function splitCell(props:
|
|
148
|
+
export declare function splitCell(props: TableGrid, r: number, c: number): TableGrid;
|
|
113
149
|
/**
|
|
114
150
|
* Set or clear the column weights (`table-view.ts`); `undefined` returns every column to auto-fit.
|
|
115
151
|
*/
|
|
116
|
-
export declare function setWidths(props:
|
|
152
|
+
export declare function setWidths(props: TableGrid, widths: (number | null)[] | undefined): TableGrid;
|
|
117
153
|
/**
|
|
118
154
|
* Each column's share of the table's width, summing to 1, or `undefined` for a table that auto-fits
|
|
119
155
|
* throughout. An auto-fit column beside weighted ones takes the mean weight, since the editor's
|
|
120
156
|
* fixed-layout grid cannot size it to content as the page does.
|
|
121
157
|
*/
|
|
122
|
-
export declare function columnShares(props:
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
* `continues` line, the hard break it decodes to. The cell's marks are that content's marks.
|
|
126
|
-
*/
|
|
127
|
-
export declare function cellContent(cell: TableCell): Content;
|
|
158
|
+
export declare function columnShares(props: TableGrid): number[] | undefined;
|
|
159
|
+
/** A cell as its slot: one paragraph, for `decode` under `cellSchema`. */
|
|
160
|
+
export declare function cellContent(cell: GridCell): Content;
|
|
128
161
|
/**
|
|
129
|
-
* The cell a nested PM doc projects, carrying `prior`'s
|
|
162
|
+
* The cell a nested PM doc projects, carrying `prior`'s layout, ids and anchors through.
|
|
130
163
|
*
|
|
131
|
-
* Anchors inside a cell are preserved
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
164
|
+
* Anchors inside a cell are preserved, never minted: they are not in the field plugin's coordinate
|
|
165
|
+
* space (its position map holds one `atom` run for the whole table), so the popover withholds its
|
|
166
|
+
* `anchor` button in a cell. Preserving still means rebasing: each held anchor maps through the
|
|
167
|
+
* edit by the store's rule, a range's start after it and its end before, a point before, and a
|
|
168
|
+
* range the edit closes is dropped.
|
|
136
169
|
*/
|
|
137
|
-
export declare function cellFromDoc(doc: PMNode, prior:
|
|
170
|
+
export declare function cellFromDoc(doc: PMNode, prior: GridCell): GridCell;
|
|
138
171
|
/**
|
|
139
172
|
* Whether two cells are the same value, telling an own edit from an external one (an undo, a
|
|
140
173
|
* re-hydrate) without a flag. Marks compare structurally, as `reconcile.ts` states.
|
|
141
174
|
*/
|
|
142
|
-
export declare function cellEqual(a:
|
|
175
|
+
export declare function cellEqual(a: GridCell, b: GridCell): boolean;
|
|
143
176
|
/** Whether two tables have the same rectangle, alignment, header and widths: the
|
|
144
177
|
* change that forces a rebuild rather than a per-cell reseed. */
|
|
145
|
-
export declare function shapeEqual(a:
|
|
178
|
+
export declare function shapeEqual(a: TableGrid, b: TableGrid): boolean;
|
|
179
|
+
export {};
|