@uva-glass/component-library 3.0.7 → 3.0.9

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 (201) hide show
  1. package/dist/Lexical.prod-BqkvGy5o.js +4879 -0
  2. package/dist/Lexical.prod-BqkvGy5o.js.map +1 -0
  3. package/dist/LexicalClipboard.prod-BSR9LEVL.js +258 -0
  4. package/dist/LexicalClipboard.prod-BSR9LEVL.js.map +1 -0
  5. package/dist/LexicalComposerContext.prod--Rm7-Z9o.js +26 -0
  6. package/dist/LexicalComposerContext.prod--Rm7-Z9o.js.map +1 -0
  7. package/dist/{LexicalLink.prod-JpC4y56U.js → LexicalLink.prod-D-CG9yYv.js} +36 -36
  8. package/dist/LexicalLink.prod-D-CG9yYv.js.map +1 -0
  9. package/dist/LexicalList.prod-CDTuG8cz.js +600 -0
  10. package/dist/LexicalList.prod-CDTuG8cz.js.map +1 -0
  11. package/dist/LexicalSelection.prod-BxYY0fGG.js +86 -0
  12. package/dist/LexicalSelection.prod-BxYY0fGG.js.map +1 -0
  13. package/dist/LexicalTable.prod-Ckge-lZb.js +1515 -0
  14. package/dist/LexicalTable.prod-Ckge-lZb.js.map +1 -0
  15. package/dist/LexicalUtils.prod-CIQUUsvA.js +112 -0
  16. package/dist/LexicalUtils.prod-CIQUUsvA.js.map +1 -0
  17. package/dist/{TablePlugin-Co5vgBHF.js → TablePlugin-BBgBJKsb.js} +63 -63
  18. package/dist/{TablePlugin-Co5vgBHF.js.map → TablePlugin-BBgBJKsb.js.map} +1 -1
  19. package/dist/assets/VarIndicator.css +1 -0
  20. package/dist/components/Accordion/Accordion.stories.d.ts +2 -2
  21. package/dist/components/Accordion/Accordion.test.js +3 -3
  22. package/dist/components/AccordionCard/AccordionCard.stories.d.ts +1 -1
  23. package/dist/components/AccordionCard/AccordionCard.test.js +3 -3
  24. package/dist/components/ActionList/ActionList.stories.d.ts +1 -1
  25. package/dist/components/ActionList/ActionList.test.d.ts +0 -0
  26. package/dist/components/ActionList/ActionList.test.js +60 -0
  27. package/dist/components/ActionList/ActionList.test.js.map +1 -0
  28. package/dist/components/AppStatusBar/AppStatusBar.stories.d.ts +1 -1
  29. package/dist/components/AppStatusBar/AppStatusBar.test.d.ts +0 -0
  30. package/dist/components/AppStatusBar/AppStatusBar.test.js +10 -0
  31. package/dist/components/AppStatusBar/AppStatusBar.test.js.map +1 -0
  32. package/dist/components/Attention/Attention.stories.d.ts +1 -1
  33. package/dist/components/Attention/Attention.test.d.ts +0 -0
  34. package/dist/components/Attention/Attention.test.js +10 -0
  35. package/dist/components/Attention/Attention.test.js.map +1 -0
  36. package/dist/components/Backdrop/Backdrop.stories.d.ts +1 -1
  37. package/dist/components/Backdrop/Backdrop.test.d.ts +0 -0
  38. package/dist/components/Backdrop/Backdrop.test.js +10 -0
  39. package/dist/components/Backdrop/Backdrop.test.js.map +1 -0
  40. package/dist/components/ButtonGroup/ButtonGroup.stories.d.ts +1 -1
  41. package/dist/components/Buttons/Button.stories.d.ts +2 -2
  42. package/dist/components/Buttons/Button.stories.js +1 -1
  43. package/dist/components/Buttons/Button.test.d.ts +0 -0
  44. package/dist/components/Buttons/Button.test.js +35 -0
  45. package/dist/components/Buttons/Button.test.js.map +1 -0
  46. package/dist/components/Buttons/LinkButton.stories.d.ts +2 -2
  47. package/dist/components/Buttons/LinkButton.stories.js +1 -1
  48. package/dist/components/Buttons/LinkButton.test.d.ts +0 -0
  49. package/dist/components/Buttons/LinkButton.test.js +67 -0
  50. package/dist/components/Buttons/LinkButton.test.js.map +1 -0
  51. package/dist/components/Buttons/MenuButton.stories.d.ts +3 -3
  52. package/dist/components/Buttons/MenuButton.stories.js +1 -1
  53. package/dist/components/Buttons/MenuButton.test.d.ts +0 -0
  54. package/dist/components/Buttons/MenuButton.test.js +66 -0
  55. package/dist/components/Buttons/MenuButton.test.js.map +1 -0
  56. package/dist/components/Card/Card.stories.d.ts +3 -3
  57. package/dist/components/Checkbox/Checkbox.stories.d.ts +2 -2
  58. package/dist/components/Checkbox/Checkbox.stories.js +1 -1
  59. package/dist/components/CheckboxButton/CheckboxButton.stories.d.ts +1 -1
  60. package/dist/components/CheckboxButton/CheckboxButton.stories.js +1 -1
  61. package/dist/components/CheckboxButtonBar/CheckboxButtonBar.stories.d.ts +1 -1
  62. package/dist/components/CheckboxButtonBar/CheckboxButtonBar.stories.js +1 -1
  63. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  64. package/dist/components/CheckboxTree/CheckboxTree.stories.d.ts +1 -1
  65. package/dist/components/CheckboxTree/CheckboxTree.stories.js +109 -87
  66. package/dist/components/CheckboxTree/CheckboxTree.stories.js.map +1 -1
  67. package/dist/components/Chip/Chip.stories.d.ts +2 -2
  68. package/dist/components/Chip/Chip.stories.js +1 -1
  69. package/dist/components/Drawer/Drawer.stories.d.ts +2 -2
  70. package/dist/components/Drawer/Drawer.stories.js +1 -1
  71. package/dist/components/EmptyStateDataDisplay/EmptyStateDataDisplay.stories.d.ts +1 -1
  72. package/dist/components/FeedbackBox/FeedbackBox.stories.d.ts +1 -1
  73. package/dist/components/FieldHint/FieldHint.stories.d.ts +2 -2
  74. package/dist/components/Fieldset/Fieldset.stories.d.ts +2 -2
  75. package/dist/components/FormField/FormField.stories.d.ts +1 -1
  76. package/dist/components/FormInput/FormInput.js +1 -1
  77. package/dist/components/FormInput/FormInput.stories.d.ts +2 -2
  78. package/dist/components/FormInput/FormInput.stories.js +1 -1
  79. package/dist/components/GridRow/GridRow.stories.d.ts +2 -2
  80. package/dist/components/HorizontalList/HorizontalList.stories.d.ts +2 -2
  81. package/dist/components/Icon/Icon.stories.d.ts +1 -1
  82. package/dist/components/Icon/icons/index.d.ts +30 -0
  83. package/dist/components/Icon/icons/index.js +160 -135
  84. package/dist/components/Icon/icons/index.js.map +1 -1
  85. package/dist/components/IconButton/IconButton.stories.d.ts +1 -1
  86. package/dist/components/IconButton/IconButton.stories.js +1 -1
  87. package/dist/components/InfoMessage/InfoMessage.stories.d.ts +1 -1
  88. package/dist/components/Input/Input.stories.d.ts +4 -4
  89. package/dist/components/InputField/InputField.stories.d.ts +3 -3
  90. package/dist/components/InputField/InputField.stories.js +2 -2
  91. package/dist/components/Label/Label.stories.d.ts +2 -2
  92. package/dist/components/Label/Label.test.js +2 -2
  93. package/dist/components/MenuLink/MenuLink.stories.d.ts +2 -2
  94. package/dist/components/MetaDataList/MetaDataList.stories.d.ts +1 -1
  95. package/dist/components/ModalDialog/ModalDialog.stories.d.ts +3 -3
  96. package/dist/components/ModalDialog/ModalDialog.stories.js +1 -1
  97. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  98. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +3 -3
  99. package/dist/components/MultiSelect/MultiSelect.stories.js +2 -2
  100. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  101. package/dist/components/MultiSelect/index.js +1 -1
  102. package/dist/components/OverlayCloseButton/OverlayCloseButton.stories.d.ts +1 -1
  103. package/dist/components/OverlayCloseButton/OverlayCloseButton.stories.js +4 -4
  104. package/dist/components/OverlayStepBar/OverlayStepBar.js +1 -1
  105. package/dist/components/OverlayStepBar/OverlayStepBar.stories.d.ts +1 -1
  106. package/dist/components/PageOverlay/PageOverlay.stories.d.ts +3 -3
  107. package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
  108. package/dist/components/PeriodSelector/PeriodSelector.stories.d.ts +1 -1
  109. package/dist/components/PeriodSelector/PeriodSelector.stories.js +1 -1
  110. package/dist/components/Periods/Periods.stories.d.ts +1 -1
  111. package/dist/components/ProgrammeCard/ProgrammeCard.stories.d.ts +3 -3
  112. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +2 -2
  113. package/dist/components/RadioButton/RadioButton.stories.d.ts +1 -1
  114. package/dist/components/Repeater/Repeater.stories.d.ts +1 -1
  115. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  116. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +5 -5
  117. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +12 -12
  118. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
  119. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
  120. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +58 -58
  121. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  122. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +31 -31
  123. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +14 -14
  124. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  125. package/dist/components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu.js +1 -1
  126. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +4 -4
  127. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +28 -28
  128. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  129. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +13 -13
  130. package/dist/components/RteEditor/Plugins/index.js +1 -1
  131. package/dist/components/RteEditor/RteEditor.js +415 -415
  132. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  133. package/dist/components/RteEditor/RteEditor.stories.d.ts +1 -1
  134. package/dist/components/RteEditor/helpers.js +13 -13
  135. package/dist/components/SectionNotification/SectionNotification.stories.d.ts +1 -1
  136. package/dist/components/SelectListbox/SelectListBox.stories.d.ts +2 -2
  137. package/dist/components/SelectListbox/SelectListBox.stories.js +1 -1
  138. package/dist/components/Sortable/Sortable.stories.d.ts +3 -3
  139. package/dist/components/Sortable/Sortable.stories.js +7 -7
  140. package/dist/components/Spinner/Spinner.stories.d.ts +1 -1
  141. package/dist/components/StatusPill/StatusPill.stories.d.ts +1 -1
  142. package/dist/components/ToggleSwitch/ToggleSwitch.stories.d.ts +1 -1
  143. package/dist/components/ToggleSwitch/ToggleSwitch.stories.js +5 -5
  144. package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -1
  145. package/dist/components/VarIndicator/VarIndicator.d.ts +9 -0
  146. package/dist/components/VarIndicator/VarIndicator.js +32 -0
  147. package/dist/components/VarIndicator/VarIndicator.js.map +1 -0
  148. package/dist/components/VarIndicator/VarIndicator.stories.d.ts +5 -0
  149. package/dist/components/VarIndicator/VarIndicator.stories.js +30 -0
  150. package/dist/components/VarIndicator/VarIndicator.stories.js.map +1 -0
  151. package/dist/components/VarIndicator/VarIndicator.test.d.ts +0 -0
  152. package/dist/components/VarIndicator/VarIndicator.test.js +58 -0
  153. package/dist/components/VarIndicator/VarIndicator.test.js.map +1 -0
  154. package/dist/components/VarIndicator/index.d.ts +1 -0
  155. package/dist/components/VarIndicator/index.js +5 -0
  156. package/dist/components/VarIndicator/index.js.map +1 -0
  157. package/dist/components/index.d.ts +1 -0
  158. package/dist/components/index.js +32 -30
  159. package/dist/components/index.js.map +1 -1
  160. package/dist/helpers-CzeCSkV-.js +168 -0
  161. package/dist/helpers-CzeCSkV-.js.map +1 -0
  162. package/dist/index-BldK5xU9.js +9513 -0
  163. package/dist/index-BldK5xU9.js.map +1 -0
  164. package/dist/{index-sIsmp53X.js → index-DMVXQIB9.js} +2 -2
  165. package/dist/{index-sIsmp53X.js.map → index-DMVXQIB9.js.map} +1 -1
  166. package/dist/index-DpyOH4wL.js +14735 -0
  167. package/dist/index-DpyOH4wL.js.map +1 -0
  168. package/dist/{index-DuZiPGs-.js → index-Z7qwJmRM.js} +3 -2
  169. package/dist/{index-DuZiPGs-.js.map → index-Z7qwJmRM.js.map} +1 -1
  170. package/dist/index.js +32 -30
  171. package/dist/index.js.map +1 -1
  172. package/dist/{react.esm-f8cBAyS5.js → react.esm-BOUd0cvD.js} +3 -3
  173. package/dist/{react.esm-f8cBAyS5.js.map → react.esm-BOUd0cvD.js.map} +1 -1
  174. package/dist/setupTests.js +1555 -7
  175. package/dist/setupTests.js.map +1 -1
  176. package/dist/storybook__react.d.js +8528 -537
  177. package/dist/storybook__react.d.js.map +1 -1
  178. package/dist/{test-utils-CTqdUiUm.js → test-utils-uaSbIYda.js} +2 -2
  179. package/dist/{test-utils-CTqdUiUm.js.map → test-utils-uaSbIYda.js.map} +1 -1
  180. package/package.json +29 -29
  181. package/dist/Lexical.prod-DTADK2yJ.js +0 -4263
  182. package/dist/Lexical.prod-DTADK2yJ.js.map +0 -1
  183. package/dist/LexicalClipboard.prod-Dx5Fm6e5.js +0 -258
  184. package/dist/LexicalClipboard.prod-Dx5Fm6e5.js.map +0 -1
  185. package/dist/LexicalComposerContext.prod-BCXERl09.js +0 -26
  186. package/dist/LexicalComposerContext.prod-BCXERl09.js.map +0 -1
  187. package/dist/LexicalLink.prod-JpC4y56U.js.map +0 -1
  188. package/dist/LexicalList.prod-w0kSq9sB.js +0 -579
  189. package/dist/LexicalList.prod-w0kSq9sB.js.map +0 -1
  190. package/dist/LexicalSelection.prod-DQLHaigk.js +0 -78
  191. package/dist/LexicalSelection.prod-DQLHaigk.js.map +0 -1
  192. package/dist/LexicalTable.prod-DjfZc87j.js +0 -1465
  193. package/dist/LexicalTable.prod-DjfZc87j.js.map +0 -1
  194. package/dist/LexicalUtils.prod-BBwue2Aj.js +0 -122
  195. package/dist/LexicalUtils.prod-BBwue2Aj.js.map +0 -1
  196. package/dist/helpers-DgTW1vIO.js +0 -168
  197. package/dist/helpers-DgTW1vIO.js.map +0 -1
  198. package/dist/index-2mUSc_Ki.js +0 -8
  199. package/dist/index-2mUSc_Ki.js.map +0 -1
  200. package/dist/index-CcK2jjMp.js +0 -23343
  201. package/dist/index-CcK2jjMp.js.map +0 -1
@@ -1,1465 +0,0 @@
1
- import { i as N, j as V, w as lt, V as ye, N as bt, g as wt, v as st, c as _t, d as yt } from "./LexicalUtils.prod-BBwue2Aj.js";
2
- import { L as Pe, P as Se, x as Le, M as P, j as G, d as Nt, C as ue, S as $e, J as xt, A as it, f as Q, e as Tt, g as Ft, h as be, F as Fe, i as je, a as H, q as D, k as Ot, v as vt, y as kt, p as Rt, X as Oe, l as Kt, u as Et, n as at, r as Mt, Y as q, t as At, N as Pt, B as Lt, w as $t, z as Ht, D as Dt, I as Wt, $ as Bt, K as It, O as re, c as U, Q as Ne, R as Jt, o as zt, U as qt, H as ct, m as Xt, T as Yt, V as _e, s as jt, W as Ut, Z as Vt } from "./Lexical.prod-DTADK2yJ.js";
3
- import { O as Gt, L as Qt } from "./LexicalClipboard.prod-Dx5Fm6e5.js";
4
- const He = /^(\d+(?:\.\d+)?)px$/, J = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
5
- class te extends Pe {
6
- static getType() {
7
- return "tablecell";
8
- }
9
- static clone(e) {
10
- return new te(e.__headerState, e.__colSpan, e.__width, e.__key);
11
- }
12
- afterCloneFrom(e) {
13
- super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor;
14
- }
15
- static importDOM() {
16
- return { td: (e) => ({ conversion: Ue, priority: 0 }), th: (e) => ({ conversion: Ue, priority: 0 }) };
17
- }
18
- static importJSON(e) {
19
- return he().updateFromJSON(e);
20
- }
21
- updateFromJSON(e) {
22
- return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan || 1).setRowSpan(e.rowSpan || 1).setWidth(e.width || void 0).setBackgroundColor(e.backgroundColor || null);
23
- }
24
- constructor(e = J.NO_STATUS, t = 1, o, l) {
25
- super(l), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = o, this.__backgroundColor = null;
26
- }
27
- createDOM(e) {
28
- const t = document.createElement(this.getTag());
29
- return this.__width && (t.style.width = `${this.__width}px`), this.__colSpan > 1 && (t.colSpan = this.__colSpan), this.__rowSpan > 1 && (t.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (t.style.backgroundColor = this.__backgroundColor), V(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
30
- }
31
- exportDOM(e) {
32
- const t = super.exportDOM(e);
33
- if (Se(t.element)) {
34
- const o = t.element;
35
- o.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), o.style.border = "1px solid black", this.__colSpan > 1 && (o.colSpan = this.__colSpan), this.__rowSpan > 1 && (o.rowSpan = this.__rowSpan), o.style.width = `${this.getWidth() || 75}px`, o.style.verticalAlign = "top", o.style.textAlign = "start", this.__backgroundColor === null && this.hasHeader() && (o.style.backgroundColor = "#f2f3f5");
36
- }
37
- return t;
38
- }
39
- exportJSON() {
40
- return { ...super.exportJSON(), backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, width: this.getWidth() };
41
- }
42
- getColSpan() {
43
- return this.getLatest().__colSpan;
44
- }
45
- setColSpan(e) {
46
- const t = this.getWritable();
47
- return t.__colSpan = e, t;
48
- }
49
- getRowSpan() {
50
- return this.getLatest().__rowSpan;
51
- }
52
- setRowSpan(e) {
53
- const t = this.getWritable();
54
- return t.__rowSpan = e, t;
55
- }
56
- getTag() {
57
- return this.hasHeader() ? "th" : "td";
58
- }
59
- setHeaderStyles(e, t = J.BOTH) {
60
- const o = this.getWritable();
61
- return o.__headerState = e & t | o.__headerState & ~t, o;
62
- }
63
- getHeaderStyles() {
64
- return this.getLatest().__headerState;
65
- }
66
- setWidth(e) {
67
- const t = this.getWritable();
68
- return t.__width = e, t;
69
- }
70
- getWidth() {
71
- return this.getLatest().__width;
72
- }
73
- getBackgroundColor() {
74
- return this.getLatest().__backgroundColor;
75
- }
76
- setBackgroundColor(e) {
77
- const t = this.getWritable();
78
- return t.__backgroundColor = e, t;
79
- }
80
- toggleHeaderStyle(e) {
81
- const t = this.getWritable();
82
- return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
83
- }
84
- hasHeaderState(e) {
85
- return (this.getHeaderStyles() & e) === e;
86
- }
87
- hasHeader() {
88
- return this.getLatest().__headerState !== J.NO_STATUS;
89
- }
90
- updateDOM(e) {
91
- return e.__headerState !== this.__headerState || e.__width !== this.__width || e.__colSpan !== this.__colSpan || e.__rowSpan !== this.__rowSpan || e.__backgroundColor !== this.__backgroundColor;
92
- }
93
- isShadowRoot() {
94
- return !0;
95
- }
96
- collapseAtStart() {
97
- return !0;
98
- }
99
- canBeEmpty() {
100
- return !1;
101
- }
102
- canIndent() {
103
- return !1;
104
- }
105
- }
106
- function Ue(n) {
107
- const e = n, t = n.nodeName.toLowerCase();
108
- let o;
109
- He.test(e.style.width) && (o = parseFloat(e.style.width));
110
- const l = he(t === "th" ? J.ROW : J.NO_STATUS, e.colSpan, o);
111
- l.__rowSpan = e.rowSpan;
112
- const i = e.style.backgroundColor;
113
- i !== "" && (l.__backgroundColor = i);
114
- const r = e.style, c = (r && r.textDecoration || "").split(" "), h = r.fontWeight === "700" || r.fontWeight === "bold", f = c.includes("line-through"), s = r.fontStyle === "italic", a = c.includes("underline");
115
- return { after: (u) => (u.length === 0 && u.push(G()), u), forChild: (u, d) => {
116
- if (S(d) && !P(u)) {
117
- const g = G();
118
- return Nt(u) && u.getTextContent() === `
119
- ` ? null : (ue(u) && (h && u.toggleFormat("bold"), f && u.toggleFormat("strikethrough"), s && u.toggleFormat("italic"), a && u.toggleFormat("underline")), g.append(u), g);
120
- }
121
- return u;
122
- }, node: l };
123
- }
124
- function he(n = J.NO_STATUS, e = 1, t) {
125
- return Le(new te(n, e, t));
126
- }
127
- function S(n) {
128
- return n instanceof te;
129
- }
130
- const Zt = Tt();
131
- function en(n) {
132
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
133
- }
134
- var b = en(function(n) {
135
- const e = new URLSearchParams();
136
- e.append("code", n);
137
- for (let t = 1; t < arguments.length; t++) e.append("v", arguments[t]);
138
- throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
139
- });
140
- class de extends Pe {
141
- static getType() {
142
- return "tablerow";
143
- }
144
- static clone(e) {
145
- return new de(e.__height, e.__key);
146
- }
147
- static importDOM() {
148
- return { tr: (e) => ({ conversion: tn, priority: 0 }) };
149
- }
150
- static importJSON(e) {
151
- return De().updateFromJSON(e);
152
- }
153
- updateFromJSON(e) {
154
- return super.updateFromJSON(e).setHeight(e.height);
155
- }
156
- constructor(e, t) {
157
- super(t), this.__height = e;
158
- }
159
- exportJSON() {
160
- const e = this.getHeight();
161
- return { ...super.exportJSON(), ...e === void 0 ? void 0 : { height: e } };
162
- }
163
- createDOM(e) {
164
- const t = document.createElement("tr");
165
- return this.__height && (t.style.height = `${this.__height}px`), V(t, e.theme.tableRow), t;
166
- }
167
- extractWithChild(e, t, o) {
168
- return o === "html";
169
- }
170
- isShadowRoot() {
171
- return !0;
172
- }
173
- setHeight(e) {
174
- const t = this.getWritable();
175
- return t.__height = e, t;
176
- }
177
- getHeight() {
178
- return this.getLatest().__height;
179
- }
180
- updateDOM(e) {
181
- return e.__height !== this.__height;
182
- }
183
- canBeEmpty() {
184
- return !1;
185
- }
186
- canIndent() {
187
- return !1;
188
- }
189
- }
190
- function tn(n) {
191
- const e = n;
192
- let t;
193
- return He.test(e.style.height) && (t = parseFloat(e.style.height)), { after: (o) => lt(o, S), node: De(t) };
194
- }
195
- function De(n) {
196
- return Le(new de(n));
197
- }
198
- function M(n) {
199
- return n instanceof de;
200
- }
201
- const We = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, nn = We && "documentMode" in document ? document.documentMode : null, on = We && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
202
- function rn(n, e, t = !0) {
203
- const o = ze();
204
- for (let l = 0; l < n; l++) {
205
- const i = De();
206
- for (let r = 0; r < e; r++) {
207
- let c = J.NO_STATUS;
208
- typeof t == "object" ? (l === 0 && t.rows && (c |= J.ROW), r === 0 && t.columns && (c |= J.COLUMN)) : t && (l === 0 && (c |= J.ROW), r === 0 && (c |= J.COLUMN));
209
- const h = he(c), f = G();
210
- f.append($e()), h.append(f), i.append(h);
211
- }
212
- o.append(i);
213
- }
214
- return o;
215
- }
216
- function xn(n) {
217
- const e = N(n, (t) => S(t));
218
- return S(e) ? e : null;
219
- }
220
- function ut(n) {
221
- const e = N(n, (t) => M(t));
222
- if (M(e)) return e;
223
- throw new Error("Expected table cell to be inside of table row.");
224
- }
225
- function ln(n) {
226
- const e = N(n, (t) => R(t));
227
- if (R(e)) return e;
228
- throw new Error("Expected table cell to be inside of table.");
229
- }
230
- function Tn(n) {
231
- const e = ut(n);
232
- return ln(e).getChildren().findIndex((t) => t.is(e));
233
- }
234
- function Fn(n) {
235
- return ut(n).getChildren().findIndex((e) => e.is(n));
236
- }
237
- We && "InputEvent" in window && !nn && new window.InputEvent("input");
238
- function On(n, e) {
239
- const t = n.getChildren();
240
- for (let o = 0; o < t.length; o++) {
241
- const l = t[o];
242
- if (M(l)) {
243
- const i = l.getChildren();
244
- if (e >= i.length || e < 0) throw new Error("Table column target index out of range");
245
- i[e].remove();
246
- }
247
- }
248
- return n;
249
- }
250
- function j(n, e, t) {
251
- const [o, l, i] = Be(n, e, t);
252
- return l === null && b(207), i === null && b(208), [o, l, i];
253
- }
254
- function Be(n, e, t) {
255
- const o = [];
256
- let l = null, i = null;
257
- function r(h) {
258
- let f = o[h];
259
- return f === void 0 && (o[h] = f = []), f;
260
- }
261
- const c = n.getChildren();
262
- for (let h = 0; h < c.length; h++) {
263
- const f = c[h];
264
- M(f) || b(209);
265
- const s = r(h);
266
- for (let a = f.getFirstChild(), u = 0; a != null; a = a.getNextSibling()) {
267
- for (S(a) || b(147); s[u] !== void 0; ) u++;
268
- const d = { cell: a, startColumn: u, startRow: h }, { __rowSpan: g, __colSpan: p } = a;
269
- for (let m = 0; m < g && !(h + m >= c.length); m++) {
270
- const C = r(h + m);
271
- for (let w = 0; w < p; w++) C[u + w] = d;
272
- }
273
- e !== null && l === null && e.is(a) && (l = d), t !== null && i === null && t.is(a) && (i = d);
274
- }
275
- }
276
- return [o, l, i];
277
- }
278
- function le(n) {
279
- let e;
280
- if (n instanceof te) e = n;
281
- else if ("__type" in n) {
282
- const l = N(n, S);
283
- S(l) || b(148), e = l;
284
- } else {
285
- const l = N(n.getNode(), S);
286
- S(l) || b(148), e = l;
287
- }
288
- const t = e.getParent();
289
- M(t) || b(149);
290
- const o = t.getParent();
291
- return R(o) || b(210), [e, t, o];
292
- }
293
- function Ke(n, e, t) {
294
- let o = Math.min(e.startColumn, t.startColumn), l = Math.min(e.startRow, t.startRow), i = Math.max(e.startColumn + e.cell.__colSpan - 1, t.startColumn + t.cell.__colSpan - 1), r = Math.max(e.startRow + e.cell.__rowSpan - 1, t.startRow + t.cell.__rowSpan - 1), c = o, h = l, f = o, s = l;
295
- function a(u) {
296
- const { cell: d, startColumn: g, startRow: p } = u;
297
- o = Math.min(o, g), l = Math.min(l, p), i = Math.max(i, g + d.__colSpan - 1), r = Math.max(r, p + d.__rowSpan - 1);
298
- }
299
- for (; o < c || l < h || i > f || r > s; ) {
300
- if (o < c) {
301
- const u = s - h, d = c - 1;
302
- for (let g = 0; g <= u; g++) a(n[h + g][d]);
303
- c = d;
304
- }
305
- if (l < h) {
306
- const u = f - c, d = h - 1;
307
- for (let g = 0; g <= u; g++) a(n[d][c + g]);
308
- h = d;
309
- }
310
- if (i > f) {
311
- const u = s - h, d = f + 1;
312
- for (let g = 0; g <= u; g++) a(n[h + g][d]);
313
- f = d;
314
- }
315
- if (r > s) {
316
- const u = f - c, d = s + 1;
317
- for (let g = 0; g <= u; g++) a(n[d][c + g]);
318
- s = d;
319
- }
320
- }
321
- return { maxColumn: i, maxRow: r, minColumn: o, minRow: l };
322
- }
323
- function Ve(n) {
324
- const [e, , t] = le(n), o = t.getChildren(), l = o.length, i = o[0].getChildren().length, r = new Array(l);
325
- for (let c = 0; c < l; c++) r[c] = new Array(i);
326
- for (let c = 0; c < l; c++) {
327
- const h = o[c].getChildren();
328
- let f = 0;
329
- for (let s = 0; s < h.length; s++) {
330
- for (; r[c][f]; ) f++;
331
- const a = h[s], u = a.__rowSpan || 1, d = a.__colSpan || 1;
332
- for (let g = 0; g < u; g++) for (let p = 0; p < d; p++) r[c + g][f + p] = a;
333
- if (e === a) return { colSpan: d, columnIndex: f, rowIndex: c, rowSpan: u };
334
- f += d;
335
- }
336
- }
337
- return null;
338
- }
339
- function Ge(n) {
340
- const [[e, t, o, l], [i, r, c, h]] = ["anchor", "focus"].map((f) => {
341
- const s = n[f].getNode(), a = N(s, S);
342
- S(a) || b(238, f, s.getKey(), s.getType());
343
- const u = a.getParent();
344
- M(u) || b(239, f);
345
- const d = u.getParent();
346
- return R(d) || b(240, f), [s, a, u, d];
347
- });
348
- return l.is(h) || b(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: l, focusCell: r, focusNode: i, focusRow: c, focusTable: h };
349
- }
350
- class xe {
351
- constructor(e, t, o) {
352
- this.anchor = t, this.focus = o, t._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
353
- }
354
- getStartEndPoints() {
355
- return [this.anchor, this.focus];
356
- }
357
- isValid() {
358
- return this.tableKey !== "root" && this.anchor.key !== "root" && this.anchor.type === "element" && this.focus.key !== "root" && this.focus.type === "element";
359
- }
360
- isBackward() {
361
- return this.focus.isBefore(this.anchor);
362
- }
363
- getCachedNodes() {
364
- return this._cachedNodes;
365
- }
366
- setCachedNodes(e) {
367
- this._cachedNodes = e;
368
- }
369
- is(e) {
370
- return k(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
371
- }
372
- set(e, t, o) {
373
- this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || o !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = o, this._cachedNodes = null;
374
- }
375
- clone() {
376
- return new xe(this.tableKey, _e(this.anchor.key, this.anchor.offset, this.anchor.type), _e(this.focus.key, this.focus.offset, this.focus.type));
377
- }
378
- isCollapsed() {
379
- return !1;
380
- }
381
- extract() {
382
- return this.getNodes();
383
- }
384
- insertRawText(e) {
385
- }
386
- insertText() {
387
- }
388
- hasFormat(e) {
389
- let t = 0;
390
- this.getNodes().filter(S).forEach((l) => {
391
- const i = l.getFirstChild();
392
- ct(i) && (t |= i.getTextFormat());
393
- });
394
- const o = Vt[e];
395
- return !!(t & o);
396
- }
397
- insertNodes(e) {
398
- const t = this.focus.getNode();
399
- P(t) || b(151), jt(t.select(0, t.getChildrenSize())).insertNodes(e);
400
- }
401
- getShape() {
402
- const { anchorCell: e, focusCell: t } = Ge(this), o = Ve(e);
403
- o === null && b(153);
404
- const l = Ve(t);
405
- l === null && b(155);
406
- const i = Math.min(o.columnIndex, l.columnIndex), r = Math.max(o.columnIndex + o.colSpan - 1, l.columnIndex + l.colSpan - 1), c = Math.min(o.rowIndex, l.rowIndex), h = Math.max(o.rowIndex + o.rowSpan - 1, l.rowIndex + l.rowSpan - 1);
407
- return { fromX: Math.min(i, r), fromY: Math.min(c, h), toX: Math.max(i, r), toY: Math.max(c, h) };
408
- }
409
- getNodes() {
410
- if (!this.isValid()) return [];
411
- const e = this._cachedNodes;
412
- if (e !== null) return e;
413
- const { anchorTable: t, anchorCell: o, focusCell: l } = Ge(this), i = l.getParents()[1];
414
- if (i !== t) {
415
- if (t.isParentOf(l)) {
416
- const m = i.getParent();
417
- m == null && b(159), this.set(this.tableKey, l.getKey(), m.getKey());
418
- } else {
419
- const m = t.getParent();
420
- m == null && b(158), this.set(this.tableKey, m.getKey(), l.getKey());
421
- }
422
- return this.getNodes();
423
- }
424
- const [r, c, h] = j(t, o, l), { minColumn: f, maxColumn: s, minRow: a, maxRow: u } = Ke(r, c, h), d = /* @__PURE__ */ new Map([[t.getKey(), t]]);
425
- let g = null;
426
- for (let m = a; m <= u; m++) for (let C = f; C <= s; C++) {
427
- const { cell: w } = r[m][C], K = w.getParent();
428
- M(K) || b(160), K !== g && (d.set(K.getKey(), K), g = K), d.has(w.getKey()) || sn(w, (E) => {
429
- d.set(E.getKey(), E);
430
- });
431
- }
432
- const p = Array.from(d.values());
433
- return Ut() || (this._cachedNodes = p), p;
434
- }
435
- getTextContent() {
436
- const e = this.getNodes().filter((o) => S(o));
437
- let t = "";
438
- for (let o = 0; o < e.length; o++) {
439
- const l = e[o], i = l.__parent, r = (e[o + 1] || {}).__parent;
440
- t += l.getTextContent() + (r !== i ? `
441
- ` : " ");
442
- }
443
- return t;
444
- }
445
- }
446
- function k(n) {
447
- return n instanceof xe;
448
- }
449
- function Qe() {
450
- const n = _e("root", 0, "element"), e = _e("root", 0, "element");
451
- return new xe("root", n, e);
452
- }
453
- function sn(n, e) {
454
- const t = [[n]];
455
- for (let o = t.at(-1); o !== void 0 && t.length > 0; o = t.at(-1)) {
456
- const l = o.pop();
457
- l === void 0 ? t.pop() : e(l) !== !1 && P(l) && t.push(l.getChildren());
458
- }
459
- }
460
- function ht(n, e = it()) {
461
- const t = be(n);
462
- R(t) || b(231, n);
463
- const o = Z(t, e.getElementByKey(n));
464
- return o === null && b(232, n), { tableElement: o, tableNode: t };
465
- }
466
- class an {
467
- constructor(e, t) {
468
- this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = t, this.editor = e, this.table = { columns: 0, domRows: [], rows: 0 }, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.isSelecting = !1, this.shouldCheckSelection = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.nextFocus = null, this.trackTable();
469
- }
470
- getTable() {
471
- return this.table;
472
- }
473
- removeListeners() {
474
- this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
475
- }
476
- $lookup() {
477
- return ht(this.tableNodeKey, this.editor);
478
- }
479
- trackTable() {
480
- const e = new MutationObserver((t) => {
481
- this.editor.getEditorState().read(() => {
482
- let o = !1;
483
- for (let r = 0; r < t.length; r++) {
484
- const c = t[r].target.nodeName;
485
- if (c === "TABLE" || c === "TBODY" || c === "THEAD" || c === "TR") {
486
- o = !0;
487
- break;
488
- }
489
- }
490
- if (!o) return;
491
- const { tableNode: l, tableElement: i } = this.$lookup();
492
- this.table = ae(l, i);
493
- }, { editor: this.editor });
494
- });
495
- this.editor.getEditorState().read(() => {
496
- const { tableNode: t, tableElement: o } = this.$lookup();
497
- this.table = ae(t, o), e.observe(o, { attributes: !0, childList: !0, subtree: !0 });
498
- }, { editor: this.editor });
499
- }
500
- $clearHighlight() {
501
- const e = this.editor;
502
- this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.$enableHighlightStyle();
503
- const { tableNode: t, tableElement: o } = this.$lookup();
504
- ge(e, ae(t, o), null), D() !== null && (U(null), e.dispatchCommand(re, void 0));
505
- }
506
- $enableHighlightStyle() {
507
- const e = this.editor, { tableElement: t } = this.$lookup();
508
- ye(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
509
- }
510
- $disableHighlightStyle() {
511
- const { tableElement: e } = this.$lookup();
512
- V(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
513
- }
514
- $updateTableTableSelection(e) {
515
- if (e !== null) {
516
- e.tableKey !== this.tableNodeKey && b(233, e.tableKey, this.tableNodeKey);
517
- const t = this.editor;
518
- this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), ge(t, this.table, this.tableSelection);
519
- } else this.$clearHighlight();
520
- }
521
- setShouldCheckSelection() {
522
- this.shouldCheckSelection = !0;
523
- }
524
- getAndClearShouldCheckSelection() {
525
- return !!this.shouldCheckSelection && (this.shouldCheckSelection = !1, !0);
526
- }
527
- setNextFocus(e) {
528
- this.nextFocus = e;
529
- }
530
- getAndClearNextFocus() {
531
- const { nextFocus: e } = this;
532
- return e !== null && (this.nextFocus = null), e;
533
- }
534
- updateDOMSelection() {
535
- if (this.anchorCell !== null && this.focusCell !== null) {
536
- const e = Ne(this.editor._window);
537
- e && e.rangeCount > 0 && e.removeAllRanges();
538
- }
539
- }
540
- $setFocusCellForSelection(e, t = !1) {
541
- const o = this.editor, { tableNode: l } = this.$lookup(), i = e.x, r = e.y;
542
- if (this.focusCell = e, this.isHighlightingCells || this.anchorX === i && this.anchorY === r && !t) {
543
- if (i === this.focusX && r === this.focusY) return !1;
544
- } else this.isHighlightingCells = !0, this.$disableHighlightStyle();
545
- if (this.focusX = i, this.focusY = r, this.isHighlightingCells) {
546
- const c = Me(l, e.elem);
547
- if (this.tableSelection != null && this.anchorCellNodeKey != null && c !== null) return this.focusCellNodeKey = c.getKey(), this.tableSelection = function(h, f, s) {
548
- h.getKey(), f.getKey(), s.getKey();
549
- const a = D(), u = k(a) ? a.clone() : Qe();
550
- return u.set(h.getKey(), f.getKey(), s.getKey()), u;
551
- }(l, this.$getAnchorTableCellOrThrow(), c), U(this.tableSelection), o.dispatchCommand(re, void 0), ge(o, this.table, this.tableSelection), !0;
552
- }
553
- return !1;
554
- }
555
- $getAnchorTableCell() {
556
- return this.anchorCellNodeKey ? be(this.anchorCellNodeKey) : null;
557
- }
558
- $getAnchorTableCellOrThrow() {
559
- const e = this.$getAnchorTableCell();
560
- return e === null && b(234), e;
561
- }
562
- $getFocusTableCell() {
563
- return this.focusCellNodeKey ? be(this.focusCellNodeKey) : null;
564
- }
565
- $getFocusTableCellOrThrow() {
566
- const e = this.$getFocusTableCell();
567
- return e === null && b(235), e;
568
- }
569
- $setAnchorCellForSelection(e) {
570
- this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y;
571
- const { tableNode: t } = this.$lookup(), o = Me(t, e.elem);
572
- if (o !== null) {
573
- const l = o.getKey();
574
- this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : Qe(), this.anchorCellNodeKey = l;
575
- }
576
- }
577
- $formatCells(e) {
578
- const t = D();
579
- k(t) || b(236);
580
- const o = qt(), l = o.anchor, i = o.focus, r = t.getNodes().filter(S);
581
- r.length > 0 || b(237);
582
- const c = r[0].getFirstChild(), h = ct(c) ? c.getFormatFlags(e, null) : null;
583
- r.forEach((f) => {
584
- l.set(f.getKey(), 0, "element"), i.set(f.getKey(), f.getChildrenSize(), "element"), o.formatText(e, h);
585
- }), U(t), this.editor.dispatchCommand(re, void 0);
586
- }
587
- $clearText() {
588
- const { editor: e } = this, t = be(this.tableNodeKey);
589
- if (!R(t)) throw new Error("Expected TableNode.");
590
- const o = D();
591
- k(o) || b(253);
592
- const l = o.getNodes().filter(S);
593
- if (l.length === this.table.columns * this.table.rows) return t.selectPrevious(), void t.remove();
594
- l.forEach((i) => {
595
- if (P(i)) {
596
- const r = G(), c = $e();
597
- r.append(c), i.append(r), i.getChildren().forEach((h) => {
598
- h !== r && h.remove();
599
- });
600
- }
601
- }), ge(e, this.table, null), U(null), e.dispatchCommand(re, void 0);
602
- }
603
- }
604
- const Ee = "__lexicalTableSelection", cn = (n) => !(1 & ~n.buttons);
605
- function Z(n, e) {
606
- if (!e) return e;
607
- const t = e.nodeName === "TABLE" ? e : n.getDOMSlot(e).element;
608
- return t.nodeName !== "TABLE" && b(245, e.nodeName), t;
609
- }
610
- function Ie(n) {
611
- return n._window;
612
- }
613
- function ie(n, e) {
614
- for (let t = e, o = null; t !== null; t = t.getParent()) {
615
- if (n.is(t)) return o;
616
- S(t) && (o = t);
617
- }
618
- return null;
619
- }
620
- const un = [[Ot, "down"], [vt, "up"], [kt, "backward"], [Rt, "forward"]], hn = [Et, at, Mt], dn = [At, Pt];
621
- function fn(n, e, t, o) {
622
- const l = t.getRootElement(), i = Ie(t);
623
- l !== null && i !== null || b(246);
624
- const r = new an(t, n.getKey()), c = Z(n, e);
625
- (function(s, a) {
626
- Ze(s) !== null && b(205), s[Ee] = a;
627
- })(c, r), r.listenersToRemove.add(() => function(s, a) {
628
- Ze(s) === a && delete s[Ee];
629
- }(c, r)), c.addEventListener("mousedown", (s) => {
630
- if (s.button !== 0 || !Fe(s.target) || !i) return;
631
- const a = ve(s.target);
632
- a !== null && t.update(() => {
633
- const u = je();
634
- if (on && s.shiftKey && X(u, n) && (H(u) || k(u))) {
635
- const d = u.anchor.getNode(), g = ie(n, u.anchor.getNode());
636
- g ? (r.$setAnchorCellForSelection(ce(r, g)), r.$setFocusCellForSelection(a), Y(s)) : (n.isBefore(d) ? n.selectStart() : n.selectEnd()).anchor.set(u.anchor.key, u.anchor.offset, u.anchor.type);
637
- } else r.$setAnchorCellForSelection(a);
638
- }), (() => {
639
- if (r.isSelecting) return;
640
- const u = () => {
641
- r.isSelecting = !1, i.removeEventListener("mouseup", u), i.removeEventListener("mousemove", d);
642
- }, d = (g) => {
643
- if (!Fe(g.target)) return;
644
- if (!cn(g) && r.isSelecting) return r.isSelecting = !1, i.removeEventListener("mouseup", u), void i.removeEventListener("mousemove", d);
645
- const p = !c.contains(g.target);
646
- let m = null;
647
- if (p) {
648
- for (const C of document.elementsFromPoint(g.clientX, g.clientY)) if (m = c.contains(C) ? ve(C) : null, m) break;
649
- } else m = ve(g.target);
650
- !m || r.focusCell !== null && m.elem === r.focusCell.elem || (r.setNextFocus({ focusCell: m, override: p }), t.dispatchCommand(re, void 0));
651
- };
652
- r.isSelecting = !0, i.addEventListener("mouseup", u, r.listenerOptions), i.addEventListener("mousemove", d, r.listenerOptions);
653
- })();
654
- }, r.listenerOptions), i.addEventListener("mousedown", (s) => {
655
- const a = s.target;
656
- s.button === 0 && Fe(a) && t.update(() => {
657
- const u = D();
658
- k(u) && u.tableKey === r.tableNodeKey && l.contains(a) && r.$clearHighlight();
659
- });
660
- }, r.listenerOptions);
661
- for (const [s, a] of un) r.listenersToRemove.add(t.registerCommand(s, (u) => gt(t, u, a, n, r), Oe));
662
- r.listenersToRemove.add(t.registerCommand(Kt, (s) => {
663
- const a = D();
664
- if (k(a)) {
665
- const u = ie(n, a.focus.getNode());
666
- if (u !== null) return Y(s), u.selectEnd(), !0;
667
- }
668
- return !1;
669
- }, Oe));
670
- const h = (s) => () => {
671
- const a = D();
672
- if (!X(a, n)) return !1;
673
- if (k(a)) return r.$clearText(), !0;
674
- if (H(a)) {
675
- if (!S(ie(n, a.anchor.getNode()))) return !1;
676
- const u = a.anchor.getNode(), d = a.focus.getNode(), g = n.isParentOf(u), p = n.isParentOf(d);
677
- if (g && !p || p && !g) return r.$clearText(), !0;
678
- const m = N(a.anchor.getNode(), (w) => P(w)), C = m && N(m, (w) => P(w) && S(w.getParent()));
679
- if (!P(C) || !P(m)) return !1;
680
- if (s === at && C.getPreviousSibling() === null) return !0;
681
- }
682
- return !1;
683
- };
684
- for (const s of hn) r.listenersToRemove.add(t.registerCommand(s, h(s), q));
685
- const f = (s) => {
686
- const a = D();
687
- if (!k(a) && !H(a)) return !1;
688
- const u = n.isParentOf(a.anchor.getNode());
689
- if (u !== n.isParentOf(a.focus.getNode())) {
690
- const d = u ? "anchor" : "focus", g = u ? "focus" : "anchor", { key: p, offset: m, type: C } = a[g];
691
- return n[a[d].isBefore(a[g]) ? "selectPrevious" : "selectNext"]()[g].set(p, m, C), !1;
692
- }
693
- return !!X(a, n) && !!k(a) && (s && (s.preventDefault(), s.stopPropagation()), r.$clearText(), !0);
694
- };
695
- for (const s of dn) r.listenersToRemove.add(t.registerCommand(s, f, q));
696
- return r.listenersToRemove.add(t.registerCommand(Lt, (s) => {
697
- const a = D();
698
- if (a) {
699
- if (!k(a) && !H(a)) return !1;
700
- Gt(t, yt(s, ClipboardEvent) ? s : null, Qt(a));
701
- const u = f(s);
702
- return H(a) ? (a.removeText(), !0) : u;
703
- }
704
- return !1;
705
- }, q)), r.listenersToRemove.add(t.registerCommand($t, (s) => {
706
- const a = D();
707
- if (!X(a, n)) return !1;
708
- if (k(a)) return r.$formatCells(s), !0;
709
- if (H(a)) {
710
- const u = N(a.anchor.getNode(), (d) => S(d));
711
- if (!S(u)) return !1;
712
- }
713
- return !1;
714
- }, q)), r.listenersToRemove.add(t.registerCommand(Ht, (s) => {
715
- const a = D();
716
- if (!k(a) || !X(a, n)) return !1;
717
- const u = a.anchor.getNode(), d = a.focus.getNode();
718
- if (!S(u) || !S(d)) return !1;
719
- if (function(y, F) {
720
- if (k(y)) {
721
- const x = y.anchor.getNode(), _ = y.focus.getNode();
722
- if (F && x && _) {
723
- const [T] = j(F, x, _);
724
- return x.getKey() === T[0][0].cell.getKey() && _.getKey() === T[T.length - 1].at(-1).cell.getKey();
725
- }
726
- }
727
- return !1;
728
- }(a, n)) return n.setFormat(s), !0;
729
- const [g, p, m] = j(n, u, d), C = Math.max(p.startRow + p.cell.__rowSpan - 1, m.startRow + m.cell.__rowSpan - 1), w = Math.max(p.startColumn + p.cell.__colSpan - 1, m.startColumn + m.cell.__colSpan - 1), K = Math.min(p.startRow, m.startRow), E = Math.min(p.startColumn, m.startColumn), A = /* @__PURE__ */ new Set();
730
- for (let y = K; y <= C; y++) for (let F = E; F <= w; F++) {
731
- const x = g[y][F].cell;
732
- if (A.has(x)) continue;
733
- A.add(x), x.setFormat(s);
734
- const _ = x.getChildren();
735
- for (let T = 0; T < _.length; T++) {
736
- const v = _[T];
737
- P(v) && !v.isInline() && v.setFormat(s);
738
- }
739
- }
740
- return !0;
741
- }, q)), r.listenersToRemove.add(t.registerCommand(Dt, (s) => {
742
- const a = D();
743
- if (!X(a, n)) return !1;
744
- if (k(a)) return r.$clearHighlight(), !1;
745
- if (H(a)) {
746
- const u = N(a.anchor.getNode(), (d) => S(d));
747
- if (!S(u)) return !1;
748
- if (typeof s == "string") {
749
- const d = nt(t, a, n);
750
- if (d) return tt(d, n, [$e(s)]), !0;
751
- }
752
- }
753
- return !1;
754
- }, q)), o && r.listenersToRemove.add(t.registerCommand(Wt, (s) => {
755
- const a = D();
756
- if (!H(a) || !a.isCollapsed() || !X(a, n)) return !1;
757
- const u = Ce(a.anchor.getNode());
758
- return !(u === null || !n.is(we(u))) && (Y(s), function(d, g) {
759
- const p = g === "next" ? "getNextSibling" : "getPreviousSibling", m = g === "next" ? "getFirstChild" : "getLastChild", C = d[p]();
760
- if (P(C)) return C.selectEnd();
761
- const w = N(d, M);
762
- w === null && b(247);
763
- for (let E = w[p](); M(E); E = E[p]()) {
764
- const A = E[m]();
765
- if (P(A)) return A.selectEnd();
766
- }
767
- const K = N(w, R);
768
- K === null && b(248), g === "next" ? K.selectNext() : K.selectPrevious();
769
- }(u, s.shiftKey ? "previous" : "next"), !0);
770
- }, q)), r.listenersToRemove.add(t.registerCommand(Bt, (s) => n.isSelected(), Oe)), r.listenersToRemove.add(t.registerCommand(It, (s) => {
771
- const { nodes: a, selection: u } = s, d = u.getStartEndPoints(), g = k(u), p = H(u) && N(u.anchor.getNode(), (O) => S(O)) !== null && N(u.focus.getNode(), (O) => S(O)) !== null || g;
772
- if (a.length !== 1 || !R(a[0]) || !p || d === null) return !1;
773
- const [m] = d, C = a[0], w = C.getChildren(), K = C.getFirstChildOrThrow().getChildrenSize(), E = C.getChildrenSize(), A = N(m.getNode(), (O) => S(O)), y = A && N(A, (O) => M(O)), F = y && N(y, (O) => R(O));
774
- if (!S(A) || !M(y) || !R(F)) return !1;
775
- const x = y.getIndexWithinParent(), _ = Math.min(F.getChildrenSize() - 1, x + E - 1), T = A.getIndexWithinParent(), v = Math.min(y.getChildrenSize() - 1, T + K - 1), L = Math.min(T, v), $ = Math.min(x, _), B = Math.max(T, v), W = Math.max(x, _), z = F.getChildren();
776
- let I = 0;
777
- for (let O = $; O <= W; O++) {
778
- const se = z[O];
779
- if (!M(se)) return !1;
780
- const qe = w[I];
781
- if (!M(qe)) return !1;
782
- const pt = se.getChildren(), Ct = qe.getChildren();
783
- let Xe = 0;
784
- for (let Te = L; Te <= B; Te++) {
785
- const fe = pt[Te];
786
- if (!S(fe)) return !1;
787
- const Ye = Ct[Xe];
788
- if (!S(Ye)) return !1;
789
- const St = fe.getChildren();
790
- Ye.getChildren().forEach((ne) => {
791
- ue(ne) && G().append(ne), fe.append(ne);
792
- }), St.forEach((ne) => ne.remove()), Xe++;
793
- }
794
- I++;
795
- }
796
- return !0;
797
- }, q)), r.listenersToRemove.add(t.registerCommand(re, () => {
798
- const s = D(), a = je(), u = r.getAndClearNextFocus();
799
- if (u !== null) {
800
- const { focusCell: d } = u;
801
- if (k(s) && s.tableKey === r.tableNodeKey) return (d.x !== r.focusX || d.y !== r.focusY) && (r.$setFocusCellForSelection(d), !0);
802
- if (d !== r.anchorCell && X(s, n)) return r.$setFocusCellForSelection(d), !0;
803
- }
804
- if (r.getAndClearShouldCheckSelection() && H(a) && H(s) && s.isCollapsed()) {
805
- const d = s.anchor.getNode(), g = n.getFirstChild(), p = Ce(d);
806
- if (p !== null && M(g)) {
807
- const m = g.getFirstChild();
808
- if (S(m) && n.is(N(p, (C) => C.is(n) || C.is(m)))) return m.selectStart(), !0;
809
- }
810
- }
811
- if (H(s)) {
812
- const { anchor: d, focus: g } = s, p = d.getNode(), m = g.getNode(), C = Ce(p), w = Ce(m), K = !(!C || !n.is(we(C))), E = !(!w || !n.is(we(w))), A = K !== E, y = K && E, F = s.isBackward();
813
- if (A) {
814
- const x = s.clone();
815
- if (E) {
816
- const [_] = j(n, w, w), T = _[0][0].cell, v = _[_.length - 1].at(-1).cell;
817
- x.focus.set(F ? T.getKey() : v.getKey(), F ? T.getChildrenSize() : v.getChildrenSize(), "element");
818
- } else if (K) {
819
- const [_] = j(n, C, C), T = _[0][0].cell, v = _[_.length - 1].at(-1).cell;
820
- x.anchor.set(F ? v.getKey() : T.getKey(), F ? v.getChildrenSize() : 0, "element");
821
- }
822
- U(x), et(t, r);
823
- } else y && (C.is(w) || (r.$setAnchorCellForSelection(ce(r, C)), r.$setFocusCellForSelection(ce(r, w), !0)));
824
- } else if (s && k(s) && s.is(a) && s.tableKey === n.getKey()) {
825
- const d = Ne(i);
826
- if (d && d.anchorNode && d.focusNode) {
827
- const g = Q(d.focusNode), p = g && !n.isParentOf(g), m = Q(d.anchorNode), C = m && n.isParentOf(m);
828
- if (p && C && d.rangeCount > 0) {
829
- const w = Jt(d, t);
830
- w && (w.anchor.set(n.getKey(), s.isBackward() ? n.getChildrenSize() : 0, "element"), d.removeAllRanges(), U(w));
831
- }
832
- }
833
- }
834
- return s && !s.is(a) && (k(s) || k(a)) && r.tableSelection && !r.tableSelection.is(a) ? (k(s) && s.tableKey === r.tableNodeKey ? r.$updateTableTableSelection(s) : !k(s) && k(a) && a.tableKey === r.tableNodeKey && r.$updateTableTableSelection(null), !1) : (r.hasHijackedSelectionStyles && !n.isSelected() ? function(d, g) {
835
- g.$enableHighlightStyle(), Je(g.table, (p) => {
836
- const m = p.elem;
837
- p.highlighted = !1, ft(d, p), m.getAttribute("style") || m.removeAttribute("style");
838
- });
839
- }(t, r) : !r.hasHijackedSelectionStyles && n.isSelected() && et(t, r), !1);
840
- }, q)), r.listenersToRemove.add(t.registerCommand(zt, () => {
841
- const s = D();
842
- if (!H(s) || !s.isCollapsed() || !X(s, n)) return !1;
843
- const a = nt(t, s, n);
844
- return !!a && (tt(a, n), !0);
845
- }, q)), r;
846
- }
847
- function Ze(n) {
848
- return n[Ee] || null;
849
- }
850
- function ve(n) {
851
- let e = n;
852
- for (; e != null; ) {
853
- const t = e.nodeName;
854
- if (t === "TD" || t === "TH") {
855
- const o = e._cell;
856
- return o === void 0 ? null : o;
857
- }
858
- e = e.parentNode;
859
- }
860
- return null;
861
- }
862
- function ae(n, e) {
863
- const t = [], o = { columns: 0, domRows: t, rows: 0 };
864
- let l = Z(n, e).querySelector("tr"), i = 0, r = 0;
865
- for (t.length = 0; l != null; ) {
866
- const c = l.nodeName;
867
- if (c === "TD" || c === "TH") {
868
- const s = { elem: l, hasBackgroundColor: l.style.backgroundColor !== "", highlighted: !1, x: i, y: r };
869
- l._cell = s;
870
- let a = t[r];
871
- a === void 0 && (a = t[r] = []), a[i] = s;
872
- } else {
873
- const s = l.firstChild;
874
- if (s != null) {
875
- l = s;
876
- continue;
877
- }
878
- }
879
- const h = l.nextSibling;
880
- if (h != null) {
881
- i++, l = h;
882
- continue;
883
- }
884
- const f = l.parentNode;
885
- if (f != null) {
886
- const s = f.nextSibling;
887
- if (s == null) break;
888
- r++, i = 0, l = s;
889
- }
890
- }
891
- return o.columns = i + 1, o.rows = r + 1, o;
892
- }
893
- function ge(n, e, t) {
894
- const o = new Set(t ? t.getNodes() : []);
895
- Je(e, (l, i) => {
896
- const r = l.elem;
897
- o.has(i) ? (l.highlighted = !0, dt(n, l)) : (l.highlighted = !1, ft(n, l), r.getAttribute("style") || r.removeAttribute("style"));
898
- });
899
- }
900
- function Je(n, e) {
901
- const { domRows: t } = n;
902
- for (let o = 0; o < t.length; o++) {
903
- const l = t[o];
904
- if (l) for (let i = 0; i < l.length; i++) {
905
- const r = l[i];
906
- if (!r) continue;
907
- const c = Q(r.elem);
908
- c !== null && e(r, c, { x: i, y: o });
909
- }
910
- }
911
- }
912
- function et(n, e) {
913
- e.$disableHighlightStyle(), Je(e.table, (t) => {
914
- t.highlighted = !0, dt(n, t);
915
- });
916
- }
917
- const gn = (n, e, t, o, l) => {
918
- const i = l === "forward";
919
- switch (l) {
920
- case "backward":
921
- case "forward":
922
- return t !== (i ? n.table.columns - 1 : 0) ? pe(e.getCellNodeFromCordsOrThrow(t + (i ? 1 : -1), o, n.table), i) : o !== (i ? n.table.rows - 1 : 0) ? pe(e.getCellNodeFromCordsOrThrow(i ? 0 : n.table.columns - 1, o + (i ? 1 : -1), n.table), i) : i ? e.selectNext() : e.selectPrevious(), !0;
923
- case "up":
924
- return o !== 0 ? pe(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0;
925
- case "down":
926
- return o !== n.table.rows - 1 ? pe(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0;
927
- default:
928
- return !1;
929
- }
930
- };
931
- function ke(n, e) {
932
- let t, o;
933
- if (e.startColumn === n.minColumn) t = "minColumn";
934
- else {
935
- if (e.startColumn + e.cell.__colSpan - 1 !== n.maxColumn) return null;
936
- t = "maxColumn";
937
- }
938
- if (e.startRow === n.minRow) o = "minRow";
939
- else {
940
- if (e.startRow + e.cell.__rowSpan - 1 !== n.maxRow) return null;
941
- o = "maxRow";
942
- }
943
- return [t, o];
944
- }
945
- function me([n, e]) {
946
- return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"];
947
- }
948
- function oe(n, e, [t, o]) {
949
- const l = e[o], i = n[l];
950
- i === void 0 && b(250, o, String(l));
951
- const r = e[t], c = i[r];
952
- return c === void 0 && b(250, t, String(r)), c;
953
- }
954
- function mn(n, e, t, o, l) {
955
- const i = Ke(e, t, o), r = function(y, F) {
956
- const { minColumn: x, maxColumn: _, minRow: T, maxRow: v } = F;
957
- let L = 1, $ = 1, B = 1, W = 1;
958
- const z = y[T], I = y[v];
959
- for (let O = x; O <= _; O++) L = Math.max(L, z[O].cell.__rowSpan), W = Math.max(W, I[O].cell.__rowSpan);
960
- for (let O = T; O <= v; O++) $ = Math.max($, y[O][x].cell.__colSpan), B = Math.max(B, y[O][_].cell.__colSpan);
961
- return { bottomSpan: W, leftSpan: $, rightSpan: B, topSpan: L };
962
- }(e, i), { topSpan: c, leftSpan: h, bottomSpan: f, rightSpan: s } = r, a = function(y, F) {
963
- const x = ke(y, F);
964
- return x === null && b(249, F.cell.getKey()), x;
965
- }(i, t), [u, d] = me(a);
966
- let g = i[u], p = i[d];
967
- l === "forward" ? g += u === "maxColumn" ? 1 : h : l === "backward" ? g -= u === "minColumn" ? 1 : s : l === "down" ? p += d === "maxRow" ? 1 : c : l === "up" && (p -= d === "minRow" ? 1 : f);
968
- const m = e[p];
969
- if (m === void 0) return !1;
970
- const C = m[g];
971
- if (C === void 0) return !1;
972
- const [w, K] = function(y, F, x) {
973
- const _ = Ke(y, F, x), T = ke(_, F);
974
- if (T) return [oe(y, _, T), oe(y, _, me(T))];
975
- const v = ke(_, x);
976
- if (v) return [oe(y, _, me(v)), oe(y, _, v)];
977
- const L = ["minColumn", "minRow"];
978
- return [oe(y, _, L), oe(y, _, me(L))];
979
- }(e, t, C), E = ce(n, w.cell), A = ce(n, K.cell);
980
- return n.$setAnchorCellForSelection(E), n.$setFocusCellForSelection(A, !0), !0;
981
- }
982
- function X(n, e) {
983
- if (H(n) || k(n)) {
984
- const t = e.isParentOf(n.anchor.getNode()), o = e.isParentOf(n.focus.getNode());
985
- return t && o;
986
- }
987
- return !1;
988
- }
989
- function pe(n, e) {
990
- e ? n.selectStart() : n.selectEnd();
991
- }
992
- function dt(n, e) {
993
- const t = e.elem, o = n._config.theme;
994
- S(Q(t)) || b(131), V(t, o.tableCellSelected);
995
- }
996
- function ft(n, e) {
997
- const t = e.elem;
998
- S(Q(t)) || b(131);
999
- const o = n._config.theme;
1000
- ye(t, o.tableCellSelected);
1001
- }
1002
- function Ce(n) {
1003
- const e = N(n, S);
1004
- return S(e) ? e : null;
1005
- }
1006
- function we(n) {
1007
- const e = N(n, R);
1008
- return R(e) ? e : null;
1009
- }
1010
- function gt(n, e, t, o, l) {
1011
- if ((t === "up" || t === "down") && function(r) {
1012
- const c = r.getRootElement();
1013
- return c ? c.hasAttribute("aria-controls") && c.getAttribute("aria-controls") === "typeahead-menu" : !1;
1014
- }(n)) return !1;
1015
- const i = D();
1016
- if (!X(i, o)) {
1017
- if (H(i)) {
1018
- if (t === "backward") {
1019
- if (i.focus.offset > 0) return !1;
1020
- const r = function(h) {
1021
- for (let f = h, s = h; s !== null; f = s, s = s.getParent()) if (P(s)) {
1022
- if (s !== f && s.getFirstChild() !== f) return null;
1023
- if (!s.isInline()) return s;
1024
- }
1025
- return null;
1026
- }(i.focus.getNode());
1027
- if (!r) return !1;
1028
- const c = r.getPreviousSibling();
1029
- return !!R(c) && (Y(e), e.shiftKey ? i.focus.set(c.getParentOrThrow().getKey(), c.getIndexWithinParent(), "element") : c.selectEnd(), !0);
1030
- }
1031
- if (e.shiftKey && (t === "up" || t === "down")) {
1032
- const r = i.focus.getNode();
1033
- if (!i.isCollapsed() && (t === "up" && !i.isBackward() || t === "down" && i.isBackward())) {
1034
- let c = N(r, (u) => R(u));
1035
- if (S(c) && (c = N(c, R)), c !== o || !c) return !1;
1036
- const h = t === "down" ? c.getNextSibling() : c.getPreviousSibling();
1037
- if (!h) return !1;
1038
- let f = 0;
1039
- t === "up" && P(h) && (f = h.getChildrenSize());
1040
- let s = h;
1041
- t === "up" && P(h) && (s = h.getLastChild() || h, f = ue(s) ? s.getTextContentSize() : 0);
1042
- const a = i.clone();
1043
- return a.focus.set(s.getKey(), f, ue(s) ? "text" : "element"), U(a), Y(e), !0;
1044
- }
1045
- if (Xt(r)) {
1046
- const c = t === "up" ? i.getNodes()[i.getNodes().length - 1] : i.getNodes()[0];
1047
- if (c && ie(o, c) !== null) {
1048
- const h = o.getFirstDescendant(), f = o.getLastDescendant();
1049
- if (!h || !f) return !1;
1050
- const [s] = le(h), [a] = le(f), u = o.getCordsFromCellNode(s, l.table), d = o.getCordsFromCellNode(a, l.table), g = o.getDOMCellFromCordsOrThrow(u.x, u.y, l.table), p = o.getDOMCellFromCordsOrThrow(d.x, d.y, l.table);
1051
- return l.$setAnchorCellForSelection(g), l.$setFocusCellForSelection(p, !0), !0;
1052
- }
1053
- return !1;
1054
- }
1055
- {
1056
- let c = N(r, (f) => P(f) && !f.isInline());
1057
- if (S(c) && (c = N(c, R)), !c) return !1;
1058
- const h = t === "down" ? c.getNextSibling() : c.getPreviousSibling();
1059
- if (R(h) && l.tableNodeKey === h.getKey()) {
1060
- const f = h.getFirstDescendant(), s = h.getLastDescendant();
1061
- if (!f || !s) return !1;
1062
- const [a] = le(f), [u] = le(s), d = i.clone();
1063
- return d.focus.set((t === "up" ? a : u).getKey(), t === "up" ? 0 : u.getChildrenSize(), "element"), Y(e), U(d), !0;
1064
- }
1065
- }
1066
- }
1067
- }
1068
- return t === "down" && mt(n) && l.setShouldCheckSelection(), !1;
1069
- }
1070
- if (H(i) && i.isCollapsed()) {
1071
- const { anchor: r, focus: c } = i, h = N(r.getNode(), S), f = N(c.getNode(), S);
1072
- if (!S(h) || !h.is(f)) return !1;
1073
- const s = we(h);
1074
- if (s !== o && s != null) {
1075
- const C = Z(s, n.getElementByKey(s.getKey()));
1076
- if (C != null) return l.table = ae(s, C), gt(n, e, t, s, l);
1077
- }
1078
- if (t === "backward" || t === "forward") {
1079
- const C = r.type, w = r.offset, K = r.getNode();
1080
- if (!K) return !1;
1081
- const E = i.getNodes();
1082
- return (E.length !== 1 || !Yt(E[0])) && !!function(A, y, F, x) {
1083
- return function(_, T, v) {
1084
- return _ === "element" && (v === "backward" ? T.getPreviousSibling() === null : T.getNextSibling() === null);
1085
- }(A, F, x) || function(_, T, v, L) {
1086
- const $ = N(v, (W) => P(W) && !W.isInline());
1087
- if (!$) return !1;
1088
- const B = L === "backward" ? T === 0 : T === v.getTextContentSize();
1089
- return _ === "text" && B && (L === "backward" ? $.getPreviousSibling() === null : $.getNextSibling() === null);
1090
- }(A, y, F, x);
1091
- }(C, w, K, t) && function(A, y, F, x, _) {
1092
- const [T, v] = j(x, F, F);
1093
- if (!function($, B, W) {
1094
- const z = $[0][0], I = $[$.length - 1][$[0].length - 1], { startColumn: O, startRow: se } = B;
1095
- return W === "backward" ? O === z.startColumn && se === z.startRow : O === I.startColumn && se === I.startRow;
1096
- }(T, v, _)) return !1;
1097
- const L = function($, B, W) {
1098
- const z = N($, (O) => P(O) && !O.isInline());
1099
- if (!z) return;
1100
- const I = B === "backward" ? z.getPreviousSibling() : z.getNextSibling();
1101
- return I && R(I) ? I : B === "backward" ? W.getPreviousSibling() : W.getNextSibling();
1102
- }(y, _, x);
1103
- return !L || R(L) ? !1 : (Y(A), _ === "backward" ? L.selectEnd() : L.selectStart(), !0);
1104
- }(e, K, h, o, t);
1105
- }
1106
- const a = n.getElementByKey(h.__key), u = n.getElementByKey(r.key);
1107
- if (u == null || a == null) return !1;
1108
- let d;
1109
- if (r.type === "element") d = u.getBoundingClientRect();
1110
- else {
1111
- const C = Ne(Ie(n));
1112
- if (C === null || C.rangeCount === 0) return !1;
1113
- d = C.getRangeAt(0).getBoundingClientRect();
1114
- }
1115
- const g = t === "up" ? h.getFirstChild() : h.getLastChild();
1116
- if (g == null) return !1;
1117
- const p = n.getElementByKey(g.__key);
1118
- if (p == null) return !1;
1119
- const m = p.getBoundingClientRect();
1120
- if (t === "up" ? m.top > d.top - d.height : d.bottom + d.height > m.bottom) {
1121
- Y(e);
1122
- const C = o.getCordsFromCellNode(h, l.table);
1123
- if (!e.shiftKey) return gn(l, o, C.x, C.y, t);
1124
- {
1125
- const w = o.getDOMCellFromCordsOrThrow(C.x, C.y, l.table);
1126
- l.$setAnchorCellForSelection(w), l.$setFocusCellForSelection(w, !0);
1127
- }
1128
- return !0;
1129
- }
1130
- } else if (k(i)) {
1131
- const { anchor: r, focus: c } = i, h = N(r.getNode(), S), f = N(c.getNode(), S), [s] = i.getNodes();
1132
- R(s) || b(251);
1133
- const a = Z(s, n.getElementByKey(s.getKey()));
1134
- if (!S(h) || !S(f) || !R(s) || a == null) return !1;
1135
- l.$updateTableTableSelection(i);
1136
- const u = ae(s, a), d = o.getCordsFromCellNode(h, u), g = o.getDOMCellFromCordsOrThrow(d.x, d.y, u);
1137
- if (l.$setAnchorCellForSelection(g), Y(e), e.shiftKey) {
1138
- const [p, m, C] = j(o, h, f);
1139
- return mn(l, p, m, C, t);
1140
- }
1141
- return f.selectEnd(), !0;
1142
- }
1143
- return !1;
1144
- }
1145
- function Y(n) {
1146
- n.preventDefault(), n.stopImmediatePropagation(), n.stopPropagation();
1147
- }
1148
- function tt(n, e, t) {
1149
- const o = G();
1150
- n === "first" ? e.insertBefore(o) : e.insertAfter(o), o.append(...t || []), o.selectEnd();
1151
- }
1152
- function nt(n, e, t) {
1153
- const o = t.getParent();
1154
- if (!o) return;
1155
- const l = Ne(Ie(n));
1156
- if (!l) return;
1157
- const i = l.anchorNode, r = n.getElementByKey(o.getKey()), c = Z(t, n.getElementByKey(t.getKey()));
1158
- if (!i || !r || !c || !r.contains(i) || c.contains(i)) return;
1159
- const h = N(e.anchor.getNode(), (w) => S(w));
1160
- if (!h) return;
1161
- const f = N(h, (w) => R(w));
1162
- if (!R(f) || !f.is(t)) return;
1163
- const [s, a] = j(t, h, h), u = s[0][0], d = s[s.length - 1][s[0].length - 1], { startRow: g, startColumn: p } = a, m = g === u.startRow && p === u.startColumn, C = g === d.startRow && p === d.startColumn;
1164
- return m ? "first" : C ? "last" : void 0;
1165
- }
1166
- function ce(n, e) {
1167
- const { tableNode: t } = n.$lookup(), o = t.getCordsFromCellNode(e, n.table);
1168
- return t.getDOMCellFromCordsOrThrow(o.x, o.y, n.table);
1169
- }
1170
- function Me(n, e, t) {
1171
- return ie(n, Q(e, t));
1172
- }
1173
- function ot(n, e, t, o) {
1174
- const l = n.querySelector("colgroup");
1175
- if (!l) return;
1176
- const i = [];
1177
- for (let r = 0; r < t; r++) {
1178
- const c = document.createElement("col"), h = o && o[r];
1179
- h && (c.style.width = `${h}px`), i.push(c);
1180
- }
1181
- l.replaceChildren(...i);
1182
- }
1183
- function rt(n, e, t) {
1184
- t ? (V(n, e.theme.tableRowStriping), n.setAttribute("data-lexical-row-striping", "true")) : (ye(n, e.theme.tableRowStriping), n.removeAttribute("data-lexical-row-striping"));
1185
- }
1186
- function Re(n, e, t) {
1187
- if (!e.theme.tableAlignment) return;
1188
- const o = [], l = [];
1189
- for (const i of ["center", "right"]) {
1190
- const r = e.theme.tableAlignment[i];
1191
- r && (i === t ? l : o).push(r);
1192
- }
1193
- ye(n, ...o), V(n, ...l);
1194
- }
1195
- const Ae = /* @__PURE__ */ new WeakSet();
1196
- function mt(n = it()) {
1197
- return Ae.has(n);
1198
- }
1199
- function vn(n, e) {
1200
- e ? Ae.add(n) : Ae.delete(n);
1201
- }
1202
- class ee extends Pe {
1203
- static getType() {
1204
- return "table";
1205
- }
1206
- getColWidths() {
1207
- return this.getLatest().__colWidths;
1208
- }
1209
- setColWidths(e) {
1210
- const t = this.getWritable();
1211
- return t.__colWidths = e, t;
1212
- }
1213
- static clone(e) {
1214
- return new ee(e.__key);
1215
- }
1216
- afterCloneFrom(e) {
1217
- super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping;
1218
- }
1219
- static importDOM() {
1220
- return { table: (e) => ({ conversion: pn, priority: 1 }) };
1221
- }
1222
- static importJSON(e) {
1223
- return ze().updateFromJSON(e);
1224
- }
1225
- updateFromJSON(e) {
1226
- return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setColWidths(e.colWidths);
1227
- }
1228
- constructor(e) {
1229
- super(e), this.__rowStriping = !1;
1230
- }
1231
- exportJSON() {
1232
- return { ...super.exportJSON(), colWidths: this.getColWidths(), rowStriping: this.__rowStriping ? this.__rowStriping : void 0 };
1233
- }
1234
- extractWithChild(e, t, o) {
1235
- return o === "html";
1236
- }
1237
- getDOMSlot(e) {
1238
- const t = e.nodeName !== "TABLE" && e.querySelector("table") || e;
1239
- return t.nodeName !== "TABLE" && b(229), super.getDOMSlot(t).withAfter(t.querySelector("colgroup"));
1240
- }
1241
- createDOM(e, t) {
1242
- const o = document.createElement("table"), l = document.createElement("colgroup");
1243
- if (o.appendChild(l), ot(o, 0, this.getColumnCount(), this.getColWidths()), xt(l), V(o, e.theme.table), Re(o, e, this.getFormatType()), this.__rowStriping && rt(o, e, !0), mt(t)) {
1244
- const i = document.createElement("div"), r = e.theme.tableScrollableWrapper;
1245
- return r ? V(i, r) : i.style.cssText = "overflow-x: auto;", i.appendChild(o), i;
1246
- }
1247
- return o;
1248
- }
1249
- updateDOM(e, t, o) {
1250
- return e.__rowStriping !== this.__rowStriping && rt(t, o, this.__rowStriping), ot(t, 0, this.getColumnCount(), this.getColWidths()), Re(this.getDOMSlot(t).element, o, this.getFormatType()), !1;
1251
- }
1252
- exportDOM(e) {
1253
- const t = super.exportDOM(e), { element: o } = t;
1254
- return { after: (l) => {
1255
- if (t.after && (l = t.after(l), this.__format && Re(l, e._config, this.getFormatType())), Se(l) && l.nodeName !== "TABLE" && (l = l.querySelector("table")), !Se(l)) return null;
1256
- const [i] = Be(this, null, null), r = /* @__PURE__ */ new Map();
1257
- for (const s of i) for (const a of s) {
1258
- const u = a.cell.getKey();
1259
- r.has(u) || r.set(u, { colSpan: a.cell.getColSpan(), startColumn: a.startColumn });
1260
- }
1261
- const c = /* @__PURE__ */ new Set();
1262
- for (const s of l.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
1263
- const a = s.getAttribute("data-temporary-table-cell-lexical-key");
1264
- if (a) {
1265
- const u = r.get(a);
1266
- if (s.removeAttribute("data-temporary-table-cell-lexical-key"), u) {
1267
- r.delete(a);
1268
- for (let d = 0; d < u.colSpan; d++) c.add(d + u.startColumn);
1269
- }
1270
- }
1271
- }
1272
- const h = l.querySelector(":scope > colgroup");
1273
- if (h) {
1274
- const s = Array.from(l.querySelectorAll(":scope > colgroup > col")).filter((a, u) => c.has(u));
1275
- h.replaceChildren(...s);
1276
- }
1277
- const f = l.querySelectorAll(":scope > tr");
1278
- if (f.length > 0) {
1279
- const s = document.createElement("tbody");
1280
- for (const a of f) s.appendChild(a);
1281
- l.append(s);
1282
- }
1283
- return l;
1284
- }, element: Se(o) && o.nodeName !== "TABLE" ? o.querySelector("table") : o };
1285
- }
1286
- canBeEmpty() {
1287
- return !1;
1288
- }
1289
- isShadowRoot() {
1290
- return !0;
1291
- }
1292
- getCordsFromCellNode(e, t) {
1293
- const { rows: o, domRows: l } = t;
1294
- for (let i = 0; i < o; i++) {
1295
- const r = l[i];
1296
- if (r != null) for (let c = 0; c < r.length; c++) {
1297
- const h = r[c];
1298
- if (h == null) continue;
1299
- const { elem: f } = h, s = Me(this, f);
1300
- if (s !== null && e.is(s)) return { x: c, y: i };
1301
- }
1302
- }
1303
- throw new Error("Cell not found in table.");
1304
- }
1305
- getDOMCellFromCords(e, t, o) {
1306
- const { domRows: l } = o, i = l[t];
1307
- if (i == null) return null;
1308
- const r = i[e < i.length ? e : i.length - 1];
1309
- return r ?? null;
1310
- }
1311
- getDOMCellFromCordsOrThrow(e, t, o) {
1312
- const l = this.getDOMCellFromCords(e, t, o);
1313
- if (!l) throw new Error("Cell not found at cords.");
1314
- return l;
1315
- }
1316
- getCellNodeFromCords(e, t, o) {
1317
- const l = this.getDOMCellFromCords(e, t, o);
1318
- if (l == null) return null;
1319
- const i = Q(l.elem);
1320
- return S(i) ? i : null;
1321
- }
1322
- getCellNodeFromCordsOrThrow(e, t, o) {
1323
- const l = this.getCellNodeFromCords(e, t, o);
1324
- if (!l) throw new Error("Node at cords not TableCellNode.");
1325
- return l;
1326
- }
1327
- getRowStriping() {
1328
- return !!this.getLatest().__rowStriping;
1329
- }
1330
- setRowStriping(e) {
1331
- const t = this.getWritable();
1332
- return t.__rowStriping = e, t;
1333
- }
1334
- canSelectBefore() {
1335
- return !0;
1336
- }
1337
- canIndent() {
1338
- return !1;
1339
- }
1340
- getColumnCount() {
1341
- const e = this.getFirstChild();
1342
- if (!e) return 0;
1343
- let t = 0;
1344
- return e.getChildren().forEach((o) => {
1345
- S(o) && (t += o.getColSpan());
1346
- }), t;
1347
- }
1348
- }
1349
- function pn(n) {
1350
- const e = ze();
1351
- n.hasAttribute("data-lexical-row-striping") && e.setRowStriping(!0);
1352
- const t = n.querySelector(":scope > colgroup");
1353
- if (t) {
1354
- let o = [];
1355
- for (const l of t.querySelectorAll(":scope > col")) {
1356
- let i = l.style.width || "";
1357
- if (!He.test(i) && (i = l.getAttribute("width") || "", !/^\d+$/.test(i))) {
1358
- o = void 0;
1359
- break;
1360
- }
1361
- o.push(parseFloat(i));
1362
- }
1363
- o && e.setColWidths(o);
1364
- }
1365
- return { after: (o) => lt(o, M), node: e };
1366
- }
1367
- function ze() {
1368
- return Le(new ee());
1369
- }
1370
- function R(n) {
1371
- return n instanceof ee;
1372
- }
1373
- function Cn({ rows: n, columns: e, includeHeaders: t }) {
1374
- const o = rn(Number(n), Number(e), t);
1375
- _t(o);
1376
- const l = o.getFirstDescendant();
1377
- return ue(l) && l.select(), !0;
1378
- }
1379
- function Sn(n) {
1380
- M(n.getParent()) ? n.isEmpty() && n.append(G()) : n.remove();
1381
- }
1382
- function bn(n) {
1383
- R(n.getParent()) ? st(n, S) : n.remove();
1384
- }
1385
- function wn(n) {
1386
- st(n, M);
1387
- const [e] = Be(n, null, null), t = e.reduce((l, i) => Math.max(l, i.length), 0), o = n.getChildren();
1388
- for (let l = 0; l < e.length; ++l) {
1389
- const i = o[l];
1390
- if (!i) continue;
1391
- M(i) || b(254, i.constructor.name, i.getType());
1392
- const r = e[l].reduce((c, h) => h ? 1 + c : c, 0);
1393
- if (r !== t) for (let c = r; c < t; ++c) {
1394
- const h = he();
1395
- h.append(G()), i.append(h);
1396
- }
1397
- }
1398
- }
1399
- function kn(n) {
1400
- return n.registerNodeTransform(te, (e) => {
1401
- if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
1402
- const [, , t] = le(e), [o] = j(t, e, e), l = o.length, i = o[0].length;
1403
- let r = t.getFirstChild();
1404
- M(r) || b(175);
1405
- const c = [];
1406
- for (let h = 0; h < l; h++) {
1407
- h !== 0 && (r = r.getNextSibling(), M(r) || b(175));
1408
- let f = null;
1409
- for (let s = 0; s < i; s++) {
1410
- const a = o[h][s], u = a.cell;
1411
- if (a.startRow === h && a.startColumn === s) f = u, c.push(u);
1412
- else if (u.getColSpan() > 1 || u.getRowSpan() > 1) {
1413
- S(u) || b(176);
1414
- const d = he(u.__headerState);
1415
- f !== null ? f.insertAfter(d) : wt(r, d);
1416
- }
1417
- }
1418
- }
1419
- for (const h of c) h.setColSpan(1), h.setRowSpan(1);
1420
- }
1421
- });
1422
- }
1423
- function Rn(n, e = !0) {
1424
- const t = /* @__PURE__ */ new Map(), o = (i, r, c) => {
1425
- const h = Z(i, c), f = fn(i, h, n, e);
1426
- t.set(r, [f, h]);
1427
- }, l = n.registerMutationListener(ee, (i) => {
1428
- n.getEditorState().read(() => {
1429
- for (const [r, c] of i) {
1430
- const h = t.get(r);
1431
- if (c === "created" || c === "updated") {
1432
- const { tableNode: f, tableElement: s } = ht(r);
1433
- h === void 0 ? o(f, r, s) : s !== h[1] && (h[0].removeListeners(), t.delete(r), o(f, r, s));
1434
- } else c === "destroyed" && h !== void 0 && (h[0].removeListeners(), t.delete(r));
1435
- }
1436
- }, { editor: n });
1437
- }, { skipInitialization: !1 });
1438
- return () => {
1439
- l();
1440
- for (const [, [i]] of t) i.removeListeners();
1441
- };
1442
- }
1443
- function Kn(n) {
1444
- return n.hasNodes([ee]) || b(255), bt(n.registerCommand(Zt, Cn, Ft), n.registerNodeTransform(ee, wn), n.registerNodeTransform(de, bn), n.registerNodeTransform(te, Sn));
1445
- }
1446
- export {
1447
- Fn as F,
1448
- On as L,
1449
- Tn as O,
1450
- vn as P,
1451
- ln as R,
1452
- de as S,
1453
- xn as T,
1454
- Kn as V,
1455
- ee as W,
1456
- kn as X,
1457
- De as _,
1458
- he as d,
1459
- S as g,
1460
- Rn as j,
1461
- te as u,
1462
- ut as v,
1463
- rn as x
1464
- };
1465
- //# sourceMappingURL=LexicalTable.prod-DjfZc87j.js.map