@atlaskit/editor-plugin-table 7.25.6 → 7.25.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 +16 -0
- package/dist/cjs/commands/column-resize.js +2 -1
- package/dist/cjs/commands/delete.js +5 -5
- package/dist/cjs/commands/insert.js +20 -20
- package/dist/cjs/commands-with-analytics.js +18 -17
- package/dist/cjs/event-handlers.js +5 -5
- package/dist/cjs/nodeviews/TableComponent.js +1 -1
- package/dist/cjs/nodeviews/TableContainer.js +2 -9
- package/dist/cjs/nodeviews/TableResizer.js +1 -1
- package/dist/cjs/nodeviews/table-container-styles.js +18 -0
- package/dist/cjs/plugin.js +11 -7
- package/dist/cjs/pm-plugins/keymap.js +19 -19
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/pm-plugins/table-resizing/commands.js +5 -4
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +5 -4
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +4 -4
- package/dist/cjs/toDOM.js +10 -1
- package/dist/cjs/toolbar.js +31 -31
- package/dist/cjs/transforms/column-width.js +4 -3
- package/dist/cjs/transforms/delete-columns.js +5 -5
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/cjs/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -1
- package/dist/cjs/ui/FloatingDragMenu/index.js +4 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/utils/drag-menu.js +10 -10
- package/dist/es2019/commands/column-resize.js +2 -1
- package/dist/es2019/commands/delete.js +2 -2
- package/dist/es2019/commands/insert.js +8 -8
- package/dist/es2019/commands-with-analytics.js +11 -10
- package/dist/es2019/event-handlers.js +2 -2
- package/dist/es2019/nodeviews/TableComponent.js +1 -1
- package/dist/es2019/nodeviews/TableContainer.js +2 -9
- package/dist/es2019/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/nodeviews/table-container-styles.js +10 -0
- package/dist/es2019/plugin.js +11 -7
- package/dist/es2019/pm-plugins/keymap.js +9 -9
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/commands.js +5 -4
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/es2019/toDOM.js +4 -1
- package/dist/es2019/toolbar.js +13 -13
- package/dist/es2019/transforms/column-width.js +4 -5
- package/dist/es2019/transforms/delete-columns.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/es2019/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -1
- package/dist/es2019/ui/FloatingDragMenu/index.js +4 -2
- package/dist/es2019/ui/FloatingInsertButton/index.js +1 -1
- package/dist/es2019/utils/drag-menu.js +4 -4
- package/dist/esm/commands/column-resize.js +2 -1
- package/dist/esm/commands/delete.js +5 -5
- package/dist/esm/commands/insert.js +20 -20
- package/dist/esm/commands-with-analytics.js +18 -17
- package/dist/esm/event-handlers.js +5 -5
- package/dist/esm/nodeviews/TableComponent.js +1 -1
- package/dist/esm/nodeviews/TableContainer.js +2 -9
- package/dist/esm/nodeviews/TableResizer.js +1 -1
- package/dist/esm/nodeviews/table-container-styles.js +12 -0
- package/dist/esm/plugin.js +11 -7
- package/dist/esm/pm-plugins/keymap.js +19 -19
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/pm-plugins/table-resizing/commands.js +5 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +5 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +4 -4
- package/dist/esm/toDOM.js +10 -1
- package/dist/esm/toolbar.js +31 -31
- package/dist/esm/transforms/column-width.js +4 -4
- package/dist/esm/transforms/delete-columns.js +5 -5
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/esm/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -1
- package/dist/esm/ui/FloatingDragMenu/index.js +4 -2
- package/dist/esm/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/utils/drag-menu.js +10 -10
- package/dist/types/commands/column-resize.d.ts +3 -1
- package/dist/types/commands/delete.d.ts +2 -1
- package/dist/types/commands/insert.d.ts +5 -4
- package/dist/types/commands-with-analytics.d.ts +6 -6
- package/dist/types/event-handlers.d.ts +2 -1
- package/dist/types/nodeviews/table-container-styles.d.ts +5 -0
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/commands.d.ts +4 -2
- package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/plugin.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +2 -1
- package/dist/types/toolbar.d.ts +4 -4
- package/dist/types/transforms/column-width.d.ts +3 -2
- package/dist/types/transforms/delete-columns.d.ts +2 -1
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -0
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +3 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -0
- package/dist/types/utils/drag-menu.d.ts +2 -2
- package/dist/types-ts4.5/commands/column-resize.d.ts +3 -1
- package/dist/types-ts4.5/commands/delete.d.ts +2 -1
- package/dist/types-ts4.5/commands/insert.d.ts +5 -4
- package/dist/types-ts4.5/commands-with-analytics.d.ts +6 -6
- package/dist/types-ts4.5/event-handlers.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/table-container-styles.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/commands.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +2 -1
- package/dist/types-ts4.5/toolbar.d.ts +4 -4
- package/dist/types-ts4.5/transforms/column-width.d.ts +3 -2
- package/dist/types-ts4.5/transforms/delete-columns.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/drag-menu.d.ts +2 -2
- package/package.json +7 -7
- package/src/commands/column-resize.ts +4 -2
- package/src/commands/delete.ts +3 -0
- package/src/commands/insert.ts +9 -0
- package/src/commands-with-analytics.ts +17 -3
- package/src/event-handlers.ts +3 -0
- package/src/nodeviews/TableComponent.tsx +1 -0
- package/src/nodeviews/TableContainer.tsx +2 -5
- package/src/nodeviews/TableResizer.tsx +1 -0
- package/src/nodeviews/table-container-styles.ts +9 -0
- package/src/plugin.tsx +7 -0
- package/src/pm-plugins/keymap.ts +10 -3
- package/src/pm-plugins/main.ts +1 -0
- package/src/pm-plugins/table-resizing/commands.ts +13 -3
- package/src/pm-plugins/table-resizing/event-handlers.ts +5 -2
- package/src/pm-plugins/table-resizing/plugin.ts +3 -1
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +3 -1
- package/src/toDOM.ts +8 -1
- package/src/toolbar.tsx +14 -2
- package/src/transforms/column-width.ts +11 -3
- package/src/transforms/delete-columns.ts +3 -0
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +5 -1
- package/src/ui/FloatingContextualMenu/index.tsx +4 -1
- package/src/ui/FloatingDeleteButton/index.tsx +3 -2
- package/src/ui/FloatingDragMenu/DragMenu.tsx +4 -1
- package/src/ui/FloatingDragMenu/index.tsx +4 -1
- package/src/ui/FloatingInsertButton/index.tsx +3 -0
- package/src/utils/drag-menu.ts +5 -2
|
@@ -9,6 +9,7 @@ import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
|
9
9
|
import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils';
|
|
10
10
|
import { TableCssClassName as ClassName } from '../types';
|
|
11
11
|
import { ALIGN_CENTER, ALIGN_START } from '../utils/alignment';
|
|
12
|
+
import { getAlignmentStyle } from './table-container-styles';
|
|
12
13
|
import { TableResizer } from './TableResizer';
|
|
13
14
|
export const InnerContainer = /*#__PURE__*/forwardRef(({
|
|
14
15
|
className,
|
|
@@ -29,14 +30,6 @@ export const InnerContainer = /*#__PURE__*/forwardRef(({
|
|
|
29
30
|
"data-testid": "table-container"
|
|
30
31
|
}, children);
|
|
31
32
|
});
|
|
32
|
-
const centerAlignStyle = {
|
|
33
|
-
display: 'flex',
|
|
34
|
-
justifyContent: 'center'
|
|
35
|
-
};
|
|
36
|
-
const leftAlignStyle = {
|
|
37
|
-
display: 'flex',
|
|
38
|
-
justifyContent: 'flex-start'
|
|
39
|
-
};
|
|
40
33
|
const AlignmentTableContainer = ({
|
|
41
34
|
node,
|
|
42
35
|
children,
|
|
@@ -73,7 +66,7 @@ const AlignmentTableContainer = ({
|
|
|
73
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
67
|
}, [editorView, tableState, node]);
|
|
75
68
|
const style = useMemo(() => {
|
|
76
|
-
return alignment
|
|
69
|
+
return getAlignmentStyle(alignment);
|
|
77
70
|
}, [alignment]);
|
|
78
71
|
return (
|
|
79
72
|
/*#__PURE__*/
|
|
@@ -325,7 +325,7 @@ export const TableResizer = ({
|
|
|
325
325
|
prevNode: node,
|
|
326
326
|
start: pos + 1,
|
|
327
327
|
parentWidth: newWidth
|
|
328
|
-
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled, shouldUseIncreasedScalingPercent || false)(tr);
|
|
328
|
+
}, editorView.domAtPos.bind(editorView), pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent || false)(tr);
|
|
329
329
|
const scaledNode = tr.doc.nodeAt(pos);
|
|
330
330
|
(_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
|
|
331
331
|
originalNode: node,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ALIGN_START } from '../utils/alignment';
|
|
2
|
+
const centerAlignStyle = {
|
|
3
|
+
display: 'flex',
|
|
4
|
+
justifyContent: 'center'
|
|
5
|
+
};
|
|
6
|
+
const leftAlignStyle = {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
justifyContent: 'flex-start'
|
|
9
|
+
};
|
|
10
|
+
export const getAlignmentStyle = alignment => alignment === ALIGN_START ? leftAlignStyle : centerAlignStyle;
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -191,7 +191,7 @@ const tablesPlugin = ({
|
|
|
191
191
|
} = pluginConfig(tableOptions);
|
|
192
192
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
193
193
|
lastColumnResizable: !fullWidthEnabled
|
|
194
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, isTableAlignmentEnabled, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
194
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, isTableAlignmentEnabled, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
195
195
|
}
|
|
196
196
|
}, {
|
|
197
197
|
name: 'tableEditing',
|
|
@@ -212,7 +212,7 @@ const tablesPlugin = ({
|
|
|
212
212
|
isCommentEditor = false,
|
|
213
213
|
tableResizingEnabled = false
|
|
214
214
|
} = options || {};
|
|
215
|
-
return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, tableResizingEnabled);
|
|
215
|
+
return keymapPlugin(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, tableResizingEnabled);
|
|
216
216
|
}
|
|
217
217
|
}, {
|
|
218
218
|
name: 'tableSelectionKeymap',
|
|
@@ -402,7 +402,8 @@ const tablesPlugin = ({
|
|
|
402
402
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
403
403
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
404
404
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
405
|
-
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
|
|
405
|
+
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
406
|
+
api: api
|
|
406
407
|
}), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
|
|
407
408
|
editorView: editorView,
|
|
408
409
|
mountPoint: popupsMountPoint,
|
|
@@ -414,7 +415,8 @@ const tablesPlugin = ({
|
|
|
414
415
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
415
416
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
416
417
|
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
417
|
-
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor
|
|
418
|
+
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
419
|
+
api: api
|
|
418
420
|
}), isDragAndDropEnabled && /*#__PURE__*/React.createElement(FloatingDragMenu, {
|
|
419
421
|
editorView: editorView,
|
|
420
422
|
mountPoint: popupsMountPoint,
|
|
@@ -431,7 +433,8 @@ const tablesPlugin = ({
|
|
|
431
433
|
pluginConfig: pluginConfig,
|
|
432
434
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
433
435
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags,
|
|
434
|
-
ariaNotifyPlugin: ariaNotifyPlugin
|
|
436
|
+
ariaNotifyPlugin: ariaNotifyPlugin,
|
|
437
|
+
api: api
|
|
435
438
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
436
439
|
editorView: editorView,
|
|
437
440
|
selection: editorView.state.selection,
|
|
@@ -441,7 +444,8 @@ const tablesPlugin = ({
|
|
|
441
444
|
scrollableElement: popupsScrollableElement,
|
|
442
445
|
stickyHeaders: stickyHeader,
|
|
443
446
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
444
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
447
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
448
|
+
api: api
|
|
445
449
|
}), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.tableResizingEnabled) && options.isCommentEditor) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/React.createElement(FloatingToolbarLabel, {
|
|
446
450
|
target: resizingTableRef,
|
|
447
451
|
content: /*#__PURE__*/React.createElement(FullWidthDisplay, null),
|
|
@@ -491,7 +495,7 @@ const tablesPlugin = ({
|
|
|
491
495
|
return tr;
|
|
492
496
|
}
|
|
493
497
|
}],
|
|
494
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
498
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
495
499
|
}
|
|
496
500
|
};
|
|
497
501
|
};
|
|
@@ -8,7 +8,7 @@ import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSele
|
|
|
8
8
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
9
9
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
|
|
10
10
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
|
-
export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isTableResizingEnabled) {
|
|
11
|
+
export function keymapPlugin(getEditorContainerWidth, api, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isTableResizingEnabled) {
|
|
12
12
|
var _pluginInjectionApi$a;
|
|
13
13
|
const list = {};
|
|
14
14
|
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
@@ -21,12 +21,12 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
21
21
|
// Add row/column shortcuts
|
|
22
22
|
bindKeymapWithCommand(addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
23
23
|
bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
24
|
-
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
|
-
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
24
|
+
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(api, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
|
+
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(api, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
26
26
|
bindKeymapWithCommand(addRowBeforeVO.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
27
27
|
bindKeymapWithCommand(addRowAfterVO.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
28
|
-
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
29
|
-
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
28
|
+
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(api, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
29
|
+
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(api, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
30
30
|
if (dragAndDropEnabled) {
|
|
31
31
|
// Move row/column shortcuts
|
|
32
32
|
/**
|
|
@@ -42,8 +42,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
42
42
|
bindKeymapWithCommand(moveColumnRight.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)('table-column', 1), list);
|
|
43
43
|
|
|
44
44
|
// Delete row/column shortcuts
|
|
45
|
-
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
46
|
-
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
45
|
+
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
46
|
+
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
47
47
|
}
|
|
48
48
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing({
|
|
49
49
|
ariaNotify: ariaNotifyPlugin,
|
|
@@ -59,8 +59,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
59
59
|
ariaNotify: ariaNotifyPlugin,
|
|
60
60
|
getIntl: getIntl
|
|
61
61
|
}), list);
|
|
62
|
-
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, !!isCommentEditor, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
63
|
-
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, !!isCommentEditor, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
62
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI, api)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, !!isCommentEditor, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
63
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI, api)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, !!isCommentEditor, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
64
64
|
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing({
|
|
65
65
|
ariaNotify: ariaNotifyPlugin,
|
|
66
66
|
getIntl: getIntl
|
|
@@ -77,7 +77,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
77
77
|
tableWithFixedColumnWidthsOption = false
|
|
78
78
|
} = getEditorFeatureFlags();
|
|
79
79
|
// "fixTables" removes empty rows as we don't allow that in schema
|
|
80
|
-
const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent);
|
|
80
|
+
const updatedTr = handleCut(tr, oldState, newState, pluginInjectionApi, editorAnalyticsAPI, editorViewRef || undefined, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent);
|
|
81
81
|
return fixTables(updatedTr) || updatedTr;
|
|
82
82
|
}
|
|
83
83
|
if (transactions.find(tr => tr.docChanged)) {
|
|
@@ -8,7 +8,8 @@ export const evenColumns = ({
|
|
|
8
8
|
resizeState,
|
|
9
9
|
table,
|
|
10
10
|
start,
|
|
11
|
-
event
|
|
11
|
+
event,
|
|
12
|
+
api
|
|
12
13
|
}) => (state, dispatch) => {
|
|
13
14
|
if (!isTableSelected(state.selection)) {
|
|
14
15
|
return false;
|
|
@@ -22,7 +23,7 @@ export const evenColumns = ({
|
|
|
22
23
|
const now = Date.now();
|
|
23
24
|
if (lastClick && now - lastClick.time < 500 && isClickNear(event, lastClick)) {
|
|
24
25
|
const newState = evenAllColumnsWidths(resizeState);
|
|
25
|
-
setLastClick(null, tr => updateColumnWidths(newState, table, start)(tr))(state, dispatch);
|
|
26
|
+
setLastClick(null, tr => updateColumnWidths(newState, table, start, api)(tr))(state, dispatch);
|
|
26
27
|
return true;
|
|
27
28
|
}
|
|
28
29
|
setLastClick({
|
|
@@ -32,9 +33,9 @@ export const evenColumns = ({
|
|
|
32
33
|
})(state, dispatch);
|
|
33
34
|
return false;
|
|
34
35
|
};
|
|
35
|
-
export const distributeColumnsWidths = (newResizeState, table) => (state, dispatch) => {
|
|
36
|
+
export const distributeColumnsWidths = (newResizeState, table, api) => (state, dispatch) => {
|
|
36
37
|
if (dispatch) {
|
|
37
|
-
const tr = updateColumnWidths(newResizeState, table.node, table.start)(state.tr);
|
|
38
|
+
const tr = updateColumnWidths(newResizeState, table.node, table.start, api)(state.tr);
|
|
38
39
|
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
39
40
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS
|
|
40
41
|
});
|
|
@@ -14,7 +14,7 @@ import { evenColumns, setDragging, stopResizing } from './commands';
|
|
|
14
14
|
import { getPluginState } from './plugin-factory';
|
|
15
15
|
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, resizeColumnAndTable, updateControls } from './utils';
|
|
16
16
|
import { scaleResizeState } from './utils/resize-column';
|
|
17
|
-
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
17
|
+
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
18
18
|
const {
|
|
19
19
|
state,
|
|
20
20
|
dispatch
|
|
@@ -79,7 +79,8 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
79
79
|
resizeState,
|
|
80
80
|
table: originalTable,
|
|
81
81
|
start,
|
|
82
|
-
event
|
|
82
|
+
event,
|
|
83
|
+
api
|
|
83
84
|
})(state, dispatch)) {
|
|
84
85
|
finish(event);
|
|
85
86
|
return true;
|
|
@@ -183,7 +184,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
183
184
|
lineLength,
|
|
184
185
|
isTableAlignmentEnabled
|
|
185
186
|
});
|
|
186
|
-
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
187
|
+
tr = updateColumnWidths(newResizeState, table, start, api)(tr);
|
|
187
188
|
|
|
188
189
|
// If the table is aligned to the start and the table width is greater than the line length, we should change the alignment to center
|
|
189
190
|
const shouldChangeAlignment = shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, originalTable, lineLength, newResizeState.maxSize);
|
|
@@ -213,7 +214,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
213
214
|
}
|
|
214
215
|
} else {
|
|
215
216
|
const newResizeState = resizeColumn(resizeState, colIndex, resizedDelta, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale, shouldUseIncreasedScalingPercent);
|
|
216
|
-
tr = updateColumnWidths(newResizeState, table, start)(tr);
|
|
217
|
+
tr = updateColumnWidths(newResizeState, table, start, api)(tr);
|
|
217
218
|
}
|
|
218
219
|
if (colIndex === map.width - 1) {
|
|
219
220
|
const mouseUpTime = event.timeStamp;
|
|
@@ -9,7 +9,7 @@ import { pluginKey } from './plugin-key';
|
|
|
9
9
|
import { getResizeCellPos } from './utils';
|
|
10
10
|
export function createPlugin(dispatch, {
|
|
11
11
|
lastColumnResizable = true
|
|
12
|
-
}, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI, isTableScalingEnabled, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) {
|
|
12
|
+
}, getEditorContainerWidth, getEditorFeatureFlags, api, editorAnalyticsAPI, isTableScalingEnabled, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) {
|
|
13
13
|
return new SafePlugin({
|
|
14
14
|
key: pluginKey,
|
|
15
15
|
state: createPluginState(dispatch, {
|
|
@@ -51,7 +51,7 @@ export function createPlugin(dispatch, {
|
|
|
51
51
|
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
52
52
|
}
|
|
53
53
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
54
|
-
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor)) {
|
|
54
|
+
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor)) {
|
|
55
55
|
const {
|
|
56
56
|
state,
|
|
57
57
|
dispatch
|
|
@@ -135,7 +135,7 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
138
|
-
export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
138
|
+
export const scaleTable = (tableRef, options, domAtPos, api, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
139
139
|
if (!tableRef) {
|
|
140
140
|
return tr;
|
|
141
141
|
}
|
|
@@ -162,7 +162,7 @@ export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabledOnC
|
|
|
162
162
|
resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabledOnCurrentTable, shouldUseIncreasedScalingPercent);
|
|
163
163
|
}
|
|
164
164
|
if (resizeState) {
|
|
165
|
-
tr = updateColumnWidths(resizeState, node, start)(tr);
|
|
165
|
+
tr = updateColumnWidths(resizeState, node, start, api)(tr);
|
|
166
166
|
if (tr.docChanged) {
|
|
167
167
|
tr.setMeta('scrollIntoView', false);
|
|
168
168
|
// TODO: ED-8995
|
package/dist/es2019/toDOM.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import kebabCase from 'lodash/kebabCase';
|
|
1
2
|
import { table } from '@atlaskit/adf-schema';
|
|
2
3
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
3
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { getAlignmentStyle } from './nodeviews/table-container-styles';
|
|
4
6
|
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
5
7
|
export const tableNodeSpecWithFixedToDOM = config => {
|
|
6
8
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
@@ -10,6 +12,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
10
12
|
...table,
|
|
11
13
|
toDOM: node => {
|
|
12
14
|
const editorWidthFromGetter = Math.min(config.getEditorContainerWidth().width - akEditorGutterPaddingDynamic() * 2, node.attrs.width);
|
|
15
|
+
const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
|
|
13
16
|
const attrs = {
|
|
14
17
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
15
18
|
'data-layout': node.attrs.layout,
|
|
@@ -55,7 +58,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
55
58
|
}
|
|
56
59
|
const tableResizingDiv = ['div', {
|
|
57
60
|
'data-testid': 'table-alignment-container',
|
|
58
|
-
style:
|
|
61
|
+
style: alignmentStyle
|
|
59
62
|
}, ['div', {
|
|
60
63
|
class: 'pm-table-resizer-container',
|
|
61
64
|
style: `width: ${node.attrs.width}px`
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -115,7 +115,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
115
115
|
// with native widgets. It's enabled via a plugin config.
|
|
116
116
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
117
117
|
formatMessage
|
|
118
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
118
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
119
119
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
120
120
|
const {
|
|
121
121
|
top,
|
|
@@ -133,7 +133,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
133
133
|
const selectionRect = getClosestSelectionRect(state);
|
|
134
134
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
135
135
|
if (index) {
|
|
136
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
136
|
+
insertColumnWithAnalytics(api, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
137
137
|
}
|
|
138
138
|
return true;
|
|
139
139
|
},
|
|
@@ -171,7 +171,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
171
171
|
onClick: (state, dispatch, view) => {
|
|
172
172
|
const selectionRect = getClosestSelectionRect(state);
|
|
173
173
|
if (selectionRect) {
|
|
174
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
174
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
175
175
|
}
|
|
176
176
|
return true;
|
|
177
177
|
},
|
|
@@ -221,7 +221,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
221
221
|
const wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
222
222
|
const distributeColumnWidths = (state, dispatch) => {
|
|
223
223
|
if (newResizeStateWithAnalytics) {
|
|
224
|
-
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
224
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI, api)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
225
225
|
return true;
|
|
226
226
|
}
|
|
227
227
|
return false;
|
|
@@ -326,7 +326,7 @@ export const getClosestSelectionOrTableRect = state => {
|
|
|
326
326
|
const tableRect = new Rect(0, 0, map.width, map.height);
|
|
327
327
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
328
328
|
};
|
|
329
|
-
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
|
|
329
|
+
export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
|
|
330
330
|
const tableObject = findTable(state.selection);
|
|
331
331
|
const pluginState = getPluginState(state);
|
|
332
332
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
@@ -359,8 +359,8 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
359
359
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
360
360
|
const alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
361
361
|
const isCellBackgroundDuplicated = getEditorFeatureFlags().tableDuplicateCellColouring || false;
|
|
362
|
-
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
363
|
-
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
362
|
+
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
363
|
+
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
364
364
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
365
365
|
|
|
366
366
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -440,24 +440,24 @@ const separator = hidden => {
|
|
|
440
440
|
};
|
|
441
441
|
const getCellItems = (state, view, {
|
|
442
442
|
formatMessage
|
|
443
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
443
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
444
444
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
445
445
|
if (initialSelectionRect) {
|
|
446
446
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
447
447
|
formatMessage
|
|
448
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor);
|
|
448
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor);
|
|
449
449
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
450
450
|
}
|
|
451
451
|
return [];
|
|
452
452
|
};
|
|
453
|
-
export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => (state, dispatch, editorView) => {
|
|
453
|
+
export const getDistributeConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => (state, dispatch, editorView) => {
|
|
454
454
|
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
455
455
|
if (!editorView || !selectionOrTableRect) {
|
|
456
456
|
return false;
|
|
457
457
|
}
|
|
458
458
|
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor);
|
|
459
459
|
if (newResizeStateWithAnalytics) {
|
|
460
|
-
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
460
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI, api)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
461
461
|
return true;
|
|
462
462
|
}
|
|
463
463
|
return false;
|
|
@@ -467,7 +467,7 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
|
|
|
467
467
|
// fixed column button should be in this function call in the future
|
|
468
468
|
const getColumnSettingItems = (editorState, editorView, {
|
|
469
469
|
formatMessage
|
|
470
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => {
|
|
470
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => {
|
|
471
471
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
472
472
|
const pluginState = getPluginState(editorState);
|
|
473
473
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
@@ -483,7 +483,7 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
483
483
|
type: 'button',
|
|
484
484
|
title: formatMessage(messages.distributeColumns),
|
|
485
485
|
icon: DistributeColumnIcon,
|
|
486
|
-
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor)(state, dispatch, view),
|
|
486
|
+
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor)(state, dispatch, view),
|
|
487
487
|
disabled: !wouldChange
|
|
488
488
|
});
|
|
489
489
|
}
|
|
@@ -5,7 +5,6 @@ import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResize
|
|
|
5
5
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
6
6
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
7
7
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
11
10
|
* @param resizeState
|
|
@@ -13,7 +12,7 @@ import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
|
13
12
|
* @param start
|
|
14
13
|
* @returns
|
|
15
14
|
*/
|
|
16
|
-
export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
15
|
+
export const updateColumnWidths = (resizeState, table, start, _api) => tr => {
|
|
17
16
|
const map = TableMap.get(table);
|
|
18
17
|
const updatedCellsAttrs = {};
|
|
19
18
|
|
|
@@ -87,7 +86,7 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
|
|
|
87
86
|
* @param view
|
|
88
87
|
* @returns Updated transaction with rescaled columns for a given table
|
|
89
88
|
*/
|
|
90
|
-
export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => (table, view) => tr => {
|
|
89
|
+
export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, api) => (table, view) => tr => {
|
|
91
90
|
if (!view) {
|
|
92
91
|
return tr;
|
|
93
92
|
}
|
|
@@ -160,7 +159,7 @@ export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumn
|
|
|
160
159
|
tableWidth: previousTableInfo.width,
|
|
161
160
|
overflow: wasTableInOverflow
|
|
162
161
|
};
|
|
163
|
-
return updateColumnWidths(minWidthResizeState, table.node, table.start)(tr);
|
|
162
|
+
return updateColumnWidths(minWidthResizeState, table.node, table.start, api)(tr);
|
|
164
163
|
}
|
|
165
164
|
let resizeState = getResizeState({
|
|
166
165
|
minWidth: tableCellMinWidth,
|
|
@@ -179,5 +178,5 @@ export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumn
|
|
|
179
178
|
if (!wasTableInOverflow && resizeState.overflow || resizeState.tableWidth < resizeState.maxSize) {
|
|
180
179
|
resizeState = scaleTableTo(resizeState, previousTableInfo.possibleMaxWidth);
|
|
181
180
|
}
|
|
182
|
-
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
181
|
+
return updateColumnWidths(resizeState, table.node, table.start, api)(tr);
|
|
183
182
|
};
|
|
@@ -192,7 +192,7 @@ function fixRowSpans(table) {
|
|
|
192
192
|
}
|
|
193
193
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
194
194
|
}
|
|
195
|
-
export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
195
|
+
export const deleteColumns = (rect, allowCustomStep, api, view, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => tr => {
|
|
196
196
|
let updatedTr = tr;
|
|
197
197
|
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
198
198
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
@@ -204,7 +204,7 @@ export const deleteColumns = (rect, allowCustomStep, view, isTableScalingEnabled
|
|
|
204
204
|
}
|
|
205
205
|
const table = findTable(updatedTr.selection);
|
|
206
206
|
if (table) {
|
|
207
|
-
updatedTr = rescaleColumns(isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(table, view)(updatedTr);
|
|
207
|
+
updatedTr = rescaleColumns(isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, api)(table, view)(updatedTr);
|
|
208
208
|
}
|
|
209
209
|
return updatedTr;
|
|
210
210
|
};
|
|
@@ -546,7 +546,7 @@ export class ContextualMenu extends Component {
|
|
|
546
546
|
case 'distribute_columns':
|
|
547
547
|
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled, tableWithFixedColumnWidthsOption);
|
|
548
548
|
if (newResizeStateWithAnalytics) {
|
|
549
|
-
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
|
|
549
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI, this.props.api)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
|
|
550
550
|
this.toggleOpen();
|
|
551
551
|
}
|
|
552
552
|
break;
|
|
@@ -555,7 +555,7 @@ export class ContextualMenu extends Component {
|
|
|
555
555
|
this.toggleOpen();
|
|
556
556
|
break;
|
|
557
557
|
case 'insert_column':
|
|
558
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
558
|
+
insertColumnWithAnalytics(this.props.api, editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
559
559
|
this.toggleOpen();
|
|
560
560
|
break;
|
|
561
561
|
case 'insert_row':
|
|
@@ -566,7 +566,7 @@ export class ContextualMenu extends Component {
|
|
|
566
566
|
this.toggleOpen();
|
|
567
567
|
break;
|
|
568
568
|
case 'delete_column':
|
|
569
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
569
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, this.props.api, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.CONTEXT_MENU, selectionRect)(state, dispatch, editorView);
|
|
570
570
|
this.toggleOpen();
|
|
571
571
|
break;
|
|
572
572
|
case 'delete_row':
|
|
@@ -23,7 +23,8 @@ const FloatingContextualMenu = ({
|
|
|
23
23
|
getEditorContainerWidth,
|
|
24
24
|
getEditorFeatureFlags,
|
|
25
25
|
isCellMenuOpenByKeyboard,
|
|
26
|
-
isCommentEditor
|
|
26
|
+
isCommentEditor,
|
|
27
|
+
api
|
|
27
28
|
}) => {
|
|
28
29
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
29
30
|
const {
|
|
@@ -78,7 +79,8 @@ const FloatingContextualMenu = ({
|
|
|
78
79
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
79
80
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
80
81
|
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
81
|
-
isCommentEditor: isCommentEditor
|
|
82
|
+
isCommentEditor: isCommentEditor,
|
|
83
|
+
api: api
|
|
82
84
|
})));
|
|
83
85
|
};
|
|
84
86
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -108,7 +108,7 @@ class FloatingDeleteButton extends Component {
|
|
|
108
108
|
switch (this.state.selectionType) {
|
|
109
109
|
case 'column':
|
|
110
110
|
{
|
|
111
|
-
deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch, this.props.editorView);
|
|
111
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPI, this.props.api)(INPUT_METHOD.BUTTON, rect)(state, dispatch, this.props.editorView);
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
case 'row':
|
|
@@ -179,6 +179,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
179
179
|
tableNode,
|
|
180
180
|
targetCellPosition,
|
|
181
181
|
getEditorContainerWidth,
|
|
182
|
+
api,
|
|
182
183
|
editorAnalyticsAPI,
|
|
183
184
|
pluginConfig,
|
|
184
185
|
intl: {
|
|
@@ -212,7 +213,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
212
213
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
213
214
|
const hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
|
|
214
215
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
215
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, tableSortColumnReorder, ariaNotifyPlugin);
|
|
216
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, tableDuplicateCellColouring, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, tableSortColumnReorder, ariaNotifyPlugin);
|
|
216
217
|
const {
|
|
217
218
|
menuItems,
|
|
218
219
|
menuCallback
|
|
@@ -21,7 +21,8 @@ const FloatingDragMenu = ({
|
|
|
21
21
|
pluginConfig,
|
|
22
22
|
isTableScalingEnabled,
|
|
23
23
|
getEditorFeatureFlags,
|
|
24
|
-
ariaNotifyPlugin
|
|
24
|
+
ariaNotifyPlugin,
|
|
25
|
+
api
|
|
25
26
|
}) => {
|
|
26
27
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
27
28
|
return null;
|
|
@@ -76,7 +77,8 @@ const FloatingDragMenu = ({
|
|
|
76
77
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
77
78
|
isTableFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
|
|
78
79
|
tableSortColumnReorder: tableSortColumnReorder,
|
|
79
|
-
ariaNotifyPlugin: ariaNotifyPlugin
|
|
80
|
+
ariaNotifyPlugin: ariaNotifyPlugin,
|
|
81
|
+
api: api
|
|
80
82
|
}));
|
|
81
83
|
};
|
|
82
84
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -193,7 +193,7 @@ export class FloatingInsertButton extends React.Component {
|
|
|
193
193
|
state,
|
|
194
194
|
dispatch
|
|
195
195
|
} = editorView;
|
|
196
|
-
insertColumnWithAnalytics(editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
196
|
+
insertColumnWithAnalytics(this.props.api, editorAnalyticsAPI, isTableScalingEnabled, tableDuplicateCellColouring, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
}
|