@atlaskit/editor-plugin-table 5.4.7 → 5.4.8
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 +6 -0
- package/dist/cjs/plugins/table/commands/misc.js +14 -12
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -4
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/cjs/plugins/table/types.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +6 -9
- package/dist/cjs/plugins/table/ui/ui-styles.js +12 -16
- package/dist/cjs/plugins/table/utils/decoration.js +20 -25
- package/dist/es2019/plugins/table/commands/misc.js +5 -4
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -4
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/es2019/plugins/table/types.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +20 -20
- package/dist/es2019/plugins/table/ui/ui-styles.js +18 -21
- package/dist/es2019/plugins/table/utils/decoration.js +20 -25
- package/dist/esm/plugins/table/commands/misc.js +13 -13
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -4
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +9 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -3
- package/dist/esm/plugins/table/types.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -1
- package/dist/esm/plugins/table/ui/common-styles.js +6 -9
- package/dist/esm/plugins/table/ui/ui-styles.js +12 -16
- package/dist/esm/plugins/table/utils/decoration.js +20 -25
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types/plugins/table/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +10 -4
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/__tests__/unit/event-handlers.ts +37 -38
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -36
- package/src/plugins/table/commands/misc.ts +9 -7
- package/src/plugins/table/nodeviews/TableComponent.tsx +20 -22
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +7 -2
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +20 -11
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +2 -4
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +14 -7
- package/src/plugins/table/types.ts +2 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +73 -67
- package/src/plugins/table/ui/common-styles.ts +20 -23
- package/src/plugins/table/ui/ui-styles.ts +18 -21
- package/src/plugins/table/utils/decoration.ts +27 -32
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
getCellsInRow,
|
|
23
23
|
getSelectionRect,
|
|
24
24
|
} from '@atlaskit/editor-tables/utils';
|
|
25
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
25
|
|
|
27
26
|
import type { Cell, CellColumnPositioning } from '../types';
|
|
28
27
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
@@ -219,37 +218,33 @@ export const createColumnControlsDecoration = (
|
|
|
219
218
|
): Decoration[] => {
|
|
220
219
|
const cells: ContentNodeWithPos[] = getCellsInRow(0)(selection) || [];
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
221
|
+
let index = 0;
|
|
222
|
+
return cells.map((cell) => {
|
|
223
|
+
const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
|
|
224
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
225
|
+
// and we want to avoid value leak
|
|
226
|
+
const startIndex = index;
|
|
227
|
+
const endIndex = startIndex + colspan;
|
|
228
|
+
|
|
229
|
+
// The next cell start index will commence from the current cell end index.
|
|
230
|
+
index = endIndex;
|
|
231
|
+
|
|
232
|
+
return Decoration.widget(
|
|
233
|
+
cell.pos + 1,
|
|
234
|
+
() => {
|
|
235
|
+
const element = document.createElement('div');
|
|
236
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
237
|
+
element.dataset.startIndex = `${startIndex}`;
|
|
238
|
+
element.dataset.endIndex = `${endIndex}`;
|
|
239
|
+
return element;
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
|
|
243
|
+
// this decoration should be the first one, even before gap cursor.
|
|
244
|
+
side: -100,
|
|
245
|
+
},
|
|
246
|
+
);
|
|
247
|
+
});
|
|
253
248
|
};
|
|
254
249
|
|
|
255
250
|
export const updateDecorations = (
|