@atlaskit/editor-plugin-table 7.16.0 → 7.16.2
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 +20 -0
- package/dist/cjs/commands/insert.js +14 -2
- package/dist/cjs/commands/misc.js +15 -1
- package/dist/cjs/commands-with-analytics.js +25 -2
- package/dist/cjs/nodeviews/TableComponent.js +4 -2
- package/dist/cjs/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/cjs/nodeviews/TableContainer.js +72 -34
- package/dist/cjs/nodeviews/table.js +7 -4
- package/dist/cjs/plugin.js +13 -5
- package/dist/cjs/pm-plugins/keymap.js +1 -13
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/toolbar.js +9 -26
- package/dist/cjs/utils/alignment.js +13 -0
- package/dist/es2019/commands/insert.js +15 -3
- package/dist/es2019/commands/misc.js +15 -1
- package/dist/es2019/commands-with-analytics.js +22 -2
- package/dist/es2019/nodeviews/TableComponent.js +5 -2
- package/dist/es2019/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/es2019/nodeviews/TableContainer.js +51 -11
- package/dist/es2019/nodeviews/table.js +7 -4
- package/dist/es2019/plugin.js +13 -6
- package/dist/es2019/pm-plugins/keymap.js +4 -14
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/toolbar.js +8 -25
- package/dist/es2019/utils/alignment.js +5 -0
- package/dist/esm/commands/insert.js +15 -3
- package/dist/esm/commands/misc.js +14 -0
- package/dist/esm/commands-with-analytics.js +25 -2
- package/dist/esm/nodeviews/TableComponent.js +4 -2
- package/dist/esm/nodeviews/TableComponentWithSharedState.js +1 -0
- package/dist/esm/nodeviews/TableContainer.js +73 -35
- package/dist/esm/nodeviews/table.js +7 -4
- package/dist/esm/plugin.js +14 -6
- package/dist/esm/pm-plugins/keymap.js +4 -16
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/toolbar.js +8 -27
- package/dist/esm/utils/alignment.js +7 -0
- package/dist/types/commands/insert.d.ts +3 -2
- package/dist/types/commands/misc.d.ts +3 -1
- package/dist/types/commands-with-analytics.d.ts +3 -1
- package/dist/types/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/nodeviews/TableContainer.d.ts +7 -5
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/toolbar.d.ts +3 -4
- package/dist/types/types.d.ts +1 -0
- package/dist/types/utils/alignment.d.ts +7 -0
- package/dist/types-ts4.5/commands/insert.d.ts +3 -2
- package/dist/types-ts4.5/commands/misc.d.ts +3 -1
- package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -5
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/toolbar.d.ts +3 -4
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/utils/alignment.d.ts +7 -0
- package/package.json +6 -6
- package/src/commands/insert.ts +26 -18
- package/src/commands/misc.ts +28 -6
- package/src/commands-with-analytics.ts +38 -1
- package/src/nodeviews/TableComponent.tsx +3 -0
- package/src/nodeviews/TableComponentWithSharedState.tsx +1 -0
- package/src/nodeviews/TableContainer.tsx +75 -13
- package/src/nodeviews/table.tsx +4 -1
- package/src/nodeviews/types.ts +1 -0
- package/src/plugin.tsx +20 -22
- package/src/pm-plugins/keymap.ts +4 -25
- package/src/pm-plugins/main.ts +1 -0
- package/src/toolbar.tsx +16 -37
- package/src/types.ts +2 -0
- package/src/utils/alignment.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.16.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#101820](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101820)
|
|
8
|
+
[`d6a194ef42d7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6a194ef42d7) -
|
|
9
|
+
Add new left alignment to table container in editor, based on layout node attribute
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 7.16.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#101355](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101355)
|
|
17
|
+
[`040f4ffe7af0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/040f4ffe7af0) -
|
|
18
|
+
Add analytic event to table alignment command
|
|
19
|
+
- [#101524](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101524)
|
|
20
|
+
[`4821570088e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4821570088e6) -
|
|
21
|
+
ED-23362 Bump ADF schema to version 36.8.1 and add support for adf validation and transformation
|
|
22
|
+
|
|
3
23
|
## 7.16.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -143,11 +143,23 @@ var insertRow = exports.insertRow = function insertRow(row, moveCursorToTheNewRo
|
|
|
143
143
|
return true;
|
|
144
144
|
};
|
|
145
145
|
};
|
|
146
|
-
var createTable = exports.createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled) {
|
|
146
|
+
var createTable = exports.createTable = function createTable(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
147
147
|
return function (state, dispatch) {
|
|
148
148
|
var table = (0, _utils3.createTableWithWidth)(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
|
|
149
149
|
if (dispatch) {
|
|
150
|
-
|
|
150
|
+
var tr = (0, _utils.safeInsert)(table)(state.tr).scrollIntoView();
|
|
151
|
+
if (editorAnalyticsAPI) {
|
|
152
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
153
|
+
action: _analytics.ACTION.INSERTED,
|
|
154
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
155
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
|
|
156
|
+
attributes: {
|
|
157
|
+
inputMethod: _analytics.INPUT_METHOD.SHORTCUT
|
|
158
|
+
},
|
|
159
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
160
|
+
})(tr);
|
|
161
|
+
}
|
|
162
|
+
dispatch(tr);
|
|
151
163
|
}
|
|
152
164
|
return true;
|
|
153
165
|
};
|
|
@@ -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.updateWidthToWidest = exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
7
|
+
exports.updateWidthToWidest = exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setTableAlignment = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
@@ -586,4 +586,18 @@ var updateWidthToWidest = exports.updateWidthToWidest = function updateWidthToWi
|
|
|
586
586
|
}
|
|
587
587
|
};
|
|
588
588
|
});
|
|
589
|
+
};
|
|
590
|
+
var setTableAlignment = exports.setTableAlignment = function setTableAlignment(newAlignment) {
|
|
591
|
+
return function (_ref2) {
|
|
592
|
+
var tr = _ref2.tr;
|
|
593
|
+
var tableObject = (0, _utils2.findTable)(tr.selection);
|
|
594
|
+
if (!tableObject) {
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
var nextTableAttrs = _objectSpread(_objectSpread({}, tableObject.node.attrs), {}, {
|
|
598
|
+
layout: newAlignment
|
|
599
|
+
});
|
|
600
|
+
tr.setNodeMarkup(tableObject.pos, undefined, nextTableAttrs).setMeta('scrollIntoView', false);
|
|
601
|
+
return tr;
|
|
602
|
+
};
|
|
589
603
|
};
|
|
@@ -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.wrapTableInExpandWithAnalytics = exports.toggleTableLockWithAnalytics = exports.toggleTableLayoutWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setColorWithAnalytics = exports.mergeCellsWithAnalytics = exports.insertRowWithAnalytics = exports.insertColumnWithAnalytics = exports.emptyMultipleCellsWithAnalytics = exports.distributeColumnsWidthsWithAnalytics = exports.deleteTableWithAnalytics = exports.deleteTableIfSelectedWithAnalytics = exports.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteRowsWithAnalytics = exports.deleteColumnsWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = exports.addRowAroundSelection = void 0;
|
|
7
|
+
exports.wrapTableInExpandWithAnalytics = exports.toggleTableLockWithAnalytics = exports.toggleTableLayoutWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setTableAlignmentWithAnalytics = exports.setColorWithAnalytics = exports.mergeCellsWithAnalytics = exports.insertRowWithAnalytics = exports.insertColumnWithAnalytics = exports.emptyMultipleCellsWithAnalytics = exports.distributeColumnsWidthsWithAnalytics = exports.deleteTableWithAnalytics = exports.deleteTableIfSelectedWithAnalytics = exports.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteRowsWithAnalytics = exports.deleteColumnsWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = exports.addRowAroundSelection = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -537,4 +537,27 @@ var toggleTableLockWithAnalytics = exports.toggleTableLockWithAnalytics = functi
|
|
|
537
537
|
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)(_displayMode.setTableDisplayMode));
|
|
538
538
|
};
|
|
539
539
|
};
|
|
540
|
-
|
|
540
|
+
var setTableAlignmentWithAnalytics = exports.setTableAlignmentWithAnalytics = function setTableAlignmentWithAnalytics(editorAnalyticsAPI) {
|
|
541
|
+
return function (newAlignment, previousAlignment, inputMethod) {
|
|
542
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
|
|
543
|
+
var _getSelectedTableInfo14 = (0, _utils2.getSelectedTableInfo)(state.selection),
|
|
544
|
+
table = _getSelectedTableInfo14.table,
|
|
545
|
+
totalRowCount = _getSelectedTableInfo14.totalRowCount,
|
|
546
|
+
totalColumnCount = _getSelectedTableInfo14.totalColumnCount;
|
|
547
|
+
return {
|
|
548
|
+
action: _analytics.TABLE_ACTION.CHANGED_ALIGNMENT,
|
|
549
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
550
|
+
actionSubjectId: null,
|
|
551
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
552
|
+
attributes: {
|
|
553
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
554
|
+
newAlignment: newAlignment,
|
|
555
|
+
previousAlignment: previousAlignment === 'center' || previousAlignment === 'align-start' ? previousAlignment : null,
|
|
556
|
+
totalRowCount: totalRowCount,
|
|
557
|
+
totalColumnCount: totalColumnCount,
|
|
558
|
+
inputMethod: inputMethod
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)((0, _misc.setTableAlignment)(newAlignment)));
|
|
562
|
+
};
|
|
563
|
+
};
|
|
@@ -652,7 +652,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
652
652
|
pluginInjectionApi = _this$props11.pluginInjectionApi,
|
|
653
653
|
isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
|
|
654
654
|
getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
|
|
655
|
-
isTableScalingEnabled = _this$props11.isTableScalingEnabled
|
|
655
|
+
isTableScalingEnabled = _this$props11.isTableScalingEnabled,
|
|
656
|
+
isTableAlignmentEnabled = _this$props11.isTableAlignmentEnabled;
|
|
656
657
|
var _this$props12 = this.props,
|
|
657
658
|
isInDanger = _this$props12.isInDanger,
|
|
658
659
|
hoveredRows = _this$props12.hoveredRows,
|
|
@@ -761,7 +762,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
761
762
|
isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
|
|
762
763
|
isResizing: isResizing,
|
|
763
764
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
764
|
-
isWholeTableInDanger: isWholeTableInDanger
|
|
765
|
+
isWholeTableInDanger: isWholeTableInDanger,
|
|
766
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
765
767
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
766
768
|
className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
|
|
767
769
|
"data-testid": "sticky-sentinel-top"
|
|
@@ -69,6 +69,7 @@ var TableComponentWithSharedState = exports.TableComponentWithSharedState = func
|
|
|
69
69
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
70
70
|
isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
|
|
71
71
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
72
|
+
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled,
|
|
72
73
|
tableActive: tableActive,
|
|
73
74
|
ordering: ordering,
|
|
74
75
|
isResizing: isResizing,
|
|
@@ -31,19 +31,57 @@ var InnerContainer = exports.InnerContainer = /*#__PURE__*/(0, _react.forwardRef
|
|
|
31
31
|
"data-testid": "table-container"
|
|
32
32
|
}, children);
|
|
33
33
|
});
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
var centerAlignStyle = {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
justifyContent: 'center'
|
|
37
|
+
};
|
|
38
|
+
var leftAlignStyle = {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
justifyContent: 'flex-start'
|
|
41
|
+
};
|
|
42
|
+
var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
|
|
43
|
+
var node = _ref2.node,
|
|
44
|
+
children = _ref2.children;
|
|
45
|
+
var alignment = node.attrs.layout;
|
|
46
|
+
var style = (0, _react.useMemo)(function () {
|
|
47
|
+
return alignment === 'align-start' ? leftAlignStyle : centerAlignStyle;
|
|
48
|
+
}, [alignment]);
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
50
|
+
"data-testid": "table-alignment-container",
|
|
51
|
+
style: style
|
|
52
|
+
}, children);
|
|
53
|
+
};
|
|
54
|
+
var AlignmentTableContainerWrapper = function AlignmentTableContainerWrapper(_ref3) {
|
|
55
|
+
var isTableAlignmentEnabled = _ref3.isTableAlignmentEnabled,
|
|
56
|
+
node = _ref3.node,
|
|
57
|
+
children = _ref3.children;
|
|
58
|
+
if (!isTableAlignmentEnabled) {
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
+
"data-testid": "table-alignment-container",
|
|
61
|
+
style: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
justifyContent: 'center'
|
|
64
|
+
}
|
|
65
|
+
}, children);
|
|
66
|
+
}
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(AlignmentTableContainer, {
|
|
68
|
+
node: node
|
|
69
|
+
}, children);
|
|
70
|
+
};
|
|
71
|
+
var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_react.default.memo(function (_ref4) {
|
|
72
|
+
var children = _ref4.children,
|
|
73
|
+
className = _ref4.className,
|
|
74
|
+
node = _ref4.node,
|
|
75
|
+
containerWidth = _ref4.containerWidth,
|
|
76
|
+
editorView = _ref4.editorView,
|
|
77
|
+
getPos = _ref4.getPos,
|
|
78
|
+
tableRef = _ref4.tableRef,
|
|
79
|
+
isResizing = _ref4.isResizing,
|
|
80
|
+
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
81
|
+
tableWrapperHeight = _ref4.tableWrapperHeight,
|
|
82
|
+
isWholeTableInDanger = _ref4.isWholeTableInDanger,
|
|
83
|
+
isTableScalingEnabled = _ref4.isTableScalingEnabled,
|
|
84
|
+
isTableAlignmentEnabled = _ref4.isTableAlignmentEnabled;
|
|
47
85
|
var containerRef = (0, _react.useRef)(null);
|
|
48
86
|
var tableWidthRef = (0, _react.useRef)(_editorSharedStyles.akEditorDefaultLayoutWidth);
|
|
49
87
|
var _useState = (0, _react.useState)(false),
|
|
@@ -132,11 +170,9 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
132
170
|
onResizeStop: onResizeStop
|
|
133
171
|
};
|
|
134
172
|
var isLivePageViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
135
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
justifyContent: 'center'
|
|
139
|
-
}
|
|
173
|
+
return /*#__PURE__*/_react.default.createElement(AlignmentTableContainerWrapper, {
|
|
174
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
175
|
+
node: node
|
|
140
176
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
141
177
|
style: {
|
|
142
178
|
width: tableWidthRef.current,
|
|
@@ -156,21 +192,22 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
156
192
|
node: node
|
|
157
193
|
}, children))));
|
|
158
194
|
});
|
|
159
|
-
var TableContainer = exports.TableContainer = function TableContainer(
|
|
160
|
-
var children =
|
|
161
|
-
node =
|
|
162
|
-
className =
|
|
163
|
-
editorWidth =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
195
|
+
var TableContainer = exports.TableContainer = function TableContainer(_ref5) {
|
|
196
|
+
var children = _ref5.children,
|
|
197
|
+
node = _ref5.node,
|
|
198
|
+
className = _ref5.className,
|
|
199
|
+
editorWidth = _ref5.containerWidth.width,
|
|
200
|
+
editorView = _ref5.editorView,
|
|
201
|
+
getPos = _ref5.getPos,
|
|
202
|
+
tableRef = _ref5.tableRef,
|
|
203
|
+
isNested = _ref5.isNested,
|
|
204
|
+
tableWrapperHeight = _ref5.tableWrapperHeight,
|
|
205
|
+
isResizing = _ref5.isResizing,
|
|
206
|
+
pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
207
|
+
isWholeTableInDanger = _ref5.isWholeTableInDanger,
|
|
208
|
+
isTableResizingEnabled = _ref5.isTableResizingEnabled,
|
|
209
|
+
isTableScalingEnabled = _ref5.isTableScalingEnabled,
|
|
210
|
+
isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled;
|
|
174
211
|
if (isTableResizingEnabled && !isNested) {
|
|
175
212
|
return /*#__PURE__*/_react.default.createElement(ResizableTableContainer, {
|
|
176
213
|
className: className,
|
|
@@ -183,7 +220,8 @@ var TableContainer = exports.TableContainer = function TableContainer(_ref3) {
|
|
|
183
220
|
isResizing: isResizing,
|
|
184
221
|
pluginInjectionApi: pluginInjectionApi,
|
|
185
222
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
186
|
-
isWholeTableInDanger: isWholeTableInDanger
|
|
223
|
+
isWholeTableInDanger: isWholeTableInDanger,
|
|
224
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
187
225
|
}, children);
|
|
188
226
|
}
|
|
189
227
|
return /*#__PURE__*/_react.default.createElement(InnerContainer, {
|
|
@@ -176,7 +176,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
176
176
|
},
|
|
177
177
|
editorView: props.view,
|
|
178
178
|
render: function render(pluginStates) {
|
|
179
|
-
var _props$options;
|
|
179
|
+
var _props$options, _props$options2;
|
|
180
180
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
181
181
|
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
182
182
|
pluginState = pluginStates.pluginState,
|
|
@@ -208,8 +208,9 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
208
208
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
209
209
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
210
210
|
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
211
|
-
isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled
|
|
211
|
+
isTableScalingEnabled: (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.isTableScalingEnabled // this.options?.isTableScalingEnabled same as TableOptions.isTableScalingEnabled same as pluginState.isTableScalingEnabled
|
|
212
212
|
,
|
|
213
|
+
isTableAlignmentEnabled: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.isTableAlignmentEnabled,
|
|
213
214
|
tableActive: tableActive,
|
|
214
215
|
ordering: pluginState.ordering,
|
|
215
216
|
isResizing: isResizing,
|
|
@@ -283,7 +284,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
283
284
|
}]);
|
|
284
285
|
return TableView;
|
|
285
286
|
}(_reactNodeView.default);
|
|
286
|
-
var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) {
|
|
287
|
+
var createTableView = exports.createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled) {
|
|
287
288
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
|
|
288
289
|
pluginConfig = _getPluginState2.pluginConfig,
|
|
289
290
|
isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
|
|
@@ -308,7 +309,9 @@ var createTableView = exports.createTableView = function createTableView(node, v
|
|
|
308
309
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled,
|
|
309
310
|
isTableResizingEnabled: isTableResizingEnabled,
|
|
310
311
|
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
311
|
-
isTableScalingEnabled: isTableScalingEnabled
|
|
312
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
313
|
+
// same as options.isTableScalingEnabled
|
|
314
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
312
315
|
},
|
|
313
316
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
314
317
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -45,6 +46,8 @@ var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertB
|
|
|
45
46
|
var _FloatingToolbarLabel = require("./ui/FloatingToolbarLabel/FloatingToolbarLabel");
|
|
46
47
|
var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
|
|
47
48
|
var _utils2 = require("./utils");
|
|
49
|
+
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; }
|
|
50
|
+
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; }
|
|
48
51
|
var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
49
52
|
return {};
|
|
50
53
|
};
|
|
@@ -110,7 +113,11 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
110
113
|
node: node,
|
|
111
114
|
options: {
|
|
112
115
|
selectNodeInserted: false,
|
|
113
|
-
analyticsPayload: analyticsPayload
|
|
116
|
+
analyticsPayload: _objectSpread(_objectSpread({}, analyticsPayload), {}, {
|
|
117
|
+
attributes: _objectSpread(_objectSpread({}, analyticsPayload.attributes), {}, {
|
|
118
|
+
localId: node.attrs.localId
|
|
119
|
+
})
|
|
120
|
+
})
|
|
114
121
|
}
|
|
115
122
|
})) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
|
|
116
123
|
};
|
|
@@ -120,10 +127,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
120
127
|
insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
121
128
|
},
|
|
122
129
|
nodes: function nodes() {
|
|
123
|
-
var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') ? _adfSchema.tableStage0 : _adfSchema.table;
|
|
124
130
|
return [{
|
|
125
131
|
name: 'table',
|
|
126
|
-
node:
|
|
132
|
+
node: _adfSchema.table
|
|
127
133
|
}, {
|
|
128
134
|
name: 'tableHeader',
|
|
129
135
|
node: _adfSchema.tableHeader
|
|
@@ -436,13 +442,15 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
436
442
|
var _api$table;
|
|
437
443
|
// see comment on tablesPlugin.getSharedState on usage
|
|
438
444
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
439
|
-
var
|
|
445
|
+
var tableNode = (0, _utils2.createTableWithWidth)(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema);
|
|
446
|
+
var tr = insert(tableNode);
|
|
440
447
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
441
448
|
action: _analytics.ACTION.INSERTED,
|
|
442
449
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
443
450
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
|
|
444
451
|
attributes: {
|
|
445
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
452
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
453
|
+
localId: tableNode.attrs.localId
|
|
446
454
|
},
|
|
447
455
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
448
456
|
})(tr);
|
|
@@ -15,18 +15,6 @@ var _commandsWithAnalytics = require("../commands-with-analytics");
|
|
|
15
15
|
var _columnResize = require("../commands/column-resize");
|
|
16
16
|
var _insert = require("../commands/insert");
|
|
17
17
|
var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
18
|
-
var _analytics2 = require("../utils/analytics");
|
|
19
|
-
var createTableWithAnalytics = function createTableWithAnalytics(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
20
|
-
return (0, _analytics2.withEditorAnalyticsAPI)({
|
|
21
|
-
action: _analytics.ACTION.INSERTED,
|
|
22
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
23
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TABLE,
|
|
24
|
-
attributes: {
|
|
25
|
-
inputMethod: _analytics.INPUT_METHOD.SHORTCUT
|
|
26
|
-
},
|
|
27
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
28
|
-
})(editorAnalyticsAPI)((0, _commands2.createTable)(isTableScalingEnabled, isFullWidthModeEnabled));
|
|
29
|
-
};
|
|
30
18
|
function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
|
|
31
19
|
var _pluginInjectionApi$a;
|
|
32
20
|
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
@@ -37,7 +25,7 @@ function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEn
|
|
|
37
25
|
var ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
38
26
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.nextCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1), list);
|
|
39
27
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.previousCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1), list);
|
|
40
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common,
|
|
28
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, (0, _insert.createTable)(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
|
|
41
29
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, (0, _commands.chainCommands)((0, _commandsWithAnalytics.deleteTableIfSelectedWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD), (0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD)), list);
|
|
42
30
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, _commands2.moveCursorBackward, list);
|
|
43
31
|
|
|
@@ -260,7 +260,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
260
260
|
},
|
|
261
261
|
nodeViews: {
|
|
262
262
|
table: function table(node, view, getPos) {
|
|
263
|
-
return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi);
|
|
263
|
+
return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi, isTableAlignmentEnabled);
|
|
264
264
|
},
|
|
265
265
|
tableRow: function tableRow(node, view, getPos) {
|
|
266
266
|
return new _TableRow.default(node, view, getPos, eventDispatcher);
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getSelectedAlignmentIcon = exports.getLockBtnConfig = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = exports.getAlignmentOptionsConfig = void 0;
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
11
|
var _react = require("@emotion/react");
|
|
@@ -38,10 +37,11 @@ var _types = require("./types");
|
|
|
38
37
|
var _FloatingAlignmentButtons = require("./ui/FloatingAlignmentButtons/FloatingAlignmentButtons");
|
|
39
38
|
var _icons = require("./ui/icons");
|
|
40
39
|
var _utils4 = require("./utils");
|
|
40
|
+
var _alignment = require("./utils/alignment");
|
|
41
41
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
42
42
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/** @jsx jsx */
|
|
44
|
+
|
|
45
45
|
var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
|
|
46
46
|
var formatMessage = _ref.formatMessage;
|
|
47
47
|
var optionItem = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-table-floating-toolbar-dropdown-menu_zkb33') ? 'item-checkbox' : 'item';
|
|
@@ -331,7 +331,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
331
331
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
332
332
|
var alignmentMenu;
|
|
333
333
|
var isNested = pluginState.tablePos && (0, _utils4.isTableNested)(state, pluginState.tablePos);
|
|
334
|
-
alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl) : [];
|
|
334
|
+
alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI) : [];
|
|
335
335
|
var cellItems;
|
|
336
336
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
337
337
|
var columnSettingsItems;
|
|
@@ -595,7 +595,7 @@ var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch)
|
|
|
595
595
|
}
|
|
596
596
|
return false;
|
|
597
597
|
};
|
|
598
|
-
var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6) {
|
|
598
|
+
var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6, editorAnalyticsAPI) {
|
|
599
599
|
var formatMessage = _ref6.formatMessage;
|
|
600
600
|
var tableObject = (0, _utils3.findTable)(editorState.selection);
|
|
601
601
|
if (!tableObject) {
|
|
@@ -620,13 +620,14 @@ var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function get
|
|
|
620
620
|
var id = alignmentIcon.id,
|
|
621
621
|
value = alignmentIcon.value,
|
|
622
622
|
icon = alignmentIcon.icon;
|
|
623
|
+
var currentLayout = tableObject.node.attrs.layout;
|
|
623
624
|
return {
|
|
624
625
|
id: id,
|
|
625
626
|
type: 'button',
|
|
626
627
|
icon: icon,
|
|
627
628
|
title: formatMessage(layoutToMessages[value]),
|
|
628
|
-
selected:
|
|
629
|
-
onClick:
|
|
629
|
+
selected: (0, _alignment.normaliseAlignment)(currentLayout) === value,
|
|
630
|
+
onClick: (0, _commandsWithAnalytics.setTableAlignmentWithAnalytics)(editorAnalyticsAPI)(value, currentLayout, _analytics.INPUT_METHOD.FLOATING_TB)
|
|
630
631
|
};
|
|
631
632
|
});
|
|
632
633
|
var alignmentItemOptions = {
|
|
@@ -649,27 +650,9 @@ var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function get
|
|
|
649
650
|
}];
|
|
650
651
|
return alignmentToolbarItem;
|
|
651
652
|
};
|
|
652
|
-
var alignTable = function alignTable(nextLayoutValue) {
|
|
653
|
-
return function (state, dispatch) {
|
|
654
|
-
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
655
|
-
if (!tableObject || !dispatch) {
|
|
656
|
-
return false;
|
|
657
|
-
}
|
|
658
|
-
var nextTableAttrs = _objectSpread(_objectSpread({}, tableObject.node.attrs), {}, {
|
|
659
|
-
layout: nextLayoutValue
|
|
660
|
-
});
|
|
661
|
-
var tr = state.tr.setNodeMarkup(tableObject.pos, undefined, nextTableAttrs);
|
|
662
|
-
tr.setMeta('scrollIntoView', false);
|
|
663
|
-
|
|
664
|
-
// TODO - insert analytics here for layout selection
|
|
665
|
-
|
|
666
|
-
dispatch(tr);
|
|
667
|
-
return true;
|
|
668
|
-
};
|
|
669
|
-
};
|
|
670
653
|
var getSelectedAlignmentIcon = exports.getSelectedAlignmentIcon = function getSelectedAlignmentIcon(alignmentIcons, selectedNode) {
|
|
671
654
|
var selectedAlignment = selectedNode.attrs.layout;
|
|
672
655
|
return alignmentIcons.find(function (icon) {
|
|
673
|
-
return icon.value === (
|
|
656
|
+
return icon.value === (0, _alignment.normaliseAlignment)(selectedAlignment);
|
|
674
657
|
});
|
|
675
658
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normaliseAlignment = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Normalise table layout attribute an alignment value ('center' or 'align-start'), returns
|
|
9
|
+
* center if layout equals a breakout value (e.g. 'default', 'wide', 'full-width')
|
|
10
|
+
*/
|
|
11
|
+
var normaliseAlignment = exports.normaliseAlignment = function normaliseAlignment(layout) {
|
|
12
|
+
return layout === 'center' || layout === 'align-start' ? layout : 'center';
|
|
13
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/custom-steps';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
@@ -119,10 +119,22 @@ export const insertRow = (row, moveCursorToTheNewRow, isCellBackgroundDuplicated
|
|
|
119
119
|
}
|
|
120
120
|
return true;
|
|
121
121
|
};
|
|
122
|
-
export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled) => (state, dispatch) => {
|
|
122
|
+
export const createTable = (isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) => (state, dispatch) => {
|
|
123
123
|
const table = createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled)(state.schema);
|
|
124
124
|
if (dispatch) {
|
|
125
|
-
|
|
125
|
+
const tr = safeInsert(table)(state.tr).scrollIntoView();
|
|
126
|
+
if (editorAnalyticsAPI) {
|
|
127
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
128
|
+
action: ACTION.INSERTED,
|
|
129
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
130
|
+
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
131
|
+
attributes: {
|
|
132
|
+
inputMethod: INPUT_METHOD.SHORTCUT
|
|
133
|
+
},
|
|
134
|
+
eventType: EVENT_TYPE.TRACK
|
|
135
|
+
})(tr);
|
|
136
|
+
}
|
|
137
|
+
dispatch(tr);
|
|
126
138
|
}
|
|
127
139
|
return true;
|
|
128
140
|
};
|
|
@@ -549,4 +549,18 @@ export const updateWidthToWidest = widthToWidest => createCommand(state => {
|
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
};
|
|
552
|
-
});
|
|
552
|
+
});
|
|
553
|
+
export const setTableAlignment = newAlignment => ({
|
|
554
|
+
tr
|
|
555
|
+
}) => {
|
|
556
|
+
const tableObject = findTable(tr.selection);
|
|
557
|
+
if (!tableObject) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
const nextTableAttrs = {
|
|
561
|
+
...tableObject.node.attrs,
|
|
562
|
+
layout: newAlignment
|
|
563
|
+
};
|
|
564
|
+
tr.setNodeMarkup(tableObject.pos, undefined, nextTableAttrs).setMeta('scrollIntoView', false);
|
|
565
|
+
return tr;
|
|
566
|
+
};
|
|
@@ -9,7 +9,7 @@ import { changeColumnWidthByStep } from './commands/column-resize';
|
|
|
9
9
|
import { deleteColumnsCommand } from './commands/delete';
|
|
10
10
|
import { setTableDisplayMode } from './commands/display-mode';
|
|
11
11
|
import { insertColumn, insertRow } from './commands/insert';
|
|
12
|
-
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs } from './commands/misc';
|
|
12
|
+
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs, setTableAlignment } from './commands/misc';
|
|
13
13
|
import { sortByColumn } from './commands/sort';
|
|
14
14
|
import { splitCell } from './commands/split-cell';
|
|
15
15
|
import { getNextLayout, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './commands/toggle';
|
|
@@ -490,4 +490,24 @@ export const toggleTableLockWithAnalytics = editorAnalyticsAPI => (displayMode,
|
|
|
490
490
|
eventType: EVENT_TYPE.TRACK
|
|
491
491
|
};
|
|
492
492
|
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
|
|
493
|
-
|
|
493
|
+
export const setTableAlignmentWithAnalytics = editorAnalyticsAPI => (newAlignment, previousAlignment, inputMethod) => withEditorAnalyticsAPI(state => {
|
|
494
|
+
const {
|
|
495
|
+
table,
|
|
496
|
+
totalRowCount,
|
|
497
|
+
totalColumnCount
|
|
498
|
+
} = getSelectedTableInfo(state.selection);
|
|
499
|
+
return {
|
|
500
|
+
action: TABLE_ACTION.CHANGED_ALIGNMENT,
|
|
501
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
502
|
+
actionSubjectId: null,
|
|
503
|
+
eventType: EVENT_TYPE.TRACK,
|
|
504
|
+
attributes: {
|
|
505
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
506
|
+
newAlignment,
|
|
507
|
+
previousAlignment: previousAlignment === 'center' || previousAlignment === 'align-start' ? previousAlignment : null,
|
|
508
|
+
totalRowCount,
|
|
509
|
+
totalColumnCount,
|
|
510
|
+
inputMethod
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignment(newAlignment)));
|