@quillmark/svelte 0.29.2 → 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.
Files changed (70) hide show
  1. package/README.md +2 -1
  2. package/THEMING.md +8 -6
  3. package/dist/core/address.d.ts +3 -3
  4. package/dist/core/address.js +1 -1
  5. package/dist/core/bloom.d.ts +3 -2
  6. package/dist/core/bloom.js +6 -7
  7. package/dist/core/codec/decode.d.ts +1 -3
  8. package/dist/core/codec/decode.js +145 -206
  9. package/dist/core/codec/encode.d.ts +13 -35
  10. package/dist/core/codec/encode.js +127 -408
  11. package/dist/core/codec/field.d.ts +9 -9
  12. package/dist/core/codec/field.js +87 -80
  13. package/dist/core/codec/index.d.ts +2 -5
  14. package/dist/core/codec/index.js +4 -4
  15. package/dist/core/codec/inputrules.d.ts +0 -3
  16. package/dist/core/codec/inputrules.js +1 -1
  17. package/dist/core/codec/islands.d.ts +13 -19
  18. package/dist/core/codec/islands.js +55 -50
  19. package/dist/core/codec/list-move.d.ts +0 -3
  20. package/dist/core/codec/list-move.js +2 -2
  21. package/dist/core/codec/list-node.d.ts +2 -0
  22. package/dist/core/codec/list-node.js +1 -0
  23. package/dist/core/codec/list-paste.js +1 -1
  24. package/dist/core/codec/markdown-paste.d.ts +0 -9
  25. package/dist/core/codec/markdown-paste.js +1 -1
  26. package/dist/core/codec/marks.d.ts +12 -18
  27. package/dist/core/codec/marks.js +16 -26
  28. package/dist/core/codec/nesting.d.ts +0 -4
  29. package/dist/core/codec/nesting.js +1 -1
  30. package/dist/core/codec/positions.d.ts +14 -7
  31. package/dist/core/codec/positions.js +43 -50
  32. package/dist/core/codec/prose.css +1 -1
  33. package/dist/core/codec/reveal.d.ts +14 -0
  34. package/dist/core/codec/reveal.js +40 -0
  35. package/dist/core/codec/schema.d.ts +1 -1
  36. package/dist/core/codec/schema.js +26 -8
  37. package/dist/core/codec/slash.js +0 -0
  38. package/dist/core/codec/table-copy.d.ts +3 -3
  39. package/dist/core/codec/table-copy.js +6 -4
  40. package/dist/core/codec/table-paste.js +13 -9
  41. package/dist/core/codec/table-view.js +22 -15
  42. package/dist/core/codec/table.d.ts +77 -49
  43. package/dist/core/codec/table.js +158 -49
  44. package/dist/core/codec/touching.d.ts +0 -2
  45. package/dist/core/codec/touching.js +1 -11
  46. package/dist/preview/Preview.svelte +20 -1
  47. package/dist/preview/Preview.svelte.d.ts +1 -0
  48. package/dist/preview/controller.d.ts +5 -0
  49. package/dist/preview/controller.js +6 -0
  50. package/dist/preview/viewport.js +19 -1
  51. package/dist/preview/wash.d.ts +9 -0
  52. package/dist/preview/wash.js +38 -0
  53. package/dist/visual/ArrayField.svelte +18 -115
  54. package/dist/visual/FormatPopover.svelte +1 -1
  55. package/dist/visual/MatrixField.svelte +15 -19
  56. package/dist/visual/ObjectField.svelte +10 -13
  57. package/dist/visual/ProseValue.svelte +8 -8
  58. package/dist/visual/VisualEditorInner.svelte +17 -11
  59. package/dist/visual/guidance.d.ts +0 -12
  60. package/dist/visual/guidance.js +2 -2
  61. package/dist/visual/leaves.d.ts +1 -1
  62. package/dist/visual/leaves.js +1 -1
  63. package/dist/visual/props.d.ts +2 -2
  64. package/dist/visual/rowdrag.svelte.d.ts +21 -0
  65. package/dist/visual/rowdrag.svelte.js +118 -0
  66. package/dist/visual/structure.d.ts +6 -6
  67. package/dist/visual/structure.js +18 -21
  68. package/package.json +2 -2
  69. package/dist/visual/checklists.d.ts +0 -3
  70. package/dist/visual/checklists.js +0 -7
@@ -25,7 +25,7 @@ export declare const cellSchema: Schema<"hard_break", string>;
25
25
  * containers, the shape `Content::is_plain` admits. A paragraph and a break both store one `\n`, so
26
26
  * a paragraph here is a line (`data-qm-line`): `prose.css` draws a run of them at the leading.
27
27
  */
28
- export declare const plainSchema: Schema<"text" | "doc" | "paragraph" | "hard_break", never>;
28
+ export declare const plainSchema: Schema<"text" | "paragraph" | "hard_break" | "doc", never>;
29
29
  /** The schema a leaf of the declared type mounts: `inline` narrows either type to one
30
30
  * textblock, and `plaintext` takes its marks away. */
31
31
  export declare function leafSchema(opts: {
@@ -95,6 +95,13 @@ const marks = {
95
95
  ];
96
96
  }
97
97
  },
98
+ // A content mark this build names no PM mark for, by its `x-` type and attributes as written. It
99
+ // formats nothing, and several stack on one character.
100
+ ext: {
101
+ attrs: { type: {}, attrs: { default: null } },
102
+ excludes: '',
103
+ toDOM: () => ['span', 0]
104
+ },
98
105
  link: {
99
106
  attrs: { href: { default: '' } },
100
107
  inclusive: false,
@@ -134,22 +141,26 @@ function fenceLang(pre) {
134
141
  return null;
135
142
  }
136
143
  // ── Block nodes ─────────────────────────────────────────────────────────────
144
+ // Every block and container carries the id of the content part it decodes from, `null` on one a
145
+ // command or a paste made. No `toDOM` writes it, so a copy carries none, and the projection keeps the
146
+ // first holder of an id a split copied (`encode.ts`).
147
+ const ID = { default: null };
137
148
  const blockNodes = {
138
149
  doc: { content: 'block+' },
139
150
  paragraph: {
140
151
  content: 'inline*',
141
152
  group: 'block',
153
+ attrs: { id: ID, ext: { default: null } },
142
154
  parseDOM: [{ tag: 'p' }],
143
155
  toDOM: () => ['p', 0]
144
156
  },
145
- // A heading holds no `hard_break`: the store clears a `continues` after one and markdown has no
146
- // syntax for a break inside it. Declaring it out makes that structural rather than a rule each
147
- // door holds.
157
+ // A heading holds no `hard_break`: the store refuses a break in one and markdown has no syntax
158
+ // for it. Declaring it out makes that structural rather than a rule each door holds.
148
159
  heading: {
149
160
  content: '(text | island_inline)*',
150
161
  group: 'block',
151
162
  defining: true,
152
- attrs: { level: { default: 1 } },
163
+ attrs: { id: ID, level: { default: 1 } },
153
164
  parseDOM: [1, 2, 3, 4, 5, 6].map((level) => ({ tag: `h${level}`, attrs: { level } })),
154
165
  toDOM: (node) => [`h${node.attrs.level}`, 0]
155
166
  },
@@ -160,7 +171,7 @@ const blockNodes = {
160
171
  defining: true,
161
172
  marks: '',
162
173
  whitespace: 'pre',
163
- attrs: { lang: { default: null } },
174
+ attrs: { id: ID, lang: { default: null } },
164
175
  parseDOM: [
165
176
  {
166
177
  tag: 'pre',
@@ -178,14 +189,20 @@ const blockNodes = {
178
189
  content: 'block+',
179
190
  group: 'block',
180
191
  defining: true,
192
+ attrs: { id: ID },
181
193
  parseDOM: [{ tag: 'blockquote' }],
182
194
  toDOM: () => ['blockquote', 0]
183
195
  },
184
- horizontal_rule: { group: 'block', parseDOM: [{ tag: 'hr' }], toDOM: () => ['hr'] },
196
+ horizontal_rule: {
197
+ group: 'block',
198
+ attrs: { id: ID },
199
+ parseDOM: [{ tag: 'hr' }],
200
+ toDOM: () => ['hr']
201
+ },
185
202
  ordered_list: {
186
203
  content: 'list_item+',
187
204
  group: 'block',
188
- attrs: { start: { default: 1 } },
205
+ attrs: { id: ID, start: { default: 1 } },
189
206
  parseDOM: [
190
207
  {
191
208
  tag: 'ol',
@@ -206,6 +223,7 @@ const blockNodes = {
206
223
  bullet_list: {
207
224
  content: 'list_item+',
208
225
  group: 'block',
226
+ attrs: { id: ID },
209
227
  parseDOM: [{ tag: 'ul' }],
210
228
  toDOM: () => ['ul', 0]
211
229
  },
@@ -213,7 +231,7 @@ const blockNodes = {
213
231
  list_item: {
214
232
  content: 'block+',
215
233
  defining: true,
216
- attrs: { checked: { default: null } },
234
+ attrs: { id: ID, checked: { default: null } },
217
235
  parseDOM: [
218
236
  {
219
237
  tag: 'li',
Binary file
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'prosemirror-state';
2
- import type { TableProps } from '@quillmark/wasm';
2
+ import type { TableGrid } from './table.js';
3
3
  /** A block of cells, both corners inclusive, in the row space `table.ts` names. */
4
4
  export interface CellRange {
5
5
  r0: number;
@@ -11,8 +11,8 @@ export interface CellRange {
11
11
  * holds them. The cells carry their marks, breaks and spans, a span cut to the range,
12
12
  * and nothing else of the table's layout. A slot a merged cell in the range covers
13
13
  * draws nothing; one whose cell starts outside the range draws empty. */
14
- export declare function tableElement(props: TableProps, range?: CellRange): HTMLTableElement;
14
+ export declare function tableElement(props: TableGrid, range?: CellRange): HTMLTableElement;
15
15
  /** The cells of `range` as tab-separated text, a line a row. */
16
- export declare function tableText(props: TableProps, range?: CellRange): string;
16
+ export declare function tableText(props: TableGrid, range?: CellRange): string;
17
17
  /** A block leaf's copy: a table in the slice writes as a table in both spellings. */
18
18
  export declare function tableCopyPlugin(): Plugin;
@@ -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 { tablePropsOfNode } from './islands.js';
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(text) {
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 = tablePropsOfNode(node);
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 ? tablePropsOfNode(node) : undefined;
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 { emptyCell, normalizeTable } from './table.js';
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 are lines and a `<br>` a break, each one `\n`
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 { text, marks } = pmToContent(cellParser.parse(el));
22
- // Every whitespace character is in the BMP, so `lead` counts USVs as well.
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 = usvLength(kept);
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?/g, '\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({ islandType: 'table', props });
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,11 +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 { tablePropsOfNode } from './islands.js';
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
- 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';
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, islandOf } from './table.js';
25
26
  /**
26
27
  * The package's English for the island chrome. It lives beside the surface that draws it so a
27
28
  * consumer reaching `createField` directly gets wording; the visual `strings` set extends it.
@@ -173,11 +174,16 @@ const spanCells = (a, b) => ({
173
174
  */
174
175
  const mounted = new WeakMap();
175
176
  /**
176
- * Where the caret stood as each table value was written over, keyed by that value: an undo hands
177
- * back the `props` object the edit replaced, so the seat held against it is where the edit was made
178
- * 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.
179
180
  */
180
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
+ };
181
187
  class TableIslandView {
182
188
  node;
183
189
  outer;
@@ -237,7 +243,7 @@ class TableIslandView {
237
243
  return false;
238
244
  const before = this.rendered;
239
245
  this.node = node;
240
- const props = tablePropsOfNode(node);
246
+ const props = tableOfNode(node);
241
247
  if (!props || !before || !shapeEqual(before, props)) {
242
248
  this.render();
243
249
  return true;
@@ -247,7 +253,8 @@ class TableIslandView {
247
253
  // re-hydrate takes fresh state. Compared against `shown`, not a doc projection: this runs
248
254
  // every keystroke and projecting costs a `mapMarks` across WASM per anchored cell.
249
255
  this.rendered = props;
250
- const departure = departures.get(props);
256
+ const key = valueKey(node);
257
+ const departure = key && departures.get(key);
251
258
  for (const mounted of this.cells) {
252
259
  const stored = cellAt(props, mounted.r, mounted.c);
253
260
  if (cellEqual(stored, mounted.shown))
@@ -1054,8 +1061,9 @@ class TableIslandView {
1054
1061
  this.cellCluster = undefined;
1055
1062
  this.rails = [];
1056
1063
  this.dom.textContent = '';
1057
- const props = tablePropsOfNode(this.node);
1058
- const departure = props && departures.get(props);
1064
+ const props = tableOfNode(this.node);
1065
+ const key = valueKey(this.node);
1066
+ const departure = props && key && departures.get(key);
1059
1067
  this.rendered = props;
1060
1068
  if (props)
1061
1069
  mounted.set(this.dom, this);
@@ -1327,9 +1335,8 @@ class TableIslandView {
1327
1335
  }),
1328
1336
  attributes: { 'aria-label': name, class: 'qm-table-cell-editor' },
1329
1337
  // A cell is one of the leaf's lines, so a reveal keeps the leaf's clearance, not PM's
1330
- // 5px default (`field.ts`).
1331
- scrollThreshold: this.deps.clearance,
1332
- scrollMargin: this.deps.clearance,
1338
+ // 5px default, and the same scroll padding (`reveal.ts`).
1339
+ ...revealProps(this.deps.clearance),
1333
1340
  dispatchTransaction: (tr) => {
1334
1341
  const from = { r, c, head: view.state.selection.head };
1335
1342
  const next = view.state.apply(tr);
@@ -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 tablePropsOfNode(this.node) ?? normalizeTable({ header: [], rows: [], aligns: [] });
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 = tablePropsOfNode(node);
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
- props: normalizeTable(next)
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, TableCell, TableProps } from '@quillmark/wasm';
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, read off the boundary rather than restated. */
4
- export type TableAlign = TableProps['aligns'][number];
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(): TableCell;
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: TableProps): number;
51
+ export declare function rowCount(props: TableGrid): number;
16
52
  /** The cells of row `r` in that space. */
17
- export declare function rowCells(props: TableProps, r: number): TableCell[];
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: TableProps, r: number): boolean;
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: TableProps, r: number, c: number): TableCell;
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: TableProps): number;
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: TableProps): TableProps;
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: TableProps): number;
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: TableProps): (Span | null)[][];
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.
@@ -48,50 +84,44 @@ export declare function anchorAt(grid: (Span | null)[][], r: number, c: number):
48
84
  c: number;
49
85
  span: Span;
50
86
  };
51
- /**
52
- * The rows as one list, header first: the space a row op works in, so move and delete treat every
53
- * row alike. `header` is a separate field because a table always has one; {@link fromRows} splits
54
- * it back.
55
- */
56
- export declare function allRows(props: TableProps): TableCell[][];
57
87
  /** A fresh table: a header plus `bodyRows` empty rows, every column unaligned. */
58
- export declare function newTable(cols?: number, bodyRows?: number): TableProps;
88
+ export declare function newTable(cols?: number, bodyRows?: number): TableGrid;
59
89
  /** `props` with the cell at `(r, c)` replaced. */
60
- export declare function withCell(props: TableProps, r: number, c: number, cell: TableCell): TableProps;
90
+ export declare function withCell(props: TableGrid, r: number, c: number, cell: GridCell): TableGrid;
61
91
  /** A new empty body row below row `r` (row 0, the header, opens the first body row). */
62
- export declare function insertRow(props: TableProps, r: number): TableProps;
92
+ export declare function insertRow(props: TableGrid, r: number): TableGrid;
63
93
  /**
64
94
  * Drop row `r`, the header included: the row left at index 0 becomes the header. A no-op at the
65
95
  * last row, which is the removal of the table and the island's to answer.
66
96
  */
67
- export declare function deleteRow(props: TableProps, r: number): TableProps;
97
+ export declare function deleteRow(props: TableGrid, r: number): TableGrid;
68
98
  /** A new empty column after column `c`. */
69
- export declare function insertColumn(props: TableProps, c: number): TableProps;
99
+ export declare function insertColumn(props: TableGrid, c: number): TableGrid;
70
100
  /** Drop column `c`; a no-op at one column (a table has at least one). */
71
- export declare function deleteColumn(props: TableProps, c: number): TableProps;
101
+ export declare function deleteColumn(props: TableGrid, c: number): TableGrid;
72
102
  /**
73
103
  * Row `r` moved by `by` places, clamped: a drag past the rectangle is a no-op, not an error. The
74
104
  * header travels like any other row; being the header is holding index 0.
75
105
  */
76
- export declare function moveRow(props: TableProps, r: number, by: number): TableProps;
106
+ export declare function moveRow(props: TableGrid, r: number, by: number): TableGrid;
77
107
  /**
78
108
  * Column `c` moved by `by` places, clamped. `aligns` and `widths` travel with the column, being its
79
109
  * properties.
80
110
  */
81
- export declare function moveColumn(props: TableProps, c: number, by: number): TableProps;
111
+ export declare function moveColumn(props: TableGrid, c: number, by: number): TableGrid;
82
112
  /**
83
113
  * Every cell in the inclusive rectangle emptied, alignment kept (a cell its own, a column its
84
114
  * alignment and width): a delete over a block covering no whole rank. A rectangle spanning one axis
85
115
  * deletes ranks and one spanning both is the table, so what reaches here is a proper sub-rectangle.
86
116
  */
87
- export declare function clearCells(props: TableProps, r0: number, c0: number, r1: number, c1: number): TableProps;
117
+ export declare function clearCells(props: TableGrid, r0: number, c0: number, r1: number, c1: number): TableGrid;
88
118
  /**
89
119
  * Set column `c`'s alignment and clear its cells' own `align`, which would outrank it
90
120
  * (`table-view.ts`).
91
121
  */
92
- export declare function setAlign(props: TableProps, c: number, align: TableAlign): TableProps;
122
+ export declare function setAlign(props: TableGrid, c: number, align: TableAlign): TableGrid;
93
123
  /** Draw the top `head` rows as header rows (`table-view.ts`). */
94
- export declare function setHead(props: TableProps, head: number): TableProps;
124
+ export declare function setHead(props: TableGrid, head: number): TableGrid;
95
125
  /** An inclusive block of cells, in the row space {@link rowCount} names. */
96
126
  export interface CellBlock {
97
127
  r0: number;
@@ -100,52 +130,50 @@ export interface CellBlock {
100
130
  c1: number;
101
131
  }
102
132
  /** `block` grown until every drawn cell it touches lies wholly inside it. */
103
- export declare function closeBlock(props: TableProps, block: CellBlock): CellBlock;
133
+ export declare function closeBlock(props: TableGrid, block: CellBlock): CellBlock;
104
134
  /**
105
135
  * Whether `block` can be one cell: more than one drawn cell, inside the header rows or the body.
106
136
  */
107
- export declare function canMerge(props: TableProps, block: CellBlock): boolean;
137
+ export declare function canMerge(props: TableGrid, block: CellBlock): boolean;
108
138
  /**
109
139
  * The block's cells as one, at its top-left: the text of each drawn cell holding any, in reading
110
140
  * order, a line apiece, every other slot an empty one the span covers, alignment kept. The top-left
111
141
  * cell's alignment is the merged cell's. A block {@link canMerge} refuses comes back as it was.
112
142
  */
113
- export declare function mergeCells(props: TableProps, block: CellBlock): TableProps;
143
+ export declare function mergeCells(props: TableGrid, block: CellBlock): TableGrid;
114
144
  /**
115
145
  * The merged cell covering `(r, c)` back to the cells under it: its text stays top-left, the rest
116
146
  * are the empty cells it covered.
117
147
  */
118
- export declare function splitCell(props: TableProps, r: number, c: number): TableProps;
148
+ export declare function splitCell(props: TableGrid, r: number, c: number): TableGrid;
119
149
  /**
120
150
  * Set or clear the column weights (`table-view.ts`); `undefined` returns every column to auto-fit.
121
151
  */
122
- export declare function setWidths(props: TableProps, widths: (number | null)[] | undefined): TableProps;
152
+ export declare function setWidths(props: TableGrid, widths: (number | null)[] | undefined): TableGrid;
123
153
  /**
124
154
  * Each column's share of the table's width, summing to 1, or `undefined` for a table that auto-fits
125
155
  * throughout. An auto-fit column beside weighted ones takes the mean weight, since the editor's
126
156
  * fixed-layout grid cannot size it to content as the page does.
127
157
  */
128
- export declare function columnShares(props: TableProps): number[] | undefined;
129
- /**
130
- * A cell as a one-paragraph `Content` for `decode` under `cellSchema`: each `\n` opens a
131
- * `continues` line, the hard break it decodes to. The cell's marks are that content's marks.
132
- */
133
- 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;
134
161
  /**
135
- * The cell a nested PM doc projects, carrying `prior`'s identity anchors through.
162
+ * The cell a nested PM doc projects, carrying `prior`'s layout, ids and anchors through.
136
163
  *
137
- * Anchors inside a cell are preserved verbatim, never minted: they are not in the field plugin's
138
- * coordinate space (its position map holds one `atom` run for the whole table), so the popover
139
- * withholds its `anchor` button in a cell. Preserving still means rebasing: `mapMarks` carries each
140
- * held anchor through the cell's delta by the store's rule, and a mark the splice deleted through
141
- * lands where the splice left it.
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.
142
169
  */
143
- export declare function cellFromDoc(doc: PMNode, prior: TableCell): TableCell;
170
+ export declare function cellFromDoc(doc: PMNode, prior: GridCell): GridCell;
144
171
  /**
145
172
  * Whether two cells are the same value, telling an own edit from an external one (an undo, a
146
173
  * re-hydrate) without a flag. Marks compare structurally, as `reconcile.ts` states.
147
174
  */
148
- export declare function cellEqual(a: TableCell, b: TableCell): boolean;
175
+ export declare function cellEqual(a: GridCell, b: GridCell): boolean;
149
176
  /** Whether two tables have the same rectangle, alignment, header and widths: the
150
177
  * change that forces a rebuild rather than a per-cell reseed. */
151
- export declare function shapeEqual(a: TableProps, b: TableProps): boolean;
178
+ export declare function shapeEqual(a: TableGrid, b: TableGrid): boolean;
179
+ export {};