@docmentis/udoc-editor 0.8.17 → 0.8.18

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 (128) hide show
  1. package/dist/commands.js +2 -2
  2. package/dist/commands.js.map +1 -1
  3. package/dist/components/TablePropertiesModal.d.ts +12 -0
  4. package/dist/components/TablePropertiesModal.d.ts.map +1 -0
  5. package/dist/components/TablePropertiesModal.js +222 -0
  6. package/dist/components/TablePropertiesModal.js.map +1 -0
  7. package/dist/context-menu.d.ts.map +1 -1
  8. package/dist/context-menu.js +12 -2
  9. package/dist/context-menu.js.map +1 -1
  10. package/dist/docmentis-theme.d.ts +2 -0
  11. package/dist/docmentis-theme.d.ts.map +1 -1
  12. package/dist/docmentis-theme.js +4 -0
  13. package/dist/docmentis-theme.js.map +1 -1
  14. package/dist/edit-client.d.ts +28 -1
  15. package/dist/edit-client.d.ts.map +1 -1
  16. package/dist/edit-client.js +33 -0
  17. package/dist/edit-client.js.map +1 -1
  18. package/dist/edit-mode.d.ts.map +1 -1
  19. package/dist/edit-mode.js +13 -3
  20. package/dist/edit-mode.js.map +1 -1
  21. package/dist/grips.d.ts.map +1 -1
  22. package/dist/grips.js +173 -10
  23. package/dist/grips.js.map +1 -1
  24. package/dist/i18n/ar.d.ts.map +1 -1
  25. package/dist/i18n/ar.js +58 -7
  26. package/dist/i18n/ar.js.map +1 -1
  27. package/dist/i18n/de.d.ts.map +1 -1
  28. package/dist/i18n/de.js +58 -7
  29. package/dist/i18n/de.js.map +1 -1
  30. package/dist/i18n/en.d.ts.map +1 -1
  31. package/dist/i18n/en.js +58 -7
  32. package/dist/i18n/en.js.map +1 -1
  33. package/dist/i18n/es.d.ts.map +1 -1
  34. package/dist/i18n/es.js +58 -7
  35. package/dist/i18n/es.js.map +1 -1
  36. package/dist/i18n/fr.d.ts.map +1 -1
  37. package/dist/i18n/fr.js +58 -7
  38. package/dist/i18n/fr.js.map +1 -1
  39. package/dist/i18n/ja.d.ts.map +1 -1
  40. package/dist/i18n/ja.js +62 -11
  41. package/dist/i18n/ja.js.map +1 -1
  42. package/dist/i18n/ko.d.ts.map +1 -1
  43. package/dist/i18n/ko.js +58 -7
  44. package/dist/i18n/ko.js.map +1 -1
  45. package/dist/i18n/messages.d.ts +108 -7
  46. package/dist/i18n/messages.d.ts.map +1 -1
  47. package/dist/i18n/pt-BR.d.ts.map +1 -1
  48. package/dist/i18n/pt-BR.js +58 -7
  49. package/dist/i18n/pt-BR.js.map +1 -1
  50. package/dist/i18n/ru.d.ts.map +1 -1
  51. package/dist/i18n/ru.js +58 -7
  52. package/dist/i18n/ru.js.map +1 -1
  53. package/dist/i18n/zh-CN.d.ts.map +1 -1
  54. package/dist/i18n/zh-CN.js +62 -11
  55. package/dist/i18n/zh-CN.js.map +1 -1
  56. package/dist/i18n/zh-TW.d.ts.map +1 -1
  57. package/dist/i18n/zh-TW.js +58 -7
  58. package/dist/i18n/zh-TW.js.map +1 -1
  59. package/dist/icons.d.ts +38 -0
  60. package/dist/icons.d.ts.map +1 -1
  61. package/dist/icons.js +38 -0
  62. package/dist/icons.js.map +1 -1
  63. package/dist/image.d.ts +5 -0
  64. package/dist/image.d.ts.map +1 -1
  65. package/dist/image.js +37 -4
  66. package/dist/image.js.map +1 -1
  67. package/dist/insert-table.d.ts +23 -0
  68. package/dist/insert-table.d.ts.map +1 -0
  69. package/dist/insert-table.js +135 -0
  70. package/dist/insert-table.js.map +1 -0
  71. package/dist/insert.d.ts +4 -1
  72. package/dist/insert.d.ts.map +1 -1
  73. package/dist/insert.js +5 -4
  74. package/dist/insert.js.map +1 -1
  75. package/dist/markup.d.ts +36 -1
  76. package/dist/markup.d.ts.map +1 -1
  77. package/dist/markup.js +175 -0
  78. package/dist/markup.js.map +1 -1
  79. package/dist/menu-action.d.ts +12 -3
  80. package/dist/menu-action.d.ts.map +1 -1
  81. package/dist/menu-action.js +13 -3
  82. package/dist/menu-action.js.map +1 -1
  83. package/dist/paint.d.ts +13 -2
  84. package/dist/paint.d.ts.map +1 -1
  85. package/dist/paint.js +2 -2
  86. package/dist/paint.js.map +1 -1
  87. package/dist/ruler-edits.js +7 -7
  88. package/dist/ruler-edits.js.map +1 -1
  89. package/dist/styles.d.ts.map +1 -1
  90. package/dist/styles.js +66 -0
  91. package/dist/styles.js.map +1 -1
  92. package/dist/table-edits.d.ts +44 -0
  93. package/dist/table-edits.d.ts.map +1 -0
  94. package/dist/table-edits.js +97 -0
  95. package/dist/table-edits.js.map +1 -0
  96. package/dist/table-format.d.ts +78 -0
  97. package/dist/table-format.d.ts.map +1 -0
  98. package/dist/table-format.js +222 -0
  99. package/dist/table-format.js.map +1 -0
  100. package/dist/table-picker.d.ts +14 -0
  101. package/dist/table-picker.d.ts.map +1 -0
  102. package/dist/table-picker.js +15 -0
  103. package/dist/table-picker.js.map +1 -0
  104. package/dist/table-properties.d.ts +12 -0
  105. package/dist/table-properties.d.ts.map +1 -0
  106. package/dist/table-properties.js +27 -0
  107. package/dist/table-properties.js.map +1 -0
  108. package/dist/table.d.ts +19 -9
  109. package/dist/table.d.ts.map +1 -1
  110. package/dist/table.js +230 -40
  111. package/dist/table.js.map +1 -1
  112. package/dist/tabs.d.ts +1 -1
  113. package/dist/tabs.d.ts.map +1 -1
  114. package/dist/tabs.js +64 -38
  115. package/dist/tabs.js.map +1 -1
  116. package/dist/text-format.d.ts +9 -3
  117. package/dist/text-format.d.ts.map +1 -1
  118. package/dist/text-format.js +45 -39
  119. package/dist/text-format.js.map +1 -1
  120. package/dist/version.d.ts +1 -1
  121. package/dist/version.js +1 -1
  122. package/dist/worker/handlers.d.ts.map +1 -1
  123. package/dist/worker/handlers.js +28 -0
  124. package/dist/worker/handlers.js.map +1 -1
  125. package/dist/worker/protocol.d.ts +38 -1
  126. package/dist/worker/protocol.d.ts.map +1 -1
  127. package/dist/worker/worker-source.js +1 -1
  128. package/package.json +3 -3
@@ -0,0 +1,44 @@
1
+ import type { TableSelectionEdit, TableSelectionProperties, TextSelection, UDocSelection } from "@docmentis/udoc-wasm";
2
+ /** The value a consensus holds, `null` where it holds several or none. */
3
+ export declare function consensusValue<T>(consensus: "absent" | "mixed" | {
4
+ value: T;
5
+ } | undefined): T | null;
6
+ /** The one position the innermost table `text` is in takes in its story, as a
7
+ * range over it — what a delete of that table deletes. `null` outside a table. */
8
+ export declare function tableSlotSelection(text: TextSelection): TextSelection | null;
9
+ /** A word document's selection with the table it is in selected as text — the
10
+ * body's, a header's or a footer's — or `null` where it isn't in one. */
11
+ export declare function wordTableSelection(selection: UDocSelection): UDocSelection | null;
12
+ /** The four sides of a cell's margins, by name. */
13
+ export type MarginSide = "top" | "bottom" | "left" | "right";
14
+ export declare const MARGIN_SIDES: readonly MarginSide[];
15
+ /** What the dialog shows: each value the selection holds one of, `null` where
16
+ * it holds several (or none) — a blank field. In points. */
17
+ export interface TablePropertiesValues {
18
+ rowHeight: number | null;
19
+ columnWidth: number | null;
20
+ margins: Record<MarginSide, number | null>;
21
+ /** Repeat Header Rows — a word document's alone. */
22
+ header: boolean | null;
23
+ }
24
+ /** What the dialog opens on: the selection's values, and how its rows declare
25
+ * their height, which an edited height keeps. */
26
+ export interface TablePropertiesSeed {
27
+ values: TablePropertiesValues;
28
+ /** `exact` where every selected row is exactly its height; `atLeast` — a
29
+ * minimum, a deck's only rule and a word document's default — otherwise. */
30
+ heightRule: "atLeast" | "exact";
31
+ /** Whether Repeat Header Rows shows — in a word document, which repeats a
32
+ * table's header rows across pages; a deck's table never splits. */
33
+ showHeader: boolean;
34
+ }
35
+ /** The dialog's opening values for `table`, the selection's table properties. */
36
+ export declare function tablePropertiesSeed(table: TableSelectionProperties, wordprocessing: boolean): TablePropertiesSeed;
37
+ /**
38
+ * The edits OK sends for `values` against what the dialog opened on: only what
39
+ * changed, at most one per kind — the rows' height and header together, the
40
+ * columns' width, the cells' margins with only the sides that moved — so a
41
+ * field left as it was stays as each cell has it.
42
+ */
43
+ export declare function tablePropertiesEdits(seed: TablePropertiesSeed, values: TablePropertiesValues): TableSelectionEdit[];
44
+ //# sourceMappingURL=table-edits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-edits.d.ts","sourceRoot":"","sources":["../src/table-edits.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGR,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,aAAa,EAChB,MAAM,sBAAsB,CAAC;AAE9B,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,GAAG,OAAO,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG,SAAS,GAAG,CAAC,GAAG,IAAI,CAEpG;AAED;mFACmF;AACnF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI,CAS5E;AAED;0EAC0E;AAC1E,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI,CAiBjF;AAED,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7D,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAuC,CAAC;AAEtF;6DAC6D;AAC7D,MAAM,WAAW,qBAAqB;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,oDAAoD;IACpD,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1B;AAED;kDACkD;AAClD,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,qBAAqB,CAAC;IAC9B;iFAC6E;IAC7E,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;yEACqE;IACrE,UAAU,EAAE,OAAO,CAAC;CACvB;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,OAAO,GAAG,mBAAmB,CAmBjH;AAQD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,qBAAqB,GAAG,kBAAkB,EAAE,CAqBnH"}
@@ -0,0 +1,97 @@
1
+ /** The value a consensus holds, `null` where it holds several or none. */
2
+ export function consensusValue(consensus) {
3
+ return typeof consensus === "object" ? consensus.value : null;
4
+ }
5
+ /** The one position the innermost table `text` is in takes in its story, as a
6
+ * range over it — what a delete of that table deletes. `null` outside a table. */
7
+ export function tableSlotSelection(text) {
8
+ if (!("table" in text))
9
+ return null;
10
+ const { story, offset, table } = text.table;
11
+ // A table in a cell of this one is the innermost: descend through the cell.
12
+ if ("cellText" in table) {
13
+ const inner = tableSlotSelection(table.cellText.text);
14
+ if (inner)
15
+ return { table: { story, offset, table: { cellText: { ...table.cellText, text: inner } } } };
16
+ }
17
+ return { range: { story, anchor: offset, focus: offset + 1 } };
18
+ }
19
+ /** A word document's selection with the table it is in selected as text — the
20
+ * body's, a header's or a footer's — or `null` where it isn't in one. */
21
+ export function wordTableSelection(selection) {
22
+ if (!("wordprocessing" in selection))
23
+ return null;
24
+ const word = selection.wordprocessing;
25
+ if (typeof word !== "object")
26
+ return null;
27
+ if ("sectionText" in word) {
28
+ const slot = tableSlotSelection(word.sectionText.selection);
29
+ return slot && { wordprocessing: { sectionText: { ...word.sectionText, selection: slot } } };
30
+ }
31
+ if ("headerText" in word) {
32
+ const slot = tableSlotSelection(word.headerText.selection);
33
+ return slot && { wordprocessing: { headerText: { ...word.headerText, selection: slot } } };
34
+ }
35
+ if ("footerText" in word) {
36
+ const slot = tableSlotSelection(word.footerText.selection);
37
+ return slot && { wordprocessing: { footerText: { ...word.footerText, selection: slot } } };
38
+ }
39
+ return null;
40
+ }
41
+ export const MARGIN_SIDES = ["top", "bottom", "left", "right"];
42
+ /** The dialog's opening values for `table`, the selection's table properties. */
43
+ export function tablePropertiesSeed(table, wordprocessing) {
44
+ const height = consensusValue(table.height);
45
+ const margins = consensusValue(table.margins);
46
+ return {
47
+ values: {
48
+ // An automatic height states no measure: the field opens blank.
49
+ rowHeight: height === null || height === "auto" ? null : "exact" in height ? height.exact : height.atLeast,
50
+ columnWidth: consensusValue(table.width),
51
+ margins: {
52
+ top: margins?.top ?? null,
53
+ bottom: margins?.bottom ?? null,
54
+ left: margins?.left ?? null,
55
+ right: margins?.right ?? null,
56
+ },
57
+ header: consensusValue(table.header),
58
+ },
59
+ heightRule: height !== null && height !== "auto" && "exact" in height ? "exact" : "atLeast",
60
+ showHeader: wordprocessing,
61
+ };
62
+ }
63
+ /** Whether `next` is a value other than `was` — a blank field never is, and a
64
+ * measure differs once it moves by a hundredth of a point. */
65
+ function changed(next, was) {
66
+ return next !== null && (was === null || Math.abs(next - was) >= 0.005);
67
+ }
68
+ /**
69
+ * The edits OK sends for `values` against what the dialog opened on: only what
70
+ * changed, at most one per kind — the rows' height and header together, the
71
+ * columns' width, the cells' margins with only the sides that moved — so a
72
+ * field left as it was stays as each cell has it.
73
+ */
74
+ export function tablePropertiesEdits(seed, values) {
75
+ const was = seed.values;
76
+ const edits = [];
77
+ const row = {};
78
+ if (changed(values.rowHeight, was.rowHeight)) {
79
+ row.height = seed.heightRule === "exact" ? { exact: values.rowHeight } : { atLeast: values.rowHeight };
80
+ }
81
+ if (seed.showHeader && values.header !== null && values.header !== was.header)
82
+ row.header = values.header;
83
+ if (Object.keys(row).length > 0)
84
+ edits.push({ patchRowProperties: { properties: row } });
85
+ if (changed(values.columnWidth, was.columnWidth))
86
+ edits.push({ setColumnWidth: { width: values.columnWidth } });
87
+ const margins = {};
88
+ for (const side of MARGIN_SIDES) {
89
+ const next = values.margins[side];
90
+ if (changed(next, was.margins[side]))
91
+ margins[side] = next;
92
+ }
93
+ if (Object.keys(margins).length > 0)
94
+ edits.push({ patchCellProperties: { properties: { margins } } });
95
+ return edits;
96
+ }
97
+ //# sour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from "@docmentis/udoc-wasm";
2
+ import type { LineDash, PaintSpec, RibbonControl, RibbonControlEnv, UIShellHost } from "@docmentis/udoc-ui/internal";
3
+ import type { MessageKey } from "./i18n/index.js";
4
+ import type { EditTools } from "./tools.js";
5
+ /** The selection's table properties — what the Table tab's controls mirror —
6
+ * or `null` outside a table. */
7
+ export declare function selectionTable(properties: UDocSelectionProperties | null): TableSelectionProperties | null;
8
+ /** Turn one of the Table Style Options on or off — the rest of the look as the
9
+ * table has it, since the look is set whole. */
10
+ export declare function toggleTableLook(host: UIShellHost, flag: keyof TableLook): Promise<void>;
11
+ /**
12
+ * Delete the table the selection is in. A deck's table is its frame, a shape
13
+ * like any other, so it goes as the selected shape does. A word document's
14
+ * takes one position in its story, so that position is selected and deleted as
15
+ * text — the paragraphs either side stay apart, as a table's own position is
16
+ * all a delete of it covers.
17
+ */
18
+ export declare function deleteTable(host: UIShellHost): Promise<void>;
19
+ /** Run `edit` on the table the selection is in — one committing edit. */
20
+ export declare function runTableEdit(host: UIShellHost, edit: TableSelectionEdit): Promise<void>;
21
+ /**
22
+ * The Shading dropdown: the cells' fill. Like the Shape tab's Fill it mirrors
23
+ * the selection — the swatch is the shading of the cells it covers, the one a
24
+ * table style's banding gives them included — and the caret opens the color
25
+ * panel, whose No Fill row takes the shading away.
26
+ */
27
+ export declare function tableShadingControl(env: RibbonControlEnv, tools: EditTools): RibbonControl;
28
+ /** The pen a Border lays: a color, a weight in points and a dash. */
29
+ export interface BorderPen {
30
+ paint: PaintSpec;
31
+ weight: number;
32
+ dash: LineDash;
33
+ }
34
+ /** The pen a Border starts with: Office's, a 1pt solid black line. */
35
+ export declare const DEFAULT_BORDER_PEN: BorderPen;
36
+ /** Diagonal Down Border: the top-left to bottom-right diagonal. */
37
+ export declare const ICON_BORDER_DIAGONAL_DOWN = "<svg viewBox=\"0 -960 960 960\" fill=\"currentColor\"><path d=\"M144-144v-72h72v72h-72ZM144-294v-72h72v72h-72ZM144-444v-72h72v72h-72ZM144-594v-72h72v72h-72ZM144-744v-72h72v72h-72ZM744-144v-72h72v72h-72ZM744-294v-72h72v72h-72ZM744-444v-72h72v72h-72ZM744-594v-72h72v72h-72ZM744-744v-72h72v72h-72ZM294-744v-72h72v72h-72ZM444-744v-72h72v72h-72ZM594-744v-72h72v72h-72ZM294-144v-72h72v72h-72ZM444-144v-72h72v72h-72ZM594-144v-72h72v72h-72Z\"/><path d=\"M144-816h51l621 621v51h-51L144-765v-51Z\"/></svg>";
38
+ /** Diagonal Up Border: the bottom-left to top-right diagonal. */
39
+ export declare const ICON_BORDER_DIAGONAL_UP = "<svg viewBox=\"0 -960 960 960\" fill=\"currentColor\"><path d=\"M144-144v-72h72v72h-72ZM144-294v-72h72v72h-72ZM144-444v-72h72v72h-72ZM144-594v-72h72v72h-72ZM144-744v-72h72v72h-72ZM744-144v-72h72v72h-72ZM744-294v-72h72v72h-72ZM744-444v-72h72v72h-72ZM744-594v-72h72v72h-72ZM744-744v-72h72v72h-72ZM294-744v-72h72v72h-72ZM444-744v-72h72v72h-72ZM594-744v-72h72v72h-72ZM294-144v-72h72v72h-72ZM444-144v-72h72v72h-72ZM594-144v-72h72v72h-72Z\"/><path d=\"M144-144h51l621-621v-51h-51L144-195v51Z\"/></svg>";
40
+ /** One of the Border menu's edge choices: what it lays the pen on, its name, and
41
+ * its glyph. */
42
+ export interface EdgeChoice {
43
+ edges: TableCellBorderEdge;
44
+ label: MessageKey;
45
+ icon: string;
46
+ }
47
+ /** The edge choices, in Word's and PowerPoint's order. */
48
+ export declare const BORDER_EDGES: readonly EdgeChoice[];
49
+ /** The border `pen` draws as: its `DrawingML` line alone, which the renderer
50
+ * strokes and a save of either format writes. */
51
+ export declare function borderOfPen(pen: BorderPen): TableBorder;
52
+ /** No Border's line: one with no fill, which draws nothing — laid on every
53
+ * edge, the diagonals included. */
54
+ export declare function noBorder(): TableBorder;
55
+ /** The edit that lays `border` on `edges` of the selected block. */
56
+ export declare function borderEdit(edges: TableCellBorderEdge, border: TableBorder): TableSelectionEdit;
57
+ /** The pen the Border control lays — what the Border Color and Border
58
+ * controls share, made once for edit mode and kept across the ribbon's
59
+ * rebuilds. */
60
+ export interface BorderState {
61
+ pen: BorderPen;
62
+ }
63
+ /** A border state at Office's starting pen. */
64
+ export declare function createBorderState(): BorderState;
65
+ /**
66
+ * The Border Color dropdown: the pen the Border control lays — its color, and
67
+ * its weight and dash in the panel's fly-outs. It sets the pen and nothing else,
68
+ * as Word's Pen Color does: the borders already drawn keep theirs, and the next
69
+ * Border draws with it. The swatch shows the pen's color.
70
+ */
71
+ export declare function tableBorderColorControl(env: RibbonControlEnv, tools: EditTools, state: BorderState): RibbonControl;
72
+ /**
73
+ * The Border split button: the main part lays the pen on All Borders, which
74
+ * its glyph shows; the caret lists the edge choices, then No Border, each
75
+ * laying the pen (or taking the borders away) at once.
76
+ */
77
+ export declare function tableBorderControl(env: RibbonControlEnv, tools: EditTools, state: BorderState): RibbonControl;
78
+ //# sourceMappingURL=table-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-format.d.ts","sourceRoot":"","sources":["../src/table-format.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAER,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EAC1B,MAAM,sBAAsB,CAAC;AAa9B,OAAO,KAAK,EACR,QAAQ,EAER,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,WAAW,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkBlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;iCACiC;AACjC,wBAAgB,cAAc,CAAC,UAAU,EAAE,uBAAuB,GAAG,IAAI,GAAG,wBAAwB,GAAG,IAAI,CAE1G;AAED;iDACiD;AACjD,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,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,IAAI,WAAW,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,GAAG,aAAa,CAwClH;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,GAAG,aAAa,CAyC7G"}
@@ -0,0 +1,222 @@
1
+ import { applyPaintBar, buildPaintPanel, createDropdownButton, createMenuItem, createSplitButton, displayToActivePaint, drawingProperties, ICON_FILL as ICON_SHADING, paintSwatch, tableShadingDisplay, } from "@docmentis/udoc-ui/internal";
2
+ import { ICON_BORDER_ALL, ICON_BORDER_BOTTOM, ICON_BORDER_COLOR, ICON_BORDER_INSIDE, ICON_BORDER_INSIDE_HORIZONTAL, ICON_BORDER_INSIDE_VERTICAL, ICON_BORDER_LEFT, ICON_BORDER_NONE, ICON_BORDER_OUTSIDE, ICON_BORDER_RIGHT, ICON_BORDER_TOP, } from "./icons.js";
3
+ import { changedDrawingLine } from "./line-edit.js";
4
+ import { mapThemeColors, paintToDrawingFill, THEMED } from "./paint.js";
5
+ import { editState } from "./state.js";
6
+ import { consensusValue, wordTableSelection } from "./table-edits.js";
7
+ /** The selection's table properties — what the Table tab's controls mirror —
8
+ * or `null` outside a table. */
9
+ export function selectionTable(properties) {
10
+ return drawingProperties(properties)?.table ?? null;
11
+ }
12
+ /** Turn one of the Table Style Options on or off — the rest of the look as the
13
+ * table has it, since the look is set whole. */
14
+ export function toggleTableLook(host, flag) {
15
+ const look = consensusValue(selectionTable(editState(host.store.getState()).selectionProperties)?.look);
16
+ if (!look)
17
+ return Promise.resolve();
18
+ return runTableEdit(host, { patchTableProperties: { properties: { look: { ...look, [flag]: !look[flag] } } } });
19
+ }
20
+ /**
21
+ * Delete the table the selection is in. A deck's table is its frame, a shape
22
+ * like any other, so it goes as the selected shape does. A word document's
23
+ * takes one position in its story, so that position is selected and deleted as
24
+ * text — the paragraphs either side stay apart, as a table's own position is
25
+ * all a delete of it covers.
26
+ */
27
+ export async function deleteTable(host) {
28
+ if (host.store.getState().docType === "wordprocessing") {
29
+ const selection = await host.client.selection();
30
+ const slot = selection && wordTableSelection(selection);
31
+ if (!slot)
32
+ return;
33
+ host.client.setSelection(slot);
34
+ await host.commit(() => host.client.executeOnSelection({ kind: "deleteText", forward: true }));
35
+ return;
36
+ }
37
+ await host.commit(() => host.client.executeOnSelection({ kind: "deleteShapes" }));
38
+ }
39
+ /** Run `edit` on the table the selection is in — one committing edit. */
40
+ export function runTableEdit(host, edit) {
41
+ return host.commit(() => host.client.executeOnSelection(edit));
42
+ }
43
+ /** The theme block the color panels show: the document's palette for an Office
44
+ * document, none for a PDF. */
45
+ function themeOf(env) {
46
+ const state = env.store.getState();
47
+ return state.docType !== null && THEMED.has(state.docType) ? mapThemeColors(editState(state).themePalette) : null;
48
+ }
49
+ /**
50
+ * The Shading dropdown: the cells' fill. Like the Shape tab's Fill it mirrors
51
+ * the selection — the swatch is the shading of the cells it covers, the one a
52
+ * table style's banding gives them included — and the caret opens the color
53
+ * panel, whose No Fill row takes the shading away.
54
+ */
55
+ export function tableShadingControl(env, tools) {
56
+ const { i18n } = tools;
57
+ const shading = () => tableShadingDisplay(editState(env.store.getState()).selectionProperties);
58
+ const dd = createDropdownButton({ icon: paintSwatch(ICON_SHADING, shading()), label: env.label }, {
59
+ menuLabel: i18n.t("ribbon.paintOptions", { label: env.label }),
60
+ onOpen: () => buildPaintPanel(dd.menu, {
61
+ i18n,
62
+ variant: "fill",
63
+ theme: themeOf(env),
64
+ recent: env.recentPaint.fill,
65
+ active: displayToActivePaint(shading()),
66
+ stroke: null,
67
+ onPick: (paint) => {
68
+ if (paint.kind !== "none")
69
+ env.pushRecent("fill", paint.hex);
70
+ dd.controller.close();
71
+ void runTableEdit(tools.host, {
72
+ patchCellProperties: { properties: { fill: paintToDrawingFill(paint) } },
73
+ });
74
+ },
75
+ }),
76
+ });
77
+ dd.trigger.dataset.command = "tableShading";
78
+ return {
79
+ el: dd.el,
80
+ sync: (state) => applyPaintBar(dd.trigger, tableShadingDisplay(editState(state).selectionProperties)),
81
+ close: () => dd.controller.close(),
82
+ destroy: () => dd.destroy(),
83
+ };
84
+ }
85
+ /** The pen a Border starts with: Office's, a 1pt solid black line. */
86
+ export const DEFAULT_BORDER_PEN = { paint: { kind: "solid", hex: "#000000" }, weight: 1, dash: "solid" };
87
+ // The two diagonal borders Material Symbols has no symbol for, drawn from
88
+ // `border_clear`, the no-border glyph: its dotted frame, less the dotted cross
89
+ // inside it — a diagonal is a cell's own, and the cross's centre would sit on
90
+ // it — with one solid diagonal corner to corner, as thick across as Material's
91
+ // own diagonals. Modified from Material Symbols, © Google LLC, licensed under
92
+ // the Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0
93
+ /** Diagonal Down Border: the top-left to bottom-right diagonal. */
94
+ export const ICON_BORDER_DIAGONAL_DOWN = `<svg viewBox="0 -960 960 960" fill="currentColor"><path d="M144-144v-72h72v72h-72ZM144-294v-72h72v72h-72ZM144-444v-72h72v72h-72ZM144-594v-72h72v72h-72ZM144-744v-72h72v72h-72ZM744-144v-72h72v72h-72ZM744-294v-72h72v72h-72ZM744-444v-72h72v72h-72ZM744-594v-72h72v72h-72ZM744-744v-72h72v72h-72ZM294-744v-72h72v72h-72ZM444-744v-72h72v72h-72ZM594-744v-72h72v72h-72ZM294-144v-72h72v72h-72ZM444-144v-72h72v72h-72ZM594-144v-72h72v72h-72Z"/><path d="M144-816h51l621 621v51h-51L144-765v-51Z"/></svg>`;
95
+ /** Diagonal Up Border: the bottom-left to top-right diagonal. */
96
+ export const ICON_BORDER_DIAGONAL_UP = `<svg viewBox="0 -960 960 960" fill="currentColor"><path d="M144-144v-72h72v72h-72ZM144-294v-72h72v72h-72ZM144-444v-72h72v72h-72ZM144-594v-72h72v72h-72ZM144-744v-72h72v72h-72ZM744-144v-72h72v72h-72ZM744-294v-72h72v72h-72ZM744-444v-72h72v72h-72ZM744-594v-72h72v72h-72ZM744-744v-72h72v72h-72ZM294-744v-72h72v72h-72ZM444-744v-72h72v72h-72ZM594-744v-72h72v72h-72ZM294-144v-72h72v72h-72ZM444-144v-72h72v72h-72ZM594-144v-72h72v72h-72Z"/><path d="M144-144h51l621-621v-51h-51L144-195v51Z"/></svg>`;
97
+ /** The edge choices, in Word's and PowerPoint's order. */
98
+ export const BORDER_EDGES = [
99
+ { edges: "all", label: "table.borderAll", icon: ICON_BORDER_ALL },
100
+ { edges: "outside", label: "table.borderOutside", icon: ICON_BORDER_OUTSIDE },
101
+ { edges: "inside", label: "table.borderInside", icon: ICON_BORDER_INSIDE },
102
+ { edges: "top", label: "table.borderTop", icon: ICON_BORDER_TOP },
103
+ { edges: "bottom", label: "table.borderBottom", icon: ICON_BORDER_BOTTOM },
104
+ { edges: "left", label: "table.borderLeft", icon: ICON_BORDER_LEFT },
105
+ { edges: "right", label: "table.borderRight", icon: ICON_BORDER_RIGHT },
106
+ { edges: "insideHorizontal", label: "table.borderInsideHorizontal", icon: ICON_BORDER_INSIDE_HORIZONTAL },
107
+ { edges: "insideVertical", label: "table.borderInsideVertical", icon: ICON_BORDER_INSIDE_VERTICAL },
108
+ { edges: "diagonalDown", label: "table.borderDiagonalDown", icon: ICON_BORDER_DIAGONAL_DOWN },
109
+ { edges: "diagonalUp", label: "table.borderDiagonalUp", icon: ICON_BORDER_DIAGONAL_UP },
110
+ ];
111
+ /** The border `pen` draws as: its `DrawingML` line alone, which the renderer
112
+ * strokes and a save of either format writes. */
113
+ export function borderOfPen(pen) {
114
+ const line = changedDrawingLine(null, {}, { fill: paintToDrawingFill(pen.paint), weight: pen.weight, dash: pen.dash });
115
+ return { line };
116
+ }
117
+ /** No Border's line: one with no fill, which draws nothing — laid on every
118
+ * edge, the diagonals included. */
119
+ export function noBorder() {
120
+ return { line: changedDrawingLine(null, { fill: "none" }, { fill: "none", weight: 1, dash: "solid" }) };
121
+ }
122
+ /** The edit that lays `border` on `edges` of the selected block. */
123
+ export function borderEdit(edges, border) {
124
+ return { patchCellBorders: { edges, border } };
125
+ }
126
+ /** A border state at Office's starting pen. */
127
+ export function createBorderState() {
128
+ return { pen: { ...DEFAULT_BORDER_PEN } };
129
+ }
130
+ /**
131
+ * The Border Color dropdown: the pen the Border control lays — its color, and
132
+ * its weight and dash in the panel's fly-outs. It sets the pen and nothing else,
133
+ * as Word's Pen Color does: the borders already drawn keep theirs, and the next
134
+ * Border draws with it. The swatch shows the pen's color.
135
+ */
136
+ export function tableBorderColorControl(env, tools, state) {
137
+ const { i18n } = tools;
138
+ const dd = createDropdownButton({ icon: paintSwatch(ICON_BORDER_COLOR, displayOfPen(state.pen)), label: env.label }, {
139
+ menuLabel: i18n.t("ribbon.paintOptions", { label: env.label }),
140
+ onOpen: () => {
141
+ buildPaintPanel(dd.menu, {
142
+ i18n,
143
+ variant: "stroke",
144
+ theme: themeOf(env),
145
+ recent: env.recentPaint.stroke,
146
+ active: state.pen.paint,
147
+ stroke: { weight: state.pen.weight, dash: state.pen.dash },
148
+ onPick: (paint) => {
149
+ if (paint.kind !== "none")
150
+ env.pushRecent("stroke", paint.hex);
151
+ setPen({ ...state.pen, paint });
152
+ },
153
+ onWeight: (weight) => setPen({ ...state.pen, weight }),
154
+ onDash: (dash) => setPen({ ...state.pen, dash }),
155
+ });
156
+ // A pen has a color; taking the borders away is the Border
157
+ // menu's No Border.
158
+ dd.menu.querySelector(".udoc-paintpanel__none")?.remove();
159
+ },
160
+ });
161
+ dd.trigger.dataset.command = "tableBorderColor";
162
+ function setPen(pen) {
163
+ state.pen = pen;
164
+ applyPaintBar(dd.trigger, displayOfPen(pen));
165
+ dd.controller.close();
166
+ }
167
+ return {
168
+ el: dd.el,
169
+ close: () => dd.controller.close(),
170
+ destroy: () => dd.destroy(),
171
+ };
172
+ }
173
+ /**
174
+ * The Border split button: the main part lays the pen on All Borders, which
175
+ * its glyph shows; the caret lists the edge choices, then No Border, each
176
+ * laying the pen (or taking the borders away) at once.
177
+ */
178
+ export function tableBorderControl(env, tools, state) {
179
+ const { i18n } = tools;
180
+ const split = createSplitButton({
181
+ mainLabel: env.label,
182
+ mainIcon: ICON_BORDER_ALL,
183
+ caretLabel: i18n.t("table.borderOptions"),
184
+ menuLabel: i18n.t("table.borderOptions"),
185
+ onOpen: () => fill(),
186
+ });
187
+ split.main.dataset.command = "tableBorder";
188
+ split.caret.dataset.command = "tableBorder";
189
+ const lay = (edges) => {
190
+ void runTableEdit(tools.host, borderEdit(edges, borderOfPen(state.pen)));
191
+ };
192
+ split.main.addEventListener("click", () => lay("all"));
193
+ function fill() {
194
+ split.menu.innerHTML = "";
195
+ const row = (icon, label, run) => {
196
+ const item = createMenuItem({ icon, text: i18n.t(label) });
197
+ item.addEventListener("click", (e) => {
198
+ e.stopPropagation();
199
+ split.controller.close();
200
+ run();
201
+ });
202
+ return item;
203
+ };
204
+ for (const choice of BORDER_EDGES)
205
+ split.menu.append(row(choice.icon, choice.label, () => lay(choice.edges)));
206
+ const none = row(ICON_BORDER_NONE, "table.borderNone", () => {
207
+ void runTableEdit(tools.host, borderEdit("allAndDiagonals", noBorder()));
208
+ });
209
+ none.classList.add("udoc-toolbar__menu-item--divider");
210
+ split.menu.append(none);
211
+ }
212
+ return {
213
+ el: split.el,
214
+ close: () => split.controller.close(),
215
+ destroy: () => split.destroy(),
216
+ };
217
+ }
218
+ /** The bar a pen's color shows as under the Border Color glyph. */
219
+ function displayOfPen(pen) {
220
+ return pen.paint.kind === "none" ? { kind: "none" } : { kind: "solid", hex: pen.paint.hex };
221
+ }
222
+ //# sourceMappingURL=table-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-format.js","sourceRoot":"","sources":["../src/table-format.ts"],"names":[],"mappings":"AAWA,OAAO,EACH,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,IAAI,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AAK,CAAC,IAAI,EAAE,UAAU,CAAC,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE;KACjC,CAAC;AACN,CAAC;AAED,mEAAmE;AACnE,SAAS,YAAY,CAAC,GAAc;IAChC,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChG,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** The grid's size: the largest table it inserts, as Word's and PowerPoint's. */
2
+ export declare const PICKER_ROWS = 8;
3
+ export declare const PICKER_COLUMNS = 10;
4
+ /** A table's size, in rows and columns. */
5
+ export interface TableSize {
6
+ rows: number;
7
+ columns: number;
8
+ }
9
+ /** The size the grid's cell at `row`, `column` (0-based) stands for: every cell
10
+ * up to it and left of it, inclusive. */
11
+ export declare function pickedSize(row: number, column: number): TableSize;
12
+ /** Whether the grid's cell at `row`, `column` lies inside `size`, so it lights. */
13
+ export declare function inSize(size: TableSize | null, row: number, column: number): boolean;
14
+ //# sourceMappingURL=table-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-picker.d.ts","sourceRoot":"","sources":["../src/table-picker.ts"],"names":[],"mappings":"AAGA,iFAAiF;AACjF,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;0CAC0C;AAC1C,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAEjE;AAED,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnF"}
@@ -0,0 +1,15 @@
1
+ // The sizing behind Insert Table's grid, apart from the grid itself: which
2
+ // table a cell of it stands for, and which cells light for a size.
3
+ /** The grid's size: the largest table it inserts, as Word's and PowerPoint's. */
4
+ export const PICKER_ROWS = 8;
5
+ export const PICKER_COLUMNS = 10;
6
+ /** The size the grid's cell at `row`, `column` (0-based) stands for: every cell
7
+ * up to it and left of it, inclusive. */
8
+ export function pickedSize(row, column) {
9
+ return { rows: row + 1, columns: column + 1 };
10
+ }
11
+ /** Whether the grid's cell at `row`, `column` lies inside `size`, so it lights. */
12
+ export function inSize(size, row, column) {
13
+ return size !== null && row < size.rows && column < size.columns;
14
+ }
15
+ //# sourceMappingURL=table-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-picker.js","sourceRoot":"","sources":["../src/table-picker.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mEAAmE;AAEnE,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAQjC;0CAC0C;AAC1C,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,MAAc;IAClD,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,MAAM,CAAC,IAAsB,EAAE,GAAW,EAAE,MAAc;IACtE,OAAO,IAAI,KAAK,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;AACrE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { EditHost } from "./edit-client.js";
2
+ import type { I18n } from "./i18n/index.js";
3
+ /** The Table Properties dialog, mounted into a shell. */
4
+ export interface TableProperties {
5
+ /** Open the dialog on the table the selection is in. */
6
+ open(): void;
7
+ destroy(): void;
8
+ }
9
+ /** Mount the Table Properties dialog into `host` — once, seeded from the
10
+ * selection each open. Its OK sends one edit per kind that changed, in turn. */
11
+ export declare function mountTableProperties(host: EditHost, i18n: I18n): TableProperties;
12
+ //# sourceMappingURL=table-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-properties.d.ts","sourceRoot":"","sources":["../src/table-properties.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAK5C,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC5B,wDAAwD;IACxD,IAAI,IAAI,IAAI,CAAC;IACb,OAAO,IAAI,IAAI,CAAC;CACnB;AAED;iFACiF;AACjF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,eAAe,CAehF"}
@@ -0,0 +1,27 @@
1
+ // The Table Properties dialog, mounted into edit mode: seeded from the selection's
2
+ // table on each open, its OK sending the edits of what changed.
3
+ import { createTablePropertiesModal } from "./components/TablePropertiesModal.js";
4
+ import { editState } from "./state.js";
5
+ import { tablePropertiesEdits, tablePropertiesSeed } from "./table-edits.js";
6
+ import { runTableEdit, selectionTable } from "./table-format.js";
7
+ /** Mount the Table Properties dialog into `host` — once, seeded from the
8
+ * selection each open. Its OK sends one edit per kind that changed, in turn. */
9
+ export function mountTableProperties(host, i18n) {
10
+ const modal = createTablePropertiesModal(i18n);
11
+ modal.mount(host.root);
12
+ return {
13
+ open() {
14
+ const state = host.store.getState();
15
+ const table = selectionTable(editState(state).selectionProperties);
16
+ if (!table)
17
+ return;
18
+ const seed = tablePropertiesSeed(table, state.docType === "wordprocessing");
19
+ modal.open(seed, async (values) => {
20
+ for (const edit of tablePropertiesEdits(seed, values))
21
+ await runTableEdit(host, edit);
22
+ });
23
+ },
24
+ destroy: () => modal.destroy(),
25
+ };
26
+ }
27
+ //# sourceMappingURL=table-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-properties.js","sourceRoot":"","sources":["../src/table-properties.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,gEAAgE;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AASjE;iFACiF;AACjF,MAAM,UAAU,oBAAoB,CAAC,IAAc,EAAE,IAAU;IAC3D,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAC/C,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO;QACH,IAAI;YACA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,mBAAmB,CAAC,CAAC;YACnE,IAAI,CAAC,KAAK;gBAAE,OAAO;YACnB,MAAM,IAAI,GAAG,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,KAAK,gBAAgB,CAAC,CAAC;YAC5E,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBAC9B,KAAK,MAAM,IAAI,IAAI,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC;oBAAE,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC1F,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE;KACjC,CAAC;AACN,CAAC"}
package/dist/table.d.ts CHANGED
@@ -8,6 +8,12 @@ export declare const ICON_DELETE_ROWS = "<svg viewBox=\"0 -960 960 960\" fill=\"
8
8
  * heads clear of the frame's sides, and their tails meet where the merge arrows'
9
9
  * tips do. */
10
10
  export declare const ICON_UNMERGE_CELLS = "<svg viewBox=\"0 -960 960 960\" fill=\"currentColor\"><path d=\"M144-144v-240h72v168h168v72H144Zm432 0v-72h168v-168h72v240H576ZM312-336L168-480l144-144 51 51-57 57H432v72H306l57 57-51 51Zm336 0l-51-51 57-57H528v-72h126l-57-57 51-51 144 144-144 144ZM144-576v-240h240v72H216v168h-72Zm600 0v-168H576v-72h240v240h-72Z\"/></svg>";
11
+ /** Top: the block at the top of the frame — and the Align dropdown's own glyph. */
12
+ export declare const ICON_CELL_ALIGN_TOP = "<svg viewBox=\"0 -960 960 960\" fill=\"currentColor\"><path d=\"M312-576h336v-96H312v96ZM216-144q-29.7 0-50.85-21.15Q144-186.3 144-216v-528q0-29.7 21.15-50.85Q186.3-816 216-816h528q29.7 0 50.85 21.15Q816-773.7 816-744v528q0 29.7-21.15 50.85Q773.7-144 744-144H216Zm0-72h528v-528H216v528Zm0-528v528-528Z\"/></svg>";
13
+ /** Center: the block midway. */
14
+ export declare const ICON_CELL_ALIGN_CENTER = "<svg viewBox=\"0 -960 960 960\" fill=\"currentColor\"><path d=\"M312-432h336v-96H312v96ZM216-144q-29.7 0-50.85-21.15Q144-186.3 144-216v-528q0-29.7 21.15-50.85Q186.3-816 216-816h528q29.7 0 50.85 21.15Q816-773.7 816-744v528q0 29.7-21.15 50.85Q773.7-144 744-144H216Zm0-72h528v-528H216v528Zm0-528v528-528Z\"/></svg>";
15
+ /** Bottom: the block at the bottom of the frame. */
16
+ export declare const ICON_CELL_ALIGN_BOTTOM = "<svg viewBox=\"0 -960 960 960\" fill=\"currentColor\"><path d=\"M312-288h336v-96H312v96ZM216-144q-29.7 0-50.85-21.15Q144-186.3 144-216v-528q0-29.7 21.15-50.85Q186.3-816 216-816h528q29.7 0 50.85 21.15Q816-773.7 816-744v528q0 29.7-21.15 50.85Q773.7-144 744-144H216Zm0-72h528v-528H216v528Zm0-528v528-528Z\"/></svg>";
11
17
  /** What a Select ▸ … row widens the current table selection to. Named for the
12
18
  * verbs (`selectTableRows` / `selectTableColumns` / `selectTable`) rather than
13
19
  * the row labels: the commands widen to *every* row or column the selection
@@ -20,16 +26,20 @@ export declare const whenTableEdit: (kind: TableEditKind) => EnabledWhen;
20
26
  export declare const TABLE_SELECT_MENU: readonly MenuItem<MessageKey>[];
21
27
  export declare const TABLE_INSERT_MENU: readonly MenuItem<MessageKey>[];
22
28
  export declare const TABLE_DELETE_MENU: readonly MenuItem<MessageKey>[];
29
+ /** Merge and Unmerge, the Cells dropdown's two rows. */
30
+ export declare const TABLE_CELLS_MENU: readonly MenuItem<MessageKey>[];
31
+ /** The Align dropdown: where the cells' text sits, top to bottom, then across
32
+ * — the paragraph alignments the Text tab sets — then the direction it runs in. */
33
+ export declare const TABLE_ALIGN_MENU: readonly MenuItem<MessageKey>[];
34
+ /** The Style dropdown: the six regions of the table's style that apply. */
35
+ export declare const TABLE_STYLE_MENU: readonly MenuItem<MessageKey>[];
23
36
  /**
24
37
  * The Table tab's commands, over the {@link EditTools} once edit mode is mounted,
25
- * in the order of the context menu's rows over a table: the Select dropdown, the
26
- * four inserts, the two deletes, then Merge and Unmerge.
27
- *
28
- * The inserts and deletes stand on the band where the menu puts them behind
29
- * fly-outs: they are the edits made over and over, and the band has room for them,
30
- * so a row more or less is a press rather than a dropdown's two, and each delete
31
- * greys on its own. Select stays a dropdown, its rows named by words that no glyph
32
- * on the band could tell apart.
38
+ * and `openProperties`, which opens the Table Properties dialog. One tab, kept
39
+ * short: Select, then Insert, Delete and Cells as dropdowns beside Distribute
40
+ * Columns; Shading, Border Color and Border; the Align and Style dropdowns; and
41
+ * the dialog, which holds the measures — height, width, margins — that would
42
+ * cost the band a field each.
33
43
  */
34
- export declare function tableCommands(tools: () => EditTools): Readonly<Record<string, CommandDef<MessageKey>>>;
44
+ export declare function tableCommands(tools: () => EditTools, openProperties: () => void): Readonly<Record<string, CommandDef<MessageKey>>>;
35
45
  //# sourceMappingURL=table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEpG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C;yEACyE;AACzE,eAAO,MAAM,gBAAgB,sPAAgP,CAAC;AAK9Q;;eAEe;AACf,eAAO,MAAM,kBAAkB,wUAAkU,CAAC;AAElW;;;uEAGuE;AACvE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAO5D;;mBAEmB;AACnB,eAAO,MAAM,aAAa,GACrB,MAAM,aAAa,KAAG,WAEe,CAAC;AAM3C,eAAO,MAAM,iBAAiB,EAAE,SAAS,QAAQ,CAAC,UAAU,CAAC,EAQ5D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,SAAS,QAAQ,CAAC,UAAU,CAAC,EA0B5D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,SAAS,QAAQ,CAAC,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