@atlaskit/editor-plugin-table 7.31.2 → 8.0.0
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 +92 -0
- package/dist/cjs/commands/insert.js +16 -19
- package/dist/cjs/commands-with-analytics.js +5 -7
- package/dist/cjs/event-handlers.js +12 -1
- package/dist/cjs/nodeviews/TableComponent.js +18 -15
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/cjs/nodeviews/lazy-node-views.js +2 -3
- package/dist/cjs/nodeviews/table.js +16 -12
- package/dist/cjs/plugin.js +22 -28
- package/dist/cjs/pm-plugins/keymap.js +9 -10
- package/dist/cjs/pm-plugins/main.js +3 -5
- package/dist/cjs/toolbar.js +10 -13
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +2 -4
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -7
- package/dist/cjs/utils/drag-menu.js +6 -7
- package/dist/es2019/commands/insert.js +10 -10
- package/dist/es2019/commands-with-analytics.js +4 -4
- package/dist/es2019/event-handlers.js +12 -1
- package/dist/es2019/nodeviews/TableComponent.js +18 -15
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/es2019/nodeviews/lazy-node-views.js +2 -3
- package/dist/es2019/nodeviews/table.js +16 -12
- package/dist/es2019/plugin.js +22 -26
- package/dist/es2019/pm-plugins/keymap.js +5 -5
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/toolbar.js +6 -7
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -3
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +2 -3
- package/dist/es2019/ui/FloatingInsertButton/index.js +3 -6
- package/dist/es2019/utils/drag-menu.js +3 -3
- package/dist/esm/commands/insert.js +16 -19
- package/dist/esm/commands-with-analytics.js +5 -7
- package/dist/esm/event-handlers.js +12 -1
- package/dist/esm/nodeviews/TableComponent.js +18 -15
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +5 -2
- package/dist/esm/nodeviews/lazy-node-views.js +2 -3
- package/dist/esm/nodeviews/table.js +16 -12
- package/dist/esm/plugin.js +22 -28
- package/dist/esm/pm-plugins/keymap.js +9 -10
- package/dist/esm/pm-plugins/main.js +3 -5
- package/dist/esm/toolbar.js +10 -13
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +2 -4
- package/dist/esm/ui/FloatingInsertButton/index.js +3 -7
- package/dist/esm/utils/drag-menu.js +6 -7
- package/dist/types/commands/insert.d.ts +5 -5
- package/dist/types/commands-with-analytics.d.ts +3 -4
- package/dist/types/event-handlers.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types/nodeviews/TableComponentWithSharedState.d.ts +3 -1
- package/dist/types/nodeviews/lazy-node-views.d.ts +0 -1
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +2 -2
- package/dist/types/plugin.d.ts +1 -3
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/toolbar.d.ts +1 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert.d.ts +5 -5
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -4
- package/dist/types-ts4.5/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/TableComponentWithSharedState.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +2 -2
- package/dist/types-ts4.5/plugin.d.ts +1 -3
- 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/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/package.json +3 -3
- package/src/commands/insert.ts +3 -10
- package/src/commands-with-analytics.ts +7 -8
- package/src/event-handlers.ts +17 -1
- package/src/nodeviews/TableComponent.tsx +22 -16
- package/src/nodeviews/TableComponentWithSharedState.tsx +6 -1
- package/src/nodeviews/lazy-node-views.ts +0 -4
- package/src/nodeviews/table.tsx +13 -8
- package/src/nodeviews/types.ts +2 -2
- package/src/plugin.tsx +24 -35
- package/src/pm-plugins/keymap.ts +0 -5
- package/src/pm-plugins/main.ts +2 -6
- package/src/toolbar.tsx +1 -9
- package/src/types.ts +2 -1
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +7 -10
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -3
- package/src/ui/FloatingDragMenu/index.tsx +1 -3
- package/src/ui/FloatingInsertButton/index.tsx +5 -10
- package/src/utils/drag-menu.ts +4 -9
|
@@ -137,7 +137,8 @@ class TableComponent extends React.Component {
|
|
|
137
137
|
const {
|
|
138
138
|
getNode,
|
|
139
139
|
containerWidth,
|
|
140
|
-
options
|
|
140
|
+
options,
|
|
141
|
+
allowTableResizing
|
|
141
142
|
} = this.props;
|
|
142
143
|
const prevNode = this.node;
|
|
143
144
|
const node = getNode();
|
|
@@ -172,7 +173,7 @@ class TableComponent extends React.Component {
|
|
|
172
173
|
// This last check is also to cater for dynamic text sizing changing the 'default' layout width
|
|
173
174
|
// Usually happens on window resize.
|
|
174
175
|
layoutSize !== this.layoutSize || noOfColumnsChanged) {
|
|
175
|
-
const shouldScaleTable = (!
|
|
176
|
+
const shouldScaleTable = (!allowTableResizing || allowTableResizing && isNested) && !hasNumberedColumnChanged && !noOfColumnsChanged;
|
|
176
177
|
|
|
177
178
|
// If column has been inserted/deleted avoid multi dispatch
|
|
178
179
|
if (shouldScaleTable) {
|
|
@@ -182,7 +183,7 @@ class TableComponent extends React.Component {
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
185
|
-
if (
|
|
186
|
+
if (allowTableResizing && hasNumberedColumnChanged) {
|
|
186
187
|
if (!hasTableBeenResized(prevNode)) {
|
|
187
188
|
this.scaleTable({
|
|
188
189
|
parentWidth: node.attrs.width
|
|
@@ -240,7 +241,7 @@ class TableComponent extends React.Component {
|
|
|
240
241
|
const {
|
|
241
242
|
dispatchAnalyticsEvent,
|
|
242
243
|
containerWidth,
|
|
243
|
-
|
|
244
|
+
allowTableResizing
|
|
244
245
|
} = this.props;
|
|
245
246
|
const parentWidth = ((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.parentWidth) || 0;
|
|
246
247
|
this.initialOverflowCaptureTimerId = setTimeout(() => {
|
|
@@ -252,7 +253,7 @@ class TableComponent extends React.Component {
|
|
|
252
253
|
attributes: {
|
|
253
254
|
editorWidth: containerWidth.width || 0,
|
|
254
255
|
isOverflowing,
|
|
255
|
-
tableResizingEnabled:
|
|
256
|
+
tableResizingEnabled: allowTableResizing || false,
|
|
256
257
|
width: this.node.attrs.width || 0,
|
|
257
258
|
parentWidth
|
|
258
259
|
}
|
|
@@ -361,8 +362,8 @@ class TableComponent extends React.Component {
|
|
|
361
362
|
var _this$table, _this$table2, _this$table3;
|
|
362
363
|
const {
|
|
363
364
|
allowColumnResizing,
|
|
365
|
+
allowTableResizing,
|
|
364
366
|
eventDispatcher,
|
|
365
|
-
options,
|
|
366
367
|
isDragAndDropEnabled,
|
|
367
368
|
getNode,
|
|
368
369
|
getEditorFeatureFlags,
|
|
@@ -407,7 +408,7 @@ class TableComponent extends React.Component {
|
|
|
407
408
|
* We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
|
|
408
409
|
* Instead we use the resize event to only trigger updates when necessary.
|
|
409
410
|
*/
|
|
410
|
-
if (!
|
|
411
|
+
if (!allowTableResizing) {
|
|
411
412
|
window.addEventListener('resize', this.handleWindowResizeDebounced);
|
|
412
413
|
}
|
|
413
414
|
this.handleTableResizingDebounced();
|
|
@@ -426,8 +427,8 @@ class TableComponent extends React.Component {
|
|
|
426
427
|
var _this$resizeObserver, _this$wrapperReisizeO, _this$table4, _this$table5, _this$table6;
|
|
427
428
|
const {
|
|
428
429
|
allowColumnResizing,
|
|
430
|
+
allowTableResizing,
|
|
429
431
|
eventDispatcher,
|
|
430
|
-
options,
|
|
431
432
|
isDragAndDropEnabled
|
|
432
433
|
} = this.props;
|
|
433
434
|
if (this.wrapper && !isIE11) {
|
|
@@ -445,10 +446,10 @@ class TableComponent extends React.Component {
|
|
|
445
446
|
this.scaleTableDebounced.cancel();
|
|
446
447
|
this.handleTableResizingDebounced.cancel();
|
|
447
448
|
this.handleAutoSizeDebounced.cancel();
|
|
448
|
-
if (!
|
|
449
|
+
if (!allowTableResizing) {
|
|
449
450
|
this.handleWindowResizeDebounced.cancel();
|
|
450
451
|
}
|
|
451
|
-
if (!
|
|
452
|
+
if (!allowTableResizing && allowColumnResizing) {
|
|
452
453
|
window.removeEventListener('resize', this.handleWindowResizeDebounced);
|
|
453
454
|
}
|
|
454
455
|
this === null || this === void 0 ? void 0 : (_this$table4 = this.table) === null || _this$table4 === void 0 ? void 0 : _this$table4.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
@@ -587,6 +588,7 @@ class TableComponent extends React.Component {
|
|
|
587
588
|
getNode,
|
|
588
589
|
isMediaFullscreen,
|
|
589
590
|
allowColumnResizing,
|
|
591
|
+
allowTableResizing,
|
|
590
592
|
isResizing,
|
|
591
593
|
options,
|
|
592
594
|
isTableScalingEnabled,
|
|
@@ -623,7 +625,7 @@ class TableComponent extends React.Component {
|
|
|
623
625
|
if (isInDanger && !table) {
|
|
624
626
|
clearHoverSelection()(view.state, view.dispatch);
|
|
625
627
|
}
|
|
626
|
-
if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor &&
|
|
628
|
+
if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && allowTableResizing && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
|
|
627
629
|
this.removeInlineTableWidth();
|
|
628
630
|
}
|
|
629
631
|
if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
|
|
@@ -665,7 +667,7 @@ class TableComponent extends React.Component {
|
|
|
665
667
|
const {
|
|
666
668
|
view
|
|
667
669
|
} = this.props;
|
|
668
|
-
const shouldRecreateResizeCols = !
|
|
670
|
+
const shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
|
|
669
671
|
if (shouldRecreateResizeCols) {
|
|
670
672
|
const start = getPos() || 0;
|
|
671
673
|
const depth = view.state.doc.resolve(start).depth;
|
|
@@ -728,7 +730,8 @@ class TableComponent extends React.Component {
|
|
|
728
730
|
getEditorFeatureFlags,
|
|
729
731
|
isTableScalingEnabled,
|
|
730
732
|
// here we can use options.isTableScalingEnabled
|
|
731
|
-
|
|
733
|
+
allowTableResizing,
|
|
734
|
+
allowTableAlignment
|
|
732
735
|
} = this.props;
|
|
733
736
|
let {
|
|
734
737
|
isInDanger,
|
|
@@ -848,12 +851,12 @@ class TableComponent extends React.Component {
|
|
|
848
851
|
isNested: isNested,
|
|
849
852
|
pluginInjectionApi: pluginInjectionApi,
|
|
850
853
|
tableWrapperHeight: this.state.tableWrapperHeight,
|
|
851
|
-
isTableResizingEnabled:
|
|
854
|
+
isTableResizingEnabled: allowTableResizing,
|
|
852
855
|
isResizing: isResizing,
|
|
853
856
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
854
857
|
isTableWithFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption,
|
|
855
858
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
856
|
-
isTableAlignmentEnabled:
|
|
859
|
+
isTableAlignmentEnabled: allowTableAlignment,
|
|
857
860
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
858
861
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
859
862
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor
|
|
@@ -16,7 +16,9 @@ export const TableComponentWithSharedState = ({
|
|
|
16
16
|
allowColumnResizing,
|
|
17
17
|
allowControls,
|
|
18
18
|
getPos,
|
|
19
|
-
forwardRef
|
|
19
|
+
forwardRef,
|
|
20
|
+
allowTableAlignment,
|
|
21
|
+
allowTableResizing
|
|
20
22
|
}) => {
|
|
21
23
|
const {
|
|
22
24
|
widthState,
|
|
@@ -65,7 +67,8 @@ export const TableComponentWithSharedState = ({
|
|
|
65
67
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
66
68
|
isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
|
|
67
69
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
68
|
-
|
|
70
|
+
allowTableAlignment: allowTableAlignment,
|
|
71
|
+
allowTableResizing: allowTableResizing,
|
|
69
72
|
tableActive: tableActive,
|
|
70
73
|
ordering: ordering,
|
|
71
74
|
isResizing: isResizing,
|
|
@@ -7,7 +7,7 @@ import TableRow from './TableRow';
|
|
|
7
7
|
export const lazyTableView = options => {
|
|
8
8
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
9
9
|
return (node, view, getPos) => {
|
|
10
|
-
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.
|
|
10
|
+
return createTableView(node, view, getPos, options.portalProviderAPI, options.eventDispatcher, options.getEditorContainerWidth, options.getEditorFeatureFlags, options.dispatchAnalyticsEvent, options.pluginInjectionApi, options.isCommentEditor, options.isChromelessEditor);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
const loader = () => {
|
|
@@ -23,11 +23,10 @@ export const lazyTableView = options => {
|
|
|
23
23
|
getEditorFeatureFlags,
|
|
24
24
|
dispatchAnalyticsEvent,
|
|
25
25
|
pluginInjectionApi,
|
|
26
|
-
isTableAlignmentEnabled,
|
|
27
26
|
isCommentEditor,
|
|
28
27
|
isChromelessEditor
|
|
29
28
|
} = getNodeViewOptions();
|
|
30
|
-
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi,
|
|
29
|
+
return createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor);
|
|
31
30
|
};
|
|
32
31
|
});
|
|
33
32
|
return result;
|
|
@@ -27,15 +27,15 @@ const tableAttributes = node => {
|
|
|
27
27
|
'data-table-display-mode': node.attrs.displayMode
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
const getInlineWidth = (node, options, state, pos) => {
|
|
31
|
-
if (!node.attrs.width && options !== null && options !== void 0 && options.isCommentEditor &&
|
|
30
|
+
const getInlineWidth = (node, options, state, pos, allowTableResizing) => {
|
|
31
|
+
if (!node.attrs.width && options !== null && options !== void 0 && options.isCommentEditor && allowTableResizing) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// provide a width for tables when custom table width is supported
|
|
36
36
|
// this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
|
|
37
37
|
// support screen size adjustments
|
|
38
|
-
const shouldHaveInlineWidth =
|
|
38
|
+
const shouldHaveInlineWidth = allowTableResizing && !isTableNested(state, pos);
|
|
39
39
|
let widthValue = getTableContainerWidth(node);
|
|
40
40
|
if (node.attrs.isNumberColumnEnabled) {
|
|
41
41
|
widthValue -= akEditorTableNumberColumnWidth;
|
|
@@ -73,7 +73,7 @@ export default class TableView extends ReactNodeView {
|
|
|
73
73
|
var _this$options, _this$options2, _this$getEditorFeatur;
|
|
74
74
|
this.table = rendered.dom;
|
|
75
75
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled && (_this$getEditorFeatur = this.getEditorFeatureFlags) !== null && _this$getEditorFeatur !== void 0 && _this$getEditorFeatur.call(this).tableWithFixedColumnWidthsOption && this.node.attrs.displayMode === 'fixed') {
|
|
76
|
-
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
|
|
76
|
+
const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos(), this.reactComponentProps.allowTableResizing);
|
|
77
77
|
if (tableInlineWidth) {
|
|
78
78
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
79
79
|
}
|
|
@@ -95,7 +95,7 @@ export default class TableView extends ReactNodeView {
|
|
|
95
95
|
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled) || (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.isTableScalingEnabled && (_this$getEditorFeatur2 = this.getEditorFeatureFlags) !== null && _this$getEditorFeatur2 !== void 0 && _this$getEditorFeatur2.call(this).tableWithFixedColumnWidthsOption && node.attrs.displayMode === 'fixed') {
|
|
96
96
|
var _tableWidthPluginKey$;
|
|
97
97
|
// handle inline style when table been resized
|
|
98
|
-
const tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos());
|
|
98
|
+
const tableInlineWidth = getInlineWidth(node, this.reactComponentProps.options, this.view.state, this.getPos(), this.reactComponentProps.allowTableResizing);
|
|
99
99
|
const isTableResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(this.view.state)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
100
100
|
if (!isTableResizing && tableInlineWidth) {
|
|
101
101
|
handleInlineTableWidth(this.table, tableInlineWidth);
|
|
@@ -112,6 +112,8 @@ export default class TableView extends ReactNodeView {
|
|
|
112
112
|
eventDispatcher: props.eventDispatcher,
|
|
113
113
|
api: props.pluginInjectionApi,
|
|
114
114
|
allowColumnResizing: props.allowColumnResizing,
|
|
115
|
+
allowTableAlignment: props.allowTableAlignment,
|
|
116
|
+
allowTableResizing: props.allowTableResizing,
|
|
115
117
|
allowControls: props.allowControls,
|
|
116
118
|
getPos: props.getPos,
|
|
117
119
|
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
@@ -149,7 +151,7 @@ export default class TableView extends ReactNodeView {
|
|
|
149
151
|
},
|
|
150
152
|
editorView: props.view,
|
|
151
153
|
render: pluginStates => {
|
|
152
|
-
var _props$options
|
|
154
|
+
var _props$options;
|
|
153
155
|
const {
|
|
154
156
|
tableResizingPluginState,
|
|
155
157
|
tableWidthPluginState,
|
|
@@ -185,7 +187,8 @@ export default class TableView extends ReactNodeView {
|
|
|
185
187
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
186
188
|
isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
|
|
187
189
|
,
|
|
188
|
-
|
|
190
|
+
allowTableAlignment: props.allowTableAlignment,
|
|
191
|
+
allowTableResizing: props.allowTableResizing,
|
|
189
192
|
tableActive: tableActive,
|
|
190
193
|
ordering: pluginState.ordering,
|
|
191
194
|
isResizing: isResizing,
|
|
@@ -258,23 +261,26 @@ export default class TableView extends ReactNodeView {
|
|
|
258
261
|
super.destroy();
|
|
259
262
|
}
|
|
260
263
|
}
|
|
261
|
-
export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi,
|
|
264
|
+
export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isCommentEditor, isChromelessEditor) => {
|
|
262
265
|
const {
|
|
263
266
|
pluginConfig,
|
|
264
267
|
isFullWidthModeEnabled,
|
|
265
268
|
wasFullWidthModeEnabled,
|
|
266
|
-
isTableResizingEnabled,
|
|
267
269
|
isDragAndDropEnabled,
|
|
268
270
|
isTableScalingEnabled // same as options.isTableScalingEnabled
|
|
269
271
|
} = getPluginState(view.state);
|
|
270
272
|
const {
|
|
271
273
|
allowColumnResizing,
|
|
272
|
-
allowControls
|
|
274
|
+
allowControls,
|
|
275
|
+
allowTableResizing,
|
|
276
|
+
allowTableAlignment
|
|
273
277
|
} = getPluginConfig(pluginConfig);
|
|
274
278
|
return new TableView({
|
|
275
279
|
node,
|
|
276
280
|
view,
|
|
277
281
|
allowColumnResizing,
|
|
282
|
+
allowTableResizing,
|
|
283
|
+
allowTableAlignment,
|
|
278
284
|
allowControls,
|
|
279
285
|
portalProviderAPI,
|
|
280
286
|
eventDispatcher,
|
|
@@ -282,11 +288,9 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
282
288
|
options: {
|
|
283
289
|
isFullWidthModeEnabled,
|
|
284
290
|
wasFullWidthModeEnabled,
|
|
285
|
-
isTableResizingEnabled,
|
|
286
291
|
isDragAndDropEnabled,
|
|
287
292
|
isTableScalingEnabled,
|
|
288
293
|
// same as options.isTableScalingEnabled
|
|
289
|
-
isTableAlignmentEnabled,
|
|
290
294
|
isCommentEditor,
|
|
291
295
|
isChromelessEditor
|
|
292
296
|
},
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -57,7 +57,7 @@ const tablesPlugin = ({
|
|
|
57
57
|
config: options,
|
|
58
58
|
api
|
|
59
59
|
}) => {
|
|
60
|
-
var _api$analytics, _api$accessibilityUti, _options$getEditorFea,
|
|
60
|
+
var _api$analytics, _api$accessibilityUti, _options$getEditorFea, _api$analytics2;
|
|
61
61
|
const editorViewRef = {
|
|
62
62
|
current: null
|
|
63
63
|
};
|
|
@@ -72,7 +72,6 @@ const tablesPlugin = ({
|
|
|
72
72
|
const isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 ? void 0 : (_options$getEditorFea = options.getEditorFeatureFlags) === null || _options$getEditorFea === void 0 ? void 0 : _options$getEditorFea.call(options).tableWithFixedColumnWidthsOption) || false;
|
|
73
73
|
const shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (isTableFixedColumnWidthsOptionEnabled || ( // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
74
74
|
options === null || options === void 0 ? void 0 : options.isCommentEditor));
|
|
75
|
-
const isCellBackgroundDuplicated = (options === null || options === void 0 ? void 0 : (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableDuplicateCellColouring) || false;
|
|
76
75
|
return {
|
|
77
76
|
name: 'table',
|
|
78
77
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
@@ -108,11 +107,11 @@ const tablesPlugin = ({
|
|
|
108
107
|
var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
|
|
109
108
|
const node = createTableWithWidth({
|
|
110
109
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
111
|
-
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.
|
|
110
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
112
111
|
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.fullWidthEnabled,
|
|
113
112
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
114
113
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
115
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.
|
|
114
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing
|
|
116
115
|
})(state.schema);
|
|
117
116
|
|
|
118
117
|
// If the cursor is inside a table
|
|
@@ -148,7 +147,7 @@ const tablesPlugin = ({
|
|
|
148
147
|
}
|
|
149
148
|
},
|
|
150
149
|
commands: {
|
|
151
|
-
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.
|
|
150
|
+
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
152
151
|
},
|
|
153
152
|
nodes() {
|
|
154
153
|
const {
|
|
@@ -159,7 +158,7 @@ const tablesPlugin = ({
|
|
|
159
158
|
name: 'table',
|
|
160
159
|
node: tableNodeSpecWithFixedToDOM({
|
|
161
160
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
162
|
-
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.
|
|
161
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
163
162
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
164
163
|
isNestingSupported
|
|
165
164
|
})
|
|
@@ -176,7 +175,7 @@ const tablesPlugin = ({
|
|
|
176
175
|
name: 'table',
|
|
177
176
|
node: tableNodeSpecWithFixedToDOM({
|
|
178
177
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
179
|
-
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.
|
|
178
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
180
179
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
181
180
|
isNestingSupported
|
|
182
181
|
})
|
|
@@ -205,16 +204,14 @@ const tablesPlugin = ({
|
|
|
205
204
|
const {
|
|
206
205
|
fullWidthEnabled,
|
|
207
206
|
wasFullWidthEnabled,
|
|
208
|
-
tableResizingEnabled,
|
|
209
207
|
tableOptions,
|
|
210
208
|
getEditorFeatureFlags,
|
|
211
209
|
dragAndDropEnabled,
|
|
212
210
|
isTableScalingEnabled,
|
|
213
|
-
isTableAlignmentEnabled,
|
|
214
211
|
isCommentEditor,
|
|
215
212
|
isChromelessEditor
|
|
216
213
|
} = options || {};
|
|
217
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl,
|
|
214
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor);
|
|
218
215
|
}
|
|
219
216
|
}, {
|
|
220
217
|
name: 'tablePMColResizing',
|
|
@@ -227,15 +224,15 @@ const tablesPlugin = ({
|
|
|
227
224
|
tableOptions,
|
|
228
225
|
getEditorFeatureFlags,
|
|
229
226
|
isTableScalingEnabled,
|
|
230
|
-
isNewColumnResizingEnabled
|
|
231
|
-
isTableAlignmentEnabled
|
|
227
|
+
isNewColumnResizingEnabled
|
|
232
228
|
} = options || {};
|
|
233
229
|
const {
|
|
234
|
-
allowColumnResizing
|
|
230
|
+
allowColumnResizing,
|
|
231
|
+
allowTableAlignment
|
|
235
232
|
} = pluginConfig(tableOptions);
|
|
236
233
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
237
234
|
lastColumnResizable: !fullWidthEnabled
|
|
238
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled,
|
|
235
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, allowTableAlignment, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
239
236
|
}
|
|
240
237
|
}, {
|
|
241
238
|
name: 'tableEditing',
|
|
@@ -252,13 +249,12 @@ const tablesPlugin = ({
|
|
|
252
249
|
const {
|
|
253
250
|
dragAndDropEnabled,
|
|
254
251
|
isTableScalingEnabled = false,
|
|
255
|
-
isTableAlignmentEnabled = false,
|
|
256
252
|
fullWidthEnabled = false,
|
|
257
253
|
isCommentEditor = false,
|
|
258
254
|
isChromelessEditor = false,
|
|
259
|
-
|
|
255
|
+
tableOptions
|
|
260
256
|
} = options || {};
|
|
261
|
-
return keymapPlugin(defaultGetEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled,
|
|
257
|
+
return keymapPlugin(defaultGetEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.allowTableAlignment, fullWidthEnabled, api, getIntl, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.allowTableResizing);
|
|
262
258
|
}
|
|
263
259
|
}, {
|
|
264
260
|
name: 'tableSelectionKeymap',
|
|
@@ -320,16 +316,16 @@ const tablesPlugin = ({
|
|
|
320
316
|
dispatchAnalyticsEvent,
|
|
321
317
|
dispatch
|
|
322
318
|
}) => {
|
|
323
|
-
var _options$fullWidthEna, _options$isTableScali, _options$
|
|
324
|
-
return options !== null && options !== void 0 && options.
|
|
319
|
+
var _options$fullWidthEna, _options$isTableScali, _options$tableOptions, _options$isCommentEdi;
|
|
320
|
+
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$tableOptions = options.tableOptions.allowTableResizing) !== null && _options$tableOptions !== void 0 ? _options$tableOptions : false, (_options$isCommentEdi = options.isCommentEditor) !== null && _options$isCommentEdi !== void 0 ? _options$isCommentEdi : false) : undefined;
|
|
325
321
|
}
|
|
326
322
|
}, {
|
|
327
323
|
name: 'tableWidthInCommentFix',
|
|
328
324
|
plugin: ({
|
|
329
325
|
dispatch
|
|
330
326
|
}) => {
|
|
331
|
-
var _options$
|
|
332
|
-
return options !== null && options !== void 0 && options.
|
|
327
|
+
var _options$tableOptions2;
|
|
328
|
+
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing && options !== null && options !== void 0 && options.isCommentEditor ? createTableWidthInCommentFixPlugin(dispatch, (_options$tableOptions2 = options.tableOptions.allowTableAlignment) !== null && _options$tableOptions2 !== void 0 ? _options$tableOptions2 : false) : undefined;
|
|
333
329
|
}
|
|
334
330
|
},
|
|
335
331
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -339,8 +335,8 @@ const tablesPlugin = ({
|
|
|
339
335
|
dispatch,
|
|
340
336
|
dispatchAnalyticsEvent
|
|
341
337
|
}) => {
|
|
342
|
-
var _options$
|
|
343
|
-
return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$
|
|
338
|
+
var _options$tableOptions3;
|
|
339
|
+
return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableOptions3 = options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) !== null && _options$tableOptions3 !== void 0 ? _options$tableOptions3 : false);
|
|
344
340
|
}
|
|
345
341
|
}, {
|
|
346
342
|
name: 'tableAnalyticsPlugin',
|
|
@@ -507,7 +503,7 @@ const tablesPlugin = ({
|
|
|
507
503
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
508
504
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
509
505
|
api: api
|
|
510
|
-
}), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.
|
|
506
|
+
}), ((options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) || (options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) && options.isCommentEditor) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/React.createElement(FloatingToolbarLabel, {
|
|
511
507
|
target: resizingTableRef,
|
|
512
508
|
content: /*#__PURE__*/React.createElement(FullWidthDisplay, null),
|
|
513
509
|
alignX: 'center',
|
|
@@ -537,11 +533,11 @@ const tablesPlugin = ({
|
|
|
537
533
|
const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
538
534
|
const tableNode = createTableWithWidth({
|
|
539
535
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
540
|
-
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.
|
|
536
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
541
537
|
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
|
|
542
538
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
543
539
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
544
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.
|
|
540
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing
|
|
545
541
|
})(state.schema);
|
|
546
542
|
let {
|
|
547
543
|
tr
|
|
@@ -7,7 +7,7 @@ import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSele
|
|
|
7
7
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
8
8
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
|
|
9
9
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
10
|
-
export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl,
|
|
10
|
+
export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, isTableResizingEnabled) {
|
|
11
11
|
var _pluginInjectionApi$a;
|
|
12
12
|
const list = {};
|
|
13
13
|
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
@@ -20,12 +20,12 @@ export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProvide
|
|
|
20
20
|
// Add row/column shortcuts
|
|
21
21
|
bindKeymapWithCommand(addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
22
22
|
bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
23
|
-
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(api, isTableScalingEnabled,
|
|
24
|
-
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(api, isTableScalingEnabled,
|
|
23
|
+
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
24
|
+
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
25
|
bindKeymapWithCommand(addRowBeforeVO.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
26
26
|
bindKeymapWithCommand(addRowAfterVO.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
27
|
-
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(api, isTableScalingEnabled,
|
|
28
|
-
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(api, isTableScalingEnabled,
|
|
27
|
+
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
28
|
+
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
29
29
|
if (dragAndDropEnabled) {
|
|
30
30
|
// Move row/column shortcuts
|
|
31
31
|
/**
|
|
@@ -19,7 +19,7 @@ import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '.
|
|
|
19
19
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
20
20
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
21
21
|
import { pluginKey } from './plugin-key';
|
|
22
|
-
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl,
|
|
22
|
+
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor) => {
|
|
23
23
|
var _accessibilityUtils;
|
|
24
24
|
const state = createPluginState(dispatch, {
|
|
25
25
|
pluginConfig,
|
|
@@ -28,7 +28,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
28
28
|
insertRowButtonIndex: undefined,
|
|
29
29
|
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
30
30
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
31
|
-
isTableResizingEnabled: tableResizingEnabled,
|
|
32
31
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
33
32
|
isHeaderColumnEnabled: false,
|
|
34
33
|
isDragAndDropEnabled: dragAndDropEnabled,
|
|
@@ -168,7 +167,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
168
167
|
|
|
169
168
|
// fix for when pasting a table with default layout into comment editor
|
|
170
169
|
// table lose width and expand to full width
|
|
171
|
-
if (!insideTable(editorState) && isCommentEditor &&
|
|
170
|
+
if (!insideTable(editorState) && isCommentEditor && pluginConfig.allowTableAlignment && isTableScalingEnabled) {
|
|
172
171
|
slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
|
|
173
172
|
}
|
|
174
173
|
slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
|
|
@@ -262,7 +261,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
262
261
|
getEditorFeatureFlags,
|
|
263
262
|
dispatchAnalyticsEvent,
|
|
264
263
|
pluginInjectionApi,
|
|
265
|
-
isTableAlignmentEnabled,
|
|
266
264
|
isCommentEditor,
|
|
267
265
|
isChromelessEditor
|
|
268
266
|
}),
|
|
@@ -283,7 +281,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
283
281
|
blur: handleBlur,
|
|
284
282
|
mousedown: withCellTracking(handleMouseDown),
|
|
285
283
|
mouseleave: handleMouseLeave,
|
|
286
|
-
mousemove: whenTableInFocus(handleMouseMove(nodeViewPortalProviderAPI)),
|
|
284
|
+
mousemove: whenTableInFocus(handleMouseMove(nodeViewPortalProviderAPI), pluginInjectionApi),
|
|
287
285
|
mouseenter: handleMouseEnter,
|
|
288
286
|
mouseup: whenTableInFocus(handleMouseUp),
|
|
289
287
|
click: withCellTracking(whenTableInFocus(handleClick))
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -124,7 +124,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
124
124
|
// with native widgets. It's enabled via a plugin config.
|
|
125
125
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
126
126
|
formatMessage
|
|
127
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false,
|
|
127
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
128
128
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
129
129
|
const {
|
|
130
130
|
top,
|
|
@@ -142,7 +142,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
142
142
|
const selectionRect = getClosestSelectionRect(state);
|
|
143
143
|
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
144
144
|
if (index) {
|
|
145
|
-
insertColumnWithAnalytics(api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
145
|
+
insertColumnWithAnalytics(api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
146
146
|
}
|
|
147
147
|
return true;
|
|
148
148
|
},
|
|
@@ -366,9 +366,8 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
366
366
|
return element;
|
|
367
367
|
};
|
|
368
368
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
369
|
-
const alignmentMenu =
|
|
370
|
-
const
|
|
371
|
-
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
369
|
+
const alignmentMenu = config.allowTableAlignment && !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) : [];
|
|
370
|
+
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
372
371
|
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
373
372
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
374
373
|
|
|
@@ -445,12 +444,12 @@ const separator = hidden => {
|
|
|
445
444
|
};
|
|
446
445
|
const getCellItems = (state, view, {
|
|
447
446
|
formatMessage
|
|
448
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false,
|
|
447
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
449
448
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
450
449
|
if (initialSelectionRect) {
|
|
451
450
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
452
451
|
formatMessage
|
|
453
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
452
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor);
|
|
454
453
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
455
454
|
}
|
|
456
455
|
return [];
|
|
@@ -512,7 +512,6 @@ export class ContextualMenu extends Component {
|
|
|
512
512
|
isTableScalingEnabled = false
|
|
513
513
|
} = getPluginState(state);
|
|
514
514
|
const {
|
|
515
|
-
tableDuplicateCellColouring = false,
|
|
516
515
|
tableWithFixedColumnWidthsOption = false
|
|
517
516
|
} = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
|
|
518
517
|
// context menu opened by keyboard and any item except 'background' activated
|
|
@@ -562,11 +561,11 @@ export class ContextualMenu extends Component {
|
|
|
562
561
|
this.toggleOpen();
|
|
563
562
|
break;
|
|
564
563
|
case 'insert_column':
|
|
565
|
-
insertColumnWithAnalytics(this.props.api, editorAnalyticsAPI, isTableScalingEnabled,
|
|
564
|
+
insertColumnWithAnalytics(this.props.api, editorAnalyticsAPI, isTableScalingEnabled, tableWithFixedColumnWidthsOption, shouldUseIncreasedScalingPercent, isCommentEditor)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
566
565
|
this.toggleOpen();
|
|
567
566
|
break;
|
|
568
567
|
case 'insert_row':
|
|
569
|
-
insertRowWithAnalytics(editorAnalyticsAPI
|
|
568
|
+
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, {
|
|
570
569
|
index: selectionRect.bottom,
|
|
571
570
|
moveCursorToInsertedRow: true
|
|
572
571
|
})(state, dispatch);
|
|
@@ -196,7 +196,6 @@ const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
196
196
|
scrollableElement,
|
|
197
197
|
boundariesElement,
|
|
198
198
|
isTableScalingEnabled,
|
|
199
|
-
tableDuplicateCellColouring,
|
|
200
199
|
shouldUseIncreasedScalingPercent,
|
|
201
200
|
isTableFixedColumnWidthsOptionEnabled,
|
|
202
201
|
ariaNotifyPlugin,
|
|
@@ -218,7 +217,7 @@ const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
218
217
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
219
218
|
const hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
|
|
220
219
|
const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
|
|
221
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled,
|
|
220
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, ariaNotifyPlugin, isCommentEditor);
|
|
222
221
|
const {
|
|
223
222
|
menuItems,
|
|
224
223
|
menuCallback
|