@atlaskit/editor-plugin-table 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +14 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +14 -1
- package/dist/es2019/plugins/table/nodeviews/table.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +14 -1
- package/dist/esm/plugins/table/nodeviews/table.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -0
- package/package.json +1 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +19 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +0 -1
- package/src/plugins/table/nodeviews/table.tsx +6 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +20 -12
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,7 @@ var _commands = require("../commands");
|
|
|
25
25
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
26
26
|
var _stickyHeaders = require("../pm-plugins/sticky-headers");
|
|
27
27
|
var _utils3 = require("../pm-plugins/table-resizing/utils");
|
|
28
|
+
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
28
29
|
var _dom = require("../pm-plugins/table-resizing/utils/dom");
|
|
29
30
|
var _types = require("../types");
|
|
30
31
|
var _TableFloatingControls = _interopRequireDefault(require("../ui/TableFloatingControls"));
|
|
@@ -140,9 +141,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
140
141
|
if (shouldScaleTable) {
|
|
141
142
|
_this.scaleTable({
|
|
142
143
|
parentWidth: parentWidth,
|
|
143
|
-
layoutChanged: layoutChanged
|
|
144
|
+
layoutChanged: layoutChanged,
|
|
145
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
144
146
|
});
|
|
145
147
|
}
|
|
148
|
+
|
|
149
|
+
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
150
|
+
if (options !== null && options !== void 0 && options.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
151
|
+
if (!(0, _colgroup.hasTableBeenResized)(prevNode)) {
|
|
152
|
+
_this.scaleTable({
|
|
153
|
+
parentWidth: parentWidth,
|
|
154
|
+
layoutChanged: layoutChanged,
|
|
155
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
146
159
|
_this.updateParentWidth(parentWidth);
|
|
147
160
|
}
|
|
148
161
|
_this.node = node;
|
|
@@ -20,6 +20,7 @@ var _prosemirrorModel = require("prosemirror-model");
|
|
|
20
20
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
21
21
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
22
22
|
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
23
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
23
24
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
24
25
|
var _createPluginConfig = require("../create-plugin-config");
|
|
25
26
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
@@ -36,7 +37,7 @@ var tableAttributes = function tableAttributes(node, options, state, pos) {
|
|
|
36
37
|
// this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
|
|
37
38
|
// support screen size adjustments
|
|
38
39
|
var shouldHaveInlineWidth = (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) && !(0, _utils2.isTableNested)(state, pos);
|
|
39
|
-
var style = shouldHaveInlineWidth ? "width: ".concat((0, _nodeWidth.getTableContainerWidth)(node), "px") : undefined;
|
|
40
|
+
var style = shouldHaveInlineWidth ? "width: ".concat(node.attrs.isNumberColumnEnabled ? (0, _nodeWidth.getTableContainerWidth)(node) - _editorSharedStyles.akEditorTableNumberColumnWidth : (0, _nodeWidth.getTableContainerWidth)(node), "px") : undefined;
|
|
40
41
|
return {
|
|
41
42
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
42
43
|
'data-layout': node.attrs.layout,
|
|
@@ -8,6 +8,7 @@ exports.scaleTable = exports.scale = exports.previewScaleTable = void 0;
|
|
|
8
8
|
exports.scaleTableTo = scaleTableTo;
|
|
9
9
|
exports.scaleWithParent = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
11
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
13
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
14
|
var _transforms = require("../../../transforms");
|
|
@@ -32,12 +33,13 @@ var scale = function scale(tableRef, options, domAtPos) {
|
|
|
32
33
|
prevNode = options.prevNode,
|
|
33
34
|
start = options.start,
|
|
34
35
|
isBreakoutEnabled = options.isBreakoutEnabled,
|
|
35
|
-
layoutChanged = options.layoutChanged
|
|
36
|
-
|
|
36
|
+
layoutChanged = options.layoutChanged,
|
|
37
|
+
isTableResizingEnabled = options.isTableResizingEnabled;
|
|
38
|
+
var maxSize = isTableResizingEnabled ? (0, _nodeWidth.getTableContainerWidth)(node) : (0, _misc.getLayoutSize)(node.attrs.layout, containerWidth, {
|
|
37
39
|
isBreakoutEnabled: isBreakoutEnabled
|
|
38
40
|
});
|
|
39
41
|
var prevTableWidth = (0, _utils.getTableWidth)(prevNode);
|
|
40
|
-
var previousMaxSize = (0, _misc.getLayoutSize)(prevNode.attrs.layout, previousContainerWidth, {
|
|
42
|
+
var previousMaxSize = isTableResizingEnabled ? (0, _nodeWidth.getTableContainerWidth)(node) : (0, _misc.getLayoutSize)(prevNode.attrs.layout, previousContainerWidth, {
|
|
41
43
|
isBreakoutEnabled: isBreakoutEnabled
|
|
42
44
|
});
|
|
43
45
|
var newWidth = maxSize;
|
|
@@ -116,7 +118,9 @@ var previewScaleTable = function previewScaleTable(tableRef, options, domAtPos)
|
|
|
116
118
|
return;
|
|
117
119
|
}
|
|
118
120
|
if (parentWidth) {
|
|
119
|
-
|
|
121
|
+
var isNumberColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
122
|
+
var width = isNumberColumnEnabled ? parentWidth - _editorSharedStyles.akEditorTableNumberColumnWidth : parentWidth;
|
|
123
|
+
tableRef.style.width = "".concat(width, "px");
|
|
120
124
|
}
|
|
121
125
|
if (!(0, _colgroup.hasTableBeenResized)(node)) {
|
|
122
126
|
return;
|
|
@@ -138,7 +142,6 @@ var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
|
138
142
|
start = options.start,
|
|
139
143
|
parentWidth = options.parentWidth,
|
|
140
144
|
layoutChanged = options.layoutChanged;
|
|
141
|
-
|
|
142
145
|
// If a table has not been resized yet, columns should be auto.
|
|
143
146
|
if ((0, _colgroup.hasTableBeenResized)(node) === false) {
|
|
144
147
|
// If its not a re-sized table, we still want to re-create cols
|
package/dist/cjs/version.json
CHANGED
|
@@ -12,6 +12,7 @@ import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
|
12
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
13
|
import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
|
|
14
14
|
import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
15
|
+
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
15
16
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
16
17
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
17
18
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
@@ -125,9 +126,21 @@ class TableComponent extends React.Component {
|
|
|
125
126
|
if (shouldScaleTable) {
|
|
126
127
|
this.scaleTable({
|
|
127
128
|
parentWidth,
|
|
128
|
-
layoutChanged
|
|
129
|
+
layoutChanged,
|
|
130
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
129
131
|
});
|
|
130
132
|
}
|
|
133
|
+
|
|
134
|
+
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
135
|
+
if (options !== null && options !== void 0 && options.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
136
|
+
if (!hasTableBeenResized(prevNode)) {
|
|
137
|
+
this.scaleTable({
|
|
138
|
+
parentWidth,
|
|
139
|
+
layoutChanged,
|
|
140
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
131
144
|
this.updateParentWidth(parentWidth);
|
|
132
145
|
}
|
|
133
146
|
this.node = node;
|
|
@@ -4,6 +4,7 @@ import { DOMSerializer } from 'prosemirror-model';
|
|
|
4
4
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
5
5
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
6
6
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
7
|
+
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
9
|
import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
9
10
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -18,7 +19,7 @@ const tableAttributes = (node, options, state, pos) => {
|
|
|
18
19
|
// this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
|
|
19
20
|
// support screen size adjustments
|
|
20
21
|
const shouldHaveInlineWidth = (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) && !isTableNested(state, pos);
|
|
21
|
-
let style = shouldHaveInlineWidth ? `width: ${getTableContainerWidth(node)}px` : undefined;
|
|
22
|
+
let style = shouldHaveInlineWidth ? `width: ${node.attrs.isNumberColumnEnabled ? getTableContainerWidth(node) - akEditorTableNumberColumnWidth : getTableContainerWidth(node)}px` : undefined;
|
|
22
23
|
return {
|
|
23
24
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
24
25
|
'data-layout': node.attrs.layout,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
1
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
3
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
3
4
|
import { updateColumnWidths } from '../../../transforms';
|
|
@@ -21,13 +22,14 @@ export const scale = (tableRef, options, domAtPos) => {
|
|
|
21
22
|
prevNode,
|
|
22
23
|
start,
|
|
23
24
|
isBreakoutEnabled,
|
|
24
|
-
layoutChanged
|
|
25
|
+
layoutChanged,
|
|
26
|
+
isTableResizingEnabled
|
|
25
27
|
} = options;
|
|
26
|
-
const maxSize = getLayoutSize(node.attrs.layout, containerWidth, {
|
|
28
|
+
const maxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(node.attrs.layout, containerWidth, {
|
|
27
29
|
isBreakoutEnabled
|
|
28
30
|
});
|
|
29
31
|
const prevTableWidth = getTableWidth(prevNode);
|
|
30
|
-
const previousMaxSize = getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
32
|
+
const previousMaxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
31
33
|
isBreakoutEnabled
|
|
32
34
|
});
|
|
33
35
|
let newWidth = maxSize;
|
|
@@ -110,7 +112,9 @@ export const previewScaleTable = (tableRef, options, domAtPos) => {
|
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
if (parentWidth) {
|
|
113
|
-
|
|
115
|
+
const isNumberColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
116
|
+
const width = isNumberColumnEnabled ? parentWidth - akEditorTableNumberColumnWidth : parentWidth;
|
|
117
|
+
tableRef.style.width = `${width}px`;
|
|
114
118
|
}
|
|
115
119
|
if (!hasTableBeenResized(node)) {
|
|
116
120
|
return;
|
|
@@ -132,7 +136,6 @@ export const scaleTable = (tableRef, options, domAtPos) => tr => {
|
|
|
132
136
|
parentWidth,
|
|
133
137
|
layoutChanged
|
|
134
138
|
} = options;
|
|
135
|
-
|
|
136
139
|
// If a table has not been resized yet, columns should be auto.
|
|
137
140
|
if (hasTableBeenResized(node) === false) {
|
|
138
141
|
// If its not a re-sized table, we still want to re-create cols
|
package/dist/es2019/version.json
CHANGED
|
@@ -22,6 +22,7 @@ import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
|
22
22
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
23
23
|
import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
|
|
24
24
|
import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
25
|
+
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
25
26
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
26
27
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
27
28
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
@@ -133,9 +134,21 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
133
134
|
if (shouldScaleTable) {
|
|
134
135
|
_this.scaleTable({
|
|
135
136
|
parentWidth: parentWidth,
|
|
136
|
-
layoutChanged: layoutChanged
|
|
137
|
+
layoutChanged: layoutChanged,
|
|
138
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
137
139
|
});
|
|
138
140
|
}
|
|
141
|
+
|
|
142
|
+
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
143
|
+
if (options !== null && options !== void 0 && options.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
144
|
+
if (!hasTableBeenResized(prevNode)) {
|
|
145
|
+
_this.scaleTable({
|
|
146
|
+
parentWidth: parentWidth,
|
|
147
|
+
layoutChanged: layoutChanged,
|
|
148
|
+
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
139
152
|
_this.updateParentWidth(parentWidth);
|
|
140
153
|
}
|
|
141
154
|
_this.node = node;
|
|
@@ -15,6 +15,7 @@ import { DOMSerializer } from 'prosemirror-model';
|
|
|
15
15
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
16
16
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
17
17
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
18
|
+
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
18
19
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
19
20
|
import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
20
21
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -29,7 +30,7 @@ var tableAttributes = function tableAttributes(node, options, state, pos) {
|
|
|
29
30
|
// this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
|
|
30
31
|
// support screen size adjustments
|
|
31
32
|
var shouldHaveInlineWidth = (options === null || options === void 0 ? void 0 : options.isTableResizingEnabled) && !isTableNested(state, pos);
|
|
32
|
-
var style = shouldHaveInlineWidth ? "width: ".concat(getTableContainerWidth(node), "px") : undefined;
|
|
33
|
+
var style = shouldHaveInlineWidth ? "width: ".concat(node.attrs.isNumberColumnEnabled ? getTableContainerWidth(node) - akEditorTableNumberColumnWidth : getTableContainerWidth(node), "px") : undefined;
|
|
33
34
|
return {
|
|
34
35
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
35
36
|
'data-layout': node.attrs.layout,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
5
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
6
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
6
7
|
import { updateColumnWidths } from '../../../transforms';
|
|
@@ -23,12 +24,13 @@ export var scale = function scale(tableRef, options, domAtPos) {
|
|
|
23
24
|
prevNode = options.prevNode,
|
|
24
25
|
start = options.start,
|
|
25
26
|
isBreakoutEnabled = options.isBreakoutEnabled,
|
|
26
|
-
layoutChanged = options.layoutChanged
|
|
27
|
-
|
|
27
|
+
layoutChanged = options.layoutChanged,
|
|
28
|
+
isTableResizingEnabled = options.isTableResizingEnabled;
|
|
29
|
+
var maxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(node.attrs.layout, containerWidth, {
|
|
28
30
|
isBreakoutEnabled: isBreakoutEnabled
|
|
29
31
|
});
|
|
30
32
|
var prevTableWidth = getTableWidth(prevNode);
|
|
31
|
-
var previousMaxSize = getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
33
|
+
var previousMaxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
32
34
|
isBreakoutEnabled: isBreakoutEnabled
|
|
33
35
|
});
|
|
34
36
|
var newWidth = maxSize;
|
|
@@ -105,7 +107,9 @@ export var previewScaleTable = function previewScaleTable(tableRef, options, dom
|
|
|
105
107
|
return;
|
|
106
108
|
}
|
|
107
109
|
if (parentWidth) {
|
|
108
|
-
|
|
110
|
+
var isNumberColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
111
|
+
var width = isNumberColumnEnabled ? parentWidth - akEditorTableNumberColumnWidth : parentWidth;
|
|
112
|
+
tableRef.style.width = "".concat(width, "px");
|
|
109
113
|
}
|
|
110
114
|
if (!hasTableBeenResized(node)) {
|
|
111
115
|
return;
|
|
@@ -126,7 +130,6 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos) {
|
|
|
126
130
|
start = options.start,
|
|
127
131
|
parentWidth = options.parentWidth,
|
|
128
132
|
layoutChanged = options.layoutChanged;
|
|
129
|
-
|
|
130
133
|
// If a table has not been resized yet, columns should be auto.
|
|
131
134
|
if (hasTableBeenResized(node) === false) {
|
|
132
135
|
// If its not a re-sized table, we still want to re-create cols
|
package/dist/esm/version.json
CHANGED
|
@@ -12,6 +12,7 @@ export interface ScaleOptions {
|
|
|
12
12
|
layoutChanged?: boolean;
|
|
13
13
|
isBreakoutEnabled?: boolean;
|
|
14
14
|
isFullWidthModeEnabled?: boolean;
|
|
15
|
+
isTableResizingEnabled?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const scale: (tableRef: HTMLTableElement, options: ScaleOptions, domAtPos: DomAtPos) => ResizeState | undefined;
|
|
17
18
|
export declare const scaleWithParent: (tableRef: HTMLTableElement, parentWidth: number, table: PMNode, start: number, domAtPos: DomAtPos) => ResizeState;
|
|
@@ -12,6 +12,7 @@ export interface ScaleOptions {
|
|
|
12
12
|
layoutChanged?: boolean;
|
|
13
13
|
isBreakoutEnabled?: boolean;
|
|
14
14
|
isFullWidthModeEnabled?: boolean;
|
|
15
|
+
isTableResizingEnabled?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const scale: (tableRef: HTMLTableElement, options: ScaleOptions, domAtPos: DomAtPos) => ResizeState | undefined;
|
|
17
18
|
export declare const scaleWithParent: (tableRef: HTMLTableElement, parentWidth: number, table: PMNode, start: number, domAtPos: DomAtPos) => ResizeState;
|
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
insertColgroupFromNode as recreateResizeColsByNode,
|
|
32
32
|
scaleTable,
|
|
33
33
|
} from '../pm-plugins/table-resizing/utils';
|
|
34
|
+
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
34
35
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
35
36
|
import {
|
|
36
37
|
TableCssClassName as ClassName,
|
|
@@ -562,8 +563,24 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
562
563
|
|
|
563
564
|
// If column has been inserted/deleted avoid multi dispatch
|
|
564
565
|
if (shouldScaleTable) {
|
|
565
|
-
this.scaleTable({
|
|
566
|
+
this.scaleTable({
|
|
567
|
+
parentWidth,
|
|
568
|
+
layoutChanged,
|
|
569
|
+
isTableResizingEnabled: options?.isTableResizingEnabled,
|
|
570
|
+
});
|
|
566
571
|
}
|
|
572
|
+
|
|
573
|
+
// only when table resizing is enabled and toggle numbered column to run scaleTable
|
|
574
|
+
if (options?.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
575
|
+
if (!hasTableBeenResized(prevNode)) {
|
|
576
|
+
this.scaleTable({
|
|
577
|
+
parentWidth,
|
|
578
|
+
layoutChanged,
|
|
579
|
+
isTableResizingEnabled: options?.isTableResizingEnabled,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
567
584
|
this.updateParentWidth(parentWidth);
|
|
568
585
|
}
|
|
569
586
|
|
|
@@ -575,6 +592,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
575
592
|
private scaleTable = (scaleOptions: {
|
|
576
593
|
layoutChanged: boolean;
|
|
577
594
|
parentWidth?: number;
|
|
595
|
+
isTableResizingEnabled?: boolean;
|
|
578
596
|
}) => {
|
|
579
597
|
const { view, getNode, getPos, containerWidth, options } = this.props;
|
|
580
598
|
const node = getNode();
|
|
@@ -38,7 +38,6 @@ import { TABLE_HIGHLIGHT_GAP, TABLE_SNAP_GAP } from '../ui/consts';
|
|
|
38
38
|
import { getTableWidth } from '../utils';
|
|
39
39
|
import { defaultGuidelines, defaultGuidelineWidths } from '../utils/guidelines';
|
|
40
40
|
import { findClosestSnap } from '../utils/snapping';
|
|
41
|
-
|
|
42
41
|
interface TableResizerProps {
|
|
43
42
|
width: number;
|
|
44
43
|
maxWidth: number;
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
getPosHandlerNode,
|
|
21
21
|
} from '@atlaskit/editor-common/types';
|
|
22
22
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
23
|
+
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
23
24
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
24
25
|
|
|
25
26
|
import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
@@ -49,7 +50,11 @@ const tableAttributes = (
|
|
|
49
50
|
options?.isTableResizingEnabled && !isTableNested(state, pos);
|
|
50
51
|
|
|
51
52
|
let style = shouldHaveInlineWidth
|
|
52
|
-
? `width: ${
|
|
53
|
+
? `width: ${
|
|
54
|
+
node.attrs.isNumberColumnEnabled
|
|
55
|
+
? getTableContainerWidth(node) - akEditorTableNumberColumnWidth
|
|
56
|
+
: getTableContainerWidth(node)
|
|
57
|
+
}px`
|
|
53
58
|
: undefined;
|
|
54
59
|
|
|
55
60
|
return {
|
|
@@ -2,6 +2,7 @@ import { Node as PMNode } from 'prosemirror-model';
|
|
|
2
2
|
import { Transaction } from 'prosemirror-state';
|
|
3
3
|
import type { DomAtPos } from 'prosemirror-utils';
|
|
4
4
|
|
|
5
|
+
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
5
6
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
8
|
|
|
@@ -29,6 +30,7 @@ export interface ScaleOptions {
|
|
|
29
30
|
layoutChanged?: boolean;
|
|
30
31
|
isBreakoutEnabled?: boolean;
|
|
31
32
|
isFullWidthModeEnabled?: boolean;
|
|
33
|
+
isTableResizingEnabled?: boolean;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
// Base function to trigger the actual scale on a table node.
|
|
@@ -51,24 +53,27 @@ export const scale = (
|
|
|
51
53
|
start,
|
|
52
54
|
isBreakoutEnabled,
|
|
53
55
|
layoutChanged,
|
|
56
|
+
isTableResizingEnabled,
|
|
54
57
|
} = options;
|
|
55
58
|
|
|
56
|
-
const maxSize =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
const maxSize = isTableResizingEnabled
|
|
60
|
+
? getTableContainerWidth(node)
|
|
61
|
+
: getLayoutSize(node.attrs.layout, containerWidth, {
|
|
62
|
+
isBreakoutEnabled,
|
|
63
|
+
});
|
|
64
|
+
|
|
59
65
|
const prevTableWidth = getTableWidth(prevNode);
|
|
60
|
-
const previousMaxSize =
|
|
61
|
-
|
|
62
|
-
previousContainerWidth,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
);
|
|
66
|
+
const previousMaxSize = isTableResizingEnabled
|
|
67
|
+
? getTableContainerWidth(node)
|
|
68
|
+
: getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
69
|
+
isBreakoutEnabled,
|
|
70
|
+
});
|
|
67
71
|
|
|
68
72
|
let newWidth = maxSize;
|
|
69
73
|
|
|
70
74
|
// adjust table width if layout is updated
|
|
71
75
|
const hasOverflow = prevTableWidth > previousMaxSize;
|
|
76
|
+
|
|
72
77
|
if (layoutChanged && hasOverflow) {
|
|
73
78
|
// No keep overflow if the old content can be in the new size
|
|
74
79
|
const canFitInNewSize = prevTableWidth < maxSize;
|
|
@@ -157,7 +162,11 @@ export const previewScaleTable = (
|
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
if (parentWidth) {
|
|
160
|
-
|
|
165
|
+
const isNumberColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
166
|
+
const width = isNumberColumnEnabled
|
|
167
|
+
? parentWidth - akEditorTableNumberColumnWidth
|
|
168
|
+
: parentWidth;
|
|
169
|
+
tableRef.style.width = `${width}px`;
|
|
161
170
|
}
|
|
162
171
|
|
|
163
172
|
if (!hasTableBeenResized(node)) {
|
|
@@ -186,7 +195,6 @@ export const scaleTable =
|
|
|
186
195
|
}
|
|
187
196
|
|
|
188
197
|
const { node, start, parentWidth, layoutChanged } = options;
|
|
189
|
-
|
|
190
198
|
// If a table has not been resized yet, columns should be auto.
|
|
191
199
|
if (hasTableBeenResized(node) === false) {
|
|
192
200
|
// If its not a re-sized table, we still want to re-create cols
|