@atlaskit/editor-plugin-table 7.21.2 → 7.21.4
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 +15 -0
- package/dist/cjs/commands/insert.js +6 -3
- package/dist/cjs/nodeviews/TableComponent.js +26 -10
- package/dist/cjs/nodeviews/TableContainer.js +9 -6
- package/dist/cjs/nodeviews/lazy-node-views.js +4 -3
- package/dist/cjs/nodeviews/table.js +8 -3
- package/dist/cjs/plugin.js +16 -7
- package/dist/cjs/pm-plugins/keymap.js +3 -1
- package/dist/cjs/pm-plugins/main.js +4 -3
- package/dist/cjs/toolbar.js +4 -1
- package/dist/cjs/ui/ColumnResizeWidget/index.js +4 -1
- package/dist/cjs/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.js +4 -1
- package/dist/cjs/ui/FloatingContextualButton/index.js +4 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -1
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +4 -1
- package/dist/cjs/utils/create.js +6 -1
- package/dist/es2019/commands/insert.js +6 -3
- package/dist/es2019/nodeviews/TableComponent.js +27 -11
- package/dist/es2019/nodeviews/TableContainer.js +9 -6
- package/dist/es2019/nodeviews/lazy-node-views.js +4 -3
- package/dist/es2019/nodeviews/table.js +8 -3
- package/dist/es2019/plugin.js +14 -7
- package/dist/es2019/pm-plugins/keymap.js +2 -2
- package/dist/es2019/pm-plugins/main.js +4 -3
- package/dist/es2019/toolbar.js +4 -1
- package/dist/es2019/ui/ColumnResizeWidget/index.js +4 -1
- package/dist/es2019/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.js +4 -1
- package/dist/es2019/ui/FloatingContextualButton/index.js +4 -1
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -1
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +4 -1
- package/dist/es2019/utils/create.js +6 -1
- package/dist/esm/commands/insert.js +6 -3
- package/dist/esm/nodeviews/TableComponent.js +27 -11
- package/dist/esm/nodeviews/TableContainer.js +9 -6
- package/dist/esm/nodeviews/lazy-node-views.js +4 -3
- package/dist/esm/nodeviews/table.js +8 -3
- package/dist/esm/plugin.js +16 -7
- package/dist/esm/pm-plugins/keymap.js +3 -1
- package/dist/esm/pm-plugins/main.js +4 -3
- package/dist/esm/toolbar.js +4 -1
- package/dist/esm/ui/ColumnResizeWidget/index.js +4 -1
- package/dist/esm/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.js +4 -1
- package/dist/esm/ui/FloatingContextualButton/index.js +4 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -1
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +4 -1
- package/dist/esm/utils/create.js +6 -1
- package/dist/types/commands/insert.d.ts +2 -2
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/nodeviews/lazy-node-views.d.ts +1 -0
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +4 -1
- package/dist/types/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.d.ts +4 -1
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +4 -1
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +4 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +4 -1
- package/dist/types/utils/create.d.ts +3 -1
- package/dist/types-ts4.5/commands/insert.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.d.ts +4 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +4 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +4 -1
- package/dist/types-ts4.5/utils/create.d.ts +3 -1
- package/package.json +6 -3
- package/src/commands/insert.ts +6 -0
- package/src/nodeviews/TableComponent.tsx +23 -8
- package/src/nodeviews/TableContainer.tsx +15 -3
- package/src/nodeviews/lazy-node-views.ts +4 -0
- package/src/nodeviews/table.tsx +7 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +12 -1
- package/src/pm-plugins/keymap.ts +4 -0
- package/src/pm-plugins/main.ts +5 -1
- package/src/toolbar.tsx +4 -1
- package/src/ui/ColumnResizeWidget/index.tsx +4 -1
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +4 -1
- package/src/ui/FloatingContextualButton/index.tsx +4 -1
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +4 -1
- package/src/ui/FloatingContextualMenu/index.tsx +4 -1
- package/src/ui/FloatingDragMenu/DragMenu.tsx +4 -1
- package/src/utils/create.ts +9 -2
package/src/commands/insert.ts
CHANGED
|
@@ -231,12 +231,16 @@ export const createTable =
|
|
|
231
231
|
isTableAlignmentEnabled?: boolean,
|
|
232
232
|
isFullWidthModeEnabled?: boolean,
|
|
233
233
|
editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null,
|
|
234
|
+
isCommentEditor?: boolean,
|
|
235
|
+
isTableResizingEnabled?: boolean,
|
|
234
236
|
): Command =>
|
|
235
237
|
(state, dispatch) => {
|
|
236
238
|
const table = createTableWithWidth({
|
|
237
239
|
isTableScalingEnabled,
|
|
238
240
|
isTableAlignmentEnabled,
|
|
239
241
|
isFullWidthModeEnabled,
|
|
242
|
+
isCommentEditor,
|
|
243
|
+
isTableResizingEnabled,
|
|
240
244
|
})(state.schema);
|
|
241
245
|
|
|
242
246
|
if (dispatch) {
|
|
@@ -262,6 +266,7 @@ export const insertTableWithSize =
|
|
|
262
266
|
isTableScalingEnabled?: boolean,
|
|
263
267
|
isTableAlignmentEnabled?: boolean,
|
|
264
268
|
editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
269
|
+
isCommentEditor?: boolean,
|
|
265
270
|
) =>
|
|
266
271
|
(rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER): EditorCommand => {
|
|
267
272
|
return ({ tr }) => {
|
|
@@ -269,6 +274,7 @@ export const insertTableWithSize =
|
|
|
269
274
|
isTableScalingEnabled,
|
|
270
275
|
isFullWidthModeEnabled,
|
|
271
276
|
isTableAlignmentEnabled,
|
|
277
|
+
isCommentEditor,
|
|
272
278
|
createTableProps: {
|
|
273
279
|
rowsCount: rowsCount,
|
|
274
280
|
colsCount: colsCount,
|
|
@@ -20,12 +20,13 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
20
20
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
21
21
|
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
22
22
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
23
|
-
import {
|
|
23
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
24
24
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
25
25
|
import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
26
26
|
import { token } from '@atlaskit/tokens';
|
|
27
27
|
|
|
28
28
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
29
|
+
import { handleMouseOut, isTableInFocus } from '../event-handlers';
|
|
29
30
|
import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils';
|
|
30
31
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
31
32
|
import type { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
|
|
@@ -186,6 +187,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
|
|
190
|
+
private handleMouseOut = (event: Event) => {
|
|
191
|
+
if (!isTableInFocus(this.props.view)) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
return handleMouseOut(this.props.view, event);
|
|
195
|
+
};
|
|
196
|
+
|
|
189
197
|
componentDidMount() {
|
|
190
198
|
const {
|
|
191
199
|
allowColumnResizing,
|
|
@@ -197,13 +205,16 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
197
205
|
isTableScalingEnabled,
|
|
198
206
|
} = this.props;
|
|
199
207
|
|
|
200
|
-
if (
|
|
208
|
+
if (fg('platform.editor.table.live-pages-sorting_4malx')) {
|
|
201
209
|
const { mode } =
|
|
202
210
|
this.props.pluginInjectionApi?.editorViewMode?.sharedState.currentState() || {};
|
|
203
211
|
if (mode === 'view') {
|
|
204
212
|
this?.table?.addEventListener('mouseenter', this.handleMouseEnter);
|
|
205
213
|
}
|
|
206
214
|
}
|
|
215
|
+
if (fg('editor_react_18_fix_table_delete_col_decorations')) {
|
|
216
|
+
this?.table?.addEventListener('mouseout', this.handleMouseOut);
|
|
217
|
+
}
|
|
207
218
|
|
|
208
219
|
const { tableWithFixedColumnWidthsOption = false, stickyScrollbar } = getEditorFeatureFlags();
|
|
209
220
|
|
|
@@ -305,9 +316,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
305
316
|
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
306
317
|
}
|
|
307
318
|
|
|
308
|
-
if (
|
|
319
|
+
if (fg('platform.editor.table.live-pages-sorting_4malx')) {
|
|
309
320
|
this?.table?.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
310
321
|
}
|
|
322
|
+
if (fg('editor_react_18_fix_table_delete_col_decorations')) {
|
|
323
|
+
this?.table?.removeEventListener('mouseout', this.handleMouseOut);
|
|
324
|
+
}
|
|
311
325
|
|
|
312
326
|
if (this.overflowShadowsObserver) {
|
|
313
327
|
this.overflowShadowsObserver.dispose();
|
|
@@ -388,7 +402,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
388
402
|
|
|
389
403
|
const shouldUseIncreasedScalingPercent =
|
|
390
404
|
(isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
391
|
-
|
|
405
|
+
fg('platform.editor.table.use-increased-scaling-percent')) ||
|
|
392
406
|
false;
|
|
393
407
|
|
|
394
408
|
if (force || (!isResizing && shouldUpdateColgroup)) {
|
|
@@ -448,7 +462,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
448
462
|
|
|
449
463
|
const table = findTable(view.state.selection);
|
|
450
464
|
|
|
451
|
-
if (!
|
|
465
|
+
if (!fg('platform.editor.table.use-shared-state-hook')) {
|
|
452
466
|
const pluginState = getPluginState(view.state);
|
|
453
467
|
isInDanger = pluginState.isInDanger;
|
|
454
468
|
}
|
|
@@ -466,7 +480,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
466
480
|
isTableScalingEnabled && tableWithFixedColumnWidthsOption;
|
|
467
481
|
const shouldUseIncreasedScalingPercent =
|
|
468
482
|
isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
469
|
-
|
|
483
|
+
fg('platform.editor.table.use-increased-scaling-percent');
|
|
470
484
|
|
|
471
485
|
if (
|
|
472
486
|
isTableScalingWithFixedColumnWidthsOptionEnabled &&
|
|
@@ -651,7 +665,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
651
665
|
const { showBeforeShadow, showAfterShadow } = this.state;
|
|
652
666
|
const node = getNode();
|
|
653
667
|
|
|
654
|
-
if (!
|
|
668
|
+
if (!fg('platform.editor.table.use-shared-state-hook')) {
|
|
655
669
|
const pluginState = getPluginState(view.state);
|
|
656
670
|
isInDanger = pluginState.isInDanger;
|
|
657
671
|
hoveredRows = pluginState.hoveredRows;
|
|
@@ -748,7 +762,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
748
762
|
const shouldUseIncreasedScalingPercent =
|
|
749
763
|
isTableScalingEnabled &&
|
|
750
764
|
tableWithFixedColumnWidthsOption &&
|
|
751
|
-
|
|
765
|
+
fg('platform.editor.table.use-increased-scaling-percent');
|
|
752
766
|
|
|
753
767
|
return (
|
|
754
768
|
<TableContainer
|
|
@@ -774,6 +788,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
774
788
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
775
789
|
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
776
790
|
shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
|
|
791
|
+
isCommentEditor={options?.isCommentEditor}
|
|
777
792
|
>
|
|
778
793
|
<div
|
|
779
794
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -174,6 +174,7 @@ type ResizableTableContainerProps = {
|
|
|
174
174
|
isTableWithFixedColumnWidthsOptionEnabled?: boolean;
|
|
175
175
|
isTableAlignmentEnabled?: boolean;
|
|
176
176
|
shouldUseIncreasedScalingPercent?: boolean;
|
|
177
|
+
isCommentEditor?: boolean;
|
|
177
178
|
};
|
|
178
179
|
|
|
179
180
|
export const ResizableTableContainer = React.memo(
|
|
@@ -194,6 +195,7 @@ export const ResizableTableContainer = React.memo(
|
|
|
194
195
|
isTableWithFixedColumnWidthsOptionEnabled,
|
|
195
196
|
isTableAlignmentEnabled,
|
|
196
197
|
shouldUseIncreasedScalingPercent,
|
|
198
|
+
isCommentEditor,
|
|
197
199
|
}: PropsWithChildren<ResizableTableContainerProps>) => {
|
|
198
200
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
199
201
|
const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
|
|
@@ -296,14 +298,21 @@ export const ResizableTableContainer = React.memo(
|
|
|
296
298
|
// padding left = padding right = akEditorGutterPadding = 32
|
|
297
299
|
responsiveContainerWidth = isTableScalingEnabled
|
|
298
300
|
? containerWidth - akEditorGutterPaddingDynamic() * 2
|
|
299
|
-
: containerWidth -
|
|
301
|
+
: containerWidth -
|
|
302
|
+
akEditorGutterPaddingDynamic() * 2 -
|
|
303
|
+
(isCommentEditor ? 0 : resizeHandleSpacing);
|
|
300
304
|
}
|
|
301
|
-
let width =
|
|
305
|
+
let width =
|
|
306
|
+
!node.attrs.width && isCommentEditor
|
|
307
|
+
? responsiveContainerWidth
|
|
308
|
+
: Math.min(tableWidth, responsiveContainerWidth);
|
|
302
309
|
|
|
303
310
|
if (!isResizing) {
|
|
304
311
|
tableWidthRef.current = width;
|
|
305
312
|
}
|
|
306
|
-
const maxResizerWidth =
|
|
313
|
+
const maxResizerWidth = isCommentEditor
|
|
314
|
+
? responsiveContainerWidth
|
|
315
|
+
: Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
307
316
|
|
|
308
317
|
const tableResizerProps = {
|
|
309
318
|
width,
|
|
@@ -391,6 +400,7 @@ type TableContainerProps = {
|
|
|
391
400
|
isTableWithFixedColumnWidthsOptionEnabled?: boolean;
|
|
392
401
|
isTableAlignmentEnabled?: boolean;
|
|
393
402
|
shouldUseIncreasedScalingPercent?: boolean;
|
|
403
|
+
isCommentEditor?: boolean;
|
|
394
404
|
};
|
|
395
405
|
|
|
396
406
|
export const TableContainer = ({
|
|
@@ -411,6 +421,7 @@ export const TableContainer = ({
|
|
|
411
421
|
isTableWithFixedColumnWidthsOptionEnabled,
|
|
412
422
|
isTableAlignmentEnabled,
|
|
413
423
|
shouldUseIncreasedScalingPercent,
|
|
424
|
+
isCommentEditor,
|
|
414
425
|
}: PropsWithChildren<TableContainerProps>) => {
|
|
415
426
|
if (isTableResizingEnabled && !isNested) {
|
|
416
427
|
return (
|
|
@@ -431,6 +442,7 @@ export const TableContainer = ({
|
|
|
431
442
|
isWholeTableInDanger={isWholeTableInDanger}
|
|
432
443
|
isTableAlignmentEnabled={isTableAlignmentEnabled}
|
|
433
444
|
shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
|
|
445
|
+
isCommentEditor={isCommentEditor}
|
|
434
446
|
>
|
|
435
447
|
{children}
|
|
436
448
|
</ResizableTableContainer>
|
|
@@ -22,6 +22,7 @@ type TableViewOptions = {
|
|
|
22
22
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
23
23
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
24
|
isTableAlignmentEnabled?: boolean;
|
|
25
|
+
isCommentEditor?: boolean;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export const lazyTableView = (options: TableViewOptions) => {
|
|
@@ -38,6 +39,7 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
38
39
|
options.dispatchAnalyticsEvent,
|
|
39
40
|
options.pluginInjectionApi,
|
|
40
41
|
options.isTableAlignmentEnabled,
|
|
42
|
+
options.isCommentEditor,
|
|
41
43
|
);
|
|
42
44
|
};
|
|
43
45
|
}
|
|
@@ -62,6 +64,7 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
62
64
|
dispatchAnalyticsEvent,
|
|
63
65
|
pluginInjectionApi,
|
|
64
66
|
isTableAlignmentEnabled,
|
|
67
|
+
isCommentEditor,
|
|
65
68
|
} = getNodeViewOptions();
|
|
66
69
|
|
|
67
70
|
return createTableView(
|
|
@@ -75,6 +78,7 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
75
78
|
dispatchAnalyticsEvent,
|
|
76
79
|
pluginInjectionApi,
|
|
77
80
|
isTableAlignmentEnabled,
|
|
81
|
+
isCommentEditor,
|
|
78
82
|
);
|
|
79
83
|
};
|
|
80
84
|
});
|
package/src/nodeviews/table.tsx
CHANGED
|
@@ -43,7 +43,7 @@ const tableAttributes = (node: PmNode) => {
|
|
|
43
43
|
'data-layout': node.attrs.layout,
|
|
44
44
|
'data-autosize': node.attrs.__autoSize,
|
|
45
45
|
'data-table-local-id': node.attrs.localId || '',
|
|
46
|
-
'data-table-width': node.attrs.width,
|
|
46
|
+
'data-table-width': node.attrs.width || 'inherit',
|
|
47
47
|
'data-table-display-mode': node.attrs.displayMode,
|
|
48
48
|
};
|
|
49
49
|
};
|
|
@@ -54,6 +54,10 @@ const getInlineWidth = (
|
|
|
54
54
|
state: EditorState,
|
|
55
55
|
pos: number | undefined,
|
|
56
56
|
): number | undefined => {
|
|
57
|
+
if (!node.attrs.width && options?.isCommentEditor && options?.isTableResizingEnabled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
// provide a width for tables when custom table width is supported
|
|
58
62
|
// this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
|
|
59
63
|
// support screen size adjustments
|
|
@@ -360,6 +364,7 @@ export const createTableView = (
|
|
|
360
364
|
dispatchAnalyticsEvent: DispatchAnalyticsEvent,
|
|
361
365
|
pluginInjectionApi?: PluginInjectionAPI,
|
|
362
366
|
isTableAlignmentEnabled?: boolean,
|
|
367
|
+
isCommentEditor?: boolean,
|
|
363
368
|
): NodeView => {
|
|
364
369
|
const {
|
|
365
370
|
pluginConfig,
|
|
@@ -386,6 +391,7 @@ export const createTableView = (
|
|
|
386
391
|
isDragAndDropEnabled,
|
|
387
392
|
isTableScalingEnabled, // same as options.isTableScalingEnabled
|
|
388
393
|
isTableAlignmentEnabled,
|
|
394
|
+
isCommentEditor,
|
|
389
395
|
},
|
|
390
396
|
getEditorContainerWidth,
|
|
391
397
|
getEditorFeatureFlags,
|
package/src/nodeviews/types.ts
CHANGED
package/src/plugin.tsx
CHANGED
|
@@ -97,6 +97,7 @@ export interface TablePluginOptions {
|
|
|
97
97
|
isTableScalingEnabled?: boolean;
|
|
98
98
|
isTableAlignmentEnabled?: boolean;
|
|
99
99
|
isNewColumnResizingEnabled?: boolean;
|
|
100
|
+
isCommentEditor?: boolean;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
|
|
@@ -262,6 +263,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
262
263
|
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
263
264
|
isTableAlignmentEnabled: options?.isTableAlignmentEnabled,
|
|
264
265
|
isFullWidthModeEnabled: options?.fullWidthEnabled,
|
|
266
|
+
isCommentEditor: options?.isCommentEditor,
|
|
267
|
+
isTableResizingEnabled: options?.tableResizingEnabled,
|
|
265
268
|
})(state.schema);
|
|
266
269
|
|
|
267
270
|
return (
|
|
@@ -324,6 +327,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
324
327
|
dragAndDropEnabled,
|
|
325
328
|
isTableScalingEnabled,
|
|
326
329
|
isTableAlignmentEnabled,
|
|
330
|
+
isCommentEditor,
|
|
327
331
|
} = options || ({} as TablePluginOptions);
|
|
328
332
|
|
|
329
333
|
return createPlugin(
|
|
@@ -344,6 +348,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
344
348
|
isTableScalingEnabled,
|
|
345
349
|
isTableAlignmentEnabled,
|
|
346
350
|
shouldUseIncreasedScalingPercent,
|
|
351
|
+
isCommentEditor,
|
|
347
352
|
);
|
|
348
353
|
},
|
|
349
354
|
},
|
|
@@ -386,6 +391,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
386
391
|
isTableScalingEnabled = false,
|
|
387
392
|
isTableAlignmentEnabled = false,
|
|
388
393
|
fullWidthEnabled = false,
|
|
394
|
+
isCommentEditor = false,
|
|
395
|
+
tableResizingEnabled = false,
|
|
389
396
|
} = options || ({} as TablePluginOptions);
|
|
390
397
|
|
|
391
398
|
return keymapPlugin(
|
|
@@ -400,6 +407,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
400
407
|
isCellBackgroundDuplicated,
|
|
401
408
|
isTableFixedColumnWidthsOptionEnabled,
|
|
402
409
|
shouldUseIncreasedScalingPercent,
|
|
410
|
+
isCommentEditor,
|
|
411
|
+
tableResizingEnabled,
|
|
403
412
|
);
|
|
404
413
|
},
|
|
405
414
|
},
|
|
@@ -463,7 +472,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
463
472
|
{
|
|
464
473
|
name: 'tableWidth',
|
|
465
474
|
plugin: ({ dispatchAnalyticsEvent, dispatch }) =>
|
|
466
|
-
options?.tableResizingEnabled
|
|
475
|
+
options?.tableResizingEnabled && !options?.isCommentEditor
|
|
467
476
|
? createTableWidthPlugin(
|
|
468
477
|
dispatch,
|
|
469
478
|
dispatchAnalyticsEvent,
|
|
@@ -717,6 +726,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
717
726
|
isTableScalingEnabled: options?.isTableScalingEnabled,
|
|
718
727
|
isTableAlignmentEnabled: options?.isTableAlignmentEnabled,
|
|
719
728
|
isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
|
|
729
|
+
isCommentEditor: options?.isCommentEditor,
|
|
730
|
+
isTableResizingEnabled: options?.tableResizingEnabled,
|
|
720
731
|
})(state.schema);
|
|
721
732
|
|
|
722
733
|
const tr = insert(tableNode);
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -69,6 +69,8 @@ export function keymapPlugin(
|
|
|
69
69
|
isCellBackgroundDuplicated = false,
|
|
70
70
|
isTableFixedColumnWidthsOptionEnabled = false,
|
|
71
71
|
shouldUseIncreasedScalingPercent?: boolean,
|
|
72
|
+
isCommentEditor?: boolean,
|
|
73
|
+
isTableResizingEnabled?: boolean,
|
|
72
74
|
): SafePlugin {
|
|
73
75
|
const list = {};
|
|
74
76
|
|
|
@@ -91,6 +93,8 @@ export function keymapPlugin(
|
|
|
91
93
|
isTableAlignmentEnabled,
|
|
92
94
|
!!isFullWidthEnabled,
|
|
93
95
|
editorAnalyticsAPI,
|
|
96
|
+
isCommentEditor,
|
|
97
|
+
isTableResizingEnabled,
|
|
94
98
|
),
|
|
95
99
|
list,
|
|
96
100
|
);
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -96,6 +96,7 @@ export const createPlugin = (
|
|
|
96
96
|
isTableScalingEnabled?: boolean,
|
|
97
97
|
isTableAlignmentEnabled?: boolean,
|
|
98
98
|
shouldUseIncreasedScalingPercent?: boolean,
|
|
99
|
+
isCommentEditor?: boolean,
|
|
99
100
|
) => {
|
|
100
101
|
const state = createPluginState(dispatch, {
|
|
101
102
|
pluginConfig,
|
|
@@ -361,6 +362,7 @@ export const createPlugin = (
|
|
|
361
362
|
dispatchAnalyticsEvent,
|
|
362
363
|
pluginInjectionApi,
|
|
363
364
|
isTableAlignmentEnabled,
|
|
365
|
+
isCommentEditor,
|
|
364
366
|
}),
|
|
365
367
|
tableRow: lazyTableRowView({ eventDispatcher }),
|
|
366
368
|
tableCell: lazyTableCellView({ eventDispatcher }),
|
|
@@ -372,7 +374,9 @@ export const createPlugin = (
|
|
|
372
374
|
mousedown: withCellTracking(handleMouseDown),
|
|
373
375
|
mouseover: withCellTracking(whenTableInFocus(handleMouseOver)),
|
|
374
376
|
mouseleave: handleMouseLeave,
|
|
375
|
-
mouseout:
|
|
377
|
+
mouseout: fg('editor_react_18_fix_table_delete_col_decorations')
|
|
378
|
+
? undefined
|
|
379
|
+
: whenTableInFocus(handleMouseOut),
|
|
376
380
|
mousemove: whenTableInFocus(handleMouseMove),
|
|
377
381
|
mouseenter: handleMouseEnter,
|
|
378
382
|
mouseup: whenTableInFocus(handleMouseUp),
|
package/src/toolbar.tsx
CHANGED
package/src/utils/create.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
|
|
|
5
5
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
6
6
|
|
|
7
7
|
type CreateTableOverrides = {
|
|
8
|
-
tableWidth?: TableAttributes['width'];
|
|
8
|
+
tableWidth?: TableAttributes['width'] | 'inherit';
|
|
9
9
|
layout?: TableAttributes['layout'];
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -14,11 +14,15 @@ export const createTableWithWidth =
|
|
|
14
14
|
isTableScalingEnabled,
|
|
15
15
|
isTableAlignmentEnabled,
|
|
16
16
|
isFullWidthModeEnabled,
|
|
17
|
+
isCommentEditor,
|
|
18
|
+
isTableResizingEnabled,
|
|
17
19
|
createTableProps,
|
|
18
20
|
}: {
|
|
19
21
|
isTableScalingEnabled?: boolean;
|
|
20
22
|
isTableAlignmentEnabled?: boolean;
|
|
21
23
|
isFullWidthModeEnabled?: boolean;
|
|
24
|
+
isCommentEditor?: boolean;
|
|
25
|
+
isTableResizingEnabled?: boolean;
|
|
22
26
|
createTableProps?: {
|
|
23
27
|
rowsCount?: number;
|
|
24
28
|
colsCount?: number;
|
|
@@ -26,12 +30,15 @@ export const createTableWithWidth =
|
|
|
26
30
|
}) =>
|
|
27
31
|
(schema: Schema) => {
|
|
28
32
|
const attrsOverrides: CreateTableOverrides = {};
|
|
29
|
-
if (isTableScalingEnabled && isFullWidthModeEnabled) {
|
|
33
|
+
if (isTableScalingEnabled && isFullWidthModeEnabled && !isCommentEditor) {
|
|
30
34
|
attrsOverrides.tableWidth = TABLE_MAX_WIDTH;
|
|
31
35
|
}
|
|
32
36
|
if (isTableAlignmentEnabled && isFullWidthModeEnabled) {
|
|
33
37
|
attrsOverrides.layout = 'align-start';
|
|
34
38
|
}
|
|
39
|
+
if (isCommentEditor && isTableResizingEnabled) {
|
|
40
|
+
attrsOverrides.tableWidth = 'inherit';
|
|
41
|
+
}
|
|
35
42
|
|
|
36
43
|
return createTable({
|
|
37
44
|
schema,
|