@atlaskit/editor-plugin-table 7.31.3 → 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 +83 -0
- 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 +21 -26
- package/dist/cjs/pm-plugins/main.js +3 -5
- package/dist/cjs/toolbar.js +1 -1
- 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 +21 -24
- package/dist/es2019/pm-plugins/main.js +3 -5
- package/dist/es2019/toolbar.js +1 -1
- 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 +21 -26
- package/dist/esm/pm-plugins/main.js +3 -5
- package/dist/esm/toolbar.js +1 -1
- 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/main.d.ts +1 -1
- package/dist/types/types.d.ts +2 -1
- 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/main.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/package.json +2 -2
- 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 -31
- package/src/pm-plugins/main.ts +2 -6
- package/src/toolbar.tsx +1 -1
- package/src/types.ts +2 -1
|
@@ -414,10 +414,21 @@ export const isTableInFocus = view => {
|
|
|
414
414
|
var _getPluginState, _getResizePluginState;
|
|
415
415
|
return !!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
416
416
|
};
|
|
417
|
-
export const whenTableInFocus = eventHandler => (view, mouseEvent) => {
|
|
417
|
+
export const whenTableInFocus = (eventHandler, pluginInjectionApi) => (view, mouseEvent) => {
|
|
418
|
+
var _pluginInjectionApi$e, _pluginInjectionApi$e2;
|
|
418
419
|
if (!isTableInFocus(view)) {
|
|
419
420
|
return false;
|
|
420
421
|
}
|
|
422
|
+
const isViewMode = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : (_pluginInjectionApi$e2 = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) === 'view';
|
|
423
|
+
/**
|
|
424
|
+
* Table cannot be in focus if we are in view mode.
|
|
425
|
+
* This will prevent an infinite flow of adding and removing
|
|
426
|
+
* resize handle decorations in view mode that causes unpredictable
|
|
427
|
+
* selections.
|
|
428
|
+
*/
|
|
429
|
+
if (isViewMode) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
421
432
|
return eventHandler(view, mouseEvent);
|
|
422
433
|
};
|
|
423
434
|
const trackCellLocation = (view, mouseEvent) => {
|
|
@@ -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
|
@@ -107,11 +107,11 @@ const tablesPlugin = ({
|
|
|
107
107
|
var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
|
|
108
108
|
const node = createTableWithWidth({
|
|
109
109
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
110
|
-
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.
|
|
110
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
111
111
|
isFullWidthModeEnabled: options === null || options === void 0 ? void 0 : options.fullWidthEnabled,
|
|
112
112
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
113
113
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
114
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.
|
|
114
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing
|
|
115
115
|
})(state.schema);
|
|
116
116
|
|
|
117
117
|
// If the cursor is inside a table
|
|
@@ -147,7 +147,7 @@ const tablesPlugin = ({
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
commands: {
|
|
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.
|
|
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)
|
|
151
151
|
},
|
|
152
152
|
nodes() {
|
|
153
153
|
const {
|
|
@@ -158,7 +158,7 @@ const tablesPlugin = ({
|
|
|
158
158
|
name: 'table',
|
|
159
159
|
node: tableNodeSpecWithFixedToDOM({
|
|
160
160
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
161
|
-
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.
|
|
161
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
162
162
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
163
163
|
isNestingSupported
|
|
164
164
|
})
|
|
@@ -175,7 +175,7 @@ const tablesPlugin = ({
|
|
|
175
175
|
name: 'table',
|
|
176
176
|
node: tableNodeSpecWithFixedToDOM({
|
|
177
177
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
178
|
-
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.
|
|
178
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
179
179
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
180
180
|
isNestingSupported
|
|
181
181
|
})
|
|
@@ -204,16 +204,14 @@ const tablesPlugin = ({
|
|
|
204
204
|
const {
|
|
205
205
|
fullWidthEnabled,
|
|
206
206
|
wasFullWidthEnabled,
|
|
207
|
-
tableResizingEnabled,
|
|
208
207
|
tableOptions,
|
|
209
208
|
getEditorFeatureFlags,
|
|
210
209
|
dragAndDropEnabled,
|
|
211
210
|
isTableScalingEnabled,
|
|
212
|
-
isTableAlignmentEnabled,
|
|
213
211
|
isCommentEditor,
|
|
214
212
|
isChromelessEditor
|
|
215
213
|
} = options || {};
|
|
216
|
-
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);
|
|
217
215
|
}
|
|
218
216
|
}, {
|
|
219
217
|
name: 'tablePMColResizing',
|
|
@@ -226,15 +224,15 @@ const tablesPlugin = ({
|
|
|
226
224
|
tableOptions,
|
|
227
225
|
getEditorFeatureFlags,
|
|
228
226
|
isTableScalingEnabled,
|
|
229
|
-
isNewColumnResizingEnabled
|
|
230
|
-
isTableAlignmentEnabled
|
|
227
|
+
isNewColumnResizingEnabled
|
|
231
228
|
} = options || {};
|
|
232
229
|
const {
|
|
233
|
-
allowColumnResizing
|
|
230
|
+
allowColumnResizing,
|
|
231
|
+
allowTableAlignment
|
|
234
232
|
} = pluginConfig(tableOptions);
|
|
235
233
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
236
234
|
lastColumnResizable: !fullWidthEnabled
|
|
237
|
-
}, 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;
|
|
238
236
|
}
|
|
239
237
|
}, {
|
|
240
238
|
name: 'tableEditing',
|
|
@@ -251,13 +249,12 @@ const tablesPlugin = ({
|
|
|
251
249
|
const {
|
|
252
250
|
dragAndDropEnabled,
|
|
253
251
|
isTableScalingEnabled = false,
|
|
254
|
-
isTableAlignmentEnabled = false,
|
|
255
252
|
fullWidthEnabled = false,
|
|
256
253
|
isCommentEditor = false,
|
|
257
254
|
isChromelessEditor = false,
|
|
258
|
-
|
|
255
|
+
tableOptions
|
|
259
256
|
} = options || {};
|
|
260
|
-
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);
|
|
261
258
|
}
|
|
262
259
|
}, {
|
|
263
260
|
name: 'tableSelectionKeymap',
|
|
@@ -319,16 +316,16 @@ const tablesPlugin = ({
|
|
|
319
316
|
dispatchAnalyticsEvent,
|
|
320
317
|
dispatch
|
|
321
318
|
}) => {
|
|
322
|
-
var _options$fullWidthEna, _options$isTableScali, _options$
|
|
323
|
-
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;
|
|
324
321
|
}
|
|
325
322
|
}, {
|
|
326
323
|
name: 'tableWidthInCommentFix',
|
|
327
324
|
plugin: ({
|
|
328
325
|
dispatch
|
|
329
326
|
}) => {
|
|
330
|
-
var _options$
|
|
331
|
-
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;
|
|
332
329
|
}
|
|
333
330
|
},
|
|
334
331
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -338,8 +335,8 @@ const tablesPlugin = ({
|
|
|
338
335
|
dispatch,
|
|
339
336
|
dispatchAnalyticsEvent
|
|
340
337
|
}) => {
|
|
341
|
-
var _options$
|
|
342
|
-
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);
|
|
343
340
|
}
|
|
344
341
|
}, {
|
|
345
342
|
name: 'tableAnalyticsPlugin',
|
|
@@ -506,7 +503,7 @@ const tablesPlugin = ({
|
|
|
506
503
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
507
504
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
508
505
|
api: api
|
|
509
|
-
}), ((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, {
|
|
510
507
|
target: resizingTableRef,
|
|
511
508
|
content: /*#__PURE__*/React.createElement(FullWidthDisplay, null),
|
|
512
509
|
alignX: 'center',
|
|
@@ -536,11 +533,11 @@ const tablesPlugin = ({
|
|
|
536
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();
|
|
537
534
|
const tableNode = createTableWithWidth({
|
|
538
535
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
539
|
-
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.
|
|
536
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
540
537
|
isFullWidthModeEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled,
|
|
541
538
|
isCommentEditor: options === null || options === void 0 ? void 0 : options.isCommentEditor,
|
|
542
539
|
isChromelessEditor: options === null || options === void 0 ? void 0 : options.isChromelessEditor,
|
|
543
|
-
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.
|
|
540
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing
|
|
544
541
|
})(state.schema);
|
|
545
542
|
let {
|
|
546
543
|
tr
|
|
@@ -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
|
@@ -366,7 +366,7 @@ 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 =
|
|
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
370
|
const cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
|
|
371
371
|
const columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor) : [];
|
|
372
372
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
@@ -398,11 +398,22 @@ export var isTableInFocus = function isTableInFocus(view) {
|
|
|
398
398
|
var _getPluginState10, _getResizePluginState;
|
|
399
399
|
return !!((_getPluginState10 = getPluginState(view.state)) !== null && _getPluginState10 !== void 0 && _getPluginState10.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
400
400
|
};
|
|
401
|
-
export var whenTableInFocus = function whenTableInFocus(eventHandler) {
|
|
401
|
+
export var whenTableInFocus = function whenTableInFocus(eventHandler, pluginInjectionApi) {
|
|
402
402
|
return function (view, mouseEvent) {
|
|
403
|
+
var _pluginInjectionApi$e;
|
|
403
404
|
if (!isTableInFocus(view)) {
|
|
404
405
|
return false;
|
|
405
406
|
}
|
|
407
|
+
var isViewMode = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) === 'view';
|
|
408
|
+
/**
|
|
409
|
+
* Table cannot be in focus if we are in view mode.
|
|
410
|
+
* This will prevent an infinite flow of adding and removing
|
|
411
|
+
* resize handle decorations in view mode that causes unpredictable
|
|
412
|
+
* selections.
|
|
413
|
+
*/
|
|
414
|
+
if (isViewMode) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
406
417
|
return eventHandler(view, mouseEvent);
|
|
407
418
|
};
|
|
408
419
|
};
|