@payloadcms/richtext-lexical 3.0.0-beta.90 → 3.0.0-beta.91

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 (80) hide show
  1. package/dist/exports/client/Field-SUWHJ4HF.js +2 -0
  2. package/dist/exports/client/Field-SUWHJ4HF.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-EZORSGUZ.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-EZORSGUZ.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/{chunk-NI6Z4GBD.js → chunk-OLSILJA6.js} +1 -1
  7. package/dist/exports/client/{chunk-NI6Z4GBD.js.map → chunk-OLSILJA6.js.map} +1 -1
  8. package/dist/exports/client/{chunk-G5DTIOPI.js → chunk-TD7O23AB.js} +2 -2
  9. package/dist/exports/client/{chunk-G5DTIOPI.js.map → chunk-TD7O23AB.js.map} +2 -2
  10. package/dist/exports/client/{chunk-LGUXX2QH.js → chunk-UJDWBQ2K.js} +2 -2
  11. package/dist/exports/client/{chunk-LGUXX2QH.js.map → chunk-UJDWBQ2K.js.map} +2 -2
  12. package/dist/exports/client/{chunk-OKMIHD2R.js → chunk-YL453UOS.js} +2 -2
  13. package/dist/exports/client/chunk-YSI2QILQ.js +2 -0
  14. package/dist/exports/client/{chunk-TO2W7Q2G.js.map → chunk-YSI2QILQ.js.map} +2 -2
  15. package/dist/exports/client/component-2YLEVOFH.js +2 -0
  16. package/dist/exports/client/component-2YLEVOFH.js.map +7 -0
  17. package/dist/exports/client/{component-LCAAX56T.js → component-7RAP75FW.js} +2 -2
  18. package/dist/exports/client/{componentInline-72VZAAHP.js → componentInline-YSHGRL2J.js} +2 -2
  19. package/dist/exports/client/index.js +12 -12
  20. package/dist/exports/client/index.js.map +3 -3
  21. package/dist/features/debug/testRecorder/client/plugin/index.js +187 -363
  22. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  23. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +234 -470
  24. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  25. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -16
  26. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  27. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +59 -123
  28. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  29. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  30. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +5 -3
  31. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  32. package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js +1 -1
  33. package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
  34. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  35. package/dist/features/relationship/client/components/RelationshipComponent.js +8 -5
  36. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  37. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +6 -4
  38. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  39. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  40. package/dist/features/toolbars/inline/client/Toolbar/index.js +53 -94
  41. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  42. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  43. package/dist/features/upload/client/component/index.js +3 -0
  44. package/dist/features/upload/client/component/index.js.map +1 -1
  45. package/dist/features/upload/server/nodes/UploadNode.d.ts +9 -7
  46. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  47. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  48. package/dist/field/bundled.css +1 -1
  49. package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
  50. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  51. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -109
  52. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  53. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +96 -135
  54. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  55. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  56. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +114 -139
  57. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  58. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
  59. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +7 -25
  60. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  61. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  62. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +4 -6
  63. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  64. package/dist/lexical/ui/icons/Caret/index.svg +2 -2
  65. package/dist/lexical/utils/setFloatingElemPosition.js +1 -1
  66. package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
  67. package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
  68. package/dist/utilities/migrateSlateToLexical/index.js +16 -1
  69. package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
  70. package/package.json +13 -13
  71. package/dist/exports/client/Field-63NGLPJB.js +0 -2
  72. package/dist/exports/client/Field-63NGLPJB.js.map +0 -7
  73. package/dist/exports/client/RelationshipComponent-3QWBV4GT.js +0 -2
  74. package/dist/exports/client/RelationshipComponent-3QWBV4GT.js.map +0 -7
  75. package/dist/exports/client/chunk-TO2W7Q2G.js +0 -2
  76. package/dist/exports/client/component-3OFD6Q4Z.js +0 -2
  77. package/dist/exports/client/component-3OFD6Q4Z.js.map +0 -7
  78. /package/dist/exports/client/{chunk-OKMIHD2R.js.map → chunk-YL453UOS.js.map} +0 -0
  79. /package/dist/exports/client/{component-LCAAX56T.js.map → component-7RAP75FW.js.map} +0 -0
  80. /package/dist/exports/client/{componentInline-72VZAAHP.js.map → componentInline-YSHGRL2J.js.map} +0 -0
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import { c as _c } from "react/compiler-runtime";
4
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
6
5
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
@@ -83,39 +82,28 @@ function $selectLastDescendant(node) {
83
82
  lastDescendant.selectNext();
84
83
  }
85
84
  }
86
- function TableActionMenu(t0) {
87
- const $ = _c(69);
88
- const {
89
- cellMerge,
90
- contextRef,
91
- onClose,
92
- setIsMenuOpen,
93
- tableCellNode: _tableCellNode
94
- } = t0;
85
+ function TableActionMenu({
86
+ cellMerge,
87
+ contextRef,
88
+ onClose,
89
+ setIsMenuOpen,
90
+ tableCellNode: _tableCellNode
91
+ }) {
95
92
  const [editor] = useLexicalComposerContext();
96
93
  const dropDownRef = useRef(null);
97
94
  const [tableCellNode, updateTableCellNode] = useState(_tableCellNode);
98
- let t1;
99
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
100
- t1 = {
101
- columns: 1,
102
- rows: 1
103
- };
104
- $[0] = t1;
105
- } else {
106
- t1 = $[0];
107
- }
108
- const [selectionCounts, updateSelectionCounts] = useState(t1);
95
+ const [selectionCounts, updateSelectionCounts] = useState({
96
+ columns: 1,
97
+ rows: 1
98
+ });
109
99
  const [canMergeCells, setCanMergeCells] = useState(false);
110
100
  const [canUnmergeCell, setCanUnmergeCell] = useState(false);
111
101
  const {
112
102
  y
113
103
  } = useScrollInfo();
114
- let t2;
115
- let t3;
116
- if ($[1] !== editor || $[2] !== tableCellNode) {
117
- t2 = () => editor.registerMutationListener(TableCellNode, nodeMutations => {
118
- const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
104
+ useEffect(() => {
105
+ return editor.registerMutationListener(TableCellNode, nodeMutations => {
106
+ const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === 'updated';
119
107
  if (nodeUpdated) {
120
108
  editor.getEditorState().read(() => {
121
109
  updateTableCellNode(tableCellNode.getLatest());
@@ -124,39 +112,20 @@ function TableActionMenu(t0) {
124
112
  }, {
125
113
  skipInitialization: true
126
114
  });
127
- t3 = [editor, tableCellNode];
128
- $[1] = editor;
129
- $[2] = tableCellNode;
130
- $[3] = t2;
131
- $[4] = t3;
132
- } else {
133
- t2 = $[3];
134
- t3 = $[4];
135
- }
136
- useEffect(t2, t3);
137
- let t4;
138
- let t5;
139
- if ($[5] !== editor) {
140
- t4 = () => {
141
- editor.getEditorState().read(() => {
142
- const selection = $getSelection();
143
- if ($isTableSelection(selection)) {
144
- const currentSelectionCounts = computeSelectionCount(selection);
145
- updateSelectionCounts(computeSelectionCount(selection));
146
- setCanMergeCells(isTableSelectionRectangular(selection) && (currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1));
147
- }
148
- setCanUnmergeCell($canUnmerge());
149
- });
150
- };
151
- t5 = [editor];
152
- $[5] = editor;
153
- $[6] = t4;
154
- $[7] = t5;
155
- } else {
156
- t4 = $[6];
157
- t5 = $[7];
158
- }
159
- useEffect(t4, t5);
115
+ }, [editor, tableCellNode]);
116
+ useEffect(() => {
117
+ editor.getEditorState().read(() => {
118
+ const selection = $getSelection();
119
+ // Merge cells
120
+ if ($isTableSelection(selection)) {
121
+ const currentSelectionCounts = computeSelectionCount(selection);
122
+ updateSelectionCounts(computeSelectionCount(selection));
123
+ setCanMergeCells(isTableSelectionRectangular(selection) && (currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1));
124
+ }
125
+ // Unmerge cell
126
+ setCanUnmergeCell($canUnmerge());
127
+ });
128
+ }, [editor]);
160
129
  useEffect(() => {
161
130
  const menuButtonElement = contextRef.current;
162
131
  const dropDownElement = dropDownRef.current;
@@ -164,488 +133,294 @@ function TableActionMenu(t0) {
164
133
  if (menuButtonElement != null && dropDownElement != null && rootElement != null) {
165
134
  const rootEleRect = rootElement.getBoundingClientRect();
166
135
  const menuButtonRect = menuButtonElement.getBoundingClientRect();
167
- dropDownElement.style.opacity = "1";
136
+ dropDownElement.style.opacity = '1';
168
137
  const dropDownElementRect = dropDownElement.getBoundingClientRect();
169
- let leftPosition = menuButtonRect.right + 5;
138
+ const margin = 5;
139
+ let leftPosition = menuButtonRect.right + margin;
170
140
  if (leftPosition + dropDownElementRect.width > window.innerWidth || leftPosition + dropDownElementRect.width > rootEleRect.right) {
171
- const position = menuButtonRect.left - dropDownElementRect.width - 5;
172
- leftPosition = (position < 0 ? 5 : position) + window.pageXOffset;
141
+ const position = menuButtonRect.left - dropDownElementRect.width - margin;
142
+ leftPosition = (position < 0 ? margin : position) + window.pageXOffset;
173
143
  }
174
144
  dropDownElement.style.left = `${leftPosition + window.pageXOffset}px`;
175
145
  let topPosition = menuButtonRect.top;
176
146
  if (topPosition + dropDownElementRect.height > window.innerHeight) {
177
147
  const position_0 = menuButtonRect.bottom - dropDownElementRect.height;
178
- topPosition = (position_0 < 0 ? 5 : position_0) + window.pageYOffset;
148
+ topPosition = (position_0 < 0 ? margin : position_0) + window.pageYOffset;
179
149
  }
180
150
  dropDownElement.style.top = `${topPosition}px`;
181
151
  }
182
152
  }, [contextRef, dropDownRef, editor, y]);
183
- let t6;
184
- if ($[8] !== setIsMenuOpen || $[9] !== contextRef) {
185
- t6 = [setIsMenuOpen, contextRef];
186
- $[8] = setIsMenuOpen;
187
- $[9] = contextRef;
188
- $[10] = t6;
189
- } else {
190
- t6 = $[10];
191
- }
192
153
  useEffect(() => {
193
- const handleClickOutside = function handleClickOutside(event) {
154
+ function handleClickOutside(event) {
194
155
  if (dropDownRef.current != null && contextRef.current != null && !dropDownRef.current.contains(event.target) && !contextRef.current.contains(event.target)) {
195
156
  setIsMenuOpen(false);
196
157
  }
197
- };
198
- window.addEventListener("click", handleClickOutside);
199
- return () => window.removeEventListener("click", handleClickOutside);
200
- }, t6);
201
- let t7;
202
- if ($[11] !== editor || $[12] !== tableCellNode) {
203
- t7 = () => {
204
- editor.update(() => {
205
- if (tableCellNode.isAttached()) {
206
- const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
207
- const tableElement = editor.getElementByKey(tableNode.getKey());
208
- if (!tableElement) {
209
- throw new Error("Expected to find tableElement in DOM");
210
- }
211
- const tableSelection = getTableObserverFromTableElement(tableElement);
212
- if (tableSelection !== null) {
213
- tableSelection.clearHighlight();
214
- }
215
- tableNode.markDirty();
216
- updateTableCellNode(tableCellNode.getLatest());
158
+ }
159
+ window.addEventListener('click', handleClickOutside);
160
+ return () => window.removeEventListener('click', handleClickOutside);
161
+ }, [setIsMenuOpen, contextRef]);
162
+ const clearTableSelection = useCallback(() => {
163
+ editor.update(() => {
164
+ if (tableCellNode.isAttached()) {
165
+ const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
166
+ const tableElement = editor.getElementByKey(tableNode.getKey());
167
+ if (!tableElement) {
168
+ throw new Error('Expected to find tableElement in DOM');
217
169
  }
218
- const rootNode = $getRoot();
219
- rootNode.selectStart();
220
- });
221
- };
222
- $[11] = editor;
223
- $[12] = tableCellNode;
224
- $[13] = t7;
225
- } else {
226
- t7 = $[13];
227
- }
228
- const clearTableSelection = t7;
229
- let t8;
230
- if ($[14] !== editor || $[15] !== onClose) {
231
- t8 = () => {
232
- editor.update(() => {
233
- const selection_0 = $getSelection();
234
- if ($isTableSelection(selection_0)) {
235
- const {
236
- columns,
237
- rows
238
- } = computeSelectionCount(selection_0);
239
- const nodes = selection_0.getNodes();
240
- let firstCell = null;
241
- for (let i = 0; i < nodes.length; i++) {
242
- const node = nodes[i];
243
- if ($isTableCellNode(node)) {
244
- if (firstCell === null) {
245
- node.setColSpan(columns).setRowSpan(rows);
246
- firstCell = node;
247
- const isEmpty = $cellContainsEmptyParagraph(node);
248
- let firstChild;
249
- if (isEmpty && $isParagraphNode(firstChild = node.getFirstChild())) {
250
- firstChild.remove();
251
- }
252
- } else {
253
- if ($isTableCellNode(firstCell)) {
254
- const isEmpty_0 = $cellContainsEmptyParagraph(node);
255
- if (!isEmpty_0) {
256
- firstCell.append(...node.getChildren());
257
- }
258
- node.remove();
259
- }
170
+ const tableSelection = getTableObserverFromTableElement(tableElement);
171
+ if (tableSelection !== null) {
172
+ tableSelection.clearHighlight();
173
+ }
174
+ tableNode.markDirty();
175
+ updateTableCellNode(tableCellNode.getLatest());
176
+ }
177
+ const rootNode = $getRoot();
178
+ rootNode.selectStart();
179
+ });
180
+ }, [editor, tableCellNode]);
181
+ const mergeTableCellsAtSelection = () => {
182
+ editor.update(() => {
183
+ const selection_0 = $getSelection();
184
+ if ($isTableSelection(selection_0)) {
185
+ const {
186
+ columns,
187
+ rows
188
+ } = computeSelectionCount(selection_0);
189
+ const nodes = selection_0.getNodes();
190
+ let firstCell = null;
191
+ for (let i = 0; i < nodes.length; i++) {
192
+ const node = nodes[i];
193
+ if ($isTableCellNode(node)) {
194
+ if (firstCell === null) {
195
+ node.setColSpan(columns).setRowSpan(rows);
196
+ firstCell = node;
197
+ const isEmpty = $cellContainsEmptyParagraph(node);
198
+ let firstChild;
199
+ if (isEmpty && $isParagraphNode(firstChild = node.getFirstChild())) {
200
+ firstChild.remove();
260
201
  }
202
+ } else if ($isTableCellNode(firstCell)) {
203
+ const isEmpty_0 = $cellContainsEmptyParagraph(node);
204
+ if (!isEmpty_0) {
205
+ firstCell.append(...node.getChildren());
206
+ }
207
+ node.remove();
261
208
  }
262
209
  }
263
- if (firstCell !== null) {
264
- if (firstCell.getChildrenSize() === 0) {
265
- firstCell.append($createParagraphNode());
266
- }
267
- $selectLastDescendant(firstCell);
210
+ }
211
+ if (firstCell !== null) {
212
+ if (firstCell.getChildrenSize() === 0) {
213
+ firstCell.append($createParagraphNode());
268
214
  }
269
- onClose();
215
+ $selectLastDescendant(firstCell);
270
216
  }
271
- });
272
- };
273
- $[14] = editor;
274
- $[15] = onClose;
275
- $[16] = t8;
276
- } else {
277
- t8 = $[16];
278
- }
279
- const mergeTableCellsAtSelection = t8;
280
- let t9;
281
- if ($[17] !== editor) {
282
- t9 = () => {
283
- editor.update(() => {
284
- $unmergeCell();
285
- });
286
- };
287
- $[17] = editor;
288
- $[18] = t9;
289
- } else {
290
- t9 = $[18];
291
- }
292
- const unmergeTableCellsAtSelection = t9;
293
- let t10;
294
- if ($[19] !== editor || $[20] !== onClose) {
295
- t10 = shouldInsertAfter => {
296
- editor.update(() => {
297
- $insertTableRow__EXPERIMENTAL(shouldInsertAfter);
298
217
  onClose();
299
- });
300
- };
301
- $[19] = editor;
302
- $[20] = onClose;
303
- $[21] = t10;
304
- } else {
305
- t10 = $[21];
306
- }
307
- const insertTableRowAtSelection = t10;
308
- let t11;
309
- if ($[22] !== editor || $[23] !== selectionCounts.columns || $[24] !== onClose) {
310
- t11 = shouldInsertAfter_0 => {
311
- editor.update(() => {
312
- for (let i_0 = 0; i_0 < selectionCounts.columns; i_0++) {
313
- $insertTableColumn__EXPERIMENTAL(shouldInsertAfter_0);
218
+ }
219
+ });
220
+ };
221
+ const unmergeTableCellsAtSelection = () => {
222
+ editor.update(() => {
223
+ $unmergeCell();
224
+ });
225
+ };
226
+ const insertTableRowAtSelection = useCallback(shouldInsertAfter => {
227
+ editor.update(() => {
228
+ $insertTableRow__EXPERIMENTAL(shouldInsertAfter);
229
+ onClose();
230
+ });
231
+ }, [editor, onClose]);
232
+ const insertTableColumnAtSelection = useCallback(shouldInsertAfter_0 => {
233
+ editor.update(() => {
234
+ for (let i_0 = 0; i_0 < selectionCounts.columns; i_0++) {
235
+ $insertTableColumn__EXPERIMENTAL(shouldInsertAfter_0);
236
+ }
237
+ onClose();
238
+ });
239
+ }, [editor, onClose, selectionCounts.columns]);
240
+ const deleteTableRowAtSelection = useCallback(() => {
241
+ editor.update(() => {
242
+ $deleteTableRow__EXPERIMENTAL();
243
+ onClose();
244
+ });
245
+ }, [editor, onClose]);
246
+ const deleteTableAtSelection = useCallback(() => {
247
+ editor.update(() => {
248
+ const tableNode_0 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
249
+ tableNode_0.remove();
250
+ clearTableSelection();
251
+ onClose();
252
+ });
253
+ }, [editor, tableCellNode, clearTableSelection, onClose]);
254
+ const deleteTableColumnAtSelection = useCallback(() => {
255
+ editor.update(() => {
256
+ $deleteTableColumn__EXPERIMENTAL();
257
+ onClose();
258
+ });
259
+ }, [editor, onClose]);
260
+ const toggleTableRowIsHeader = useCallback(() => {
261
+ editor.update(() => {
262
+ const tableNode_1 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
263
+ const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
264
+ const tableRows = tableNode_1.getChildren();
265
+ if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
266
+ throw new Error('Expected table cell to be inside of table row.');
267
+ }
268
+ const tableRow = tableRows[tableRowIndex];
269
+ if (!$isTableRowNode(tableRow)) {
270
+ throw new Error('Expected table row');
271
+ }
272
+ tableRow.getChildren().forEach(tableCell => {
273
+ if (!$isTableCellNode(tableCell)) {
274
+ throw new Error('Expected table cell');
314
275
  }
315
- onClose();
276
+ tableCell.toggleHeaderStyle(TableCellHeaderStates.ROW);
316
277
  });
317
- };
318
- $[22] = editor;
319
- $[23] = selectionCounts.columns;
320
- $[24] = onClose;
321
- $[25] = t11;
322
- } else {
323
- t11 = $[25];
324
- }
325
- const insertTableColumnAtSelection = t11;
326
- let t12;
327
- if ($[26] !== editor || $[27] !== onClose) {
328
- t12 = () => {
329
- editor.update(() => {
330
- $deleteTableRow__EXPERIMENTAL();
331
- onClose();
332
- });
333
- };
334
- $[26] = editor;
335
- $[27] = onClose;
336
- $[28] = t12;
337
- } else {
338
- t12 = $[28];
339
- }
340
- const deleteTableRowAtSelection = t12;
341
- let t13;
342
- if ($[29] !== editor || $[30] !== tableCellNode || $[31] !== clearTableSelection || $[32] !== onClose) {
343
- t13 = () => {
344
- editor.update(() => {
345
- const tableNode_0 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
346
- tableNode_0.remove();
347
- clearTableSelection();
348
- onClose();
349
- });
350
- };
351
- $[29] = editor;
352
- $[30] = tableCellNode;
353
- $[31] = clearTableSelection;
354
- $[32] = onClose;
355
- $[33] = t13;
356
- } else {
357
- t13 = $[33];
358
- }
359
- const deleteTableAtSelection = t13;
360
- let t14;
361
- if ($[34] !== editor || $[35] !== onClose) {
362
- t14 = () => {
363
- editor.update(() => {
364
- $deleteTableColumn__EXPERIMENTAL();
365
- onClose();
366
- });
367
- };
368
- $[34] = editor;
369
- $[35] = onClose;
370
- $[36] = t14;
371
- } else {
372
- t14 = $[36];
373
- }
374
- const deleteTableColumnAtSelection = t14;
375
- let t15;
376
- if ($[37] !== editor || $[38] !== tableCellNode || $[39] !== clearTableSelection || $[40] !== onClose) {
377
- t15 = () => {
378
- editor.update(() => {
379
- const tableNode_1 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
380
- const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
381
- const tableRows = tableNode_1.getChildren();
382
- if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
383
- throw new Error("Expected table cell to be inside of table row.");
384
- }
385
- const tableRow = tableRows[tableRowIndex];
386
- if (!$isTableRowNode(tableRow)) {
387
- throw new Error("Expected table row");
278
+ clearTableSelection();
279
+ onClose();
280
+ });
281
+ }, [editor, tableCellNode, clearTableSelection, onClose]);
282
+ const toggleTableColumnIsHeader = useCallback(() => {
283
+ editor.update(() => {
284
+ const tableNode_2 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
285
+ const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode);
286
+ const tableRows_0 = tableNode_2.getChildren();
287
+ const maxRowsLength = Math.max(...tableRows_0.map(row => row.getChildren().length));
288
+ if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
289
+ throw new Error('Expected table cell to be inside of table row.');
290
+ }
291
+ for (let r = 0; r < tableRows_0.length; r++) {
292
+ const tableRow_0 = tableRows_0[r];
293
+ if (!$isTableRowNode(tableRow_0)) {
294
+ throw new Error('Expected table row');
388
295
  }
389
- tableRow.getChildren().forEach(tableCell => {
390
- if (!$isTableCellNode(tableCell)) {
391
- throw new Error("Expected table cell");
392
- }
393
- tableCell.toggleHeaderStyle(TableCellHeaderStates.ROW);
394
- });
395
- clearTableSelection();
396
- onClose();
397
- });
398
- };
399
- $[37] = editor;
400
- $[38] = tableCellNode;
401
- $[39] = clearTableSelection;
402
- $[40] = onClose;
403
- $[41] = t15;
404
- } else {
405
- t15 = $[41];
406
- }
407
- const toggleTableRowIsHeader = t15;
408
- let t16;
409
- if ($[42] !== editor || $[43] !== tableCellNode || $[44] !== clearTableSelection || $[45] !== onClose) {
410
- t16 = () => {
411
- editor.update(() => {
412
- const tableNode_2 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
413
- const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode);
414
- const tableRows_0 = tableNode_2.getChildren();
415
- const maxRowsLength = Math.max(...tableRows_0.map(row => row.getChildren().length));
416
- if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
417
- throw new Error("Expected table cell to be inside of table row.");
296
+ const tableCells = tableRow_0.getChildren();
297
+ if (tableColumnIndex >= tableCells.length) {
298
+ continue;
418
299
  }
419
- for (let r = 0; r < tableRows_0.length; r++) {
420
- const tableRow_0 = tableRows_0[r];
421
- if (!$isTableRowNode(tableRow_0)) {
422
- throw new Error("Expected table row");
423
- }
424
- const tableCells = tableRow_0.getChildren();
425
- if (tableColumnIndex >= tableCells.length) {
426
- continue;
427
- }
428
- const tableCell_0 = tableCells[tableColumnIndex];
429
- if (!$isTableCellNode(tableCell_0)) {
430
- throw new Error("Expected table cell");
431
- }
432
- tableCell_0.toggleHeaderStyle(TableCellHeaderStates.COLUMN);
300
+ const tableCell_0 = tableCells[tableColumnIndex];
301
+ if (!$isTableCellNode(tableCell_0)) {
302
+ throw new Error('Expected table cell');
433
303
  }
434
- clearTableSelection();
435
- onClose();
436
- });
437
- };
438
- $[42] = editor;
439
- $[43] = tableCellNode;
440
- $[44] = clearTableSelection;
441
- $[45] = onClose;
442
- $[46] = t16;
443
- } else {
444
- t16 = $[46];
445
- }
446
- const toggleTableColumnIsHeader = t16;
304
+ tableCell_0.toggleHeaderStyle(TableCellHeaderStates.COLUMN);
305
+ }
306
+ clearTableSelection();
307
+ onClose();
308
+ });
309
+ }, [editor, tableCellNode, clearTableSelection, onClose]);
447
310
  let mergeCellButton = null;
448
311
  if (cellMerge) {
449
312
  if (canMergeCells) {
450
- let t17;
451
- if ($[47] !== mergeTableCellsAtSelection) {
452
- t17 = () => mergeTableCellsAtSelection();
453
- $[47] = mergeTableCellsAtSelection;
454
- $[48] = t17;
455
- } else {
456
- t17 = $[48];
457
- }
458
- mergeCellButton = _jsx("button", {
313
+ mergeCellButton = /*#__PURE__*/_jsx("button", {
459
314
  className: "item",
460
315
  "data-test-id": "table-merge-cells",
461
- onClick: t17,
316
+ onClick: () => mergeTableCellsAtSelection(),
462
317
  type: "button",
463
318
  children: "Merge cells"
464
319
  });
465
- } else {
466
- if (canUnmergeCell) {
467
- let t17;
468
- if ($[49] !== unmergeTableCellsAtSelection) {
469
- t17 = () => unmergeTableCellsAtSelection();
470
- $[49] = unmergeTableCellsAtSelection;
471
- $[50] = t17;
472
- } else {
473
- t17 = $[50];
474
- }
475
- mergeCellButton = _jsx("button", {
476
- className: "item",
477
- "data-test-id": "table-unmerge-cells",
478
- onClick: t17,
479
- type: "button",
480
- children: "Unmerge cells"
481
- });
482
- }
320
+ } else if (canUnmergeCell) {
321
+ mergeCellButton = /*#__PURE__*/_jsx("button", {
322
+ className: "item",
323
+ "data-test-id": "table-unmerge-cells",
324
+ onClick: () => unmergeTableCellsAtSelection(),
325
+ type: "button",
326
+ children: "Unmerge cells"
327
+ });
483
328
  }
484
329
  }
485
- let t17;
486
- if ($[51] !== insertTableRowAtSelection) {
487
- t17 = () => insertTableRowAtSelection(false);
488
- $[51] = insertTableRowAtSelection;
489
- $[52] = t17;
490
- } else {
491
- t17 = $[52];
492
- }
493
- let t18;
494
- if ($[53] !== insertTableRowAtSelection) {
495
- t18 = () => insertTableRowAtSelection(true);
496
- $[53] = insertTableRowAtSelection;
497
- $[54] = t18;
498
- } else {
499
- t18 = $[54];
500
- }
501
- let t19;
502
- if ($[55] !== insertTableColumnAtSelection) {
503
- t19 = () => insertTableColumnAtSelection(false);
504
- $[55] = insertTableColumnAtSelection;
505
- $[56] = t19;
506
- } else {
507
- t19 = $[56];
508
- }
509
- let t20;
510
- if ($[57] !== insertTableColumnAtSelection) {
511
- t20 = () => insertTableColumnAtSelection(true);
512
- $[57] = insertTableColumnAtSelection;
513
- $[58] = t20;
514
- } else {
515
- t20 = $[58];
516
- }
517
- let t21;
518
- if ($[59] !== deleteTableColumnAtSelection) {
519
- t21 = () => deleteTableColumnAtSelection();
520
- $[59] = deleteTableColumnAtSelection;
521
- $[60] = t21;
522
- } else {
523
- t21 = $[60];
524
- }
525
- let t22;
526
- if ($[61] !== deleteTableRowAtSelection) {
527
- t22 = () => deleteTableRowAtSelection();
528
- $[61] = deleteTableRowAtSelection;
529
- $[62] = t22;
530
- } else {
531
- t22 = $[62];
532
- }
533
- let t23;
534
- if ($[63] !== deleteTableAtSelection) {
535
- t23 = () => deleteTableAtSelection();
536
- $[63] = deleteTableAtSelection;
537
- $[64] = t23;
538
- } else {
539
- t23 = $[64];
540
- }
541
- let t24;
542
- if ($[65] !== toggleTableRowIsHeader) {
543
- t24 = () => toggleTableRowIsHeader();
544
- $[65] = toggleTableRowIsHeader;
545
- $[66] = t24;
546
- } else {
547
- t24 = $[66];
548
- }
549
- let t25;
550
- if ($[67] !== toggleTableColumnIsHeader) {
551
- t25 = () => toggleTableColumnIsHeader();
552
- $[67] = toggleTableColumnIsHeader;
553
- $[68] = t25;
554
- } else {
555
- t25 = $[68];
556
- }
557
- return createPortal(_jsxs("div", {
330
+ return /*#__PURE__*/createPortal(
331
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events
332
+ /*#__PURE__*/
333
+ _jsxs("div", {
558
334
  className: "table-action-menu-dropdown",
559
- onClick: _temp,
335
+ onClick: e => {
336
+ e.stopPropagation();
337
+ },
560
338
  ref: dropDownRef,
561
- children: [mergeCellButton ? _jsxs(React.Fragment, {
562
- children: [mergeCellButton, _jsx("hr", {})]
563
- }) : null, _jsx("button", {
339
+ children: [mergeCellButton ? /*#__PURE__*/_jsxs(React.Fragment, {
340
+ children: [mergeCellButton, /*#__PURE__*/_jsx("hr", {})]
341
+ }) : null, /*#__PURE__*/_jsx("button", {
564
342
  className: "item",
565
343
  "data-test-id": "table-insert-row-above",
566
- onClick: t17,
344
+ onClick: () => insertTableRowAtSelection(false),
567
345
  type: "button",
568
- children: _jsxs("span", {
346
+ children: /*#__PURE__*/_jsxs("span", {
569
347
  className: "text",
570
- children: ["Insert ", selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`, " above"]
348
+ children: ["Insert ", selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`, " above"]
571
349
  })
572
- }), _jsx("button", {
350
+ }), /*#__PURE__*/_jsx("button", {
573
351
  className: "item",
574
352
  "data-test-id": "table-insert-row-below",
575
- onClick: t18,
353
+ onClick: () => insertTableRowAtSelection(true),
576
354
  type: "button",
577
- children: _jsxs("span", {
355
+ children: /*#__PURE__*/_jsxs("span", {
578
356
  className: "text",
579
- children: ["Insert ", selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`, " below"]
357
+ children: ["Insert ", selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`, " below"]
580
358
  })
581
- }), _jsx("hr", {}), _jsx("button", {
359
+ }), /*#__PURE__*/_jsx("hr", {}), /*#__PURE__*/_jsx("button", {
582
360
  className: "item",
583
361
  "data-test-id": "table-insert-column-before",
584
- onClick: t19,
362
+ onClick: () => insertTableColumnAtSelection(false),
585
363
  type: "button",
586
- children: _jsxs("span", {
364
+ children: /*#__PURE__*/_jsxs("span", {
587
365
  className: "text",
588
- children: ["Insert ", selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`, " ", "left"]
366
+ children: ["Insert ", selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`, ' ', "left"]
589
367
  })
590
- }), _jsx("button", {
368
+ }), /*#__PURE__*/_jsx("button", {
591
369
  className: "item",
592
370
  "data-test-id": "table-insert-column-after",
593
- onClick: t20,
371
+ onClick: () => insertTableColumnAtSelection(true),
594
372
  type: "button",
595
- children: _jsxs("span", {
373
+ children: /*#__PURE__*/_jsxs("span", {
596
374
  className: "text",
597
- children: ["Insert ", selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`, " ", "right"]
375
+ children: ["Insert ", selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`, ' ', "right"]
598
376
  })
599
- }), _jsx("hr", {}), _jsx("button", {
377
+ }), /*#__PURE__*/_jsx("hr", {}), /*#__PURE__*/_jsx("button", {
600
378
  className: "item",
601
379
  "data-test-id": "table-delete-columns",
602
- onClick: t21,
380
+ onClick: () => deleteTableColumnAtSelection(),
603
381
  type: "button",
604
- children: _jsx("span", {
382
+ children: /*#__PURE__*/_jsx("span", {
605
383
  className: "text",
606
384
  children: "Delete column"
607
385
  })
608
- }), _jsx("button", {
386
+ }), /*#__PURE__*/_jsx("button", {
609
387
  className: "item",
610
388
  "data-test-id": "table-delete-rows",
611
- onClick: t22,
389
+ onClick: () => deleteTableRowAtSelection(),
612
390
  type: "button",
613
- children: _jsx("span", {
391
+ children: /*#__PURE__*/_jsx("span", {
614
392
  className: "text",
615
393
  children: "Delete row"
616
394
  })
617
- }), _jsx("button", {
395
+ }), /*#__PURE__*/_jsx("button", {
618
396
  className: "item",
619
397
  "data-test-id": "table-delete",
620
- onClick: t23,
398
+ onClick: () => deleteTableAtSelection(),
621
399
  type: "button",
622
- children: _jsx("span", {
400
+ children: /*#__PURE__*/_jsx("span", {
623
401
  className: "text",
624
402
  children: "Delete table"
625
403
  })
626
- }), _jsx("hr", {}), _jsx("button", {
404
+ }), /*#__PURE__*/_jsx("hr", {}), /*#__PURE__*/_jsx("button", {
627
405
  className: "item",
628
- onClick: t24,
406
+ onClick: () => toggleTableRowIsHeader(),
629
407
  type: "button",
630
- children: _jsxs("span", {
408
+ children: /*#__PURE__*/_jsxs("span", {
631
409
  className: "text",
632
- children: [(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? "Remove" : "Add", " ", "row header"]
410
+ children: [(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? 'Remove' : 'Add', ' ', "row header"]
633
411
  })
634
- }), _jsx("button", {
412
+ }), /*#__PURE__*/_jsx("button", {
635
413
  className: "item",
636
414
  "data-test-id": "table-column-header",
637
- onClick: t25,
415
+ onClick: () => toggleTableColumnIsHeader(),
638
416
  type: "button",
639
- children: _jsxs("span", {
417
+ children: /*#__PURE__*/_jsxs("span", {
640
418
  className: "text",
641
- children: [(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN ? "Remove" : "Add", " ", "column header"]
419
+ children: [(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN ? 'Remove' : 'Add', ' ', "column header"]
642
420
  })
643
421
  })]
644
422
  }), document.body);
645
423
  }
646
- function _temp(e) {
647
- e.stopPropagation();
648
- }
649
424
  function TableCellActionMenuContainer({
650
425
  anchorElem,
651
426
  cellMerge
@@ -736,24 +511,13 @@ function TableCellActionMenuContainer({
736
511
  })
737
512
  });
738
513
  }
739
- export const TableActionMenuPlugin = t0 => {
740
- const $ = _c(3);
741
- const {
742
- anchorElem
743
- } = t0;
514
+ export const TableActionMenuPlugin = ({
515
+ anchorElem
516
+ }) => {
744
517
  const isEditable = useLexicalEditable();
745
- let t1;
746
- if ($[0] !== isEditable || $[1] !== anchorElem) {
747
- t1 = createPortal(isEditable ? _jsx(TableCellActionMenuContainer, {
748
- anchorElem: anchorElem ?? document.body,
749
- cellMerge: true
750
- }) : null, anchorElem ?? document.body);
751
- $[0] = isEditable;
752
- $[1] = anchorElem;
753
- $[2] = t1;
754
- } else {
755
- t1 = $[2];
756
- }
757
- return t1;
518
+ return /*#__PURE__*/createPortal(isEditable ? /*#__PURE__*/_jsx(TableCellActionMenuContainer, {
519
+ anchorElem: anchorElem ?? document.body,
520
+ cellMerge: true
521
+ }) : null, anchorElem ?? document.body);
758
522
  };
759
523
  //# sourceMappingURL=index.js.map