@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/dist/cjs/toolbar.js
CHANGED
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.isLayoutOptionDisabled = exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getSelectedAlignmentIcon = exports.
|
|
8
|
+
exports.isLayoutOptionDisabled = exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getSelectedAlignmentIcon = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = exports.getAlignmentOptionsConfig = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -32,12 +32,12 @@ var _commands = require("./commands");
|
|
|
32
32
|
var _commandsWithAnalytics = require("./commands-with-analytics");
|
|
33
33
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
34
34
|
var _tableResizing = require("./pm-plugins/table-resizing");
|
|
35
|
+
var _misc = require("./pm-plugins/table-resizing/utils/misc");
|
|
35
36
|
var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
|
|
36
37
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
37
38
|
var _transforms = require("./transforms");
|
|
38
39
|
var _types = require("./types");
|
|
39
40
|
var _FloatingAlignmentButtons = require("./ui/FloatingAlignmentButtons/FloatingAlignmentButtons");
|
|
40
|
-
var _icons = require("./ui/icons");
|
|
41
41
|
var _utils4 = require("./utils");
|
|
42
42
|
var _alignment = require("./utils/alignment");
|
|
43
43
|
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); }
|
|
@@ -46,8 +46,19 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
46
46
|
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; } /** @jsx jsx */
|
|
47
47
|
var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
|
|
48
48
|
var formatMessage = _ref.formatMessage;
|
|
49
|
+
var isTableScalingWithFixedColumnWidthsOptionShown = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
50
|
+
var areTableColumnWidthsFixed = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
49
51
|
var optionItem = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-table-floating-toolbar-dropdown-menu_zkb33') ? 'item-checkbox' : 'item';
|
|
50
52
|
var options = [{
|
|
53
|
+
id: 'editor.table.lockColumnWidths',
|
|
54
|
+
title: formatMessage(_messages.tableMessages.lockColumnWidths),
|
|
55
|
+
onClick: (0, _commandsWithAnalytics.toggleFixedColumnWidthsOptionAnalytics)(editorAnalyticsAPI, _analytics.INPUT_METHOD.FLOATING_TB),
|
|
56
|
+
selected: areTableColumnWidthsFixed,
|
|
57
|
+
hidden: !isTableScalingWithFixedColumnWidthsOptionShown,
|
|
58
|
+
domItemOptions: {
|
|
59
|
+
type: optionItem
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
51
62
|
id: 'editor.table.headerRow',
|
|
52
63
|
title: formatMessage(_messages.tableMessages.headerRow),
|
|
53
64
|
onClick: (0, _commandsWithAnalytics.toggleHeaderRowWithAnalytics)(editorAnalyticsAPI),
|
|
@@ -95,7 +106,8 @@ var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMen
|
|
|
95
106
|
hidden: options.every(function (option) {
|
|
96
107
|
return option.hidden;
|
|
97
108
|
}),
|
|
98
|
-
options: options
|
|
109
|
+
options: options,
|
|
110
|
+
dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined
|
|
99
111
|
};
|
|
100
112
|
} else {
|
|
101
113
|
return {
|
|
@@ -106,7 +118,8 @@ var getToolbarMenuConfig = exports.getToolbarMenuConfig = function getToolbarMen
|
|
|
106
118
|
hidden: options.every(function (option) {
|
|
107
119
|
return option.hidden;
|
|
108
120
|
}),
|
|
109
|
-
options: options
|
|
121
|
+
options: options,
|
|
122
|
+
dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined
|
|
110
123
|
};
|
|
111
124
|
}
|
|
112
125
|
};
|
|
@@ -320,7 +333,8 @@ var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = fu
|
|
|
320
333
|
return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : tableRect;
|
|
321
334
|
};
|
|
322
335
|
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
|
|
323
|
-
var
|
|
336
|
+
var isTableScalingWithFixedColumnWidthsOptionEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
337
|
+
var shouldUseIncreasedScalingPercent = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
324
338
|
return function (config) {
|
|
325
339
|
return function (state, intl) {
|
|
326
340
|
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
@@ -332,14 +346,26 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
332
346
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
333
347
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
334
348
|
var nodeType = state.schema.nodes.table;
|
|
335
|
-
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
336
|
-
var alignmentMenu;
|
|
337
349
|
var isNested = pluginState.tablePos && (0, _utils4.isTableNested)(state, pluginState.tablePos);
|
|
338
|
-
|
|
339
|
-
var
|
|
340
|
-
|
|
341
|
-
var
|
|
342
|
-
|
|
350
|
+
var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingWithFixedColumnWidthsOptionEnabled && !isNested;
|
|
351
|
+
var areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
|
|
352
|
+
var editorView = getEditorView();
|
|
353
|
+
var getDomRef = function getDomRef(editorView) {
|
|
354
|
+
var element;
|
|
355
|
+
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
356
|
+
var parent = (0, _utils2.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
|
|
357
|
+
if (parent) {
|
|
358
|
+
var tableRef = parent.querySelector('table') || undefined;
|
|
359
|
+
if (tableRef) {
|
|
360
|
+
element = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return element;
|
|
364
|
+
};
|
|
365
|
+
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
|
|
366
|
+
var alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView) : [];
|
|
367
|
+
var cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, shouldUseIncreasedScalingPercent);
|
|
368
|
+
var columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, editorView, intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) : [];
|
|
343
369
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI, getEditorView);
|
|
344
370
|
|
|
345
371
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -366,18 +392,6 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
366
392
|
};
|
|
367
393
|
};
|
|
368
394
|
}
|
|
369
|
-
var getDomRef = function getDomRef(editorView) {
|
|
370
|
-
var element;
|
|
371
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
372
|
-
var parent = (0, _utils2.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
|
|
373
|
-
if (parent) {
|
|
374
|
-
var tableRef = parent.querySelector('table') || undefined;
|
|
375
|
-
if (tableRef) {
|
|
376
|
-
element = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
return element;
|
|
380
|
-
};
|
|
381
395
|
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
382
396
|
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
383
397
|
return {
|
|
@@ -450,23 +464,6 @@ var getCellItems = function getCellItems(state, view, _ref3, getEditorContainerW
|
|
|
450
464
|
}
|
|
451
465
|
return [];
|
|
452
466
|
};
|
|
453
|
-
var getLockBtnConfig = exports.getLockBtnConfig = function getLockBtnConfig(editorAnalyticsAPI) {
|
|
454
|
-
return function (state, dispatch, editorView) {
|
|
455
|
-
var selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
456
|
-
if (!editorView || !selectionOrTableRect) {
|
|
457
|
-
return false;
|
|
458
|
-
}
|
|
459
|
-
var tr = state.tr;
|
|
460
|
-
var table = (0, _utils3.findTable)(tr.selection);
|
|
461
|
-
if (!table) {
|
|
462
|
-
return false;
|
|
463
|
-
} else {
|
|
464
|
-
var displayMode = table.node.attrs.displayMode;
|
|
465
|
-
(0, _commandsWithAnalytics.toggleTableLockWithAnalytics)(editorAnalyticsAPI)(displayMode, _analytics.INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
466
|
-
return true;
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
};
|
|
470
467
|
var getDistributeConfig = exports.getDistributeConfig = function getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
471
468
|
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
472
469
|
return function (state, dispatch, editorView) {
|
|
@@ -497,29 +494,6 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
497
494
|
var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
498
495
|
var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
499
496
|
var items = [];
|
|
500
|
-
var isNested = pluginState.tablePos && (0, _utils4.isTableNested)(editorState, pluginState.tablePos);
|
|
501
|
-
var isTableScalingLockBtnEnabled = !isNested && isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button');
|
|
502
|
-
if (isTableScalingLockBtnEnabled) {
|
|
503
|
-
var _pluginState$tableNod;
|
|
504
|
-
var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
|
|
505
|
-
var title = areColumnWidthsLocked ? formatMessage(_messages.tableMessages.unlockColumnWidths) : formatMessage(_messages.tableMessages.lockColumnWidths);
|
|
506
|
-
items.push({
|
|
507
|
-
id: 'editor.table.lockColumns',
|
|
508
|
-
type: 'button',
|
|
509
|
-
title: title,
|
|
510
|
-
icon: function icon() {
|
|
511
|
-
return (0, _react.jsx)(_icons.DisplayModeIcon, {
|
|
512
|
-
size: "medium",
|
|
513
|
-
label: title
|
|
514
|
-
});
|
|
515
|
-
},
|
|
516
|
-
onClick: function onClick(state, dispatch, view) {
|
|
517
|
-
return getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view);
|
|
518
|
-
},
|
|
519
|
-
selected: areColumnWidthsLocked,
|
|
520
|
-
testId: 'table-lock-column-widths-btn'
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
497
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
524
498
|
items.push({
|
|
525
499
|
id: 'editor.table.distributeColumns',
|
|
@@ -600,7 +574,7 @@ var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch)
|
|
|
600
574
|
}
|
|
601
575
|
return false;
|
|
602
576
|
};
|
|
603
|
-
var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6, editorAnalyticsAPI, getEditorContainerWidth) {
|
|
577
|
+
var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function getAlignmentOptionsConfig(editorState, _ref6, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView) {
|
|
604
578
|
var formatMessage = _ref6.formatMessage;
|
|
605
579
|
var tableObject = (0, _utils3.findTable)(editorState.selection);
|
|
606
580
|
if (!tableObject) {
|
|
@@ -632,8 +606,8 @@ var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function get
|
|
|
632
606
|
icon: icon,
|
|
633
607
|
title: formatMessage(layoutToMessages[value]),
|
|
634
608
|
selected: (0, _alignment.normaliseAlignment)(currentLayout) === value,
|
|
635
|
-
onClick: (0, _commandsWithAnalytics.setTableAlignmentWithAnalytics)(editorAnalyticsAPI)(value, currentLayout, _analytics.INPUT_METHOD.FLOATING_TB)
|
|
636
|
-
}, isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth) && {
|
|
609
|
+
onClick: (0, _commandsWithAnalytics.setTableAlignmentWithAnalytics)(editorAnalyticsAPI)(value, currentLayout, _analytics.INPUT_METHOD.FLOATING_TB, _analytics.CHANGE_ALIGNMENT_REASON.TOOLBAR_OPTION_CHANGED)
|
|
610
|
+
}, isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth, getDomRef, editorView) && {
|
|
637
611
|
disabled: value !== 'center'
|
|
638
612
|
});
|
|
639
613
|
});
|
|
@@ -663,10 +637,19 @@ var getSelectedAlignmentIcon = exports.getSelectedAlignmentIcon = function getSe
|
|
|
663
637
|
return icon.value === (0, _alignment.normaliseAlignment)(selectedAlignment);
|
|
664
638
|
});
|
|
665
639
|
};
|
|
666
|
-
var isLayoutOptionDisabled = exports.isLayoutOptionDisabled = function isLayoutOptionDisabled(selectedNode, getEditorContainerWidth) {
|
|
667
|
-
var
|
|
668
|
-
|
|
669
|
-
|
|
640
|
+
var isLayoutOptionDisabled = exports.isLayoutOptionDisabled = function isLayoutOptionDisabled(selectedNode, getEditorContainerWidth, getDomRef, editorView) {
|
|
641
|
+
var _getEditorContainerWi = getEditorContainerWidth(),
|
|
642
|
+
lineLength = _getEditorContainerWi.lineLength;
|
|
643
|
+
var tableContainerWidth = (0, _nodeWidth.getTableContainerWidth)(selectedNode);
|
|
644
|
+
|
|
645
|
+
// table may be scaled, use the scale percent to calculate the table width
|
|
646
|
+
if (editorView) {
|
|
647
|
+
var tableWrapper = getDomRef(editorView);
|
|
648
|
+
var tableWrapperWidth = (tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.clientWidth) || tableContainerWidth;
|
|
649
|
+
var scalePercent = (0, _misc.getStaticTableScalingPercent)(selectedNode, tableWrapperWidth);
|
|
650
|
+
tableContainerWidth = tableContainerWidth * scalePercent;
|
|
651
|
+
}
|
|
652
|
+
if (selectedNode && lineLength && tableContainerWidth > lineLength) {
|
|
670
653
|
return true;
|
|
671
654
|
}
|
|
672
655
|
return false;
|
|
@@ -27,12 +27,6 @@ Object.defineProperty(exports, "AddRowBelowIcon", {
|
|
|
27
27
|
return _AddRowBelowIcon.AddRowBelowIcon;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "DisplayModeIcon", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _DisplayModeIcon.DisplayModeIcon;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
30
|
Object.defineProperty(exports, "DragHandleDisabledIcon", {
|
|
37
31
|
enumerable: true,
|
|
38
32
|
get: function get() {
|
|
@@ -72,7 +66,6 @@ Object.defineProperty(exports, "SplitCellIcon", {
|
|
|
72
66
|
var _DragHandleIcon = require("./DragHandleIcon");
|
|
73
67
|
var _DragInMotionIcon = require("./DragInMotionIcon");
|
|
74
68
|
var _DragHandleDisabledIcon = require("./DragHandleDisabledIcon");
|
|
75
|
-
var _DisplayModeIcon = require("./DisplayModeIcon");
|
|
76
69
|
var _MinimisedHandle = require("./MinimisedHandle");
|
|
77
70
|
var _MergeCellsIcon = require("./MergeCellsIcon");
|
|
78
71
|
var _SplitCellIcon = require("./SplitCellIcon");
|
|
@@ -26,7 +26,7 @@ var calculateDefaultTablePreserveSnappings = exports.calculateDefaultTablePreser
|
|
|
26
26
|
innerGuidelines: false,
|
|
27
27
|
breakoutPoints: false
|
|
28
28
|
};
|
|
29
|
-
var dynamicFullWidthLine = editorContainerWith - _editorSharedStyles.
|
|
29
|
+
var dynamicFullWidthLine = editorContainerWith - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 >= _editorSharedStyles.akEditorFullWidthLayoutWidth ? _editorSharedStyles.akEditorFullWidthLayoutWidth : editorContainerWith - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2;
|
|
30
30
|
var guides = [dynamicFullWidthLine - lengthOffset];
|
|
31
31
|
if (!exclude.breakoutPoints) {
|
|
32
32
|
guides.unshift(_editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset, _editorSharedStyles.akEditorCalculatedWideLayoutWidth + lengthOffset);
|
|
@@ -44,7 +44,7 @@ var defaultTablePreserveSnappingWidths = exports.defaultTablePreserveSnappingWid
|
|
|
44
44
|
innerGuidelines: false,
|
|
45
45
|
breakoutPoints: false
|
|
46
46
|
};
|
|
47
|
-
return editorContainerWidth - _editorSharedStyles.
|
|
47
|
+
return editorContainerWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2 > _editorSharedStyles.akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(lengthOffset, editorContainerWidth, exclude); // lengthOffset was hardcoded 0 here, created PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -2,6 +2,7 @@ import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
|
|
|
2
2
|
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_BREAKOUT, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
6
|
import { findCellClosestToPos, findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
6
7
|
import { clearMultipleCells } from './commands/clear';
|
|
7
8
|
import { wrapTableInExpand } from './commands/collapse';
|
|
@@ -9,7 +10,7 @@ import { changeColumnWidthByStep } from './commands/column-resize';
|
|
|
9
10
|
import { deleteColumnsCommand } from './commands/delete';
|
|
10
11
|
import { setTableDisplayMode } from './commands/display-mode';
|
|
11
12
|
import { insertColumn, insertRow } from './commands/insert';
|
|
12
|
-
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs, setTableAlignment } from './commands/misc';
|
|
13
|
+
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs, setTableAlignment, setTableAlignmentWithTableContentWithPos } from './commands/misc';
|
|
13
14
|
import { sortByColumn } from './commands/sort';
|
|
14
15
|
import { splitCell } from './commands/split-cell';
|
|
15
16
|
import { getNextLayout, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './commands/toggle';
|
|
@@ -454,7 +455,7 @@ export const wrapTableInExpandWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
454
455
|
eventType: EVENT_TYPE.TRACK
|
|
455
456
|
};
|
|
456
457
|
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
457
|
-
export const
|
|
458
|
+
export const toggleFixedColumnWidthsOptionAnalytics = (editorAnalyticsAPI, inputMethod) => withEditorAnalyticsAPI(state => {
|
|
458
459
|
const {
|
|
459
460
|
table,
|
|
460
461
|
totalRowCount,
|
|
@@ -462,7 +463,7 @@ export const toggleTableLockWithAnalytics = editorAnalyticsAPI => (displayMode,
|
|
|
462
463
|
} = getSelectedTableInfo(state.selection);
|
|
463
464
|
let previousDisplayMode;
|
|
464
465
|
let newDisplayMode;
|
|
465
|
-
switch (displayMode) {
|
|
466
|
+
switch (table === null || table === void 0 ? void 0 : table.node.attrs.displayMode) {
|
|
466
467
|
case 'fixed':
|
|
467
468
|
previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
468
469
|
newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
@@ -490,7 +491,7 @@ export const toggleTableLockWithAnalytics = editorAnalyticsAPI => (displayMode,
|
|
|
490
491
|
eventType: EVENT_TYPE.TRACK
|
|
491
492
|
};
|
|
492
493
|
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
|
|
493
|
-
export const setTableAlignmentWithAnalytics = editorAnalyticsAPI => (newAlignment, previousAlignment, inputMethod) => withEditorAnalyticsAPI(state => {
|
|
494
|
+
export const setTableAlignmentWithAnalytics = editorAnalyticsAPI => (newAlignment, previousAlignment, inputMethod, reason) => withEditorAnalyticsAPI(state => {
|
|
494
495
|
const {
|
|
495
496
|
table,
|
|
496
497
|
totalRowCount,
|
|
@@ -507,7 +508,29 @@ export const setTableAlignmentWithAnalytics = editorAnalyticsAPI => (newAlignmen
|
|
|
507
508
|
previousAlignment: previousAlignment === 'center' || previousAlignment === 'align-start' ? previousAlignment : null,
|
|
508
509
|
totalRowCount,
|
|
509
510
|
totalColumnCount,
|
|
510
|
-
inputMethod
|
|
511
|
+
inputMethod,
|
|
512
|
+
reason
|
|
511
513
|
}
|
|
512
514
|
};
|
|
513
|
-
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignment(newAlignment)));
|
|
515
|
+
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignment(newAlignment)));
|
|
516
|
+
export const setTableAlignmentWithTableContentWithPosWithAnalytics = editorAnalyticsAPI => (newAlignment, previousAlignment, tableNodeWithPos, inputMethod, reason) => withEditorAnalyticsAPI(() => {
|
|
517
|
+
const map = TableMap.get(tableNodeWithPos.node);
|
|
518
|
+
const totalRowCount = map.height;
|
|
519
|
+
const totalColumnCount = map.width;
|
|
520
|
+
const attributes = {
|
|
521
|
+
tableWidth: tableNodeWithPos.node.attrs.width,
|
|
522
|
+
newAlignment: newAlignment,
|
|
523
|
+
previousAlignment: previousAlignment,
|
|
524
|
+
totalRowCount: totalRowCount,
|
|
525
|
+
totalColumnCount: totalColumnCount,
|
|
526
|
+
inputMethod: inputMethod,
|
|
527
|
+
reason: reason
|
|
528
|
+
};
|
|
529
|
+
return {
|
|
530
|
+
action: TABLE_ACTION.CHANGED_ALIGNMENT,
|
|
531
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
532
|
+
actionSubjectId: null,
|
|
533
|
+
eventType: EVENT_TYPE.TRACK,
|
|
534
|
+
attributes: attributes
|
|
535
|
+
};
|
|
536
|
+
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos)));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
+
import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
5
|
-
import { akEditorDefaultLayoutWidth,
|
|
6
|
-
import {
|
|
6
|
+
import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
|
|
7
8
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
8
9
|
import { TableCssClassName as ClassName } from '../types';
|
|
10
|
+
import { ALIGN_CENTER, ALIGN_START } from '../utils/alignment';
|
|
9
11
|
import { TableResizer } from './TableResizer';
|
|
10
12
|
export const InnerContainer = /*#__PURE__*/forwardRef(({
|
|
11
13
|
className,
|
|
@@ -41,7 +43,7 @@ const AlignmentTableContainer = ({
|
|
|
41
43
|
getPos,
|
|
42
44
|
editorView
|
|
43
45
|
}) => {
|
|
44
|
-
const alignment = node.attrs.layout;
|
|
46
|
+
const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
|
|
45
47
|
const {
|
|
46
48
|
tableState
|
|
47
49
|
} = useSharedPluginState(pluginInjectionApi, ['table']);
|
|
@@ -51,18 +53,20 @@ const AlignmentTableContainer = ({
|
|
|
51
53
|
wasFullWidthModeEnabled,
|
|
52
54
|
isFullWidthModeEnabled
|
|
53
55
|
} = tableState;
|
|
54
|
-
|
|
56
|
+
const {
|
|
57
|
+
state,
|
|
58
|
+
dispatch
|
|
59
|
+
} = editorView;
|
|
60
|
+
if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== ALIGN_CENTER && node.attrs.width > akEditorDefaultLayoutWidth) {
|
|
61
|
+
var _pluginInjectionApi$a;
|
|
55
62
|
const pos = getPos && getPos();
|
|
56
63
|
if (typeof pos !== 'number') {
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
setTableAlignmentWithTableContentWithPosWithAnalytics(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(ALIGN_CENTER, alignment, {
|
|
60
67
|
pos,
|
|
61
68
|
node
|
|
62
|
-
})(
|
|
63
|
-
if (tr) {
|
|
64
|
-
editorView.dispatch(tr);
|
|
65
|
-
}
|
|
69
|
+
}, INPUT_METHOD.AUTO, CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -176,8 +180,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
176
180
|
})) !== null && _pluginInjectionApi$g !== void 0 ? _pluginInjectionApi$g : false;
|
|
177
181
|
}, [pluginInjectionApi, editorView]);
|
|
178
182
|
const attachAnalyticsEvent = useCallback(payload => {
|
|
179
|
-
var _pluginInjectionApi$
|
|
180
|
-
return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
183
|
+
var _pluginInjectionApi$a2;
|
|
184
|
+
return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.attachAnalyticsEvent(payload);
|
|
181
185
|
}, [pluginInjectionApi]);
|
|
182
186
|
const displayGapCursor = useCallback(toggle => {
|
|
183
187
|
var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
|
|
@@ -198,13 +202,13 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
198
202
|
// When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
|
|
199
203
|
// When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
|
|
200
204
|
// scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
|
|
201
|
-
responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth -
|
|
205
|
+
responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
|
|
202
206
|
} else {
|
|
203
207
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
204
208
|
// containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
|
|
205
209
|
// a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
|
|
206
210
|
// padding left = padding right = akEditorGutterPadding = 32
|
|
207
|
-
responsiveContainerWidth = isTableScalingEnabled ? containerWidth -
|
|
211
|
+
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPaddingDynamic() * 2 : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
|
|
208
212
|
}
|
|
209
213
|
let width = Math.min(tableWidth, responsiveContainerWidth);
|
|
210
214
|
if (!isResizing) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import rafSchd from 'raf-schd';
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
|
-
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
6
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
7
|
import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
@@ -9,10 +9,11 @@ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
|
9
9
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
10
10
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
11
11
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
12
|
-
import {
|
|
12
|
+
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
14
14
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
|
-
import {
|
|
15
|
+
import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
|
|
16
|
+
import { updateWidthToWidest } from '../commands/misc';
|
|
16
17
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
17
18
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
18
19
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -80,7 +81,7 @@ const getVisibleGuidelines = (guidelines, containerWidth, lineLength, isTableSca
|
|
|
80
81
|
// guidelineVisibleAdjustment is set as a negative value, so we making it positive and adding + 1
|
|
81
82
|
const preserve_table_widths_adjustment = -1 * PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET + 1;
|
|
82
83
|
guidelineVisibleAdjustment = isFullWidthModeEnabled ? preserve_table_widths_adjustment // guidelineVisibleAdjustment = -2, if lineLength = 1180, 1181 < 1180 + 2 is true.
|
|
83
|
-
: -2 *
|
|
84
|
+
: -2 * akEditorGutterPaddingDynamic() + preserve_table_widths_adjustment; // guidelineVisibleAdjustment = -62, if containerWidth is 1244, 1181 < 1244 - 62 = 1182 is true.
|
|
84
85
|
}
|
|
85
86
|
const width = isTableScalingEnabled && isFullWidthModeEnabled ? lineLength : containerWidth;
|
|
86
87
|
return guidelines.filter(guideline => {
|
|
@@ -110,7 +111,7 @@ export const TableResizer = ({
|
|
|
110
111
|
pluginInjectionApi,
|
|
111
112
|
isFullWidthModeEnabled
|
|
112
113
|
}) => {
|
|
113
|
-
var _findTable, _editorView$state;
|
|
114
|
+
var _findTable, _editorView$state, _pluginInjectionApi$a2;
|
|
114
115
|
const currentGap = useRef(0);
|
|
115
116
|
// track resizing state - use ref over state to avoid re-render
|
|
116
117
|
const isResizing = useRef(false);
|
|
@@ -147,31 +148,29 @@ export const TableResizer = ({
|
|
|
147
148
|
}) => {
|
|
148
149
|
if (gap !== currentGap.current) {
|
|
149
150
|
currentGap.current = gap;
|
|
150
|
-
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 *
|
|
151
|
+
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * akEditorGutterPaddingDynamic() : containerWidth, excludeGuidelineConfig) : defaultGuidelines, containerWidth, lineLength, Boolean(isTableScalingEnabled), Boolean(isFullWidthModeEnabled));
|
|
151
152
|
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
|
|
152
153
|
}
|
|
153
154
|
}, [isTableScalingEnabled, excludeGuidelineConfig, containerWidth, displayGuideline, lineLength, isFullWidthModeEnabled]);
|
|
154
155
|
const guidelineSnaps = useMemo(() => snappingEnabled ? {
|
|
155
156
|
x: isTableScalingEnabled ? defaultTablePreserveSnappingWidths(PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET,
|
|
156
157
|
// was hardcoded to 0, using PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
|
|
157
|
-
isFullWidthModeEnabled ? lineLength + 2 *
|
|
158
|
+
isFullWidthModeEnabled ? lineLength + 2 * akEditorGutterPaddingDynamic() : containerWidth, excludeGuidelineConfig) : defaultSnappingWidths
|
|
158
159
|
} : undefined, [snappingEnabled, isTableScalingEnabled, excludeGuidelineConfig, containerWidth, lineLength, isFullWidthModeEnabled]);
|
|
159
160
|
const switchToCenterAlignment = useCallback((pos, node, newWidth, state, dispatch) => {
|
|
160
161
|
if (isTableAlignmentEnabled && node && node.attrs.layout === ALIGN_START && newWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH &&
|
|
161
162
|
// We don't want to switch alignment in Full-width editor
|
|
162
163
|
isResizing.current) {
|
|
164
|
+
var _pluginInjectionApi$a;
|
|
163
165
|
const tableNodeWithPos = {
|
|
164
166
|
pos,
|
|
165
167
|
node
|
|
166
168
|
};
|
|
167
|
-
|
|
168
|
-
if (tr) {
|
|
169
|
-
dispatch(tr);
|
|
170
|
-
}
|
|
169
|
+
setTableAlignmentWithTableContentWithPosWithAnalytics(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(ALIGN_CENTER, ALIGN_START, tableNodeWithPos, INPUT_METHOD.AUTO, CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
|
|
171
170
|
return true;
|
|
172
171
|
}
|
|
173
172
|
return false;
|
|
174
|
-
}, [
|
|
173
|
+
}, [isTableAlignmentEnabled, lineLength, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions]);
|
|
175
174
|
useEffect(() => {
|
|
176
175
|
return () => {
|
|
177
176
|
// only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
|
|
@@ -213,7 +212,7 @@ export const TableResizer = ({
|
|
|
213
212
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
214
213
|
});
|
|
215
214
|
dispatch(tr);
|
|
216
|
-
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 *
|
|
215
|
+
const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, isFullWidthModeEnabled ? lineLength + 2 * akEditorGutterPaddingDynamic() : containerWidth, excludeGuidelineConfig) : defaultGuidelines, containerWidth, lineLength, Boolean(isTableScalingEnabled), Boolean(isFullWidthModeEnabled));
|
|
217
216
|
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
218
217
|
if (onResizeStart) {
|
|
219
218
|
onResizeStart();
|
|
@@ -238,7 +237,7 @@ export const TableResizer = ({
|
|
|
238
237
|
start: pos + 1,
|
|
239
238
|
parentWidth: newWidth
|
|
240
239
|
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
|
|
241
|
-
const editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 *
|
|
240
|
+
const editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 * akEditorGutterPaddingDynamic() : containerWidth;
|
|
242
241
|
const closestSnap = findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE);
|
|
243
242
|
updateActiveGuidelines(closestSnap);
|
|
244
243
|
|
|
@@ -311,13 +310,13 @@ export const TableResizer = ({
|
|
|
311
310
|
dispatch(tr);
|
|
312
311
|
if (getBooleanFF('platform.editor.a11y-table-resizing_uapcv')) {
|
|
313
312
|
if (delta.width < 0) {
|
|
314
|
-
var _pluginInjectionApi$
|
|
315
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
313
|
+
var _pluginInjectionApi$a3;
|
|
314
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.ariaNotify(formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
|
|
316
315
|
newWidth: newWidth
|
|
317
316
|
}));
|
|
318
317
|
} else if (delta.width > 0) {
|
|
319
|
-
var _pluginInjectionApi$
|
|
320
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
318
|
+
var _pluginInjectionApi$a4;
|
|
319
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions.ariaNotify(formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
|
|
321
320
|
newWidth: newWidth
|
|
322
321
|
}));
|
|
323
322
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -61,7 +61,8 @@ const tablesPlugin = ({
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
64
|
-
const
|
|
64
|
+
const isTableScalingWithFixedColumnWidthsOptionEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
65
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
|
|
65
66
|
return {
|
|
66
67
|
name: 'table',
|
|
67
68
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
@@ -460,7 +461,7 @@ const tablesPlugin = ({
|
|
|
460
461
|
return tr;
|
|
461
462
|
}
|
|
462
463
|
}],
|
|
463
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
464
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableScalingWithFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
464
465
|
}
|
|
465
466
|
};
|
|
466
467
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { addColumnAfter, addColumnAfterVO, addColumnBefore, addColumnBeforeVO, addRowAfter, addRowAfterVO, addRowBefore, addRowBeforeVO, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
4
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -23,6 +23,12 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
23
23
|
bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
24
24
|
bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
25
25
|
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
|
|
26
|
+
if (getBooleanFF('platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg')) {
|
|
27
|
+
bindKeymapWithCommand(addRowBeforeVO.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
|
|
28
|
+
bindKeymapWithCommand(addRowAfterVO.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
|
|
29
|
+
bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(isTableScalingEnabled), list);
|
|
30
|
+
bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(isTableScalingEnabled), list);
|
|
31
|
+
}
|
|
26
32
|
if (dragAndDropEnabled) {
|
|
27
33
|
// Move row/column shortcuts
|
|
28
34
|
/**
|
|
@@ -2,7 +2,7 @@ import { getParentNodeWidth, getTableContainerWidth, layoutToWidth } from '@atla
|
|
|
2
2
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-common/ui';
|
|
4
4
|
import { calcTableColumnWidths, containsClassName } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { akEditorFullWidthLayoutWidth,
|
|
5
|
+
import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { hasTableBeenResized } from './colgroup';
|
|
7
7
|
import { MAX_SCALING_PERCENT, MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION } from './consts';
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ export function getLayoutSize(tableLayout, containerWidth = 0, options) {
|
|
|
12
12
|
isFullWidthModeEnabled
|
|
13
13
|
} = options;
|
|
14
14
|
if (isFullWidthModeEnabled) {
|
|
15
|
-
return containerWidth ? Math.min(containerWidth -
|
|
15
|
+
return containerWidth ? Math.min(containerWidth - akEditorGutterPaddingDynamic() * 2, akEditorFullWidthLayoutWidth) : akEditorFullWidthLayoutWidth;
|
|
16
16
|
}
|
|
17
17
|
const calculatedTableWidth = calcTableWidth(tableLayout, containerWidth, true);
|
|
18
18
|
if (calculatedTableWidth !== 'inherit') {
|