@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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableRow.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/cjs/plugins/table/transforms/column-width.js +10 -43
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableRow.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/table/transforms/column-width.js +10 -43
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableRow.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/table/transforms/column-width.js +10 -43
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
- package/package.json +3 -6
- package/src/__tests__/unit/analytics.ts +2 -1
- package/src/__tests__/unit/collab.ts +2 -1
- package/src/__tests__/unit/commands/go-to-next-cell.ts +1 -0
- package/src/__tests__/unit/commands/insert.ts +1 -0
- package/src/__tests__/unit/commands/misc.ts +1 -0
- package/src/__tests__/unit/commands/sort.ts +2 -1
- package/src/__tests__/unit/commands.ts +1 -0
- package/src/__tests__/unit/copy-paste.ts +2 -1
- package/src/__tests__/unit/event-handlers/index.ts +2 -1
- package/src/__tests__/unit/event-handlers.ts +2 -1
- package/src/__tests__/unit/fix-tables.ts +2 -1
- package/src/__tests__/unit/get-toolbar-config.ts +1 -0
- package/src/__tests__/unit/handlers.ts +2 -1
- package/src/__tests__/unit/hover-selection.ts +2 -1
- package/src/__tests__/unit/index.ts +2 -1
- package/src/__tests__/unit/layout.ts +2 -1
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +1 -1
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +1 -1
- package/src/__tests__/unit/nodeviews/cell.ts +2 -1
- package/src/__tests__/unit/nodeviews/table.ts +1 -0
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +1 -0
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +1 -0
- package/src/__tests__/unit/pm-plugins/main.ts +1 -0
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -1
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +1 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +1 -0
- package/src/__tests__/unit/pm-plugins/table-width.ts +2 -1
- package/src/__tests__/unit/sort-column.ts +2 -1
- package/src/__tests__/unit/toolbar.ts +1 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +2 -1
- package/src/__tests__/unit/transforms/delete-rows.ts +2 -1
- package/src/__tests__/unit/transforms/merging.ts +2 -1
- package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -1
- package/src/__tests__/unit/ui/CornerControls.tsx +2 -1
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -1
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -1
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +1 -1
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +2 -1
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +1 -1
- package/src/__tests__/unit/ui/NumberColumn.tsx +2 -1
- package/src/__tests__/unit/ui/RowControls.tsx +2 -1
- package/src/__tests__/unit/ui/RowDragControls.tsx +2 -1
- package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +2 -1
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -1
- package/src/__tests__/unit/undo-redo.ts +1 -0
- package/src/__tests__/unit/utils/collapse.ts +1 -0
- package/src/__tests__/unit/utils/nodes.ts +2 -1
- package/src/__tests__/unit/utils/row-controls.ts +2 -1
- package/src/__tests__/unit/utils.ts +1 -0
- package/src/plugins/table/nodeviews/TableRow.ts +1 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +1 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/utils/monitor.ts +1 -1
- package/src/plugins/table/pm-plugins/keymap.ts +4 -4
- package/src/plugins/table/transforms/column-width.ts +14 -60
- 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
|
-
|
|
82
|
-
|
|
83
|
-
for (let
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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;
|
package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx
CHANGED
|
@@ -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
|
|