@atlaskit/editor-plugin-table 7.7.3 → 7.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/commands/display-mode.js +23 -0
- package/dist/cjs/commands/index.js +8 -1
- package/dist/cjs/nodeviews/table.js +2 -1
- package/dist/cjs/plugin.js +3 -2
- package/dist/cjs/toolbar.js +43 -12
- package/dist/cjs/ui/icons/DisplayModeIcon.js +46 -0
- package/dist/cjs/ui/icons/index.js +7 -0
- package/dist/es2019/commands/display-mode.js +17 -0
- package/dist/es2019/commands/index.js +2 -1
- package/dist/es2019/nodeviews/table.js +2 -1
- package/dist/es2019/plugin.js +4 -3
- package/dist/es2019/toolbar.js +41 -12
- package/dist/es2019/ui/icons/DisplayModeIcon.js +39 -0
- package/dist/es2019/ui/icons/index.js +1 -0
- package/dist/esm/commands/display-mode.js +16 -0
- package/dist/esm/commands/index.js +2 -1
- package/dist/esm/nodeviews/table.js +2 -1
- package/dist/esm/plugin.js +4 -3
- package/dist/esm/toolbar.js +44 -13
- package/dist/esm/ui/icons/DisplayModeIcon.js +39 -0
- package/dist/esm/ui/icons/index.js +1 -0
- package/dist/types/commands/display-mode.d.ts +2 -0
- package/dist/types/commands/index.d.ts +1 -0
- package/dist/types/commands/toggle.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
- package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
- package/dist/types/toolbar.d.ts +2 -1
- package/dist/types/ui/icons/DisplayModeIcon.d.ts +4 -0
- package/dist/types/ui/icons/index.d.ts +1 -0
- package/dist/types-ts4.5/commands/display-mode.d.ts +2 -0
- package/dist/types-ts4.5/commands/index.d.ts +1 -0
- package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
- package/dist/types-ts4.5/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +4 -0
- package/dist/types-ts4.5/ui/icons/index.d.ts +1 -0
- package/package.json +6 -3
- package/src/commands/display-mode.ts +19 -0
- package/src/commands/index.ts +1 -0
- package/src/commands/toggle.ts +1 -1
- package/src/commands-with-analytics.ts +3 -2
- package/src/nodeviews/table.tsx +1 -0
- package/src/plugin.tsx +15 -2
- package/src/pm-plugins/table-resizing/utils/misc.ts +3 -3
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +1 -4
- package/src/toolbar.tsx +56 -22
- package/src/transforms/fix-tables.ts +1 -2
- package/src/types.ts +5 -0
- package/src/ui/icons/DisplayModeIcon.tsx +41 -0
- package/src/ui/icons/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.7.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92426](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92426) [`32c76c7c225c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c76c7c225c) - Bump adf-schema to 35.9.2 to support table alignment options
|
|
8
|
+
- [#90659](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90659) [`fc633861cff4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fc633861cff4) - [ux] Adds lock button on table's floating toolbar.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 7.7.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.setTableDisplayMode = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
var setTableDisplayMode = exports.setTableDisplayMode = function setTableDisplayMode(_ref) {
|
|
13
|
+
var tr = _ref.tr;
|
|
14
|
+
var table = (0, _utils.findTable)(tr.selection);
|
|
15
|
+
if (!table) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
var displayMode = table.node.attrs.displayMode;
|
|
19
|
+
tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
|
|
20
|
+
displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
|
|
21
|
+
}));
|
|
22
|
+
return tr.setMeta('scrollIntoView', false);
|
|
23
|
+
};
|
|
@@ -171,6 +171,12 @@ Object.defineProperty(exports, "setMultipleCellAttrs", {
|
|
|
171
171
|
return _misc.setMultipleCellAttrs;
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
|
+
Object.defineProperty(exports, "setTableDisplayMode", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function get() {
|
|
177
|
+
return _displayMode.setTableDisplayMode;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
174
180
|
Object.defineProperty(exports, "setTableHovered", {
|
|
175
181
|
enumerable: true,
|
|
176
182
|
get: function get() {
|
|
@@ -262,4 +268,5 @@ var _clear = require("./clear");
|
|
|
262
268
|
var _misc = require("./misc");
|
|
263
269
|
var _sort = require("./sort");
|
|
264
270
|
var _goToNextCell = require("./go-to-next-cell");
|
|
265
|
-
var _referentiality = require("./referentiality");
|
|
271
|
+
var _referentiality = require("./referentiality");
|
|
272
|
+
var _displayMode = require("./display-mode");
|
|
@@ -41,7 +41,8 @@ var tableAttributes = function tableAttributes(node) {
|
|
|
41
41
|
'data-layout': node.attrs.layout,
|
|
42
42
|
'data-autosize': node.attrs.__autoSize,
|
|
43
43
|
'data-table-local-id': node.attrs.localId || '',
|
|
44
|
-
'data-table-width': node.attrs.width
|
|
44
|
+
'data-table-width': node.attrs.width,
|
|
45
|
+
'data-table-display-mode': node.attrs.displayMode
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
48
|
var getInlineWidth = function getInlineWidth(node, options, state, pos) {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -116,9 +116,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
116
116
|
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)
|
|
117
117
|
},
|
|
118
118
|
nodes: function nodes() {
|
|
119
|
+
var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') ? _adfSchema.tableStage0 : _adfSchema.table;
|
|
119
120
|
return [{
|
|
120
121
|
name: 'table',
|
|
121
|
-
node:
|
|
122
|
+
node: tableNode
|
|
122
123
|
}, {
|
|
123
124
|
name: 'tableHeader',
|
|
124
125
|
node: _adfSchema.tableHeader
|
|
@@ -428,7 +429,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
428
429
|
},
|
|
429
430
|
floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
|
|
430
431
|
return editorViewRef.current;
|
|
431
|
-
})((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
432
|
+
}, options)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
432
433
|
}
|
|
433
434
|
};
|
|
434
435
|
};
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -12,6 +12,7 @@ var _customSteps = require("@atlaskit/custom-steps");
|
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
13
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
14
14
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
15
|
+
var _preset = require("@atlaskit/editor-common/preset");
|
|
15
16
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
16
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
@@ -31,6 +32,7 @@ var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
|
|
|
31
32
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
32
33
|
var _transforms = require("./transforms");
|
|
33
34
|
var _types = require("./types");
|
|
35
|
+
var _icons = require("./ui/icons");
|
|
34
36
|
var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
|
|
35
37
|
var _utils4 = require("./utils");
|
|
36
38
|
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); }
|
|
@@ -311,7 +313,7 @@ var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = fu
|
|
|
311
313
|
var tableRect = new _tableMap.Rect(0, 0, map.width, map.height);
|
|
312
314
|
return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : tableRect;
|
|
313
315
|
};
|
|
314
|
-
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
|
|
316
|
+
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
|
|
315
317
|
return function (config) {
|
|
316
318
|
return function (state, intl) {
|
|
317
319
|
var _tableObject$node$att, _tableObject$node;
|
|
@@ -325,7 +327,9 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
325
327
|
var isTableScalingEnabled = pluginState.isTableScalingEnabled,
|
|
326
328
|
widthToWidest = pluginState.widthToWidest;
|
|
327
329
|
var currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 || (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 || (_tableObject$node = _tableObject$node.attrs) === null || _tableObject$node === void 0 ? void 0 : _tableObject$node.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
|
|
328
|
-
if (isTableScalingEnabled &&
|
|
330
|
+
if (isTableScalingEnabled &&
|
|
331
|
+
// TODO ED-21670: check if need options.isTableScalingEnabled
|
|
332
|
+
isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
|
|
329
333
|
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
330
334
|
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
331
335
|
var nodeType = state.schema.nodes.table;
|
|
@@ -373,11 +377,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
373
377
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
374
378
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
375
379
|
_getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
|
|
376
|
-
_isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
|
|
380
|
+
_isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa; // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
|
|
381
|
+
|
|
377
382
|
var cellItems;
|
|
378
383
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
|
|
379
384
|
var columnSettingsItems;
|
|
380
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
|
|
385
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, _isTableScalingEnabled) : [];
|
|
381
386
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
382
387
|
|
|
383
388
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -504,32 +509,58 @@ var getDistributeConfig = exports.getDistributeConfig = function getDistributeCo
|
|
|
504
509
|
|
|
505
510
|
// this create the button group for distribute column and also fixed column width
|
|
506
511
|
// fixed column button should be in this function call in the future
|
|
507
|
-
var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
512
|
+
var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI, options) {
|
|
508
513
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
509
514
|
var formatMessage = _ref4.formatMessage;
|
|
510
|
-
var isTableScalingEnabled = arguments.length >
|
|
515
|
+
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
511
516
|
var pluginState = (0, _pluginFactory.getPluginState)(editorState);
|
|
512
517
|
var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
513
518
|
if (!selectionOrTableRect || !editorView) {
|
|
514
519
|
return [];
|
|
515
520
|
}
|
|
516
|
-
var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled
|
|
521
|
+
var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
|
|
522
|
+
);
|
|
517
523
|
var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
524
|
+
var items = [];
|
|
525
|
+
var isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button');
|
|
526
|
+
if (isTableScalingLockBtnEnabled) {
|
|
527
|
+
var _pluginState$tableNod;
|
|
528
|
+
var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
|
|
529
|
+
var title = areColumnWidthsLocked ? formatMessage(_messages.tableMessages.unlockColumnWidths) : formatMessage(_messages.tableMessages.lockColumnWidths);
|
|
530
|
+
items.push({
|
|
531
|
+
id: 'editor.table.lockColumns',
|
|
532
|
+
type: 'button',
|
|
533
|
+
title: title,
|
|
534
|
+
icon: function icon() {
|
|
535
|
+
return (0, _react.jsx)(_icons.DisplayModeIcon, {
|
|
536
|
+
size: "medium",
|
|
537
|
+
label: title
|
|
538
|
+
});
|
|
539
|
+
},
|
|
540
|
+
onClick: (0, _preset.editorCommandToPMCommand)(_commands.setTableDisplayMode),
|
|
541
|
+
selected: areColumnWidthsLocked,
|
|
542
|
+
testId: 'table-lock-column-widths-btn'
|
|
543
|
+
});
|
|
544
|
+
}
|
|
518
545
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
519
|
-
|
|
546
|
+
items.push({
|
|
520
547
|
id: 'editor.table.distributeColumns',
|
|
521
548
|
type: 'button',
|
|
522
549
|
title: formatMessage(_messages.tableMessages.distributeColumns),
|
|
523
550
|
icon: _layoutThreeEqual.default,
|
|
524
551
|
onClick: function onClick(state, dispatch, view) {
|
|
525
|
-
return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled
|
|
552
|
+
return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
|
|
553
|
+
)(state, dispatch, view);
|
|
526
554
|
},
|
|
527
555
|
disabled: !wouldChange
|
|
528
|
-
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
if (items.length !== 0) {
|
|
559
|
+
items.push({
|
|
529
560
|
type: 'separator'
|
|
530
|
-
}
|
|
561
|
+
});
|
|
531
562
|
}
|
|
532
|
-
return
|
|
563
|
+
return items;
|
|
533
564
|
};
|
|
534
565
|
var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
|
|
535
566
|
var _node$attrs;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DisplayModeIcon = exports.DisplayModeGlyth = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _icon = _interopRequireDefault(require("@atlaskit/icon"));
|
|
11
|
+
var DisplayModeGlyth = exports.DisplayModeGlyth = function DisplayModeGlyth(props) {
|
|
12
|
+
return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
|
|
13
|
+
width: "24",
|
|
14
|
+
height: "24",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
18
|
+
}, props), /*#__PURE__*/_react.default.createElement("rect", {
|
|
19
|
+
x: "4",
|
|
20
|
+
y: "5",
|
|
21
|
+
width: "4",
|
|
22
|
+
height: "14",
|
|
23
|
+
rx: "1",
|
|
24
|
+
fill: "currentColor"
|
|
25
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
26
|
+
fillRule: "evenodd",
|
|
27
|
+
clipRule: "evenodd",
|
|
28
|
+
d: "M11 5C10.4477 5 10 5.44772 10 6V9.10102C11.0503 8.02921 12.4424 7.29368 14 7.07089V6C14 5.44772 13.5523 5 13 5H11Z",
|
|
29
|
+
fill: "currentColor"
|
|
30
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
31
|
+
fillRule: "evenodd",
|
|
32
|
+
clipRule: "evenodd",
|
|
33
|
+
d: "M17 5C16.4477 5 16 5.44772 16 6V7.07089C17.5576 7.29368 18.9497 8.02921 20 9.10102V6C20 5.44772 19.5523 5 19 5H17Z",
|
|
34
|
+
fill: "currentColor"
|
|
35
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
36
|
+
fillRule: "evenodd",
|
|
37
|
+
clipRule: "evenodd",
|
|
38
|
+
d: "M21 14C21 17.3137 18.3137 20 15 20C11.6863 20 9 17.3137 9 14C9 10.6863 11.6863 8 15 8C18.3137 8 21 10.6863 21 14ZM12 15C12 14.4477 12.4477 14 13 14V12C13 10.8954 13.8954 10 15 10C16.1046 10 17 10.8954 17 12V14C17.5523 14 18 14.4477 18 15V17C18 17.5523 17.5523 18 17 18H13C12.4477 18 12 17.5523 12 17V15ZM16 14V12C16 11.4477 15.5523 11 15 11C14.4477 11 14 11.4477 14 12V14H16Z",
|
|
39
|
+
fill: "currentColor"
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
var DisplayModeIcon = exports.DisplayModeIcon = function DisplayModeIcon(props) {
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({
|
|
44
|
+
glyph: DisplayModeGlyth
|
|
45
|
+
}, props));
|
|
46
|
+
};
|
|
@@ -27,6 +27,12 @@ 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
|
+
});
|
|
30
36
|
Object.defineProperty(exports, "DragHandleDisabledIcon", {
|
|
31
37
|
enumerable: true,
|
|
32
38
|
get: function get() {
|
|
@@ -66,6 +72,7 @@ Object.defineProperty(exports, "SplitCellIcon", {
|
|
|
66
72
|
var _DragHandleIcon = require("./DragHandleIcon");
|
|
67
73
|
var _DragInMotionIcon = require("./DragInMotionIcon");
|
|
68
74
|
var _DragHandleDisabledIcon = require("./DragHandleDisabledIcon");
|
|
75
|
+
var _DisplayModeIcon = require("./DisplayModeIcon");
|
|
69
76
|
var _MinimisedHandle = require("./MinimisedHandle");
|
|
70
77
|
var _MergeCellsIcon = require("./MergeCellsIcon");
|
|
71
78
|
var _SplitCellIcon = require("./SplitCellIcon");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
2
|
+
export const setTableDisplayMode = ({
|
|
3
|
+
tr
|
|
4
|
+
}) => {
|
|
5
|
+
const table = findTable(tr.selection);
|
|
6
|
+
if (!table) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const {
|
|
10
|
+
displayMode
|
|
11
|
+
} = table.node.attrs;
|
|
12
|
+
tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, {
|
|
13
|
+
...table.node.attrs,
|
|
14
|
+
displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
|
|
15
|
+
});
|
|
16
|
+
return tr.setMeta('scrollIntoView', false);
|
|
17
|
+
};
|
|
@@ -5,4 +5,5 @@ export { clearMultipleCells } from './clear';
|
|
|
5
5
|
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest } from './misc';
|
|
6
6
|
export { sortByColumn } from './sort';
|
|
7
7
|
export { goToNextCell } from './go-to-next-cell';
|
|
8
|
-
export { removeDescendantNodes } from './referentiality';
|
|
8
|
+
export { removeDescendantNodes } from './referentiality';
|
|
9
|
+
export { setTableDisplayMode } from './display-mode';
|
|
@@ -23,7 +23,8 @@ const tableAttributes = node => {
|
|
|
23
23
|
'data-layout': node.attrs.layout,
|
|
24
24
|
'data-autosize': node.attrs.__autoSize,
|
|
25
25
|
'data-table-local-id': node.attrs.localId || '',
|
|
26
|
-
'data-table-width': node.attrs.width
|
|
26
|
+
'data-table-width': node.attrs.width,
|
|
27
|
+
'data-table-display-mode': node.attrs.displayMode
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
30
|
const getInlineWidth = (node, options, state, pos) => {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
2
|
+
import { table, tableCell, tableHeader, tableRow, tableStage0 } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
5
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
@@ -106,9 +106,10 @@ const tablesPlugin = ({
|
|
|
106
106
|
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
107
107
|
},
|
|
108
108
|
nodes() {
|
|
109
|
+
const tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') ? tableStage0 : table;
|
|
109
110
|
return [{
|
|
110
111
|
name: 'table',
|
|
111
|
-
node:
|
|
112
|
+
node: tableNode
|
|
112
113
|
}, {
|
|
113
114
|
name: 'tableHeader',
|
|
114
115
|
node: tableHeader
|
|
@@ -419,7 +420,7 @@ const tablesPlugin = ({
|
|
|
419
420
|
return tr;
|
|
420
421
|
}
|
|
421
422
|
}],
|
|
422
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
423
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
423
424
|
}
|
|
424
425
|
};
|
|
425
426
|
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -4,6 +4,7 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
|
4
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
6
6
|
import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
7
8
|
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
8
9
|
import { closestElement, getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
|
|
9
10
|
import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -15,7 +16,7 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
|
|
|
15
16
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
16
17
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
17
18
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
18
|
-
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
|
|
19
|
+
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes, setTableDisplayMode } from './commands';
|
|
19
20
|
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
20
21
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
21
22
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
@@ -23,6 +24,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
|
|
|
23
24
|
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
24
25
|
import { canMergeCells } from './transforms';
|
|
25
26
|
import { TableCssClassName } from './types';
|
|
27
|
+
import { DisplayModeIcon } from './ui/icons';
|
|
26
28
|
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
27
29
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
|
|
28
30
|
export const getToolbarMenuConfig = (config, state, {
|
|
@@ -299,7 +301,7 @@ export const getClosestSelectionOrTableRect = state => {
|
|
|
299
301
|
const tableRect = new Rect(0, 0, map.width, map.height);
|
|
300
302
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
301
303
|
};
|
|
302
|
-
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
|
|
304
|
+
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) => config => (state, intl) => {
|
|
303
305
|
var _tableObject$node$att, _tableObject$node, _tableObject$node$att2;
|
|
304
306
|
const tableObject = findTable(state.selection);
|
|
305
307
|
const pluginState = getPluginState(state);
|
|
@@ -313,7 +315,9 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
313
315
|
widthToWidest
|
|
314
316
|
} = pluginState;
|
|
315
317
|
const currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 ? void 0 : (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 ? void 0 : (_tableObject$node$att2 = _tableObject$node.attrs) === null || _tableObject$node$att2 === void 0 ? void 0 : _tableObject$node$att2.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
|
|
316
|
-
if (isTableScalingEnabled &&
|
|
318
|
+
if (isTableScalingEnabled &&
|
|
319
|
+
// TODO ED-21670: check if need options.isTableScalingEnabled
|
|
320
|
+
isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
|
|
317
321
|
const {
|
|
318
322
|
stickyScrollbar
|
|
319
323
|
} = getEditorFeatureFlags();
|
|
@@ -362,11 +366,12 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
362
366
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
363
367
|
const {
|
|
364
368
|
isTableScalingEnabled = false
|
|
365
|
-
} = getPluginState(state);
|
|
369
|
+
} = getPluginState(state); // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
|
|
370
|
+
|
|
366
371
|
let cellItems;
|
|
367
372
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
|
|
368
373
|
let columnSettingsItems;
|
|
369
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled) : [];
|
|
374
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, isTableScalingEnabled) : [];
|
|
370
375
|
const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
371
376
|
|
|
372
377
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -484,28 +489,52 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
|
|
|
484
489
|
// fixed column button should be in this function call in the future
|
|
485
490
|
const getColumnSettingItems = (editorState, editorView, {
|
|
486
491
|
formatMessage
|
|
487
|
-
}, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
|
|
492
|
+
}, getEditorContainerWidth, editorAnalyticsAPI, options, isTableScalingEnabled = false) => {
|
|
488
493
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
489
494
|
const pluginState = getPluginState(editorState);
|
|
490
495
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
491
496
|
if (!selectionOrTableRect || !editorView) {
|
|
492
497
|
return [];
|
|
493
498
|
}
|
|
494
|
-
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled
|
|
499
|
+
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
|
|
500
|
+
);
|
|
495
501
|
const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
502
|
+
const items = [];
|
|
503
|
+
const isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
504
|
+
if (isTableScalingLockBtnEnabled) {
|
|
505
|
+
var _pluginState$tableNod;
|
|
506
|
+
const areColumnWidthsLocked = (pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
|
|
507
|
+
const title = areColumnWidthsLocked ? formatMessage(messages.unlockColumnWidths) : formatMessage(messages.lockColumnWidths);
|
|
508
|
+
items.push({
|
|
509
|
+
id: 'editor.table.lockColumns',
|
|
510
|
+
type: 'button',
|
|
511
|
+
title,
|
|
512
|
+
icon: () => jsx(DisplayModeIcon, {
|
|
513
|
+
size: "medium",
|
|
514
|
+
label: title
|
|
515
|
+
}),
|
|
516
|
+
onClick: editorCommandToPMCommand(setTableDisplayMode),
|
|
517
|
+
selected: areColumnWidthsLocked,
|
|
518
|
+
testId: 'table-lock-column-widths-btn'
|
|
519
|
+
});
|
|
520
|
+
}
|
|
496
521
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
|
|
497
|
-
|
|
522
|
+
items.push({
|
|
498
523
|
id: 'editor.table.distributeColumns',
|
|
499
524
|
type: 'button',
|
|
500
525
|
title: formatMessage(messages.distributeColumns),
|
|
501
526
|
icon: DistributeColumnIcon,
|
|
502
|
-
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled
|
|
527
|
+
onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
|
|
528
|
+
)(state, dispatch, view),
|
|
503
529
|
disabled: !wouldChange
|
|
504
|
-
}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
if (items.length !== 0) {
|
|
533
|
+
items.push({
|
|
505
534
|
type: 'separator'
|
|
506
|
-
}
|
|
535
|
+
});
|
|
507
536
|
}
|
|
508
|
-
return
|
|
537
|
+
return items;
|
|
509
538
|
};
|
|
510
539
|
const getColorPicker = (state, menu, {
|
|
511
540
|
formatMessage
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Icon from '@atlaskit/icon';
|
|
4
|
+
export const DisplayModeGlyth = props => {
|
|
5
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
6
|
+
width: "24",
|
|
7
|
+
height: "24",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
fill: "none",
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
11
|
+
}, props), /*#__PURE__*/React.createElement("rect", {
|
|
12
|
+
x: "4",
|
|
13
|
+
y: "5",
|
|
14
|
+
width: "4",
|
|
15
|
+
height: "14",
|
|
16
|
+
rx: "1",
|
|
17
|
+
fill: "currentColor"
|
|
18
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
19
|
+
fillRule: "evenodd",
|
|
20
|
+
clipRule: "evenodd",
|
|
21
|
+
d: "M11 5C10.4477 5 10 5.44772 10 6V9.10102C11.0503 8.02921 12.4424 7.29368 14 7.07089V6C14 5.44772 13.5523 5 13 5H11Z",
|
|
22
|
+
fill: "currentColor"
|
|
23
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
24
|
+
fillRule: "evenodd",
|
|
25
|
+
clipRule: "evenodd",
|
|
26
|
+
d: "M17 5C16.4477 5 16 5.44772 16 6V7.07089C17.5576 7.29368 18.9497 8.02921 20 9.10102V6C20 5.44772 19.5523 5 19 5H17Z",
|
|
27
|
+
fill: "currentColor"
|
|
28
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
29
|
+
fillRule: "evenodd",
|
|
30
|
+
clipRule: "evenodd",
|
|
31
|
+
d: "M21 14C21 17.3137 18.3137 20 15 20C11.6863 20 9 17.3137 9 14C9 10.6863 11.6863 8 15 8C18.3137 8 21 10.6863 21 14ZM12 15C12 14.4477 12.4477 14 13 14V12C13 10.8954 13.8954 10 15 10C16.1046 10 17 10.8954 17 12V14C17.5523 14 18 14.4477 18 15V17C18 17.5523 17.5523 18 17 18H13C12.4477 18 12 17.5523 12 17V15ZM16 14V12C16 11.4477 15.5523 11 15 11C14.4477 11 14 11.4477 14 12V14H16Z",
|
|
32
|
+
fill: "currentColor"
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
export const DisplayModeIcon = props => {
|
|
36
|
+
return /*#__PURE__*/React.createElement(Icon, _extends({
|
|
37
|
+
glyph: DisplayModeGlyth
|
|
38
|
+
}, props));
|
|
39
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { DragHandleIcon } from './DragHandleIcon';
|
|
2
2
|
export { DragInMotionIcon } from './DragInMotionIcon';
|
|
3
3
|
export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
|
|
4
|
+
export { DisplayModeIcon } from './DisplayModeIcon';
|
|
4
5
|
export { MinimisedHandleIcon } from './MinimisedHandle';
|
|
5
6
|
export { MergeCellsIcon } from './MergeCellsIcon';
|
|
6
7
|
export { SplitCellIcon } from './SplitCellIcon';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
export var setTableDisplayMode = function setTableDisplayMode(_ref) {
|
|
6
|
+
var tr = _ref.tr;
|
|
7
|
+
var table = findTable(tr.selection);
|
|
8
|
+
if (!table) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
var displayMode = table.node.attrs.displayMode;
|
|
12
|
+
tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
|
|
13
|
+
displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
|
|
14
|
+
}));
|
|
15
|
+
return tr.setMeta('scrollIntoView', false);
|
|
16
|
+
};
|
|
@@ -5,4 +5,5 @@ export { clearMultipleCells } from './clear';
|
|
|
5
5
|
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest } from './misc';
|
|
6
6
|
export { sortByColumn } from './sort';
|
|
7
7
|
export { goToNextCell } from './go-to-next-cell';
|
|
8
|
-
export { removeDescendantNodes } from './referentiality';
|
|
8
|
+
export { removeDescendantNodes } from './referentiality';
|
|
9
|
+
export { setTableDisplayMode } from './display-mode';
|
|
@@ -34,7 +34,8 @@ var tableAttributes = function tableAttributes(node) {
|
|
|
34
34
|
'data-layout': node.attrs.layout,
|
|
35
35
|
'data-autosize': node.attrs.__autoSize,
|
|
36
36
|
'data-table-local-id': node.attrs.localId || '',
|
|
37
|
-
'data-table-width': node.attrs.width
|
|
37
|
+
'data-table-width': node.attrs.width,
|
|
38
|
+
'data-table-display-mode': node.attrs.displayMode
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
41
|
var getInlineWidth = function getInlineWidth(node, options, state, pos) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
2
|
+
import { table, tableCell, tableHeader, tableRow, tableStage0 } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
5
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
@@ -109,9 +109,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
109
109
|
insertTableWithSize: 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)
|
|
110
110
|
},
|
|
111
111
|
nodes: function nodes() {
|
|
112
|
+
var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') ? tableStage0 : table;
|
|
112
113
|
return [{
|
|
113
114
|
name: 'table',
|
|
114
|
-
node:
|
|
115
|
+
node: tableNode
|
|
115
116
|
}, {
|
|
116
117
|
name: 'tableHeader',
|
|
117
118
|
node: tableHeader
|
|
@@ -421,7 +422,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
421
422
|
},
|
|
422
423
|
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
|
|
423
424
|
return editorViewRef.current;
|
|
424
|
-
})(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
425
|
+
}, options)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
425
426
|
}
|
|
426
427
|
};
|
|
427
428
|
};
|