@atlaskit/editor-plugin-table 5.3.23 → 5.3.25

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 (72) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/nodeviews/TableRow.js +1 -1
  3. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -1
  4. package/dist/cjs/plugins/table/pm-plugins/keymap.js +1 -1
  5. package/dist/cjs/plugins/table/transforms/column-width.js +10 -43
  6. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
  7. package/dist/es2019/plugins/table/nodeviews/TableRow.js +1 -1
  8. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -1
  9. package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
  10. package/dist/es2019/plugins/table/transforms/column-width.js +10 -43
  11. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
  12. package/dist/esm/plugins/table/nodeviews/TableRow.js +1 -1
  13. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -1
  14. package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
  15. package/dist/esm/plugins/table/transforms/column-width.js +10 -43
  16. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
  17. package/package.json +3 -6
  18. package/src/__tests__/unit/analytics.ts +2 -1
  19. package/src/__tests__/unit/collab.ts +2 -1
  20. package/src/__tests__/unit/commands/go-to-next-cell.ts +1 -0
  21. package/src/__tests__/unit/commands/insert.ts +1 -0
  22. package/src/__tests__/unit/commands/misc.ts +1 -0
  23. package/src/__tests__/unit/commands/sort.ts +2 -1
  24. package/src/__tests__/unit/commands.ts +1 -0
  25. package/src/__tests__/unit/copy-paste.ts +2 -1
  26. package/src/__tests__/unit/event-handlers/index.ts +2 -1
  27. package/src/__tests__/unit/event-handlers.ts +2 -1
  28. package/src/__tests__/unit/fix-tables.ts +2 -1
  29. package/src/__tests__/unit/get-toolbar-config.ts +1 -0
  30. package/src/__tests__/unit/handlers.ts +2 -1
  31. package/src/__tests__/unit/hover-selection.ts +2 -1
  32. package/src/__tests__/unit/index.ts +2 -1
  33. package/src/__tests__/unit/layout.ts +2 -1
  34. package/src/__tests__/unit/nodeviews/TableComponent.tsx +1 -1
  35. package/src/__tests__/unit/nodeviews/TableContainer.tsx +1 -1
  36. package/src/__tests__/unit/nodeviews/cell.ts +2 -1
  37. package/src/__tests__/unit/nodeviews/table.ts +1 -0
  38. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +1 -0
  39. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +1 -0
  40. package/src/__tests__/unit/pm-plugins/main.ts +1 -0
  41. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -1
  42. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +1 -0
  43. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +1 -0
  44. package/src/__tests__/unit/pm-plugins/table-width.ts +2 -1
  45. package/src/__tests__/unit/sort-column.ts +2 -1
  46. package/src/__tests__/unit/toolbar.ts +1 -0
  47. package/src/__tests__/unit/transforms/delete-columns.ts +2 -1
  48. package/src/__tests__/unit/transforms/delete-rows.ts +2 -1
  49. package/src/__tests__/unit/transforms/merging.ts +2 -1
  50. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -1
  51. package/src/__tests__/unit/ui/CornerControls.tsx +2 -1
  52. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -1
  53. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -1
  54. package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +1 -1
  55. package/src/__tests__/unit/ui/FloatingDragMenu.tsx +2 -1
  56. package/src/__tests__/unit/ui/FloatingInsertButton.tsx +1 -1
  57. package/src/__tests__/unit/ui/NumberColumn.tsx +2 -1
  58. package/src/__tests__/unit/ui/RowControls.tsx +2 -1
  59. package/src/__tests__/unit/ui/RowDragControls.tsx +2 -1
  60. package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +2 -1
  61. package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -1
  62. package/src/__tests__/unit/undo-redo.ts +1 -0
  63. package/src/__tests__/unit/utils/collapse.ts +1 -0
  64. package/src/__tests__/unit/utils/nodes.ts +2 -1
  65. package/src/__tests__/unit/utils/row-controls.ts +2 -1
  66. package/src/__tests__/unit/utils.ts +1 -0
  67. package/src/plugins/table/nodeviews/TableRow.ts +1 -1
  68. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +1 -1
  69. package/src/plugins/table/pm-plugins/drag-and-drop/utils/monitor.ts +1 -1
  70. package/src/plugins/table/pm-plugins/keymap.ts +4 -4
  71. package/src/plugins/table/transforms/column-width.ts +14 -60
  72. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +1 -1
@@ -1,6 +1,6 @@
1
+ import type { ElementEventBasePayload } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
1
2
  import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
2
3
  import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
3
- import type { ElementEventBasePayload } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
4
4
 
5
5
  import type {
6
6
  DraggableData,
@@ -28,15 +28,15 @@ import {
28
28
  moveCursorBackward,
29
29
  triggerUnlessTableHeader,
30
30
  } from '../commands';
31
+ import {
32
+ addColumnAfter as addColumnAfterCommand,
33
+ addColumnBefore as addColumnBeforeCommand,
34
+ } from '../commands/insert';
31
35
  import {
32
36
  addRowAroundSelection,
33
37
  deleteTableIfSelectedWithAnalytics,
34
38
  emptyMultipleCellsWithAnalytics,
35
39
  } from '../commands-with-analytics';
36
- import {
37
- addColumnAfter as addColumnAfterCommand,
38
- addColumnBefore as addColumnBeforeCommand,
39
- } from '../commands/insert';
40
40
  import { withEditorAnalyticsAPI } from '../utils/analytics';
41
41
 
42
42
  const createTableWithAnalytics = (
@@ -78,71 +78,25 @@ export const updateColumnWidths =
78
78
  }
79
79
 
80
80
  // updating all cells with new attributes
81
- if (getBooleanFF('platform.editor.update-table-cell-width-via-step')) {
82
- const seen: { [key: number]: boolean } = {};
83
- for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
84
- for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
85
- const mapIndex = rowIndex * map.width + columnIndex;
86
- const pos = map.map[mapIndex];
87
- const cell = table.nodeAt(pos);
88
- if (!seen[pos] && cell) {
89
- if (updatedCellsAttrs[pos]) {
90
- tr.step(
91
- new AttrStep(
92
- pos + start,
93
- 'colwidth',
94
- updatedCellsAttrs[pos].colwidth,
95
- ),
96
- );
97
- }
98
- seen[pos] = true;
99
- }
100
- }
101
- }
102
- } else {
103
- const rows: PMNode[] = [];
104
- const seen: { [key: number]: boolean } = {};
105
- for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
106
- const row = table.child(rowIndex);
107
- const cells: PMNode[] = [];
108
-
109
- for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
110
- const mapIndex = rowIndex * map.width + columnIndex;
111
- const pos = map.map[mapIndex];
112
- const cell = table.nodeAt(pos);
113
- if (!seen[pos] && cell) {
114
- cells.push(
115
- cell.type.createChecked(
116
- updatedCellsAttrs[pos] || cell.attrs,
117
- cell.content,
118
- cell.marks,
81
+ const seen: { [key: number]: boolean } = {};
82
+ for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
83
+ for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
84
+ const mapIndex = rowIndex * map.width + columnIndex;
85
+ const pos = map.map[mapIndex];
86
+ const cell = table.nodeAt(pos);
87
+ if (!seen[pos] && cell) {
88
+ if (updatedCellsAttrs[pos]) {
89
+ tr.step(
90
+ new AttrStep(
91
+ pos + start,
92
+ 'colwidth',
93
+ updatedCellsAttrs[pos].colwidth,
119
94
  ),
120
95
  );
121
- seen[pos] = true;
122
96
  }
97
+ seen[pos] = true;
123
98
  }
124
- rows.push(row.type.createChecked(row.attrs, cells, row.marks));
125
99
  }
126
-
127
- const tablePos = start - 1;
128
- const selectionBookmark = tr.selection.getBookmark();
129
-
130
- tr.replaceWith(
131
- tablePos,
132
- tablePos + table.nodeSize,
133
- table.type.createChecked(table.attrs, rows, table.marks),
134
- );
135
- /**
136
- * We want to restore to the original selection but w/o applying the mapping. Function
137
- * tr.replaceWith puts the selection after the inserted content. We need to manually
138
- * set the selection back to original state. Mapping in this case doesn't quite work
139
- * e.g. if we change the content before a selection. This is because mapping
140
- * means moving it if the content in front of it changed. Instead we can get
141
- * bookmark of selection.
142
- *
143
- * @see https://github.com/ProseMirror/prosemirror/issues/645
144
- */
145
- tr.setSelection(selectionBookmark.resolve(tr.doc));
146
100
  }
147
101
 
148
102
  return tr;
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useRef } from 'react';
2
2
 
3
- import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
4
3
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
4
+ import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
5
5
 
6
6
  import type { DraggableSourceData } from '../../../types';
7
7