@atlaskit/editor-plugin-table 22.4.14 → 22.4.15
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 +8 -0
- package/dist/cjs/nodeviews/TableComponent.js +2 -2
- package/dist/cjs/nodeviews/table.js +2 -2
- package/dist/cjs/nodeviews/toDOM.js +2 -2
- package/dist/cjs/pm-plugins/main.js +4 -3
- package/dist/cjs/pm-plugins/table-width.js +2 -2
- package/dist/cjs/pm-plugins/transforms/content-mode.js +3 -2
- package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +70 -0
- package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +41 -0
- package/dist/cjs/pm-plugins/utils/tableMode/is-content-mode-supported.js +12 -0
- package/dist/cjs/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +113 -0
- package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/constants.js +10 -0
- package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +83 -0
- package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +56 -0
- package/dist/cjs/ui/toolbar.js +4 -3
- package/dist/es2019/nodeviews/TableComponent.js +1 -1
- package/dist/es2019/nodeviews/table.js +1 -1
- package/dist/es2019/nodeviews/toDOM.js +1 -1
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/es2019/pm-plugins/table-width.js +1 -1
- package/dist/es2019/pm-plugins/transforms/content-mode.js +2 -1
- package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +70 -0
- package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +38 -0
- package/dist/es2019/pm-plugins/utils/tableMode/is-content-mode-supported.js +7 -0
- package/dist/es2019/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +97 -0
- package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/constants.js +4 -0
- package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +63 -0
- package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +47 -0
- package/dist/es2019/ui/toolbar.js +2 -1
- package/dist/esm/nodeviews/TableComponent.js +1 -1
- package/dist/esm/nodeviews/table.js +1 -1
- package/dist/esm/nodeviews/toDOM.js +1 -1
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/esm/pm-plugins/table-width.js +1 -1
- package/dist/esm/pm-plugins/transforms/content-mode.js +2 -1
- package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +65 -0
- package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +36 -0
- package/dist/esm/pm-plugins/utils/tableMode/is-content-mode-supported.js +6 -0
- package/dist/esm/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +107 -0
- package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/constants.js +4 -0
- package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +77 -0
- package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +49 -0
- package/dist/esm/ui/toolbar.js +2 -1
- package/dist/types/pm-plugins/transforms/content-mode.d.ts +1 -0
- package/dist/types/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.d.ts +8 -0
- package/dist/types/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.d.ts +6 -0
- package/dist/types/pm-plugins/utils/tableMode/is-content-mode-supported.d.ts +7 -0
- package/dist/types/pm-plugins/utils/tableMode/measure-table-with-auto-layout.d.ts +2 -0
- package/dist/types/pm-plugins/utils/tableMode/smart-adjust/constants.d.ts +4 -0
- package/dist/types/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.d.ts +8 -0
- package/dist/types/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.d.ts +7 -0
- package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
- package/dist/types/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/transforms/content-mode.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/is-content-mode-supported.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/measure-table-with-auto-layout.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/constants.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.d.ts +7 -0
- package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
- package/package.json +10 -7
- package/dist/cjs/pm-plugins/utils/tableMode.js +0 -162
- package/dist/es2019/pm-plugins/utils/tableMode.js +0 -158
- package/dist/esm/pm-plugins/utils/tableMode.js +0 -156
- package/dist/types/pm-plugins/utils/tableMode.d.ts +0 -26
- package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +0 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 22.4.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`122438a5ab2b7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/122438a5ab2b7) -
|
|
8
|
+
Improve fit to content table column width distribution
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 22.4.14
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -41,7 +41,7 @@ var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
|
41
41
|
var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
|
|
42
42
|
var _nodes = require("../pm-plugins/utils/nodes");
|
|
43
43
|
var _table2 = require("../pm-plugins/utils/table");
|
|
44
|
-
var
|
|
44
|
+
var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
|
|
45
45
|
var _types = require("../types");
|
|
46
46
|
var _eventHandlers = require("../ui/event-handlers");
|
|
47
47
|
var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
|
|
@@ -785,7 +785,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
785
785
|
// Deferred from setDomAttrs — remove only once colgroup is updated and table has left content mode.
|
|
786
786
|
if ((_this$table7 = this.table) !== null && _this$table7 !== void 0 && _this$table7.hasAttribute('data-initial-width-mode') && !(0, _table.isTableInContentMode)({
|
|
787
787
|
tableNode: currentTable,
|
|
788
|
-
isSupported: (0,
|
|
788
|
+
isSupported: (0, _isContentModeSupported.isContentModeSupported)({
|
|
789
789
|
allowColumnResizing: !!allowColumnResizing,
|
|
790
790
|
allowTableResizing: !!allowTableResizing,
|
|
791
791
|
isFullPageEditor: !((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor) && !((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isChromelessEditor)
|
|
@@ -27,7 +27,7 @@ var _createPluginConfig = require("../pm-plugins/create-plugin-config");
|
|
|
27
27
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
28
28
|
var _tableWidth = require("../pm-plugins/table-width");
|
|
29
29
|
var _nodes = require("../pm-plugins/utils/nodes");
|
|
30
|
-
var
|
|
30
|
+
var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
|
|
31
31
|
var _TableComponentWithSharedState = require("./TableComponentWithSharedState");
|
|
32
32
|
var _toDOM = require("./toDOM");
|
|
33
33
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
@@ -253,7 +253,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
253
253
|
// fire exposure here
|
|
254
254
|
if ((0, _table.isTableInContentMode)({
|
|
255
255
|
tableNode: node,
|
|
256
|
-
isSupported: (0,
|
|
256
|
+
isSupported: (0, _isContentModeSupported.isContentModeSupported)({
|
|
257
257
|
allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
|
|
258
258
|
allowTableResizing: !!this.reactComponentProps.allowTableResizing,
|
|
259
259
|
isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor)
|
|
@@ -17,7 +17,7 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
17
17
|
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
18
18
|
var _consts = require("../pm-plugins/table-resizing/utils/consts");
|
|
19
19
|
var _misc = require("../pm-plugins/table-resizing/utils/misc");
|
|
20
|
-
var
|
|
20
|
+
var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
|
|
21
21
|
var _tableContainerStyles = require("./table-container-styles");
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -28,7 +28,7 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
28
28
|
var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
29
29
|
var isInContentMode = (0, _table.isTableInContentMode)({
|
|
30
30
|
tableNode: node,
|
|
31
|
-
isSupported: (0,
|
|
31
|
+
isSupported: (0, _isContentModeSupported.isContentModeSupported)({
|
|
32
32
|
allowColumnResizing: config.allowColumnResizing,
|
|
33
33
|
allowTableResizing: config.tableResizingEnabled,
|
|
34
34
|
isFullPageEditor: isFullPageEditor
|
|
@@ -33,7 +33,8 @@ var _fixTables = require("./transforms/fix-tables");
|
|
|
33
33
|
var _replaceTable = require("./transforms/replace-table");
|
|
34
34
|
var _decoration = require("./utils/decoration");
|
|
35
35
|
var _paste = require("./utils/paste");
|
|
36
|
-
var
|
|
36
|
+
var _applyMeasuredWidthToAllTables = require("./utils/tableMode/apply-measured-width-to-all-tables");
|
|
37
|
+
var _isContentModeSupported = require("./utils/tableMode/is-content-mode-supported");
|
|
37
38
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
39
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
39
40
|
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) {
|
|
@@ -140,7 +141,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
140
141
|
editorViewRef = editorView;
|
|
141
142
|
var contentModeSizeTableId = null;
|
|
142
143
|
var focusListenerBinding = null;
|
|
143
|
-
if ((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' && (0,
|
|
144
|
+
if ((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' && (0, _isContentModeSupported.isContentModeSupported)({
|
|
144
145
|
allowColumnResizing: !!pluginConfig.allowColumnResizing,
|
|
145
146
|
allowTableResizing: !!pluginConfig.allowTableResizing,
|
|
146
147
|
isFullPageEditor: !isChromelessEditor && !isCommentEditor
|
|
@@ -155,7 +156,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
155
156
|
if (!editorViewRef) {
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
158
|
-
(0,
|
|
159
|
+
(0, _applyMeasuredWidthToAllTables.applyMeasuredWidthToAllTables)(editorViewRef, pluginInjectionApi);
|
|
159
160
|
});
|
|
160
161
|
},
|
|
161
162
|
options: {
|
|
@@ -16,7 +16,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
16
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
17
|
var _consts = require("./table-resizing/utils/consts");
|
|
18
18
|
var _alignment = require("./utils/alignment");
|
|
19
|
-
var
|
|
19
|
+
var _isContentModeSupported = require("./utils/tableMode/is-content-mode-supported");
|
|
20
20
|
var _excluded = ["width"];
|
|
21
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
@@ -72,7 +72,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
72
72
|
newState.doc.forEach(function (node, offset) {
|
|
73
73
|
if ((0, _table.isTableInContentMode)({
|
|
74
74
|
tableNode: node,
|
|
75
|
-
isSupported: (0,
|
|
75
|
+
isSupported: (0, _isContentModeSupported.isContentModeSupported)({
|
|
76
76
|
allowColumnResizing: true,
|
|
77
77
|
allowTableResizing: true,
|
|
78
78
|
isFullPageEditor: true
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getTableMeasurement = exports.applyTableMeasurement = void 0;
|
|
7
|
+
exports.getTableMeasurement = exports.clampToEditorMaxWidth = exports.applyTableMeasurement = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -12,10 +12,11 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
12
12
|
var _tableTransformUtils = require("./table-transform-utils");
|
|
13
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
var
|
|
15
|
+
var clampToEditorMaxWidth = exports.clampToEditorMaxWidth = function clampToEditorMaxWidth(contentWidth) {
|
|
16
16
|
var maxEditorWidth = (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _editorSharedStyles.akEditorMaxLayoutWidth : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
17
17
|
return Math.min(maxEditorWidth, contentWidth);
|
|
18
18
|
};
|
|
19
|
+
var tableWidth = clampToEditorMaxWidth;
|
|
19
20
|
var getTableMeasurement = exports.getTableMeasurement = function getTableMeasurement(tableRef) {
|
|
20
21
|
var colWidths = getRenderedColgroupColumnWidths(tableRef);
|
|
21
22
|
var totalContentWidth = colWidths.reduce(function (acc, current) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyMeasuredWidthToAllTables = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
|
+
var _table = require("@atlaskit/editor-common/table");
|
|
10
|
+
var _contentMode = require("../../transforms/content-mode");
|
|
11
|
+
/**
|
|
12
|
+
* Iterates all top-level tables in the document, and for those in content mode,
|
|
13
|
+
* measures rendered column widths and sets colwidth + table width attributes
|
|
14
|
+
* in a single batched transaction.
|
|
15
|
+
*/
|
|
16
|
+
var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTables(view, pluginInjectionApi) {
|
|
17
|
+
var _view$state = view.state,
|
|
18
|
+
doc = _view$state.doc,
|
|
19
|
+
schema = _view$state.schema;
|
|
20
|
+
var tr = view.state.tr;
|
|
21
|
+
var table = schema.nodes.table;
|
|
22
|
+
var modified = false;
|
|
23
|
+
var measuredTables = [];
|
|
24
|
+
|
|
25
|
+
// modify only top-level tables
|
|
26
|
+
doc.forEach(function (node, offset) {
|
|
27
|
+
if (node.type !== table || (0, _table.hasTableBeenResized)(node) && node.attrs.layout !== 'align-start') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var domNode = view.domAtPos(offset + 1).node;
|
|
31
|
+
var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
|
|
32
|
+
var tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
|
|
33
|
+
if (!tableRef) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
measuredTables.push({
|
|
37
|
+
node: node,
|
|
38
|
+
offset: offset,
|
|
39
|
+
measurement: (0, _contentMode.getTableMeasurement)(tableRef)
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
measuredTables.forEach(function (_ref) {
|
|
43
|
+
var node = _ref.node,
|
|
44
|
+
offset = _ref.offset,
|
|
45
|
+
measurement = _ref.measurement;
|
|
46
|
+
tr = (0, _contentMode.applyTableMeasurement)(tr, node, measurement, offset);
|
|
47
|
+
modified = true;
|
|
48
|
+
});
|
|
49
|
+
if (modified) {
|
|
50
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$w, _pluginInjectionApi$w2;
|
|
51
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.attachAnalyticsEvent({
|
|
52
|
+
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
|
|
53
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
54
|
+
actionSubjectId: null,
|
|
55
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
56
|
+
attributes: {
|
|
57
|
+
editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 || (_pluginInjectionApi$w2 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : _pluginInjectionApi$w2.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
|
|
58
|
+
totalTablesResized: measuredTables.length,
|
|
59
|
+
measurements: measuredTables.map(function (_ref2) {
|
|
60
|
+
var measurement = _ref2.measurement;
|
|
61
|
+
return {
|
|
62
|
+
tableWidth: measurement.tableWidth,
|
|
63
|
+
totalColumnCount: measurement.colWidths.length
|
|
64
|
+
};
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
})(tr);
|
|
68
|
+
view.dispatch(tr.setMeta('addToHistory', false));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyMeasuredWidthToSelectedTable = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
|
+
var _contentMode = require("../../transforms/content-mode");
|
|
10
|
+
var _measureTableWithAutoLayout = require("./measure-table-with-auto-layout");
|
|
11
|
+
/**
|
|
12
|
+
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
13
|
+
*/
|
|
14
|
+
var applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
|
|
15
|
+
var _api$width, _api$analytics, _api$width$sharedStat, _api$width2;
|
|
16
|
+
var tableObject = (0, _utils.findTable)(view.state.selection);
|
|
17
|
+
if (!tableObject) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var node = tableObject.node,
|
|
21
|
+
pos = tableObject.pos;
|
|
22
|
+
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
23
|
+
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var editorContainerWidth = api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 || (_api$width = _api$width.sharedState.currentState()) === null || _api$width === void 0 ? void 0 : _api$width.width;
|
|
27
|
+
var measurement = (0, _measureTableWithAutoLayout.measureTableWithAutoLayout)(tableState.tableRef, editorContainerWidth);
|
|
28
|
+
var tr = (0, _contentMode.applyTableMeasurement)(view.state.tr, node, measurement, pos);
|
|
29
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
|
|
30
|
+
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
|
31
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
32
|
+
actionSubjectId: null,
|
|
33
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
34
|
+
attributes: {
|
|
35
|
+
editorContainerWidth: (_api$width$sharedStat = api === null || api === void 0 || (_api$width2 = api.width) === null || _api$width2 === void 0 || (_api$width2 = _api$width2.sharedState.currentState()) === null || _api$width2 === void 0 ? void 0 : _api$width2.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0,
|
|
36
|
+
tableWidth: measurement.tableWidth,
|
|
37
|
+
totalColumnCount: measurement.colWidths.length
|
|
38
|
+
}
|
|
39
|
+
})(tr);
|
|
40
|
+
view.dispatch(tr);
|
|
41
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isContentModeSupported = void 0;
|
|
7
|
+
var isContentModeSupported = exports.isContentModeSupported = function isContentModeSupported(_ref) {
|
|
8
|
+
var allowColumnResizing = _ref.allowColumnResizing,
|
|
9
|
+
allowTableResizing = _ref.allowTableResizing,
|
|
10
|
+
isFullPageEditor = _ref.isFullPageEditor;
|
|
11
|
+
return allowColumnResizing && allowTableResizing && isFullPageEditor;
|
|
12
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.measureTableWithAutoLayout = void 0;
|
|
7
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
|
+
var _contentMode = require("../../transforms/content-mode");
|
|
10
|
+
var _runSmartAdjust = require("./smart-adjust/run-smart-adjust");
|
|
11
|
+
var measureTableWithAutoLayout = exports.measureTableWithAutoLayout = function measureTableWithAutoLayout(tableRef, editorContainerWidth) {
|
|
12
|
+
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
13
|
+
var contentWrap = tableRef.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP));
|
|
14
|
+
var resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(".".concat(_styles.TableSharedCssClassName.TABLE_RESIZER_CONTAINER));
|
|
15
|
+
var resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
16
|
+
var prevTableWidth = tableRef.style.width;
|
|
17
|
+
var prevTableLayout = tableRef.style.tableLayout;
|
|
18
|
+
var prevColWidths = cols.map(function (col) {
|
|
19
|
+
return col.style.width;
|
|
20
|
+
});
|
|
21
|
+
var prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
|
|
22
|
+
tableRef.style.width = '';
|
|
23
|
+
tableRef.style.tableLayout = 'auto';
|
|
24
|
+
cols.forEach(function (col) {
|
|
25
|
+
return col.style.width = '';
|
|
26
|
+
});
|
|
27
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_fit_to_content_smart_adjust')) {
|
|
28
|
+
var hadTableSticky = tableRef.classList.contains(_styles.TableSharedCssClassName.TABLE_STICKY);
|
|
29
|
+
var prevTableMarginTop = tableRef.style.marginTop;
|
|
30
|
+
if (hadTableSticky) {
|
|
31
|
+
tableRef.classList.remove(_styles.TableSharedCssClassName.TABLE_NATIVE_STICKY);
|
|
32
|
+
}
|
|
33
|
+
if (prevTableMarginTop) {
|
|
34
|
+
tableRef.style.marginTop = '';
|
|
35
|
+
}
|
|
36
|
+
var stickyRows = Array.from(tableRef.querySelectorAll("tr.sticky, tr.".concat(_styles.TableSharedCssClassName.TABLE_NATIVE_STICKY)));
|
|
37
|
+
var prevStickyRowState = stickyRows.map(function (row) {
|
|
38
|
+
return {
|
|
39
|
+
row: row,
|
|
40
|
+
hadSticky: row.classList.contains('sticky'),
|
|
41
|
+
hadNative: row.classList.contains(_styles.TableSharedCssClassName.TABLE_NATIVE_STICKY),
|
|
42
|
+
width: row.style.width,
|
|
43
|
+
top: row.style.top,
|
|
44
|
+
position: row.style.position,
|
|
45
|
+
gridTemplateColumns: row.style.gridTemplateColumns
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
stickyRows.forEach(function (row) {
|
|
49
|
+
row.classList.remove('sticky');
|
|
50
|
+
row.classList.remove(_styles.TableSharedCssClassName.TABLE_NATIVE_STICKY);
|
|
51
|
+
row.style.width = '';
|
|
52
|
+
row.style.top = '';
|
|
53
|
+
row.style.position = '';
|
|
54
|
+
row.style.gridTemplateColumns = '';
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
return (0, _runSmartAdjust.runSmartAdjust)(tableRef, resizerContainer, resizerItem, editorContainerWidth);
|
|
58
|
+
} finally {
|
|
59
|
+
tableRef.style.width = prevTableWidth;
|
|
60
|
+
tableRef.style.tableLayout = prevTableLayout;
|
|
61
|
+
cols.forEach(function (col, i) {
|
|
62
|
+
return col.style.width = prevColWidths[i];
|
|
63
|
+
});
|
|
64
|
+
if (hadTableSticky) {
|
|
65
|
+
tableRef.classList.add(_styles.TableSharedCssClassName.TABLE_STICKY);
|
|
66
|
+
}
|
|
67
|
+
if (prevTableMarginTop) {
|
|
68
|
+
tableRef.style.marginTop = prevTableMarginTop;
|
|
69
|
+
}
|
|
70
|
+
prevStickyRowState.forEach(function (state) {
|
|
71
|
+
if (state.hadSticky) {
|
|
72
|
+
state.row.classList.add('sticky');
|
|
73
|
+
}
|
|
74
|
+
if (state.hadNative) {
|
|
75
|
+
state.row.classList.add(_styles.TableSharedCssClassName.TABLE_NATIVE_STICKY);
|
|
76
|
+
}
|
|
77
|
+
if (state.width) {
|
|
78
|
+
state.row.style.width = state.width;
|
|
79
|
+
}
|
|
80
|
+
if (state.top) {
|
|
81
|
+
state.row.style.top = state.top;
|
|
82
|
+
}
|
|
83
|
+
if (state.position) {
|
|
84
|
+
state.row.style.position = state.position;
|
|
85
|
+
}
|
|
86
|
+
if (state.gridTemplateColumns) {
|
|
87
|
+
state.row.style.gridTemplateColumns = state.gridTemplateColumns;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
(0, _runSmartAdjust.restoreResizerContainer)(resizerContainer);
|
|
91
|
+
if (resizerItem) {
|
|
92
|
+
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (resizerContainer) {
|
|
97
|
+
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
98
|
+
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
99
|
+
}
|
|
100
|
+
if (resizerItem) {
|
|
101
|
+
resizerItem.style.width = 'max-content';
|
|
102
|
+
}
|
|
103
|
+
var measurement = (0, _contentMode.getTableMeasurement)(tableRef);
|
|
104
|
+
tableRef.style.width = prevTableWidth;
|
|
105
|
+
tableRef.style.tableLayout = prevTableLayout;
|
|
106
|
+
cols.forEach(function (col, i) {
|
|
107
|
+
return col.style.width = prevColWidths[i];
|
|
108
|
+
});
|
|
109
|
+
if (resizerItem) {
|
|
110
|
+
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
111
|
+
}
|
|
112
|
+
return measurement;
|
|
113
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sumWidths = exports.distributeByEvenShareRatio = void 0;
|
|
7
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
|
+
var _constants = require("./constants");
|
|
10
|
+
var sumWidths = exports.sumWidths = function sumWidths(widths) {
|
|
11
|
+
return widths.reduce(function (sum, width) {
|
|
12
|
+
return sum + width;
|
|
13
|
+
}, 0);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// 2px absorbs sub-pixel rounding in `getRenderedColgroupColumnWidths`.
|
|
17
|
+
var SUB_PIXEL_ROUNDING_ALLOWANCE = 2;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Clamps each desired width to `[tableCellMinWidth, MAX × evenShare]`. Greedy
|
|
21
|
+
* columns (paragraphs) hit the ceiling and wrap; small columns stay at their
|
|
22
|
+
* natural width. Leftover canvas budget grows ceiling-hitters up to their
|
|
23
|
+
* desired; overflow reclaims from ceiling-hitters only.
|
|
24
|
+
*/
|
|
25
|
+
var distributeByEvenShareRatio = exports.distributeByEvenShareRatio = function distributeByEvenShareRatio(desiredWidths, editorContainerWidth) {
|
|
26
|
+
if (desiredWidths.length === 0 || !isFinite(editorContainerWidth) || editorContainerWidth <= 0) {
|
|
27
|
+
return desiredWidths;
|
|
28
|
+
}
|
|
29
|
+
var usableWidth = Math.max(editorContainerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2, _styles.tableCellMinWidth * desiredWidths.length);
|
|
30
|
+
var evenShare = usableWidth / desiredWidths.length;
|
|
31
|
+
var ceiling = _constants.EVEN_SHARE_RATIO.MAX * evenShare;
|
|
32
|
+
var isCompactColumn = function isCompactColumn(width) {
|
|
33
|
+
return width <= ceiling;
|
|
34
|
+
};
|
|
35
|
+
var desiredCeil = desiredWidths.map(function (desired) {
|
|
36
|
+
return Math.max(_styles.tableCellMinWidth, Math.ceil(desired) + SUB_PIXEL_ROUNDING_ALLOWANCE);
|
|
37
|
+
});
|
|
38
|
+
var capped = desiredCeil.map(function (desired) {
|
|
39
|
+
return isCompactColumn(desired) ? desired : Math.min(ceiling, desired);
|
|
40
|
+
});
|
|
41
|
+
var sum = sumWidths(capped);
|
|
42
|
+
|
|
43
|
+
// Underflow: grow non-protected ceiling-hitters into the leftover, up to their desired.
|
|
44
|
+
if (sum < usableWidth) {
|
|
45
|
+
var leftover = usableWidth - sum;
|
|
46
|
+
var growthHeadroom = capped.map(function (width, index) {
|
|
47
|
+
return !isCompactColumn(desiredCeil[index]) && width >= ceiling ? Math.max(desiredCeil[index] - width, 0) : 0;
|
|
48
|
+
});
|
|
49
|
+
var totalHeadroom = sumWidths(growthHeadroom);
|
|
50
|
+
if (totalHeadroom > 0) {
|
|
51
|
+
var totalGrowth = Math.min(leftover, totalHeadroom);
|
|
52
|
+
return capped.map(function (width, index) {
|
|
53
|
+
var headroom = growthHeadroom[index];
|
|
54
|
+
if (headroom <= 0) {
|
|
55
|
+
return width;
|
|
56
|
+
}
|
|
57
|
+
return width + headroom / totalHeadroom * totalGrowth;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return capped;
|
|
61
|
+
}
|
|
62
|
+
if (sum === usableWidth) {
|
|
63
|
+
return capped;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Overflow: reclaim from non-protected ceiling-hitters only.
|
|
67
|
+
var overage = sum - usableWidth;
|
|
68
|
+
var slacks = capped.map(function (width, index) {
|
|
69
|
+
return !isCompactColumn(desiredCeil[index]) && width >= ceiling ? Math.max(width - _styles.tableCellMinWidth, 0) : 0;
|
|
70
|
+
});
|
|
71
|
+
var totalSlack = sumWidths(slacks);
|
|
72
|
+
if (totalSlack <= 0) {
|
|
73
|
+
return capped;
|
|
74
|
+
}
|
|
75
|
+
return capped.map(function (width, index) {
|
|
76
|
+
var slack = slacks[index];
|
|
77
|
+
if (slack <= 0) {
|
|
78
|
+
return width;
|
|
79
|
+
}
|
|
80
|
+
var share = slack / totalSlack * Math.min(overage, totalSlack);
|
|
81
|
+
return Math.max(width - share, _styles.tableCellMinWidth);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.runSmartAdjust = exports.restoreResizerContainer = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _contentMode = require("../../../transforms/content-mode");
|
|
10
|
+
var _distributeColumnWidths = require("./distribute-column-widths");
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
var measureWithIntrinsicWidth = function measureWithIntrinsicWidth(tableRef, resizerContainer, resizerItem) {
|
|
14
|
+
if (resizerContainer) {
|
|
15
|
+
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
16
|
+
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
17
|
+
}
|
|
18
|
+
if (resizerItem) {
|
|
19
|
+
resizerItem.style.width = 'max-content';
|
|
20
|
+
}
|
|
21
|
+
var prevTableWidth = tableRef.style.width;
|
|
22
|
+
var prevTableMaxWidth = tableRef.style.maxWidth;
|
|
23
|
+
var prevTableMinWidth = tableRef.style.minWidth;
|
|
24
|
+
tableRef.style.setProperty('width', 'max-content', 'important');
|
|
25
|
+
tableRef.style.setProperty('max-width', 'none', 'important');
|
|
26
|
+
tableRef.style.setProperty('min-width', '0', 'important');
|
|
27
|
+
try {
|
|
28
|
+
return (0, _contentMode.getTableMeasurement)(tableRef);
|
|
29
|
+
} finally {
|
|
30
|
+
tableRef.style.width = prevTableWidth;
|
|
31
|
+
tableRef.style.maxWidth = prevTableMaxWidth;
|
|
32
|
+
tableRef.style.minWidth = prevTableMinWidth;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var restoreResizerContainer = exports.restoreResizerContainer = function restoreResizerContainer(resizerContainer) {
|
|
36
|
+
if (!resizerContainer) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
40
|
+
resizerContainer.style.removeProperty('--ak-editor-table-width');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Smart-adjust: measure unconstrained max-content per column, then clamp via
|
|
45
|
+
* `distributeByEvenShareRatio`.
|
|
46
|
+
*/
|
|
47
|
+
var runSmartAdjust = exports.runSmartAdjust = function runSmartAdjust(tableRef, resizerContainer, resizerItem, editorContainerWidthFromApi) {
|
|
48
|
+
var preferredMeasurement = measureWithIntrinsicWidth(tableRef, resizerContainer, resizerItem);
|
|
49
|
+
var desiredWidths = preferredMeasurement.colWidths;
|
|
50
|
+
var editorContainerWidth = editorContainerWidthFromApi !== null && editorContainerWidthFromApi !== void 0 ? editorContainerWidthFromApi : (0, _distributeColumnWidths.sumWidths)(desiredWidths);
|
|
51
|
+
var colWidths = (0, _distributeColumnWidths.distributeByEvenShareRatio)(desiredWidths, editorContainerWidth);
|
|
52
|
+
return _objectSpread(_objectSpread({}, preferredMeasurement), {}, {
|
|
53
|
+
colWidths: colWidths,
|
|
54
|
+
tableWidth: (0, _distributeColumnWidths.sumWidths)(colWidths)
|
|
55
|
+
});
|
|
56
|
+
};
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -50,7 +50,8 @@ var _alignment = require("../pm-plugins/utils/alignment");
|
|
|
50
50
|
var _nodes = require("../pm-plugins/utils/nodes");
|
|
51
51
|
var _selection = require("../pm-plugins/utils/selection");
|
|
52
52
|
var _table = require("../pm-plugins/utils/table");
|
|
53
|
-
var
|
|
53
|
+
var _applyMeasuredWidthToSelectedTable = require("../pm-plugins/utils/tableMode/apply-measured-width-to-selected-table");
|
|
54
|
+
var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
|
|
54
55
|
var _types = require("../types");
|
|
55
56
|
var _FloatingAlignmentButtons = require("./FloatingAlignmentButtons/FloatingAlignmentButtons");
|
|
56
57
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -459,7 +460,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
459
460
|
var isLimitedModeEnabled = (_api$limitedMode$shar = api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.enabled) !== null && _api$limitedMode$shar !== void 0 ? _api$limitedMode$shar : false;
|
|
460
461
|
var columnSettingsItems = getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, options === null || options === void 0 ? void 0 : options.isCommentEditor, isLimitedModeEnabled);
|
|
461
462
|
var colorPicker = !areAnyNewToolbarFlagsEnabled ? getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView) : [];
|
|
462
|
-
var fitToContentButton = (0,
|
|
463
|
+
var fitToContentButton = (0, _isContentModeSupported.isContentModeSupported)({
|
|
463
464
|
allowColumnResizing: !!pluginState.pluginConfig.allowColumnResizing,
|
|
464
465
|
allowTableResizing: !!pluginState.pluginConfig.allowTableResizing,
|
|
465
466
|
isFullPageEditor: !pluginState.isChromelessEditor && !pluginState.isCommentEditor
|
|
@@ -475,7 +476,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
475
476
|
},
|
|
476
477
|
onClick: function onClick(_state, _dispatch, view) {
|
|
477
478
|
if (view) {
|
|
478
|
-
(0,
|
|
479
|
+
(0, _applyMeasuredWidthToSelectedTable.applyMeasuredWidthToSelectedTable)(view, api !== null && api !== void 0 ? api : undefined);
|
|
479
480
|
}
|
|
480
481
|
return true;
|
|
481
482
|
}
|
|
@@ -28,7 +28,7 @@ import { getResizeState, updateColgroup } from '../pm-plugins/table-resizing/uti
|
|
|
28
28
|
import { scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
29
29
|
import { containsHeaderRow, isTableNested, isTableNestedInMoreThanOneNode, isTableNestedUnderBodiedSyncBlock, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../pm-plugins/utils/nodes';
|
|
30
30
|
import { getAssistiveMessage } from '../pm-plugins/utils/table';
|
|
31
|
-
import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
|
|
31
|
+
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
32
32
|
import { TableCssClassName as ClassName } from '../types';
|
|
33
33
|
import { handleMouseOut, handleMouseOver, isTableInFocus, withCellTracking } from '../ui/event-handlers';
|
|
34
34
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
@@ -13,7 +13,7 @@ import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-con
|
|
|
13
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
14
14
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
15
15
|
import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/utils/nodes';
|
|
16
|
-
import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
|
|
16
|
+
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
17
17
|
import { TableComponentWithSharedState } from './TableComponentWithSharedState';
|
|
18
18
|
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
19
19
|
const tableAttributes = node => {
|
|
@@ -7,7 +7,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
7
7
|
import { generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
8
8
|
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
|
|
9
9
|
import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
|
|
10
|
-
import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
|
|
10
|
+
import { isContentModeSupported } from '../pm-plugins/utils/tableMode/is-content-mode-supported';
|
|
11
11
|
import { getAlignmentStyle } from './table-container-styles';
|
|
12
12
|
export const tableNodeSpecWithFixedToDOM = config => {
|
|
13
13
|
const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
@@ -25,7 +25,8 @@ import { fixTables } from './transforms/fix-tables';
|
|
|
25
25
|
import { replaceSelectedTable } from './transforms/replace-table';
|
|
26
26
|
import { findControlsHoverDecoration } from './utils/decoration';
|
|
27
27
|
import { transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable, transformSliceToRemoveNestedTables, isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from './utils/paste';
|
|
28
|
-
import { applyMeasuredWidthToAllTables
|
|
28
|
+
import { applyMeasuredWidthToAllTables } from './utils/tableMode/apply-measured-width-to-all-tables';
|
|
29
|
+
import { isContentModeSupported } from './utils/tableMode/is-content-mode-supported';
|
|
29
30
|
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) => {
|
|
30
31
|
var _accessibilityUtils;
|
|
31
32
|
const state = createPluginState(dispatch, {
|
|
@@ -13,7 +13,7 @@ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorMaxWi
|
|
|
13
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
14
|
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from './table-resizing/utils/consts';
|
|
15
15
|
import { ALIGN_START } from './utils/alignment';
|
|
16
|
-
import { isContentModeSupported } from './utils/tableMode';
|
|
16
|
+
import { isContentModeSupported } from './utils/tableMode/is-content-mode-supported';
|
|
17
17
|
export const pluginKey = new PluginKey('tableWidthPlugin');
|
|
18
18
|
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, maxWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
19
19
|
return new SafePlugin({
|
|
@@ -2,10 +2,11 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
2
2
|
import { akEditorFullWidthLayoutWidth, akEditorMaxLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { updateCellsMarkup } from './table-transform-utils';
|
|
5
|
-
const
|
|
5
|
+
export const clampToEditorMaxWidth = contentWidth => {
|
|
6
6
|
const maxEditorWidth = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? akEditorMaxLayoutWidth : akEditorFullWidthLayoutWidth;
|
|
7
7
|
return Math.min(maxEditorWidth, contentWidth);
|
|
8
8
|
};
|
|
9
|
+
const tableWidth = clampToEditorMaxWidth;
|
|
9
10
|
export const getTableMeasurement = tableRef => {
|
|
10
11
|
const colWidths = getRenderedColgroupColumnWidths(tableRef);
|
|
11
12
|
const totalContentWidth = colWidths.reduce((acc, current) => acc + current, 0);
|