@atlaskit/editor-plugin-table 9.1.3 → 9.2.1
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 +23 -0
- package/dist/cjs/nodeviews/TableCell.js +0 -2
- package/dist/cjs/nodeviews/TableComponent.js +5 -5
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +6 -4
- package/dist/cjs/nodeviews/TableContainer.js +13 -2
- package/dist/cjs/nodeviews/TableNodeViewBase.js +0 -2
- package/dist/cjs/nodeviews/TableResizer.js +5 -10
- package/dist/cjs/nodeviews/TableRow.js +0 -2
- package/dist/cjs/nodeviews/lazy-node-views.js +4 -16
- package/dist/cjs/nodeviews/table.js +3 -10
- package/dist/cjs/pm-plugins/commands/column-resize.js +1 -4
- package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +4 -16
- package/dist/cjs/pm-plugins/commands/insert.js +4 -19
- package/dist/cjs/pm-plugins/commands/misc.js +3 -12
- package/dist/cjs/pm-plugins/decorations/plugin.js +1 -6
- package/dist/cjs/pm-plugins/decorations/utils/column-resizing.js +1 -4
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -12
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/cjs/pm-plugins/keymap.js +0 -2
- package/dist/cjs/pm-plugins/main.js +1 -6
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +1 -4
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +0 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +1 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/column-state.js +1 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/content-width.js +0 -8
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +1 -4
- package/dist/cjs/pm-plugins/table-width.js +1 -6
- package/dist/cjs/pm-plugins/transforms/column-width.js +1 -4
- package/dist/cjs/pm-plugins/transforms/fix-tables.js +3 -15
- package/dist/cjs/pm-plugins/transforms/replace-table.js +1 -4
- package/dist/cjs/pm-plugins/transforms/split.js +0 -2
- package/dist/cjs/pm-plugins/utils/alignment.js +1 -4
- package/dist/cjs/pm-plugins/utils/decoration.js +4 -16
- package/dist/cjs/pm-plugins/utils/drag-menu.js +1 -4
- package/dist/cjs/pm-plugins/utils/nodes.js +0 -3
- package/dist/cjs/pm-plugins/utils/paste.js +4 -0
- package/dist/cjs/pm-plugins/utils/row-controls.js +1 -4
- package/dist/cjs/tablePlugin.js +1 -0
- package/dist/cjs/ui/DragHandle/index.js +55 -6
- package/dist/cjs/ui/FloatingInsertButton/getPopupOptions.js +0 -6
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -6
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +61 -11
- package/dist/cjs/ui/TableFloatingControls/index.js +25 -8
- package/dist/cjs/ui/toolbar.js +3 -12
- package/dist/es2019/nodeviews/TableCell.js +0 -2
- package/dist/es2019/nodeviews/TableComponent.js +5 -5
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +6 -4
- package/dist/es2019/nodeviews/TableContainer.js +13 -2
- package/dist/es2019/nodeviews/TableNodeViewBase.js +0 -2
- package/dist/es2019/nodeviews/TableResizer.js +5 -10
- package/dist/es2019/nodeviews/TableRow.js +0 -2
- package/dist/es2019/nodeviews/lazy-node-views.js +4 -16
- package/dist/es2019/nodeviews/table.js +3 -10
- package/dist/es2019/pm-plugins/commands/column-resize.js +1 -4
- package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +6 -24
- package/dist/es2019/pm-plugins/commands/delete.js +1 -4
- package/dist/es2019/pm-plugins/commands/insert.js +5 -23
- package/dist/es2019/pm-plugins/commands/misc.js +3 -12
- package/dist/es2019/pm-plugins/decorations/plugin.js +1 -6
- package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +1 -4
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +4 -16
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -8
- package/dist/es2019/pm-plugins/keymap.js +0 -3
- package/dist/es2019/pm-plugins/main.js +1 -6
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +0 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -11
- package/dist/es2019/pm-plugins/table-resizing/utils/column-state.js +1 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/content-width.js +0 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +1 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +2 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -16
- package/dist/es2019/pm-plugins/table-width.js +1 -6
- package/dist/es2019/pm-plugins/transforms/column-width.js +2 -8
- package/dist/es2019/pm-plugins/transforms/delete-columns.js +1 -4
- package/dist/es2019/pm-plugins/transforms/fix-tables.js +3 -15
- package/dist/es2019/pm-plugins/transforms/replace-table.js +1 -4
- package/dist/es2019/pm-plugins/transforms/split.js +0 -2
- package/dist/es2019/pm-plugins/utils/alignment.js +1 -4
- package/dist/es2019/pm-plugins/utils/decoration.js +4 -16
- package/dist/es2019/pm-plugins/utils/drag-menu.js +2 -8
- package/dist/es2019/pm-plugins/utils/nodes.js +0 -3
- package/dist/es2019/pm-plugins/utils/paste.js +5 -4
- package/dist/es2019/pm-plugins/utils/row-controls.js +1 -4
- package/dist/es2019/pm-plugins/utils/snapping.js +1 -4
- package/dist/es2019/tablePlugin.js +1 -0
- package/dist/es2019/ui/DragHandle/index.js +57 -6
- package/dist/es2019/ui/FloatingInsertButton/getPopupOptions.js +0 -6
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +19 -7
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +63 -11
- package/dist/es2019/ui/TableFloatingControls/index.js +26 -10
- package/dist/es2019/ui/event-handlers.js +1 -4
- package/dist/es2019/ui/toolbar.js +9 -36
- package/dist/esm/nodeviews/TableCell.js +0 -2
- package/dist/esm/nodeviews/TableComponent.js +5 -5
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +6 -4
- package/dist/esm/nodeviews/TableContainer.js +13 -2
- package/dist/esm/nodeviews/TableNodeViewBase.js +0 -2
- package/dist/esm/nodeviews/TableResizer.js +5 -10
- package/dist/esm/nodeviews/TableRow.js +0 -2
- package/dist/esm/nodeviews/lazy-node-views.js +4 -16
- package/dist/esm/nodeviews/table.js +3 -10
- package/dist/esm/pm-plugins/commands/column-resize.js +1 -4
- package/dist/esm/pm-plugins/commands/commands-with-analytics.js +4 -16
- package/dist/esm/pm-plugins/commands/insert.js +4 -19
- package/dist/esm/pm-plugins/commands/misc.js +3 -12
- package/dist/esm/pm-plugins/decorations/plugin.js +1 -6
- package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +1 -4
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -12
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/esm/pm-plugins/keymap.js +0 -3
- package/dist/esm/pm-plugins/main.js +1 -6
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +0 -3
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +1 -7
- package/dist/esm/pm-plugins/table-resizing/utils/column-state.js +1 -4
- package/dist/esm/pm-plugins/table-resizing/utils/content-width.js +0 -8
- package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +1 -4
- package/dist/esm/pm-plugins/table-width.js +1 -6
- package/dist/esm/pm-plugins/transforms/column-width.js +1 -4
- package/dist/esm/pm-plugins/transforms/fix-tables.js +3 -15
- package/dist/esm/pm-plugins/transforms/replace-table.js +1 -4
- package/dist/esm/pm-plugins/transforms/split.js +0 -2
- package/dist/esm/pm-plugins/utils/alignment.js +1 -4
- package/dist/esm/pm-plugins/utils/decoration.js +4 -16
- package/dist/esm/pm-plugins/utils/drag-menu.js +1 -4
- package/dist/esm/pm-plugins/utils/nodes.js +0 -3
- package/dist/esm/pm-plugins/utils/paste.js +4 -0
- package/dist/esm/pm-plugins/utils/row-controls.js +1 -4
- package/dist/esm/tablePlugin.js +1 -0
- package/dist/esm/ui/DragHandle/index.js +54 -5
- package/dist/esm/ui/FloatingInsertButton/getPopupOptions.js +0 -6
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +19 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +61 -11
- package/dist/esm/ui/TableFloatingControls/index.js +26 -9
- package/dist/esm/ui/toolbar.js +3 -12
- package/dist/types/nodeviews/TableComponent.d.ts +3 -1
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/DragHandle/index.d.ts +21 -0
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +21 -0
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
- package/package.json +15 -6
- package/src/nodeviews/TableCell.ts +0 -2
- package/src/nodeviews/TableComponent.tsx +8 -6
- package/src/nodeviews/TableComponentWithSharedState.tsx +4 -2
- package/src/nodeviews/TableContainer.tsx +12 -1
- package/src/nodeviews/TableNodeViewBase.ts +0 -2
- package/src/nodeviews/TableResizer.tsx +9 -5
- package/src/nodeviews/TableRow.ts +0 -2
- package/src/nodeviews/lazy-node-views.ts +0 -8
- package/src/nodeviews/table.tsx +1 -6
- package/src/pm-plugins/commands/column-resize.ts +0 -2
- package/src/pm-plugins/commands/commands-with-analytics.ts +0 -12
- package/src/pm-plugins/commands/delete.ts +0 -2
- package/src/pm-plugins/commands/insert.ts +0 -12
- package/src/pm-plugins/commands/misc.ts +0 -6
- package/src/pm-plugins/decorations/plugin.ts +0 -4
- package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -2
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -6
- package/src/pm-plugins/drag-and-drop/commands.ts +0 -8
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -4
- package/src/pm-plugins/keymap.ts +0 -2
- package/src/pm-plugins/main.ts +0 -4
- package/src/pm-plugins/table-resizing/event-handlers.ts +0 -2
- package/src/pm-plugins/table-resizing/plugin.ts +0 -2
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -6
- package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -2
- package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -6
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -2
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -6
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -4
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -8
- package/src/pm-plugins/table-width.ts +0 -4
- package/src/pm-plugins/transforms/column-width.ts +0 -4
- package/src/pm-plugins/transforms/delete-columns.ts +0 -2
- package/src/pm-plugins/transforms/fix-tables.ts +0 -8
- package/src/pm-plugins/transforms/replace-table.ts +0 -2
- package/src/pm-plugins/transforms/split.ts +0 -2
- package/src/pm-plugins/utils/alignment.ts +0 -2
- package/src/pm-plugins/utils/decoration.ts +0 -8
- package/src/pm-plugins/utils/drag-menu.ts +0 -4
- package/src/pm-plugins/utils/nodes.ts +0 -2
- package/src/pm-plugins/utils/paste.ts +4 -2
- package/src/pm-plugins/utils/row-controls.ts +0 -2
- package/src/pm-plugins/utils/snapping.ts +0 -2
- package/src/tablePlugin.tsx +1 -0
- package/src/types/index.ts +1 -0
- package/src/ui/DragHandle/index.tsx +67 -2
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -4
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +37 -20
- package/src/ui/TableFloatingColumnControls/index.tsx +1 -4
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +86 -27
- package/src/ui/TableFloatingControls/index.tsx +55 -32
- package/src/ui/event-handlers.ts +0 -2
- package/src/ui/toolbar.tsx +0 -18
|
@@ -42,8 +42,6 @@ const scale = (
|
|
|
42
42
|
isTableScalingEnabledOnCurrentTable = false,
|
|
43
43
|
shouldUseIncreasedScalingPercent = false,
|
|
44
44
|
isCommentEditor = false,
|
|
45
|
-
// Ignored via go/ees005
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
47
45
|
): ResizeState | undefined => {
|
|
48
46
|
const {
|
|
49
47
|
node,
|
|
@@ -109,8 +107,6 @@ const scaleWithParent = (
|
|
|
109
107
|
isTableScalingEnabledOnCurrentTable = false,
|
|
110
108
|
shouldUseIncreasedScalingPercent = false,
|
|
111
109
|
isCommentEditor = false,
|
|
112
|
-
// Ignored via go/ees005
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
114
110
|
) => {
|
|
115
111
|
const resizeState = getResizeState({
|
|
116
112
|
minWidth: tableCellMinWidth,
|
|
@@ -163,8 +159,6 @@ export const previewScaleTable = (
|
|
|
163
159
|
isTableScalingEnabled: boolean = false,
|
|
164
160
|
isTableWithFixedColumnWidthsOptionEnabled: boolean = false,
|
|
165
161
|
isCommentEditor: boolean = false,
|
|
166
|
-
// Ignored via go/ees005
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
168
162
|
) => {
|
|
169
163
|
const { node, start, parentWidth } = options;
|
|
170
164
|
|
|
@@ -225,8 +219,6 @@ export const scaleTable =
|
|
|
225
219
|
isTableScalingEnabledOnCurrentTable = false,
|
|
226
220
|
shouldUseIncreasedScalingPercent = false,
|
|
227
221
|
isCommentEditor = false,
|
|
228
|
-
// Ignored via go/ees005
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
230
222
|
) =>
|
|
231
223
|
(tr: Transaction) => {
|
|
232
224
|
if (!tableRef) {
|
|
@@ -40,8 +40,6 @@ const createPlugin = (
|
|
|
40
40
|
isTableScalingEnabled: boolean,
|
|
41
41
|
isTableAlignmentEnabled: boolean,
|
|
42
42
|
isCommentEditor: boolean,
|
|
43
|
-
// Ignored via go/ees005
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
45
43
|
) => {
|
|
46
44
|
return new SafePlugin({
|
|
47
45
|
key: pluginKey,
|
|
@@ -159,8 +157,6 @@ const createPlugin = (
|
|
|
159
157
|
|
|
160
158
|
if (referentialityTr) {
|
|
161
159
|
referentialityTr.steps.forEach((step) => {
|
|
162
|
-
// Ignored via go/ees005
|
|
163
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
164
160
|
step.getMap().forEach((_, __, newStart, newEnd) => {
|
|
165
161
|
newState.doc.nodesBetween(newStart, newEnd, (node, pos) => {
|
|
166
162
|
if (node.type === table) {
|
|
@@ -28,8 +28,6 @@ export const updateColumnWidths =
|
|
|
28
28
|
table: PMNode,
|
|
29
29
|
start: number,
|
|
30
30
|
api: PluginInjectionAPI | undefined | null,
|
|
31
|
-
// Ignored via go/ees005
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
33
31
|
) =>
|
|
34
32
|
(tr: Transaction): Transaction => {
|
|
35
33
|
const map = TableMap.get(table);
|
|
@@ -134,8 +132,6 @@ export const rescaleColumns =
|
|
|
134
132
|
shouldUseIncreasedScalingPercent = false,
|
|
135
133
|
api: PluginInjectionAPI | undefined | null,
|
|
136
134
|
isCommentEditor = false,
|
|
137
|
-
// Ignored via go/ees005
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
139
135
|
) =>
|
|
140
136
|
(table: ContentNodeWithPos, view: EditorView | undefined) =>
|
|
141
137
|
(tr: Transaction): Transaction => {
|
|
@@ -252,8 +252,6 @@ export const deleteColumns =
|
|
|
252
252
|
isTableFixedColumnWidthsOptionEnabled = false,
|
|
253
253
|
shouldUseIncreasedScalingPercent = false,
|
|
254
254
|
isCommentEditor = false,
|
|
255
|
-
// Ignored via go/ees005
|
|
256
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
257
255
|
) =>
|
|
258
256
|
(tr: Transaction) => {
|
|
259
257
|
let updatedTr = tr;
|
|
@@ -50,8 +50,6 @@ export const removeExtraneousColumnWidths = (
|
|
|
50
50
|
basePos: number,
|
|
51
51
|
tr: Transaction,
|
|
52
52
|
reportInvalidTableCellSpanAttrs?: ReportInvalidNodeAttrs,
|
|
53
|
-
// Ignored via go/ees005
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
55
53
|
): boolean => {
|
|
56
54
|
let hasProblems = false;
|
|
57
55
|
|
|
@@ -126,8 +124,6 @@ export const fixAutoSizedTable = (
|
|
|
126
124
|
tableRef: HTMLTableElement,
|
|
127
125
|
tablePos: number,
|
|
128
126
|
opts: { containerWidth: number },
|
|
129
|
-
// Ignored via go/ees005
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
131
127
|
): Transaction => {
|
|
132
128
|
let { tr } = view.state;
|
|
133
129
|
const domAtPos = view.domAtPos.bind(view);
|
|
@@ -179,8 +175,6 @@ const getLayoutBasedOnWidth = (totalWidth: number) => {
|
|
|
179
175
|
}
|
|
180
176
|
};
|
|
181
177
|
|
|
182
|
-
// Ignored via go/ees005
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
184
178
|
function parseDOMColumnWidths(
|
|
185
179
|
domAtPos: (pos: number) => { node: Node; offset: number },
|
|
186
180
|
tableNode: PMNode,
|
|
@@ -220,8 +214,6 @@ const replaceCells = (
|
|
|
220
214
|
table: PMNode,
|
|
221
215
|
tablePos: number,
|
|
222
216
|
modifyCell: (cell: PMNode, rowIndex: number, colIndex: number) => PMNode,
|
|
223
|
-
// Ignored via go/ees005
|
|
224
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
225
217
|
): Transaction => {
|
|
226
218
|
const rows: PMNode[] = [];
|
|
227
219
|
let modifiedCells = 0;
|
|
@@ -12,8 +12,6 @@ export const replaceSelectedTable = (
|
|
|
12
12
|
content: string | Slice,
|
|
13
13
|
inputMethod: INPUT_METHOD.KEYBOARD | INPUT_METHOD.CLIPBOARD,
|
|
14
14
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
15
|
-
// Ignored via go/ees005
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
17
15
|
): Transaction => {
|
|
18
16
|
if (isTableSelected(state.selection)) {
|
|
19
17
|
const table = findTable(state.selection);
|
|
@@ -10,8 +10,6 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
10
10
|
* @param columnStart - Start of the rect included (rect.left)
|
|
11
11
|
* @param columnEnd - End of the rect not included (rect.right)
|
|
12
12
|
*/
|
|
13
|
-
// Ignored via go/ees005
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
15
13
|
export function splitCellsInColumns(
|
|
16
14
|
tr: Transaction,
|
|
17
15
|
tablePos: number,
|
|
@@ -22,8 +22,6 @@ export const shouldChangeAlignmentToCenterResized = (
|
|
|
22
22
|
tableNode: PmNode,
|
|
23
23
|
lineLength: number | undefined,
|
|
24
24
|
updatedTableWidth: number,
|
|
25
|
-
// Ignored via go/ees005
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
27
25
|
) =>
|
|
28
26
|
Boolean(
|
|
29
27
|
isTableAlignmentEnabled &&
|
|
@@ -57,8 +57,6 @@ export const createControlsHoverDecoration = (
|
|
|
57
57
|
hoveredIndexes: number[],
|
|
58
58
|
danger?: boolean,
|
|
59
59
|
selected?: boolean,
|
|
60
|
-
// Ignored via go/ees005
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
62
60
|
): Decoration[] => {
|
|
63
61
|
const table = findTable(tr.selection);
|
|
64
62
|
if (!table) {
|
|
@@ -224,8 +222,6 @@ export const updateDecorations = (
|
|
|
224
222
|
decorationSet: DecorationSet,
|
|
225
223
|
decorations: Decoration[],
|
|
226
224
|
key: TableDecorations,
|
|
227
|
-
// Ignored via go/ees005
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
229
225
|
): DecorationSet => {
|
|
230
226
|
const filteredDecorations = filterDecorationByKey(key, decorationSet);
|
|
231
227
|
const decorationSetFiltered = decorationSet.remove(filteredDecorations);
|
|
@@ -320,8 +316,6 @@ export const createResizeHandleDecoration = (
|
|
|
320
316
|
includeTooltip: boolean = false,
|
|
321
317
|
getIntl: () => IntlShape,
|
|
322
318
|
nodeViewPortalProviderAPI: PortalProviderAPI,
|
|
323
|
-
// Ignored via go/ees005
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
325
319
|
): [Decoration[], Decoration[]] => {
|
|
326
320
|
const emptyResult: [Decoration[], Decoration[]] = [[], []];
|
|
327
321
|
const table = findTable(tr.selection);
|
|
@@ -340,8 +334,6 @@ export const createResizeHandleDecoration = (
|
|
|
340
334
|
rowIndex: number,
|
|
341
335
|
cellPos: number,
|
|
342
336
|
cellNode: PmNode,
|
|
343
|
-
// Ignored via go/ees005
|
|
344
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
345
337
|
): Decoration => {
|
|
346
338
|
const decorationRenderKey = uuid();
|
|
347
339
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
@@ -85,8 +85,6 @@ export const canMove = (
|
|
|
85
85
|
totalItemsOfSourceTypeCount: number,
|
|
86
86
|
selection: Selection,
|
|
87
87
|
selectionRect?: Rect,
|
|
88
|
-
// Ignored via go/ees005
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
90
88
|
) => {
|
|
91
89
|
if (!selectionRect) {
|
|
92
90
|
return false;
|
|
@@ -174,8 +172,6 @@ export const getDragMenuConfig = (
|
|
|
174
172
|
ariaLiveElementAttributes?: AriaLiveElementAttributes,
|
|
175
173
|
) => void,
|
|
176
174
|
isCommentEditor = false,
|
|
177
|
-
// Ignored via go/ees005
|
|
178
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
179
175
|
): DragMenuConfig[] => {
|
|
180
176
|
const { selection } = editorView.state;
|
|
181
177
|
const { getIntl } = getTablePluginState(editorView.state);
|
|
@@ -94,8 +94,6 @@ export const tablesHaveDifferentNoOfRows = (
|
|
|
94
94
|
return prevMap.height !== currentMap.height;
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
// Ignored via go/ees005
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
99
97
|
function filterNearSelection<T, U>(
|
|
100
98
|
selection: Selection,
|
|
101
99
|
findNode: (selection: Selection) => { pos: number; node: PmNode } | undefined,
|
|
@@ -4,6 +4,7 @@ import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { Slice, Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
|
|
9
10
|
import { getPluginState } from '../plugin-factory';
|
|
@@ -17,6 +18,9 @@ export const unwrapContentFromTable = (maybeTable: PMNode): PMNode | PMNode[] =>
|
|
|
17
18
|
maybeTable.descendants((maybeCell) => {
|
|
18
19
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
19
20
|
content.push(...flatten(maybeCell, false).map((child) => child.node));
|
|
21
|
+
if (fg('platform_editor_nested_tables_paste_dupe_fix')) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
return true;
|
|
22
26
|
});
|
|
@@ -33,8 +37,6 @@ const unwrapNestedTables = (
|
|
|
33
37
|
schema: Schema,
|
|
34
38
|
unwrapNestDepth: number,
|
|
35
39
|
currentNestDepth = 0,
|
|
36
|
-
// Ignored via go/ees005
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
38
40
|
): PMNode[] => {
|
|
39
41
|
const flattenNested = (node: PMNode, tableDepth: number) => {
|
|
40
42
|
if (node.type === schema.nodes.table) {
|
|
@@ -92,8 +92,6 @@ export const getRowClassNames = (
|
|
|
92
92
|
hoveredRows: number[] = [],
|
|
93
93
|
isInDanger?: boolean,
|
|
94
94
|
isResizing?: boolean,
|
|
95
|
-
// Ignored via go/ees005
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
97
95
|
): string => {
|
|
98
96
|
const classNames: string[] = [];
|
|
99
97
|
if (isRowSelected(index)(selection) || (hoveredRows.indexOf(index) > -1 && !isResizing)) {
|
|
@@ -91,8 +91,6 @@ export const findClosestSnap = (
|
|
|
91
91
|
guidelines: GuidelineConfig[],
|
|
92
92
|
snapGap: number = 0,
|
|
93
93
|
tolerance: number = 0,
|
|
94
|
-
// Ignored via go/ees005
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
96
94
|
) => {
|
|
97
95
|
const closestGapIndex = snapWidths.reduce(
|
|
98
96
|
(prev, curr, index) =>
|
package/src/tablePlugin.tsx
CHANGED
|
@@ -133,6 +133,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
133
133
|
isTableResizing: tableWidthResizingPluginState?.resizing,
|
|
134
134
|
isInDanger: tablePluginState.isInDanger,
|
|
135
135
|
hoveredRows: tablePluginState.hoveredRows,
|
|
136
|
+
hoveredColumns: tablePluginState.hoveredColumns,
|
|
136
137
|
hoveredCell: tablePluginState.hoveredCell,
|
|
137
138
|
isTableHovered: tablePluginState.isTableHovered,
|
|
138
139
|
isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/no-html-button */
|
|
1
2
|
import type { MouseEventHandler } from 'react';
|
|
2
3
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
4
|
|
|
@@ -7,7 +8,9 @@ import type { WrappedComponentProps } from 'react-intl-next';
|
|
|
7
8
|
import { injectIntl } from 'react-intl-next';
|
|
8
9
|
|
|
9
10
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
11
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
12
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
11
14
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
15
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
13
16
|
import { findTable, TableMap } from '@atlaskit/editor-tables';
|
|
@@ -22,8 +25,9 @@ import {
|
|
|
22
25
|
findDuplicatePosition,
|
|
23
26
|
hasMergedCellsInSelection,
|
|
24
27
|
} from '../../pm-plugins/utils/merged-cells';
|
|
28
|
+
import type { TablePlugin } from '../../tablePluginType';
|
|
25
29
|
import { TableCssClassName as ClassName } from '../../types';
|
|
26
|
-
import type { CellHoverMeta, TableDirection } from '../../types';
|
|
30
|
+
import type { CellHoverMeta, TableDirection, TableSharedStateInternal } from '../../types';
|
|
27
31
|
import { dragTableInsertColumnButtonSize } from '../consts';
|
|
28
32
|
import { DragPreview } from '../DragPreview';
|
|
29
33
|
|
|
@@ -49,6 +53,12 @@ type DragHandleProps = {
|
|
|
49
53
|
) => void;
|
|
50
54
|
editorView: EditorView;
|
|
51
55
|
isDragMenuTarget: boolean; // this is identify which current handle component is
|
|
56
|
+
hoveredColumns?: number[];
|
|
57
|
+
hoveredRows?: number[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type DragHandleWithSharedStateProps = Exclude<DragHandleProps, 'hoveredColumns' | 'hoveredRows'> & {
|
|
61
|
+
api?: ExtractInjectionAPI<TablePlugin>;
|
|
52
62
|
};
|
|
53
63
|
|
|
54
64
|
const DragHandleComponent = ({
|
|
@@ -67,6 +77,8 @@ const DragHandleComponent = ({
|
|
|
67
77
|
onClick,
|
|
68
78
|
editorView,
|
|
69
79
|
intl: { formatMessage },
|
|
80
|
+
hoveredColumns,
|
|
81
|
+
hoveredRows,
|
|
70
82
|
}: DragHandleProps & WrappedComponentProps) => {
|
|
71
83
|
const dragHandleDivRef = useRef<HTMLButtonElement>(null);
|
|
72
84
|
const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(null);
|
|
@@ -74,7 +86,13 @@ const DragHandleComponent = ({
|
|
|
74
86
|
state,
|
|
75
87
|
state: { selection },
|
|
76
88
|
} = editorView;
|
|
77
|
-
|
|
89
|
+
|
|
90
|
+
if (hoveredColumns === undefined || hoveredRows === undefined) {
|
|
91
|
+
const { hoveredColumns: hoveredColumnsState, hoveredRows: hoveredRowsState } =
|
|
92
|
+
getPluginState(state);
|
|
93
|
+
hoveredColumns = hoveredColumnsState;
|
|
94
|
+
hoveredRows = hoveredRowsState;
|
|
95
|
+
}
|
|
78
96
|
const { isDragMenuOpen = false } = getDnDPluginState(state);
|
|
79
97
|
|
|
80
98
|
const isRow = direction === 'row';
|
|
@@ -291,4 +309,51 @@ const DragHandleComponent = ({
|
|
|
291
309
|
);
|
|
292
310
|
};
|
|
293
311
|
|
|
312
|
+
const DragHandleComponentWithSharedState = ({
|
|
313
|
+
isDragMenuTarget,
|
|
314
|
+
tableLocalId,
|
|
315
|
+
direction,
|
|
316
|
+
appearance,
|
|
317
|
+
indexes,
|
|
318
|
+
forceDefaultHandle,
|
|
319
|
+
previewHeight,
|
|
320
|
+
previewWidth,
|
|
321
|
+
onMouseOver,
|
|
322
|
+
onMouseOut,
|
|
323
|
+
toggleDragMenu,
|
|
324
|
+
hoveredCell,
|
|
325
|
+
onClick,
|
|
326
|
+
editorView,
|
|
327
|
+
intl,
|
|
328
|
+
api,
|
|
329
|
+
}: DragHandleWithSharedStateProps & WrappedComponentProps) => {
|
|
330
|
+
const { tableState } = useSharedPluginState(api, ['table']) as {
|
|
331
|
+
tableState?: TableSharedStateInternal;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
return (
|
|
335
|
+
<DragHandleComponent
|
|
336
|
+
isDragMenuTarget={isDragMenuTarget}
|
|
337
|
+
tableLocalId={tableLocalId}
|
|
338
|
+
direction={direction}
|
|
339
|
+
appearance={appearance}
|
|
340
|
+
indexes={indexes}
|
|
341
|
+
forceDefaultHandle={forceDefaultHandle}
|
|
342
|
+
previewWidth={previewWidth}
|
|
343
|
+
previewHeight={previewHeight}
|
|
344
|
+
onMouseOver={onMouseOver}
|
|
345
|
+
onMouseOut={onMouseOut}
|
|
346
|
+
toggleDragMenu={toggleDragMenu}
|
|
347
|
+
hoveredCell={hoveredCell}
|
|
348
|
+
onClick={onClick}
|
|
349
|
+
editorView={editorView}
|
|
350
|
+
intl={intl}
|
|
351
|
+
hoveredColumns={tableState?.hoveredColumns}
|
|
352
|
+
hoveredRows={tableState?.hoveredRows}
|
|
353
|
+
/>
|
|
354
|
+
);
|
|
355
|
+
};
|
|
356
|
+
|
|
294
357
|
export const DragHandle = injectIntl(DragHandleComponent);
|
|
358
|
+
|
|
359
|
+
export const DragHandleWithSharedState = injectIntl(DragHandleComponentWithSharedState);
|
|
@@ -54,8 +54,6 @@ function getRowOptions(index: number, isDragAndDropEnabled: boolean): Partial<Po
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// Ignored via go/ees005
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
59
57
|
function getColumnOptions(
|
|
60
58
|
index: number,
|
|
61
59
|
tableContainer: HTMLElement | null,
|
|
@@ -113,8 +111,6 @@ function getColumnOptions(
|
|
|
113
111
|
return options;
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
// Ignored via go/ees005
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
118
114
|
function getPopupOptions(
|
|
119
115
|
direction: TableDirection,
|
|
120
116
|
index: number,
|
|
@@ -27,7 +27,7 @@ import type { TablePlugin } from '../../../tablePluginType';
|
|
|
27
27
|
import type { CellHoverMeta, HandleTypes } from '../../../types';
|
|
28
28
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
29
29
|
import type { DragHandleAppearance } from '../../DragHandle';
|
|
30
|
-
import { DragHandle } from '../../DragHandle';
|
|
30
|
+
import { DragHandle, DragHandleWithSharedState } from '../../DragHandle';
|
|
31
31
|
|
|
32
32
|
interface ColumnControlsProps {
|
|
33
33
|
editorView: EditorView;
|
|
@@ -68,7 +68,6 @@ export const ColumnControls = ({
|
|
|
68
68
|
isInDanger,
|
|
69
69
|
rowHeights,
|
|
70
70
|
colWidths,
|
|
71
|
-
hasHeaderColumn,
|
|
72
71
|
isTableHovered,
|
|
73
72
|
tableContainerWidth,
|
|
74
73
|
isNumberColumnEnabled,
|
|
@@ -196,8 +195,6 @@ export const ColumnControls = ({
|
|
|
196
195
|
appearance: DragHandleAppearance,
|
|
197
196
|
gridColumn: string,
|
|
198
197
|
indexes: number[],
|
|
199
|
-
// Ignored via go/ees005
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
201
198
|
) => {
|
|
202
199
|
const isHover = type === 'hover';
|
|
203
200
|
const isPlaceholder = appearance === 'placeholder';
|
|
@@ -238,22 +235,42 @@ export const ColumnControls = ({
|
|
|
238
235
|
isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0]
|
|
239
236
|
}-drag-handle`}
|
|
240
237
|
>
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
238
|
+
{fg('platform_editor_table_use_shared_state_hook_fg') ? (
|
|
239
|
+
<DragHandleWithSharedState
|
|
240
|
+
isDragMenuTarget={!isHover}
|
|
241
|
+
direction="column"
|
|
242
|
+
tableLocalId={localId || ''}
|
|
243
|
+
indexes={indexes}
|
|
244
|
+
hoveredCell={hoveredCell}
|
|
245
|
+
previewWidth={previewWidth}
|
|
246
|
+
forceDefaultHandle={!isHover}
|
|
247
|
+
previewHeight={previewHeight}
|
|
248
|
+
appearance={appearance}
|
|
249
|
+
onClick={handleClick}
|
|
250
|
+
onMouseOver={handleMouseOver}
|
|
251
|
+
onMouseOut={handleMouseOut}
|
|
252
|
+
toggleDragMenu={toggleDragMenuHandler}
|
|
253
|
+
editorView={editorView}
|
|
254
|
+
api={api}
|
|
255
|
+
/>
|
|
256
|
+
) : (
|
|
257
|
+
<DragHandle
|
|
258
|
+
isDragMenuTarget={!isHover}
|
|
259
|
+
direction="column"
|
|
260
|
+
tableLocalId={localId || ''}
|
|
261
|
+
indexes={indexes}
|
|
262
|
+
hoveredCell={hoveredCell}
|
|
263
|
+
previewWidth={previewWidth}
|
|
264
|
+
forceDefaultHandle={!isHover}
|
|
265
|
+
previewHeight={previewHeight}
|
|
266
|
+
appearance={appearance}
|
|
267
|
+
onClick={handleClick}
|
|
268
|
+
onMouseOver={handleMouseOver}
|
|
269
|
+
onMouseOut={handleMouseOut}
|
|
270
|
+
toggleDragMenu={toggleDragMenuHandler}
|
|
271
|
+
editorView={editorView}
|
|
272
|
+
/>
|
|
273
|
+
)}
|
|
257
274
|
</div>
|
|
258
275
|
);
|
|
259
276
|
};
|
|
@@ -7,7 +7,6 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
10
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
10
|
|
|
12
11
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers/types';
|
|
13
12
|
import { getColumnsWidths } from '../../pm-plugins/utils/column-controls';
|
|
@@ -141,9 +140,7 @@ const TableFloatingColumnControls = ({
|
|
|
141
140
|
isNumberColumnEnabled={isNumberColumnEnabled}
|
|
142
141
|
isDragging={isDragging}
|
|
143
142
|
getScrollOffset={getScrollOffset}
|
|
144
|
-
api={
|
|
145
|
-
editorExperiment('platform_editor_table_use_shared_state_hook', true) ? api : undefined
|
|
146
|
-
}
|
|
143
|
+
api={fg('platform_editor_table_use_shared_state_hook_fg') ? api : undefined}
|
|
147
144
|
/>
|
|
148
145
|
{isDragging && (
|
|
149
146
|
<ColumnDropTargets
|