@atlaskit/editor-plugin-table 22.4.14 → 22.4.16
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 +17 -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/commands/active-table-menu.js +51 -0
- package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +42 -10
- package/dist/cjs/pm-plugins/commands/index.js +13 -0
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/cjs/pm-plugins/handlers.js +8 -1
- package/dist/cjs/pm-plugins/main.js +4 -3
- package/dist/cjs/pm-plugins/reducer.js +2 -0
- 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/tablePlugin.js +1 -0
- package/dist/cjs/ui/ContentComponent.js +1 -1
- package/dist/cjs/ui/FloatingContextualButton/index.js +28 -9
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +58 -73
- package/dist/cjs/ui/FloatingContextualMenu/index.js +26 -12
- package/dist/cjs/ui/FloatingDragMenu/index.js +21 -8
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +13 -5
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -5
- package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +16 -1
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +16 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
- package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
- package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
- package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
- package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/cjs/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
- package/dist/cjs/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
- package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- 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/commands/active-table-menu.js +39 -0
- package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +31 -2
- package/dist/es2019/pm-plugins/commands/index.js +1 -0
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/es2019/pm-plugins/handlers.js +8 -1
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/es2019/pm-plugins/reducer.js +5 -0
- 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/tablePlugin.js +1 -0
- package/dist/es2019/ui/ContentComponent.js +1 -1
- package/dist/es2019/ui/FloatingContextualButton/index.js +29 -9
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +60 -77
- package/dist/es2019/ui/FloatingContextualMenu/index.js +27 -12
- package/dist/es2019/ui/FloatingDragMenu/index.js +22 -8
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
- package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +9 -3
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +18 -2
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +18 -2
- package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -3
- package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +3 -3
- package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +3 -3
- package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +3 -3
- package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/es2019/ui/TableMenu/row/items/NumberedRowsToggleItem.js +3 -2
- package/dist/es2019/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +33 -4
- package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- 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/commands/active-table-menu.js +45 -0
- package/dist/esm/pm-plugins/commands/commands-with-analytics.js +41 -10
- package/dist/esm/pm-plugins/commands/index.js +1 -0
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -0
- package/dist/esm/pm-plugins/handlers.js +8 -1
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/esm/pm-plugins/reducer.js +2 -0
- 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/tablePlugin.js +1 -0
- package/dist/esm/ui/ContentComponent.js +1 -1
- package/dist/esm/ui/FloatingContextualButton/index.js +29 -10
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +60 -75
- package/dist/esm/ui/FloatingContextualMenu/index.js +26 -12
- package/dist/esm/ui/FloatingDragMenu/index.js +21 -8
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
- package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +16 -2
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +16 -2
- package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
- package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
- package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
- package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
- package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
- package/dist/esm/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
- package/dist/esm/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +8 -9
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +3 -1
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
- package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
- package/dist/esm/ui/toolbar.js +2 -1
- package/dist/types/entry-points/types.d.ts +1 -1
- package/dist/types/pm-plugins/commands/active-table-menu.d.ts +6 -0
- package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
- package/dist/types/pm-plugins/commands/index.d.ts +1 -0
- 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/types/index.d.ts +21 -1
- package/dist/types/ui/FloatingContextualButton/index.d.ts +2 -0
- package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +0 -1
- package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
- package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
- package/dist/types/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
- package/dist/types-ts4.5/entry-points/types.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/commands/index.d.ts +1 -0
- 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/types/index.d.ts +21 -1
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -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
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.measureTableWithAutoLayout = exports.isContentModeSupported = exports.applyMeasuredWidthToSelectedTable = 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 _utils = require("@atlaskit/editor-tables/utils");
|
|
11
|
-
var _contentMode = require("../transforms/content-mode");
|
|
12
|
-
var isContentModeSupported = exports.isContentModeSupported = function isContentModeSupported(_ref) {
|
|
13
|
-
var allowColumnResizing = _ref.allowColumnResizing,
|
|
14
|
-
allowTableResizing = _ref.allowTableResizing,
|
|
15
|
-
isFullPageEditor = _ref.isFullPageEditor;
|
|
16
|
-
return allowColumnResizing && allowTableResizing && isFullPageEditor;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Iterates all top-level tables in the document, and for those in content mode,
|
|
21
|
-
* measures rendered column widths and sets colwidth + table width attributes
|
|
22
|
-
* in a single batched transaction.
|
|
23
|
-
*/
|
|
24
|
-
var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTables(view, pluginInjectionApi) {
|
|
25
|
-
var _view$state = view.state,
|
|
26
|
-
doc = _view$state.doc,
|
|
27
|
-
schema = _view$state.schema;
|
|
28
|
-
var tr = view.state.tr;
|
|
29
|
-
var table = schema.nodes.table;
|
|
30
|
-
var modified = false;
|
|
31
|
-
var measuredTables = [];
|
|
32
|
-
|
|
33
|
-
// modify only top-level tables
|
|
34
|
-
doc.forEach(function (node, offset) {
|
|
35
|
-
if (node.type !== table || (0, _table.hasTableBeenResized)(node) && node.attrs.layout !== 'align-start') {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
var domNode = view.domAtPos(offset + 1).node;
|
|
39
|
-
var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
|
|
40
|
-
var tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
|
|
41
|
-
if (!tableRef) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
measuredTables.push({
|
|
45
|
-
node: node,
|
|
46
|
-
offset: offset,
|
|
47
|
-
measurement: (0, _contentMode.getTableMeasurement)(tableRef)
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
measuredTables.forEach(function (_ref2) {
|
|
51
|
-
var node = _ref2.node,
|
|
52
|
-
offset = _ref2.offset,
|
|
53
|
-
measurement = _ref2.measurement;
|
|
54
|
-
tr = (0, _contentMode.applyTableMeasurement)(tr, node, measurement, offset);
|
|
55
|
-
modified = true;
|
|
56
|
-
});
|
|
57
|
-
if (modified) {
|
|
58
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$w, _pluginInjectionApi$w2;
|
|
59
|
-
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({
|
|
60
|
-
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
|
|
61
|
-
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
62
|
-
actionSubjectId: null,
|
|
63
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
64
|
-
attributes: {
|
|
65
|
-
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,
|
|
66
|
-
totalTablesResized: measuredTables.length,
|
|
67
|
-
measurements: measuredTables.map(function (_ref3) {
|
|
68
|
-
var measurement = _ref3.measurement;
|
|
69
|
-
return {
|
|
70
|
-
tableWidth: measurement.tableWidth,
|
|
71
|
-
totalColumnCount: measurement.colWidths.length
|
|
72
|
-
};
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
})(tr);
|
|
76
|
-
view.dispatch(tr.setMeta('addToHistory', false));
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
82
|
-
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
83
|
-
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
84
|
-
*/
|
|
85
|
-
var measureTableWithAutoLayout = exports.measureTableWithAutoLayout = function measureTableWithAutoLayout(tableRef) {
|
|
86
|
-
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
87
|
-
var contentWrap = tableRef.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP));
|
|
88
|
-
var resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(".".concat(_styles.TableSharedCssClassName.TABLE_RESIZER_CONTAINER));
|
|
89
|
-
var resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
90
|
-
|
|
91
|
-
// Capture current inline styles so we can restore them after measurement
|
|
92
|
-
var prevTableWidth = tableRef.style.width;
|
|
93
|
-
var prevTableLayout = tableRef.style.tableLayout;
|
|
94
|
-
var prevColWidths = cols.map(function (col) {
|
|
95
|
-
return col.style.width;
|
|
96
|
-
});
|
|
97
|
-
var prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
|
|
98
|
-
|
|
99
|
-
// Apply temporary styles for content-based measurement
|
|
100
|
-
tableRef.style.width = '';
|
|
101
|
-
tableRef.style.tableLayout = 'auto';
|
|
102
|
-
cols.forEach(function (col) {
|
|
103
|
-
return col.style.width = '';
|
|
104
|
-
});
|
|
105
|
-
if (resizerContainer) {
|
|
106
|
-
// favour CSS var to align with the table first render state, which gets reset
|
|
107
|
-
// once resized by user. By doing this we avoid the need to any 'reset' work after
|
|
108
|
-
// measurement and ensures it works if the table has been resized or not in the session.
|
|
109
|
-
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
110
|
-
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
111
|
-
}
|
|
112
|
-
if (resizerItem) {
|
|
113
|
-
resizerItem.style.width = 'max-content';
|
|
114
|
-
}
|
|
115
|
-
var measurement = (0, _contentMode.getTableMeasurement)(tableRef);
|
|
116
|
-
|
|
117
|
-
// Reset all inline styles back to their previous values
|
|
118
|
-
tableRef.style.width = prevTableWidth;
|
|
119
|
-
tableRef.style.tableLayout = prevTableLayout;
|
|
120
|
-
cols.forEach(function (col, i) {
|
|
121
|
-
return col.style.width = prevColWidths[i];
|
|
122
|
-
});
|
|
123
|
-
if (resizerItem) {
|
|
124
|
-
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
125
|
-
}
|
|
126
|
-
return measurement;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
131
|
-
*/
|
|
132
|
-
var applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
|
|
133
|
-
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
134
|
-
var tableObject = (0, _utils.findTable)(view.state.selection);
|
|
135
|
-
if (!tableObject) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
var node = tableObject.node,
|
|
139
|
-
pos = tableObject.pos;
|
|
140
|
-
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
141
|
-
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
146
|
-
// for a rAF to measure natural column widths, directly update the DOM elements,
|
|
147
|
-
// take a measurement, and reset styles so no temporary overrides persist.
|
|
148
|
-
var measurement = measureTableWithAutoLayout(tableState.tableRef);
|
|
149
|
-
var tr = (0, _contentMode.applyTableMeasurement)(view.state.tr, node, measurement, pos);
|
|
150
|
-
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({
|
|
151
|
-
action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
|
152
|
-
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
153
|
-
actionSubjectId: null,
|
|
154
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
155
|
-
attributes: {
|
|
156
|
-
editorContainerWidth: (_api$width$sharedStat = 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) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0,
|
|
157
|
-
tableWidth: measurement.tableWidth,
|
|
158
|
-
totalColumnCount: measurement.colWidths.length
|
|
159
|
-
}
|
|
160
|
-
})(tr);
|
|
161
|
-
view.dispatch(tr);
|
|
162
|
-
};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import { hasTableBeenResized } from '@atlaskit/editor-common/table';
|
|
4
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import { applyTableMeasurement, getTableMeasurement } from '../transforms/content-mode';
|
|
6
|
-
export const isContentModeSupported = ({
|
|
7
|
-
allowColumnResizing,
|
|
8
|
-
allowTableResizing,
|
|
9
|
-
isFullPageEditor
|
|
10
|
-
}) => {
|
|
11
|
-
return allowColumnResizing && allowTableResizing && isFullPageEditor;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Iterates all top-level tables in the document, and for those in content mode,
|
|
16
|
-
* measures rendered column widths and sets colwidth + table width attributes
|
|
17
|
-
* in a single batched transaction.
|
|
18
|
-
*/
|
|
19
|
-
export const applyMeasuredWidthToAllTables = (view, pluginInjectionApi) => {
|
|
20
|
-
const {
|
|
21
|
-
state: {
|
|
22
|
-
doc,
|
|
23
|
-
schema
|
|
24
|
-
}
|
|
25
|
-
} = view;
|
|
26
|
-
let tr = view.state.tr;
|
|
27
|
-
const {
|
|
28
|
-
table
|
|
29
|
-
} = schema.nodes;
|
|
30
|
-
let modified = false;
|
|
31
|
-
const measuredTables = [];
|
|
32
|
-
|
|
33
|
-
// modify only top-level tables
|
|
34
|
-
doc.forEach((node, offset) => {
|
|
35
|
-
if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const domNode = view.domAtPos(offset + 1).node;
|
|
39
|
-
const tableWrapper = domNode instanceof HTMLElement ? domNode.closest(`.${TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP}`) : null;
|
|
40
|
-
const tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
|
|
41
|
-
if (!tableRef) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
measuredTables.push({
|
|
45
|
-
node,
|
|
46
|
-
offset,
|
|
47
|
-
measurement: getTableMeasurement(tableRef)
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
measuredTables.forEach(({
|
|
51
|
-
node,
|
|
52
|
-
offset,
|
|
53
|
-
measurement
|
|
54
|
-
}) => {
|
|
55
|
-
tr = applyTableMeasurement(tr, node, measurement, offset);
|
|
56
|
-
modified = true;
|
|
57
|
-
});
|
|
58
|
-
if (modified) {
|
|
59
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$w, _pluginInjectionApi$w2, _pluginInjectionApi$w3;
|
|
60
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : (_pluginInjectionApi$a2 = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.attachAnalyticsEvent({
|
|
61
|
-
action: TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
|
|
62
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
63
|
-
actionSubjectId: null,
|
|
64
|
-
eventType: EVENT_TYPE.TRACK,
|
|
65
|
-
attributes: {
|
|
66
|
-
editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : (_pluginInjectionApi$w3 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w3 === void 0 ? void 0 : _pluginInjectionApi$w3.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
|
|
67
|
-
totalTablesResized: measuredTables.length,
|
|
68
|
-
measurements: measuredTables.map(({
|
|
69
|
-
measurement
|
|
70
|
-
}) => ({
|
|
71
|
-
tableWidth: measurement.tableWidth,
|
|
72
|
-
totalColumnCount: measurement.colWidths.length
|
|
73
|
-
}))
|
|
74
|
-
}
|
|
75
|
-
})(tr);
|
|
76
|
-
view.dispatch(tr.setMeta('addToHistory', false));
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
82
|
-
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
83
|
-
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
84
|
-
*/
|
|
85
|
-
export const measureTableWithAutoLayout = tableRef => {
|
|
86
|
-
const cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
87
|
-
const contentWrap = tableRef.closest(`.${TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP}`);
|
|
88
|
-
const resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(`.${TableSharedCssClassName.TABLE_RESIZER_CONTAINER}`);
|
|
89
|
-
const resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
90
|
-
|
|
91
|
-
// Capture current inline styles so we can restore them after measurement
|
|
92
|
-
const prevTableWidth = tableRef.style.width;
|
|
93
|
-
const prevTableLayout = tableRef.style.tableLayout;
|
|
94
|
-
const prevColWidths = cols.map(col => col.style.width);
|
|
95
|
-
const prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
|
|
96
|
-
|
|
97
|
-
// Apply temporary styles for content-based measurement
|
|
98
|
-
tableRef.style.width = '';
|
|
99
|
-
tableRef.style.tableLayout = 'auto';
|
|
100
|
-
cols.forEach(col => col.style.width = '');
|
|
101
|
-
if (resizerContainer) {
|
|
102
|
-
// favour CSS var to align with the table first render state, which gets reset
|
|
103
|
-
// once resized by user. By doing this we avoid the need to any 'reset' work after
|
|
104
|
-
// measurement and ensures it works if the table has been resized or not in the session.
|
|
105
|
-
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
106
|
-
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
107
|
-
}
|
|
108
|
-
if (resizerItem) {
|
|
109
|
-
resizerItem.style.width = 'max-content';
|
|
110
|
-
}
|
|
111
|
-
const measurement = getTableMeasurement(tableRef);
|
|
112
|
-
|
|
113
|
-
// Reset all inline styles back to their previous values
|
|
114
|
-
tableRef.style.width = prevTableWidth;
|
|
115
|
-
tableRef.style.tableLayout = prevTableLayout;
|
|
116
|
-
cols.forEach((col, i) => col.style.width = prevColWidths[i]);
|
|
117
|
-
if (resizerItem) {
|
|
118
|
-
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
119
|
-
}
|
|
120
|
-
return measurement;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
125
|
-
*/
|
|
126
|
-
export const applyMeasuredWidthToSelectedTable = (view, api) => {
|
|
127
|
-
var _api$analytics, _api$analytics$action, _api$width$sharedStat, _api$width, _api$width$sharedStat2;
|
|
128
|
-
const tableObject = findTable(view.state.selection);
|
|
129
|
-
if (!tableObject) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const {
|
|
133
|
-
node,
|
|
134
|
-
pos
|
|
135
|
-
} = tableObject;
|
|
136
|
-
const tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
137
|
-
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
142
|
-
// for a rAF to measure natural column widths, directly update the DOM elements,
|
|
143
|
-
// take a measurement, and reset styles so no temporary overrides persist.
|
|
144
|
-
const measurement = measureTableWithAutoLayout(tableState.tableRef);
|
|
145
|
-
const tr = applyTableMeasurement(view.state.tr, node, measurement, pos);
|
|
146
|
-
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
|
|
147
|
-
action: TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
|
148
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
149
|
-
actionSubjectId: null,
|
|
150
|
-
eventType: EVENT_TYPE.TRACK,
|
|
151
|
-
attributes: {
|
|
152
|
-
editorContainerWidth: (_api$width$sharedStat = api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : (_api$width$sharedStat2 = _api$width.sharedState.currentState()) === null || _api$width$sharedStat2 === void 0 ? void 0 : _api$width$sharedStat2.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0,
|
|
153
|
-
tableWidth: measurement.tableWidth,
|
|
154
|
-
totalColumnCount: measurement.colWidths.length
|
|
155
|
-
}
|
|
156
|
-
})(tr);
|
|
157
|
-
view.dispatch(tr);
|
|
158
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import { hasTableBeenResized } from '@atlaskit/editor-common/table';
|
|
4
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import { applyTableMeasurement, getTableMeasurement } from '../transforms/content-mode';
|
|
6
|
-
export var isContentModeSupported = function isContentModeSupported(_ref) {
|
|
7
|
-
var allowColumnResizing = _ref.allowColumnResizing,
|
|
8
|
-
allowTableResizing = _ref.allowTableResizing,
|
|
9
|
-
isFullPageEditor = _ref.isFullPageEditor;
|
|
10
|
-
return allowColumnResizing && allowTableResizing && isFullPageEditor;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Iterates all top-level tables in the document, and for those in content mode,
|
|
15
|
-
* measures rendered column widths and sets colwidth + table width attributes
|
|
16
|
-
* in a single batched transaction.
|
|
17
|
-
*/
|
|
18
|
-
export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTables(view, pluginInjectionApi) {
|
|
19
|
-
var _view$state = view.state,
|
|
20
|
-
doc = _view$state.doc,
|
|
21
|
-
schema = _view$state.schema;
|
|
22
|
-
var tr = view.state.tr;
|
|
23
|
-
var table = schema.nodes.table;
|
|
24
|
-
var modified = false;
|
|
25
|
-
var measuredTables = [];
|
|
26
|
-
|
|
27
|
-
// modify only top-level tables
|
|
28
|
-
doc.forEach(function (node, offset) {
|
|
29
|
-
if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
var domNode = view.domAtPos(offset + 1).node;
|
|
33
|
-
var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
|
|
34
|
-
var tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
|
|
35
|
-
if (!tableRef) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
measuredTables.push({
|
|
39
|
-
node: node,
|
|
40
|
-
offset: offset,
|
|
41
|
-
measurement: getTableMeasurement(tableRef)
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
measuredTables.forEach(function (_ref2) {
|
|
45
|
-
var node = _ref2.node,
|
|
46
|
-
offset = _ref2.offset,
|
|
47
|
-
measurement = _ref2.measurement;
|
|
48
|
-
tr = applyTableMeasurement(tr, node, measurement, offset);
|
|
49
|
-
modified = true;
|
|
50
|
-
});
|
|
51
|
-
if (modified) {
|
|
52
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$w, _pluginInjectionApi$w2;
|
|
53
|
-
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({
|
|
54
|
-
action: TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
|
|
55
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
56
|
-
actionSubjectId: null,
|
|
57
|
-
eventType: EVENT_TYPE.TRACK,
|
|
58
|
-
attributes: {
|
|
59
|
-
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,
|
|
60
|
-
totalTablesResized: measuredTables.length,
|
|
61
|
-
measurements: measuredTables.map(function (_ref3) {
|
|
62
|
-
var measurement = _ref3.measurement;
|
|
63
|
-
return {
|
|
64
|
-
tableWidth: measurement.tableWidth,
|
|
65
|
-
totalColumnCount: measurement.colWidths.length
|
|
66
|
-
};
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
})(tr);
|
|
70
|
-
view.dispatch(tr.setMeta('addToHistory', false));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
76
|
-
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
77
|
-
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
78
|
-
*/
|
|
79
|
-
export var measureTableWithAutoLayout = function measureTableWithAutoLayout(tableRef) {
|
|
80
|
-
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
81
|
-
var contentWrap = tableRef.closest(".".concat(TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP));
|
|
82
|
-
var resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(".".concat(TableSharedCssClassName.TABLE_RESIZER_CONTAINER));
|
|
83
|
-
var resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
84
|
-
|
|
85
|
-
// Capture current inline styles so we can restore them after measurement
|
|
86
|
-
var prevTableWidth = tableRef.style.width;
|
|
87
|
-
var prevTableLayout = tableRef.style.tableLayout;
|
|
88
|
-
var prevColWidths = cols.map(function (col) {
|
|
89
|
-
return col.style.width;
|
|
90
|
-
});
|
|
91
|
-
var prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
|
|
92
|
-
|
|
93
|
-
// Apply temporary styles for content-based measurement
|
|
94
|
-
tableRef.style.width = '';
|
|
95
|
-
tableRef.style.tableLayout = 'auto';
|
|
96
|
-
cols.forEach(function (col) {
|
|
97
|
-
return col.style.width = '';
|
|
98
|
-
});
|
|
99
|
-
if (resizerContainer) {
|
|
100
|
-
// favour CSS var to align with the table first render state, which gets reset
|
|
101
|
-
// once resized by user. By doing this we avoid the need to any 'reset' work after
|
|
102
|
-
// measurement and ensures it works if the table has been resized or not in the session.
|
|
103
|
-
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
104
|
-
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
105
|
-
}
|
|
106
|
-
if (resizerItem) {
|
|
107
|
-
resizerItem.style.width = 'max-content';
|
|
108
|
-
}
|
|
109
|
-
var measurement = getTableMeasurement(tableRef);
|
|
110
|
-
|
|
111
|
-
// Reset all inline styles back to their previous values
|
|
112
|
-
tableRef.style.width = prevTableWidth;
|
|
113
|
-
tableRef.style.tableLayout = prevTableLayout;
|
|
114
|
-
cols.forEach(function (col, i) {
|
|
115
|
-
return col.style.width = prevColWidths[i];
|
|
116
|
-
});
|
|
117
|
-
if (resizerItem) {
|
|
118
|
-
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
119
|
-
}
|
|
120
|
-
return measurement;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
125
|
-
*/
|
|
126
|
-
export var applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
|
|
127
|
-
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
128
|
-
var tableObject = findTable(view.state.selection);
|
|
129
|
-
if (!tableObject) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
var node = tableObject.node,
|
|
133
|
-
pos = tableObject.pos;
|
|
134
|
-
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
135
|
-
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
140
|
-
// for a rAF to measure natural column widths, directly update the DOM elements,
|
|
141
|
-
// take a measurement, and reset styles so no temporary overrides persist.
|
|
142
|
-
var measurement = measureTableWithAutoLayout(tableState.tableRef);
|
|
143
|
-
var tr = applyTableMeasurement(view.state.tr, node, measurement, pos);
|
|
144
|
-
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({
|
|
145
|
-
action: TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
|
146
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
147
|
-
actionSubjectId: null,
|
|
148
|
-
eventType: EVENT_TYPE.TRACK,
|
|
149
|
-
attributes: {
|
|
150
|
-
editorContainerWidth: (_api$width$sharedStat = 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) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0,
|
|
151
|
-
tableWidth: measurement.tableWidth,
|
|
152
|
-
totalColumnCount: measurement.colWidths.length
|
|
153
|
-
}
|
|
154
|
-
})(tr);
|
|
155
|
-
view.dispatch(tr);
|
|
156
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { PluginInjectionAPI } from '../../types';
|
|
3
|
-
import { type TableMeasurement } from '../transforms/content-mode';
|
|
4
|
-
type ContentModePluginOptions = {
|
|
5
|
-
allowColumnResizing: boolean;
|
|
6
|
-
allowTableResizing: boolean;
|
|
7
|
-
isFullPageEditor: boolean;
|
|
8
|
-
};
|
|
9
|
-
export declare const isContentModeSupported: ({ allowColumnResizing, allowTableResizing, isFullPageEditor, }: ContentModePluginOptions) => boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Iterates all top-level tables in the document, and for those in content mode,
|
|
12
|
-
* measures rendered column widths and sets colwidth + table width attributes
|
|
13
|
-
* in a single batched transaction.
|
|
14
|
-
*/
|
|
15
|
-
export declare const applyMeasuredWidthToAllTables: (view: EditorView, pluginInjectionApi?: PluginInjectionAPI) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
18
|
-
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
19
|
-
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
20
|
-
*/
|
|
21
|
-
export declare const measureTableWithAutoLayout: (tableRef: HTMLTableElement) => TableMeasurement;
|
|
22
|
-
/**
|
|
23
|
-
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
24
|
-
*/
|
|
25
|
-
export declare const applyMeasuredWidthToSelectedTable: (view: EditorView, api?: PluginInjectionAPI) => void;
|
|
26
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { PluginInjectionAPI } from '../../types';
|
|
3
|
-
import { type TableMeasurement } from '../transforms/content-mode';
|
|
4
|
-
type ContentModePluginOptions = {
|
|
5
|
-
allowColumnResizing: boolean;
|
|
6
|
-
allowTableResizing: boolean;
|
|
7
|
-
isFullPageEditor: boolean;
|
|
8
|
-
};
|
|
9
|
-
export declare const isContentModeSupported: ({ allowColumnResizing, allowTableResizing, isFullPageEditor, }: ContentModePluginOptions) => boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Iterates all top-level tables in the document, and for those in content mode,
|
|
12
|
-
* measures rendered column widths and sets colwidth + table width attributes
|
|
13
|
-
* in a single batched transaction.
|
|
14
|
-
*/
|
|
15
|
-
export declare const applyMeasuredWidthToAllTables: (view: EditorView, pluginInjectionApi?: PluginInjectionAPI) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
18
|
-
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
19
|
-
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
20
|
-
*/
|
|
21
|
-
export declare const measureTableWithAutoLayout: (tableRef: HTMLTableElement) => TableMeasurement;
|
|
22
|
-
/**
|
|
23
|
-
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
24
|
-
*/
|
|
25
|
-
export declare const applyMeasuredWidthToSelectedTable: (view: EditorView, api?: PluginInjectionAPI) => void;
|
|
26
|
-
export {};
|