@atlaskit/editor-plugin-table 7.16.16 → 7.16.18
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 +34 -0
- package/dist/cjs/commands-with-analytics.js +66 -41
- package/dist/cjs/nodeviews/TableContainer.js +14 -12
- package/dist/cjs/nodeviews/TableResizer.js +17 -18
- package/dist/cjs/plugin.js +3 -2
- package/dist/cjs/pm-plugins/keymap.js +6 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -1
- package/dist/cjs/toolbar.js +54 -71
- package/dist/cjs/ui/icons/index.js +0 -7
- package/dist/cjs/utils/snapping.js +2 -2
- package/dist/es2019/commands-with-analytics.js +29 -6
- package/dist/es2019/nodeviews/TableContainer.js +17 -13
- package/dist/es2019/nodeviews/TableResizer.js +17 -18
- package/dist/es2019/plugin.js +3 -2
- package/dist/es2019/pm-plugins/keymap.js +7 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/toolbar.js +54 -71
- package/dist/es2019/ui/icons/index.js +0 -1
- package/dist/es2019/utils/snapping.js +3 -3
- package/dist/esm/commands-with-analytics.js +66 -41
- package/dist/esm/nodeviews/TableContainer.js +15 -13
- package/dist/esm/nodeviews/TableResizer.js +20 -21
- package/dist/esm/plugin.js +3 -2
- package/dist/esm/pm-plugins/keymap.js +7 -1
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/esm/toolbar.js +55 -72
- package/dist/esm/ui/icons/index.js +0 -1
- package/dist/esm/utils/snapping.js +3 -3
- package/dist/types/commands/toggle.d.ts +1 -1
- package/dist/types/commands-with-analytics.d.ts +7 -4
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
- package/dist/types/toolbar.d.ts +4 -5
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -0
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -0
- package/dist/types/ui/TableFloatingControls/index.d.ts +2 -0
- package/dist/types/ui/icons/index.d.ts +0 -1
- package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
- package/dist/types-ts4.5/commands-with-analytics.d.ts +7 -4
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
- package/dist/types-ts4.5/toolbar.d.ts +4 -5
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -0
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/icons/index.d.ts +0 -1
- package/package.json +9 -6
- package/src/commands-with-analytics.ts +80 -40
- package/src/nodeviews/TableContainer.tsx +24 -14
- package/src/nodeviews/TableResizer.tsx +29 -15
- package/src/plugin.tsx +5 -2
- package/src/pm-plugins/keymap.ts +30 -0
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/toolbar.tsx +80 -83
- package/src/ui/TableFloatingControls/index.tsx +0 -1
- package/src/ui/icons/index.ts +0 -1
- package/src/utils/snapping.ts +4 -4
- package/dist/cjs/ui/icons/DisplayModeIcon.js +0 -46
- package/dist/es2019/ui/icons/DisplayModeIcon.js +0 -39
- package/dist/esm/ui/icons/DisplayModeIcon.js +0 -39
- package/dist/types/ui/icons/DisplayModeIcon.d.ts +0 -4
- package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +0 -4
- package/src/ui/icons/DisplayModeIcon.tsx +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.16.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#109178](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109178)
|
|
8
|
+
[`c01aae3d5755d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c01aae3d5755d) -
|
|
9
|
+
Change akEditorPadding in table resizing node to use dynamic version to support editor drag and
|
|
10
|
+
drop
|
|
11
|
+
- [#109165](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109165)
|
|
12
|
+
[`0fd6be97334bc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0fd6be97334bc) -
|
|
13
|
+
Use scaled table width to calculate if left alignment should be disabled
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 7.16.17
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#106586](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/106586)
|
|
21
|
+
[`f3486a7d141c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f3486a7d141c) -
|
|
22
|
+
Update usage of akEditorGutterPadding to its dynamic version which can increase padding to support
|
|
23
|
+
editor drag and drop. Breakout logic is also updated to accommodate extra padding.
|
|
24
|
+
- [#107920](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107920)
|
|
25
|
+
[`f918580d1700`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f918580d1700) -
|
|
26
|
+
[ux] Removes Table Lock button and addes a new menu item 'Fixed column widths' in the table's
|
|
27
|
+
floating toolbar menu instead of the button.
|
|
28
|
+
- [#107415](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107415)
|
|
29
|
+
[`f7f135cdedb8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f7f135cdedb8) -
|
|
30
|
+
ED-23441: Added analytics for table aligment changes caused by resizing or appearance changes"
|
|
31
|
+
- [#100714](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100714)
|
|
32
|
+
[`81849acfe13c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/81849acfe13c) -
|
|
33
|
+
ECA11Y-228: Added new shortcuts for insert column and row and added correct formatting for help
|
|
34
|
+
modal dialog
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
|
|
3
37
|
## 7.16.16
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.wrapTableInExpandWithAnalytics = exports.
|
|
7
|
+
exports.wrapTableInExpandWithAnalytics = exports.toggleTableLayoutWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.toggleFixedColumnWidthsOptionAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setTableAlignmentWithTableContentWithPosWithAnalytics = 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");
|
|
11
11
|
var _preset = require("@atlaskit/editor-common/preset");
|
|
12
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
14
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
14
15
|
var _clear = require("./commands/clear");
|
|
15
16
|
var _collapse = require("./commands/collapse");
|
|
@@ -500,47 +501,45 @@ var wrapTableInExpandWithAnalytics = exports.wrapTableInExpandWithAnalytics = fu
|
|
|
500
501
|
};
|
|
501
502
|
})(editorAnalyticsAPI)(_collapse.wrapTableInExpand);
|
|
502
503
|
};
|
|
503
|
-
var
|
|
504
|
-
return
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)(_displayMode.setTableDisplayMode));
|
|
540
|
-
};
|
|
504
|
+
var toggleFixedColumnWidthsOptionAnalytics = exports.toggleFixedColumnWidthsOptionAnalytics = function toggleFixedColumnWidthsOptionAnalytics(editorAnalyticsAPI, inputMethod) {
|
|
505
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
|
|
506
|
+
var _getSelectedTableInfo13 = (0, _utils2.getSelectedTableInfo)(state.selection),
|
|
507
|
+
table = _getSelectedTableInfo13.table,
|
|
508
|
+
totalRowCount = _getSelectedTableInfo13.totalRowCount,
|
|
509
|
+
totalColumnCount = _getSelectedTableInfo13.totalColumnCount;
|
|
510
|
+
var previousDisplayMode;
|
|
511
|
+
var newDisplayMode;
|
|
512
|
+
switch (table === null || table === void 0 ? void 0 : table.node.attrs.displayMode) {
|
|
513
|
+
case 'fixed':
|
|
514
|
+
previousDisplayMode = _analytics.TABLE_DISPLAY_MODE.FIXED;
|
|
515
|
+
newDisplayMode = _analytics.TABLE_DISPLAY_MODE.DEFAULT;
|
|
516
|
+
break;
|
|
517
|
+
case 'default':
|
|
518
|
+
previousDisplayMode = _analytics.TABLE_DISPLAY_MODE.DEFAULT;
|
|
519
|
+
newDisplayMode = _analytics.TABLE_DISPLAY_MODE.FIXED;
|
|
520
|
+
break;
|
|
521
|
+
case null:
|
|
522
|
+
default:
|
|
523
|
+
previousDisplayMode = _analytics.TABLE_DISPLAY_MODE.INITIAL;
|
|
524
|
+
newDisplayMode = _analytics.TABLE_DISPLAY_MODE.FIXED;
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
action: _analytics.TABLE_ACTION.CHANGED_DISPLAY_MODE,
|
|
528
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
529
|
+
attributes: {
|
|
530
|
+
inputMethod: inputMethod,
|
|
531
|
+
previousDisplayMode: previousDisplayMode,
|
|
532
|
+
newDisplayMode: newDisplayMode,
|
|
533
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
534
|
+
totalRowCount: totalRowCount,
|
|
535
|
+
totalColumnCount: totalColumnCount
|
|
536
|
+
},
|
|
537
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
538
|
+
};
|
|
539
|
+
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)(_displayMode.setTableDisplayMode));
|
|
541
540
|
};
|
|
542
541
|
var setTableAlignmentWithAnalytics = exports.setTableAlignmentWithAnalytics = function setTableAlignmentWithAnalytics(editorAnalyticsAPI) {
|
|
543
|
-
return function (newAlignment, previousAlignment, inputMethod) {
|
|
542
|
+
return function (newAlignment, previousAlignment, inputMethod, reason) {
|
|
544
543
|
return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
|
|
545
544
|
var _getSelectedTableInfo14 = (0, _utils2.getSelectedTableInfo)(state.selection),
|
|
546
545
|
table = _getSelectedTableInfo14.table,
|
|
@@ -557,9 +556,35 @@ var setTableAlignmentWithAnalytics = exports.setTableAlignmentWithAnalytics = fu
|
|
|
557
556
|
previousAlignment: previousAlignment === 'center' || previousAlignment === 'align-start' ? previousAlignment : null,
|
|
558
557
|
totalRowCount: totalRowCount,
|
|
559
558
|
totalColumnCount: totalColumnCount,
|
|
560
|
-
inputMethod: inputMethod
|
|
559
|
+
inputMethod: inputMethod,
|
|
560
|
+
reason: reason
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
563
|
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)((0, _misc.setTableAlignment)(newAlignment)));
|
|
564
564
|
};
|
|
565
|
+
};
|
|
566
|
+
var setTableAlignmentWithTableContentWithPosWithAnalytics = exports.setTableAlignmentWithTableContentWithPosWithAnalytics = function setTableAlignmentWithTableContentWithPosWithAnalytics(editorAnalyticsAPI) {
|
|
567
|
+
return function (newAlignment, previousAlignment, tableNodeWithPos, inputMethod, reason) {
|
|
568
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function () {
|
|
569
|
+
var map = _tableMap.TableMap.get(tableNodeWithPos.node);
|
|
570
|
+
var totalRowCount = map.height;
|
|
571
|
+
var totalColumnCount = map.width;
|
|
572
|
+
var attributes = {
|
|
573
|
+
tableWidth: tableNodeWithPos.node.attrs.width,
|
|
574
|
+
newAlignment: newAlignment,
|
|
575
|
+
previousAlignment: previousAlignment,
|
|
576
|
+
totalRowCount: totalRowCount,
|
|
577
|
+
totalColumnCount: totalColumnCount,
|
|
578
|
+
inputMethod: inputMethod,
|
|
579
|
+
reason: reason
|
|
580
|
+
};
|
|
581
|
+
return {
|
|
582
|
+
action: _analytics.TABLE_ACTION.CHANGED_ALIGNMENT,
|
|
583
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
584
|
+
actionSubjectId: null,
|
|
585
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
586
|
+
attributes: attributes
|
|
587
|
+
};
|
|
588
|
+
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)((0, _misc.setTableAlignmentWithTableContentWithPos)(newAlignment, tableNodeWithPos)));
|
|
589
|
+
};
|
|
565
590
|
};
|
|
@@ -9,12 +9,14 @@ exports.TableContainer = exports.ResizableTableContainer = exports.InnerContaine
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
14
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
14
15
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
|
-
var
|
|
16
|
+
var _commandsWithAnalytics = require("../commands-with-analytics");
|
|
16
17
|
var _utils = require("../pm-plugins/table-resizing/utils");
|
|
17
18
|
var _types = require("../types");
|
|
19
|
+
var _alignment = require("../utils/alignment");
|
|
18
20
|
var _TableResizer = require("./TableResizer");
|
|
19
21
|
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); }
|
|
20
22
|
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; }
|
|
@@ -50,25 +52,25 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
|
|
|
50
52
|
pluginInjectionApi = _ref2.pluginInjectionApi,
|
|
51
53
|
getPos = _ref2.getPos,
|
|
52
54
|
editorView = _ref2.editorView;
|
|
53
|
-
var alignment = node.attrs.layout;
|
|
55
|
+
var alignment = node.attrs.layout !== _alignment.ALIGN_START ? _alignment.ALIGN_CENTER : _alignment.ALIGN_START;
|
|
54
56
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['table']),
|
|
55
57
|
tableState = _useSharedPluginState.tableState;
|
|
56
58
|
(0, _react.useEffect)(function () {
|
|
57
59
|
if (tableState && editorView && getPos) {
|
|
58
60
|
var wasFullWidthModeEnabled = tableState.wasFullWidthModeEnabled,
|
|
59
61
|
isFullWidthModeEnabled = tableState.isFullWidthModeEnabled;
|
|
60
|
-
|
|
62
|
+
var state = editorView.state,
|
|
63
|
+
dispatch = editorView.dispatch;
|
|
64
|
+
if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== _alignment.ALIGN_CENTER && node.attrs.width > _editorSharedStyles.akEditorDefaultLayoutWidth) {
|
|
65
|
+
var _pluginInjectionApi$a;
|
|
61
66
|
var pos = getPos && getPos();
|
|
62
67
|
if (typeof pos !== 'number') {
|
|
63
68
|
return;
|
|
64
69
|
}
|
|
65
|
-
|
|
70
|
+
(0, _commandsWithAnalytics.setTableAlignmentWithTableContentWithPosWithAnalytics)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(_alignment.ALIGN_CENTER, alignment, {
|
|
66
71
|
pos: pos,
|
|
67
72
|
node: node
|
|
68
|
-
})(
|
|
69
|
-
if (tr) {
|
|
70
|
-
editorView.dispatch(tr);
|
|
71
|
-
}
|
|
73
|
+
}, _analytics.INPUT_METHOD.AUTO, _analytics.CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -181,8 +183,8 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
181
183
|
})) !== null && _pluginInjectionApi$g !== void 0 ? _pluginInjectionApi$g : false;
|
|
182
184
|
}, [pluginInjectionApi, editorView]);
|
|
183
185
|
var attachAnalyticsEvent = (0, _react.useCallback)(function (payload) {
|
|
184
|
-
var _pluginInjectionApi$
|
|
185
|
-
return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
186
|
+
var _pluginInjectionApi$a2;
|
|
187
|
+
return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.attachAnalyticsEvent(payload);
|
|
186
188
|
}, [pluginInjectionApi]);
|
|
187
189
|
var displayGapCursor = (0, _react.useCallback)(function (toggle) {
|
|
188
190
|
var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
|
|
@@ -202,13 +204,13 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
202
204
|
// When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
|
|
203
205
|
// When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
|
|
204
206
|
// scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
|
|
205
|
-
responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - _editorSharedStyles.
|
|
207
|
+
responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 - resizeHandleSpacing;
|
|
206
208
|
} else {
|
|
207
209
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
208
210
|
// containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
|
|
209
211
|
// a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
|
|
210
212
|
// padding left = padding right = akEditorGutterPadding = 32
|
|
211
|
-
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - _editorSharedStyles.
|
|
213
|
+
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 : containerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 - resizeHandleSpacing;
|
|
212
214
|
}
|
|
213
215
|
var width = Math.min(tableWidth, responsiveContainerWidth);
|
|
214
216
|
if (!isResizing) {
|
|
@@ -22,6 +22,7 @@ var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
|
22
22
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
23
23
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
24
24
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
|
+
var _commandsWithAnalytics = require("../commands-with-analytics");
|
|
25
26
|
var _misc = require("../commands/misc");
|
|
26
27
|
var _tableAnalytics = require("../pm-plugins/table-analytics");
|
|
27
28
|
var _utils3 = require("../pm-plugins/table-resizing/utils");
|
|
@@ -94,7 +95,7 @@ var getVisibleGuidelines = function getVisibleGuidelines(guidelines, containerWi
|
|
|
94
95
|
// guidelineVisibleAdjustment is set as a negative value, so we making it positive and adding + 1
|
|
95
96
|
var preserve_table_widths_adjustment = -1 * _guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET + 1;
|
|
96
97
|
guidelineVisibleAdjustment = isFullWidthModeEnabled ? preserve_table_widths_adjustment // guidelineVisibleAdjustment = -2, if lineLength = 1180, 1181 < 1180 + 2 is true.
|
|
97
|
-
: -2 * _editorSharedStyles.
|
|
98
|
+
: -2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() + preserve_table_widths_adjustment; // guidelineVisibleAdjustment = -62, if containerWidth is 1244, 1181 < 1244 - 62 = 1182 is true.
|
|
98
99
|
}
|
|
99
100
|
var width = isTableScalingEnabled && isFullWidthModeEnabled ? lineLength : containerWidth;
|
|
100
101
|
return guidelines.filter(function (guideline) {
|
|
@@ -102,7 +103,7 @@ var getVisibleGuidelines = function getVisibleGuidelines(guidelines, containerWi
|
|
|
102
103
|
});
|
|
103
104
|
};
|
|
104
105
|
var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
105
|
-
var _findTable, _editorView$state;
|
|
106
|
+
var _findTable, _editorView$state, _pluginInjectionApi$a2;
|
|
106
107
|
var children = _ref.children,
|
|
107
108
|
width = _ref.width,
|
|
108
109
|
maxWidth = _ref.maxWidth,
|
|
@@ -160,7 +161,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
160
161
|
keys = _ref3.keys;
|
|
161
162
|
if (gap !== currentGap.current) {
|
|
162
163
|
currentGap.current = gap;
|
|
163
|
-
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * _editorSharedStyles.
|
|
164
|
+
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() : containerWidth, excludeGuidelineConfig) : _guidelines.defaultGuidelines, containerWidth, lineLength, Boolean(isTableScalingEnabled), Boolean(isFullWidthModeEnabled));
|
|
164
165
|
displayGuideline((0, _guideline.getGuidelinesWithHighlights)(gap, _consts.TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
165
166
|
}
|
|
166
167
|
}, [isTableScalingEnabled, excludeGuidelineConfig, containerWidth, displayGuideline, lineLength, isFullWidthModeEnabled]);
|
|
@@ -168,40 +169,38 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
168
169
|
return snappingEnabled ? {
|
|
169
170
|
x: isTableScalingEnabled ? (0, _snapping.defaultTablePreserveSnappingWidths)(_snapping.PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET,
|
|
170
171
|
// was hardcoded to 0, using PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
|
|
171
|
-
isFullWidthModeEnabled ? lineLength + 2 * _editorSharedStyles.
|
|
172
|
+
isFullWidthModeEnabled ? lineLength + 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() : containerWidth, excludeGuidelineConfig) : _snapping.defaultSnappingWidths
|
|
172
173
|
} : undefined;
|
|
173
174
|
}, [snappingEnabled, isTableScalingEnabled, excludeGuidelineConfig, containerWidth, lineLength, isFullWidthModeEnabled]);
|
|
174
175
|
var switchToCenterAlignment = (0, _react.useCallback)(function (pos, node, newWidth, state, dispatch) {
|
|
175
176
|
if (isTableAlignmentEnabled && node && node.attrs.layout === _alignment.ALIGN_START && newWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH &&
|
|
176
177
|
// We don't want to switch alignment in Full-width editor
|
|
177
178
|
isResizing.current) {
|
|
179
|
+
var _pluginInjectionApi$a;
|
|
178
180
|
var tableNodeWithPos = {
|
|
179
181
|
pos: pos,
|
|
180
182
|
node: node
|
|
181
183
|
};
|
|
182
|
-
|
|
183
|
-
if (_tr) {
|
|
184
|
-
dispatch(_tr);
|
|
185
|
-
}
|
|
184
|
+
(0, _commandsWithAnalytics.setTableAlignmentWithTableContentWithPosWithAnalytics)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(_alignment.ALIGN_CENTER, _alignment.ALIGN_START, tableNodeWithPos, _analytics.INPUT_METHOD.AUTO, _analytics.CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
|
|
186
185
|
return true;
|
|
187
186
|
}
|
|
188
187
|
return false;
|
|
189
|
-
}, [
|
|
188
|
+
}, [isTableAlignmentEnabled, lineLength, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions]);
|
|
190
189
|
(0, _react.useEffect)(function () {
|
|
191
190
|
return function () {
|
|
192
191
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
193
192
|
// deleted this table
|
|
194
193
|
if (isResizing.current) {
|
|
195
194
|
var dispatch = editorView.dispatch,
|
|
196
|
-
|
|
195
|
+
_tr = editorView.state.tr;
|
|
197
196
|
displayGapCursor(true);
|
|
198
197
|
displayGuideline([]);
|
|
199
|
-
|
|
198
|
+
_tr.setMeta(_tableWidth.pluginKey, {
|
|
200
199
|
resizing: false,
|
|
201
200
|
tableLocalId: '',
|
|
202
201
|
tableRef: null
|
|
203
202
|
});
|
|
204
|
-
dispatch(
|
|
203
|
+
dispatch(_tr);
|
|
205
204
|
}
|
|
206
205
|
};
|
|
207
206
|
}, [editorView, displayGuideline, displayGapCursor]);
|
|
@@ -220,7 +219,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
220
219
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
221
220
|
});
|
|
222
221
|
dispatch(tr);
|
|
223
|
-
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * _editorSharedStyles.
|
|
222
|
+
var visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() : containerWidth, excludeGuidelineConfig) : _guidelines.defaultGuidelines, containerWidth, lineLength, Boolean(isTableScalingEnabled), Boolean(isFullWidthModeEnabled));
|
|
224
223
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
225
224
|
if (onResizeStart) {
|
|
226
225
|
onResizeStart();
|
|
@@ -245,7 +244,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
245
244
|
start: pos + 1,
|
|
246
245
|
parentWidth: newWidth
|
|
247
246
|
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
248
|
-
var editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 * _editorSharedStyles.
|
|
247
|
+
var editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 * (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() : containerWidth;
|
|
249
248
|
var closestSnap = (0, _snapping.findClosestSnap)(newWidth, isTableScalingEnabled ? (0, _snapping.defaultTablePreserveSnappingWidths)(_snapping.PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : _snapping.defaultSnappingWidths, isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP, _consts.TABLE_HIGHLIGHT_TOLERANCE);
|
|
250
249
|
updateActiveGuidelines(closestSnap);
|
|
251
250
|
|
|
@@ -315,13 +314,13 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
315
314
|
dispatch(tr);
|
|
316
315
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-table-resizing_uapcv')) {
|
|
317
316
|
if (delta.width < 0) {
|
|
318
|
-
var _pluginInjectionApi$
|
|
319
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
317
|
+
var _pluginInjectionApi$a3;
|
|
318
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a3 === void 0 || _pluginInjectionApi$a3.actions.ariaNotify(formatMessage(_messages.tableMessages.tableSizeDecreaseScreenReaderInformation, {
|
|
320
319
|
newWidth: newWidth
|
|
321
320
|
}));
|
|
322
321
|
} else if (delta.width > 0) {
|
|
323
|
-
var _pluginInjectionApi$
|
|
324
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
322
|
+
var _pluginInjectionApi$a4;
|
|
323
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.ariaNotify(formatMessage(_messages.tableMessages.tableSizeIncreaseScreenReaderInformation, {
|
|
325
324
|
newWidth: newWidth
|
|
326
325
|
}));
|
|
327
326
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -72,7 +72,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
75
|
-
var
|
|
75
|
+
var isTableScalingWithFixedColumnWidthsOptionEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button');
|
|
76
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.use-increased-scaling-percent');
|
|
76
77
|
return {
|
|
77
78
|
name: 'table',
|
|
78
79
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
@@ -471,7 +472,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
471
472
|
},
|
|
472
473
|
floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
|
|
473
474
|
return editorViewRef.current;
|
|
474
|
-
}, options, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
475
|
+
}, options, isTableScalingWithFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
475
476
|
}
|
|
476
477
|
};
|
|
477
478
|
};
|
|
@@ -36,6 +36,12 @@ function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEn
|
|
|
36
36
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowAfter.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('BOTTOM'), list);
|
|
37
37
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnBefore.common, (0, _insert.addColumnBefore)(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
38
38
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfter.common, (0, _insert.addColumnAfter)(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
39
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg')) {
|
|
40
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowBeforeVO.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('TOP'), list);
|
|
41
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addRowAfterVO.common, (0, _commandsWithAnalytics.addRowAroundSelection)(editorAnalyticsAPI)('BOTTOM'), list);
|
|
42
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnBeforeVO.common, (0, _insert.addColumnBefore)(isTableScalingEnabled), list);
|
|
43
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfterVO.common, (0, _insert.addColumnAfter)(isTableScalingEnabled), list);
|
|
44
|
+
}
|
|
39
45
|
if (dragAndDropEnabled) {
|
|
40
46
|
// Move row/column shortcuts
|
|
41
47
|
/**
|
|
@@ -22,7 +22,7 @@ function getLayoutSize(tableLayout) {
|
|
|
22
22
|
var options = arguments.length > 2 ? arguments[2] : undefined;
|
|
23
23
|
var isFullWidthModeEnabled = options.isFullWidthModeEnabled;
|
|
24
24
|
if (isFullWidthModeEnabled) {
|
|
25
|
-
return containerWidth ? Math.min(containerWidth - _editorSharedStyles.
|
|
25
|
+
return containerWidth ? Math.min(containerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2, _editorSharedStyles.akEditorFullWidthLayoutWidth) : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
26
26
|
}
|
|
27
27
|
var calculatedTableWidth = (0, _styles.calcTableWidth)(tableLayout, containerWidth, true);
|
|
28
28
|
if (calculatedTableWidth !== 'inherit') {
|