@atlaskit/editor-plugin-table 7.12.1 → 7.12.3
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 +22 -0
- package/dist/cjs/nodeviews/TableResizer.js +10 -4
- package/dist/cjs/plugin.js +15 -0
- package/dist/cjs/pm-plugins/table-width.js +16 -11
- package/dist/cjs/toolbar.js +11 -57
- package/dist/cjs/ui/FloatingToolbarLabel/FloatingToolbarLabel.js +28 -0
- package/dist/cjs/ui/TableFullWidthLabel/index.js +18 -5
- package/dist/es2019/nodeviews/TableResizer.js +10 -4
- package/dist/es2019/plugin.js +15 -0
- package/dist/es2019/pm-plugins/table-width.js +16 -7
- package/dist/es2019/toolbar.js +3 -52
- package/dist/es2019/ui/FloatingToolbarLabel/FloatingToolbarLabel.js +23 -0
- package/dist/es2019/ui/TableFullWidthLabel/index.js +18 -5
- package/dist/esm/nodeviews/TableResizer.js +10 -4
- package/dist/esm/plugin.js +15 -0
- package/dist/esm/pm-plugins/table-width.js +14 -8
- package/dist/esm/toolbar.js +12 -58
- package/dist/esm/ui/FloatingToolbarLabel/FloatingToolbarLabel.js +21 -0
- package/dist/esm/ui/TableFullWidthLabel/index.js +18 -5
- package/dist/types/pm-plugins/table-width.d.ts +4 -0
- package/dist/types/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/table-width.d.ts +4 -0
- package/dist/types-ts4.5/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +15 -0
- package/package.json +5 -5
- package/src/nodeviews/TableResizer.tsx +18 -3
- package/src/plugin.tsx +23 -0
- package/src/pm-plugins/table-width.ts +15 -4
- package/src/toolbar.tsx +5 -57
- package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +36 -0
- package/src/ui/TableFullWidthLabel/index.tsx +19 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.12.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#97034](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97034)
|
|
8
|
+
[`96595e52fb33`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/96595e52fb33) -
|
|
9
|
+
ED-22627: Fixed full-width label no show when selection outside table
|
|
10
|
+
|
|
11
|
+
## 7.12.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#96641](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/96641)
|
|
16
|
+
[`8a6aa9754ed4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8a6aa9754ed4) -
|
|
17
|
+
[ux] Lock button is not shown on the floating toolbar when the table is nested.
|
|
18
|
+
- [#97698](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97698)
|
|
19
|
+
[`1c7b378c0d3b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1c7b378c0d3b) -
|
|
20
|
+
[HOT-108999] We had an incident where the cursor jumps back a character in table headers for any
|
|
21
|
+
language triggering composition on an empty line.This was fixed in a patch bump of
|
|
22
|
+
prosemirror-view. https://github.com/ProseMirror/prosemirror-view/compare/1.33.4...1.33.5
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 7.12.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -149,7 +149,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
149
149
|
displayGapCursor(true);
|
|
150
150
|
displayGuideline([]);
|
|
151
151
|
_tr.setMeta(_tableWidth.pluginKey, {
|
|
152
|
-
resizing: false
|
|
152
|
+
resizing: false,
|
|
153
|
+
tableLocalId: '',
|
|
154
|
+
tableRef: null
|
|
153
155
|
});
|
|
154
156
|
dispatch(_tr);
|
|
155
157
|
}
|
|
@@ -162,7 +164,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
162
164
|
tr = editorView.state.tr;
|
|
163
165
|
displayGapCursor(false);
|
|
164
166
|
tr.setMeta(_tableWidth.pluginKey, {
|
|
165
|
-
resizing: true
|
|
167
|
+
resizing: true,
|
|
168
|
+
tableLocalId: node.attrs.localId,
|
|
169
|
+
tableRef: tableRef
|
|
166
170
|
});
|
|
167
171
|
tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
168
172
|
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
@@ -173,7 +177,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
173
177
|
if (onResizeStart) {
|
|
174
178
|
onResizeStart();
|
|
175
179
|
}
|
|
176
|
-
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
180
|
+
}, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
177
181
|
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
178
182
|
var _node$attrs$localId, _node$attrs;
|
|
179
183
|
countFrames();
|
|
@@ -222,7 +226,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
222
226
|
var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
|
|
223
227
|
newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? _utils3.TABLE_MAX_WIDTH : newWidth;
|
|
224
228
|
var tr = state.tr.setMeta(_tableWidth.pluginKey, {
|
|
225
|
-
resizing: false
|
|
229
|
+
resizing: false,
|
|
230
|
+
tableLocalId: '',
|
|
231
|
+
tableRef: null
|
|
226
232
|
});
|
|
227
233
|
var frameRateSamples = endMeasure();
|
|
228
234
|
if (frameRateSamples.length > 0) {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -15,6 +15,7 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
15
15
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
16
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
17
|
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
18
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
18
19
|
var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
|
|
19
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
var _insert = require("./commands/insert");
|
|
@@ -41,6 +42,8 @@ var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingConte
|
|
|
41
42
|
var _FloatingDeleteButton = _interopRequireDefault(require("./ui/FloatingDeleteButton"));
|
|
42
43
|
var _FloatingDragMenu = _interopRequireDefault(require("./ui/FloatingDragMenu"));
|
|
43
44
|
var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertButton"));
|
|
45
|
+
var _FloatingToolbarLabel = require("./ui/FloatingToolbarLabel/FloatingToolbarLabel");
|
|
46
|
+
var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
|
|
44
47
|
var _utils2 = require("./utils");
|
|
45
48
|
var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
46
49
|
return {};
|
|
@@ -319,7 +322,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
319
322
|
dragAndDropState = _ref17.dragAndDropState;
|
|
320
323
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
321
324
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
325
|
+
var resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
326
|
+
var resizingTableRef = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableRef;
|
|
322
327
|
var isResizing = isColumnResizing || isTableResizing;
|
|
328
|
+
var widthToWidest = tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.widthToWidest;
|
|
323
329
|
var _ref18 = tablePluginState,
|
|
324
330
|
tableNode = _ref18.tableNode,
|
|
325
331
|
tablePos = _ref18.tablePos,
|
|
@@ -397,6 +403,15 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
397
403
|
stickyHeaders: stickyHeader,
|
|
398
404
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
399
405
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
406
|
+
}), (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/_react.default.createElement(_FloatingToolbarLabel.FloatingToolbarLabel, {
|
|
407
|
+
target: resizingTableRef,
|
|
408
|
+
content: /*#__PURE__*/_react.default.createElement(_TableFullWidthLabel.FullWidthDisplay, null),
|
|
409
|
+
alignX: 'center',
|
|
410
|
+
alignY: 'bottom',
|
|
411
|
+
stick: true,
|
|
412
|
+
forcePlacement: true,
|
|
413
|
+
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex,
|
|
414
|
+
offset: [0, 10]
|
|
400
415
|
}));
|
|
401
416
|
}
|
|
402
417
|
}));
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.pluginKey = exports.createPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
@@ -16,13 +16,12 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
16
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
17
|
var _utils2 = require("./table-resizing/utils");
|
|
18
18
|
var _excluded = ["width"];
|
|
19
|
-
|
|
19
|
+
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; }
|
|
20
|
+
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; } /**
|
|
20
21
|
* A plugin for handle table custom widths
|
|
21
22
|
* Has login to scan the document, add width value to table's width attribute when necessary
|
|
22
23
|
* Also holds resizing state to hide / show table controls
|
|
23
24
|
*/
|
|
24
|
-
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; }
|
|
25
|
-
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; }
|
|
26
25
|
var pluginKey = exports.pluginKey = new _state.PluginKey('tableWidthPlugin');
|
|
27
26
|
var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled) {
|
|
28
27
|
return new _safePlugin.SafePlugin({
|
|
@@ -30,17 +29,23 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
30
29
|
state: {
|
|
31
30
|
init: function init() {
|
|
32
31
|
return {
|
|
33
|
-
resizing: false
|
|
32
|
+
resizing: false,
|
|
33
|
+
tableLocalId: '',
|
|
34
|
+
tableRef: null
|
|
34
35
|
};
|
|
35
36
|
},
|
|
36
37
|
apply: function apply(tr, pluginState) {
|
|
37
38
|
var meta = tr.getMeta(pluginKey);
|
|
38
|
-
if (meta
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
if (meta) {
|
|
40
|
+
var keys = Object.keys(meta);
|
|
41
|
+
var changed = keys.some(function (key) {
|
|
42
|
+
return pluginState[key] !== meta[key];
|
|
43
|
+
});
|
|
44
|
+
if (changed) {
|
|
45
|
+
var newState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
46
|
+
dispatch(pluginKey, newState);
|
|
47
|
+
return newState;
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
return pluginState;
|
|
46
51
|
}
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -33,7 +33,6 @@ var _tableWidth = require("./pm-plugins/table-width");
|
|
|
33
33
|
var _transforms = require("./transforms");
|
|
34
34
|
var _types = require("./types");
|
|
35
35
|
var _icons = require("./ui/icons");
|
|
36
|
-
var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
|
|
37
36
|
var _utils4 = require("./utils");
|
|
38
37
|
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); }
|
|
39
38
|
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; }
|
|
@@ -316,7 +315,6 @@ var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = fu
|
|
|
316
315
|
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
|
|
317
316
|
return function (config) {
|
|
318
317
|
return function (state, intl) {
|
|
319
|
-
var _tableObject$node$att, _tableObject$node;
|
|
320
318
|
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
321
319
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
322
320
|
var resizeState = _tableResizing.pluginKey.getState(state);
|
|
@@ -324,53 +322,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
324
322
|
|
|
325
323
|
// We don't want to show floating toolbar while resizing the table
|
|
326
324
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
327
|
-
var widthToWidest = pluginState.widthToWidest;
|
|
328
|
-
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 : '';
|
|
329
|
-
if (options !== null && options !== void 0 && options.isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
|
|
330
|
-
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
331
|
-
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
332
|
-
var nodeType = state.schema.nodes.table;
|
|
333
|
-
var getDomRef = function getDomRef(editorView) {
|
|
334
|
-
var element;
|
|
335
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
336
|
-
var parent = (0, _utils2.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
|
|
337
|
-
if (parent) {
|
|
338
|
-
var tableRef = parent.querySelector('table') || undefined;
|
|
339
|
-
if (tableRef) {
|
|
340
|
-
element = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return element;
|
|
344
|
-
};
|
|
345
|
-
var fullWidthLabel = {
|
|
346
|
-
id: 'editor.table.fullWidthLabel',
|
|
347
|
-
type: 'custom',
|
|
348
|
-
fallback: [],
|
|
349
|
-
render: function render() {
|
|
350
|
-
return (0, _react.jsx)(_TableFullWidthLabel.FullWidthDisplay, {
|
|
351
|
-
key: 'full-width-label'
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
return {
|
|
356
|
-
title: 'Table floating label',
|
|
357
|
-
getDomRef: getDomRef,
|
|
358
|
-
nodeType: nodeType,
|
|
359
|
-
key: 'full-width-label',
|
|
360
|
-
offset: [0, 18],
|
|
361
|
-
absoluteOffset: stickyScrollbar ? {
|
|
362
|
-
top: -6
|
|
363
|
-
} : {
|
|
364
|
-
top: 0
|
|
365
|
-
},
|
|
366
|
-
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
367
|
-
// Place the context menu slightly above the others
|
|
368
|
-
items: [fullWidthLabel],
|
|
369
|
-
scrollable: true
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
325
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
373
|
-
var
|
|
326
|
+
var nodeType = state.schema.nodes.table;
|
|
374
327
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
375
328
|
var cellItems;
|
|
376
329
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
@@ -402,10 +355,10 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
402
355
|
};
|
|
403
356
|
};
|
|
404
357
|
}
|
|
405
|
-
var
|
|
358
|
+
var getDomRef = function getDomRef(editorView) {
|
|
406
359
|
var element;
|
|
407
360
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
408
|
-
var parent = (0, _utils2.findParentDomRefOfType)(
|
|
361
|
+
var parent = (0, _utils2.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
|
|
409
362
|
if (parent) {
|
|
410
363
|
var tableRef = parent.querySelector('table') || undefined;
|
|
411
364
|
if (tableRef) {
|
|
@@ -414,14 +367,14 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
414
367
|
}
|
|
415
368
|
return element;
|
|
416
369
|
};
|
|
417
|
-
var
|
|
418
|
-
|
|
370
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
371
|
+
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
419
372
|
return {
|
|
420
373
|
title: 'Table floating controls',
|
|
421
|
-
getDomRef:
|
|
422
|
-
nodeType:
|
|
374
|
+
getDomRef: getDomRef,
|
|
375
|
+
nodeType: nodeType,
|
|
423
376
|
offset: [0, 18],
|
|
424
|
-
absoluteOffset:
|
|
377
|
+
absoluteOffset: stickyScrollbar ? {
|
|
425
378
|
top: -6
|
|
426
379
|
} : {
|
|
427
380
|
top: 0
|
|
@@ -436,7 +389,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
436
389
|
items: [{
|
|
437
390
|
state: state,
|
|
438
391
|
formatMessage: intl.formatMessage,
|
|
439
|
-
nodeType:
|
|
392
|
+
nodeType: nodeType,
|
|
440
393
|
onMouseEnter: (0, _commands.hoverTable)(false, true),
|
|
441
394
|
onMouseLeave: (0, _commands.clearHoverSelection)(),
|
|
442
395
|
onFocus: (0, _commands.hoverTable)(false, true),
|
|
@@ -514,7 +467,8 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
514
467
|
var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
515
468
|
var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
516
469
|
var items = [];
|
|
517
|
-
var
|
|
470
|
+
var isNested = pluginState.tablePos && (0, _utils4.isTableNested)(editorState, pluginState.tablePos);
|
|
471
|
+
var isTableScalingLockBtnEnabled = !isNested && isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button');
|
|
518
472
|
if (isTableScalingLockBtnEnabled) {
|
|
519
473
|
var _pluginState$tableNod;
|
|
520
474
|
var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FloatingToolbarLabel = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
+
var FloatingToolbarLabel = exports.FloatingToolbarLabel = /*#__PURE__*/_react.default.memo(function (props) {
|
|
11
|
+
var target = props.target,
|
|
12
|
+
content = props.content,
|
|
13
|
+
alignX = props.alignX,
|
|
14
|
+
alignY = props.alignY,
|
|
15
|
+
zIndex = props.zIndex,
|
|
16
|
+
forcePlacement = props.forcePlacement,
|
|
17
|
+
stick = props.stick,
|
|
18
|
+
offset = props.offset;
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
20
|
+
target: target,
|
|
21
|
+
alignX: alignX,
|
|
22
|
+
alignY: alignY,
|
|
23
|
+
zIndex: zIndex,
|
|
24
|
+
stick: stick,
|
|
25
|
+
forcePlacement: forcePlacement,
|
|
26
|
+
offset: offset
|
|
27
|
+
}, content);
|
|
28
|
+
});
|
|
@@ -9,17 +9,30 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _primitives = require("@atlaskit/primitives");
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
height: "var(--ds-space-300, 24px)",
|
|
12
|
+
var tableFullWidthLabelWrapperStyles = (0, _primitives.xcss)({
|
|
13
|
+
height: "var(--ds-space-400, 32px)",
|
|
15
14
|
display: 'flex',
|
|
16
|
-
|
|
15
|
+
backgroundColor: 'elevation.surface.overlay',
|
|
16
|
+
borderRadius: 'border.radius',
|
|
17
|
+
boxShadow: 'elevation.shadow.overlay',
|
|
18
|
+
lineHeight: 1,
|
|
19
|
+
boxSizing: 'border-box',
|
|
17
20
|
alignItems: 'center'
|
|
18
21
|
});
|
|
22
|
+
var tableFullWidthLabelStyles = (0, _primitives.xcss)({
|
|
23
|
+
marginLeft: 'space.100',
|
|
24
|
+
marginRight: 'space.100',
|
|
25
|
+
paddingLeft: 'space.075',
|
|
26
|
+
paddingRight: 'space.075',
|
|
27
|
+
paddingTop: 'space.050',
|
|
28
|
+
paddingBottom: 'space.050'
|
|
29
|
+
});
|
|
19
30
|
var FullWidthDisplay = exports.FullWidthDisplay = function FullWidthDisplay() {
|
|
20
31
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
21
32
|
formatMessage = _useIntl.formatMessage;
|
|
22
33
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
34
|
+
xcss: tableFullWidthLabelWrapperStyles
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
23
36
|
xcss: tableFullWidthLabelStyles
|
|
24
|
-
},
|
|
37
|
+
}, formatMessage(_messages.tableMessages.fullWidthLabel)));
|
|
25
38
|
};
|
|
@@ -140,7 +140,9 @@ export const TableResizer = ({
|
|
|
140
140
|
displayGapCursor(true);
|
|
141
141
|
displayGuideline([]);
|
|
142
142
|
tr.setMeta(tableWidthPluginKey, {
|
|
143
|
-
resizing: false
|
|
143
|
+
resizing: false,
|
|
144
|
+
tableLocalId: '',
|
|
145
|
+
tableRef: null
|
|
144
146
|
});
|
|
145
147
|
dispatch(tr);
|
|
146
148
|
}
|
|
@@ -157,7 +159,9 @@ export const TableResizer = ({
|
|
|
157
159
|
} = editorView;
|
|
158
160
|
displayGapCursor(false);
|
|
159
161
|
tr.setMeta(tableWidthPluginKey, {
|
|
160
|
-
resizing: true
|
|
162
|
+
resizing: true,
|
|
163
|
+
tableLocalId: node.attrs.localId,
|
|
164
|
+
tableRef: tableRef
|
|
161
165
|
});
|
|
162
166
|
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
163
167
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
|
|
@@ -168,7 +172,7 @@ export const TableResizer = ({
|
|
|
168
172
|
if (onResizeStart) {
|
|
169
173
|
onResizeStart();
|
|
170
174
|
}
|
|
171
|
-
}, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
175
|
+
}, [startMeasure, editorView, displayGapCursor, node.attrs.localId, tableRef, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
|
|
172
176
|
const handleResize = useCallback((originalState, delta) => {
|
|
173
177
|
var _node$attrs$localId, _node$attrs;
|
|
174
178
|
countFrames();
|
|
@@ -219,7 +223,9 @@ export const TableResizer = ({
|
|
|
219
223
|
const currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
|
|
220
224
|
newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? TABLE_MAX_WIDTH : newWidth;
|
|
221
225
|
let tr = state.tr.setMeta(tableWidthPluginKey, {
|
|
222
|
-
resizing: false
|
|
226
|
+
resizing: false,
|
|
227
|
+
tableLocalId: '',
|
|
228
|
+
tableRef: null
|
|
223
229
|
});
|
|
224
230
|
const frameRateSamples = endMeasure();
|
|
225
231
|
if (frameRateSamples.length > 0) {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -8,6 +8,7 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
|
|
|
8
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
9
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
11
|
+
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
11
12
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
12
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { insertTableWithSize } from './commands/insert';
|
|
@@ -34,6 +35,8 @@ import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
|
34
35
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
35
36
|
import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
36
37
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
38
|
+
import { FloatingToolbarLabel } from './ui/FloatingToolbarLabel/FloatingToolbarLabel';
|
|
39
|
+
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
37
40
|
import { createTableWithWidth } from './utils';
|
|
38
41
|
const defaultGetEditorFeatureFlags = () => ({});
|
|
39
42
|
|
|
@@ -312,7 +315,10 @@ const tablesPlugin = ({
|
|
|
312
315
|
}) => {
|
|
313
316
|
const isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
314
317
|
const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
318
|
+
const resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
319
|
+
const resizingTableRef = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableRef;
|
|
315
320
|
const isResizing = isColumnResizing || isTableResizing;
|
|
321
|
+
const widthToWidest = tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.widthToWidest;
|
|
316
322
|
const {
|
|
317
323
|
tableNode,
|
|
318
324
|
tablePos,
|
|
@@ -393,6 +399,15 @@ const tablesPlugin = ({
|
|
|
393
399
|
stickyHeaders: stickyHeader,
|
|
394
400
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
395
401
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
402
|
+
}), (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && isTableResizing && widthToWidest && resizingTableLocalId && resizingTableRef && widthToWidest[resizingTableLocalId] && /*#__PURE__*/React.createElement(FloatingToolbarLabel, {
|
|
403
|
+
target: resizingTableRef,
|
|
404
|
+
content: /*#__PURE__*/React.createElement(FullWidthDisplay, null),
|
|
405
|
+
alignX: 'center',
|
|
406
|
+
alignY: 'bottom',
|
|
407
|
+
stick: true,
|
|
408
|
+
forcePlacement: true,
|
|
409
|
+
zIndex: akEditorFloatingPanelZIndex,
|
|
410
|
+
offset: [0, 10]
|
|
396
411
|
}));
|
|
397
412
|
}
|
|
398
413
|
}));
|
|
@@ -19,17 +19,26 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTabl
|
|
|
19
19
|
state: {
|
|
20
20
|
init() {
|
|
21
21
|
return {
|
|
22
|
-
resizing: false
|
|
22
|
+
resizing: false,
|
|
23
|
+
tableLocalId: '',
|
|
24
|
+
tableRef: null
|
|
23
25
|
};
|
|
24
26
|
},
|
|
25
27
|
apply(tr, pluginState) {
|
|
26
28
|
const meta = tr.getMeta(pluginKey);
|
|
27
|
-
if (meta
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (meta) {
|
|
30
|
+
const keys = Object.keys(meta);
|
|
31
|
+
const changed = keys.some(key => {
|
|
32
|
+
return pluginState[key] !== meta[key];
|
|
33
|
+
});
|
|
34
|
+
if (changed) {
|
|
35
|
+
const newState = {
|
|
36
|
+
...pluginState,
|
|
37
|
+
...meta
|
|
38
|
+
};
|
|
39
|
+
dispatch(pluginKey, newState);
|
|
40
|
+
return newState;
|
|
41
|
+
}
|
|
33
42
|
}
|
|
34
43
|
return pluginState;
|
|
35
44
|
}
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -25,8 +25,7 @@ import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
|
25
25
|
import { canMergeCells } from './transforms';
|
|
26
26
|
import { TableCssClassName } from './types';
|
|
27
27
|
import { DisplayModeIcon } from './ui/icons';
|
|
28
|
-
import {
|
|
29
|
-
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
|
|
28
|
+
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, isTableNested } from './utils';
|
|
30
29
|
export const getToolbarMenuConfig = (config, state, {
|
|
31
30
|
formatMessage
|
|
32
31
|
}, editorAnalyticsAPI) => {
|
|
@@ -302,7 +301,6 @@ export const getClosestSelectionOrTableRect = state => {
|
|
|
302
301
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
303
302
|
};
|
|
304
303
|
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) => config => (state, intl) => {
|
|
305
|
-
var _tableObject$node$att, _tableObject$node, _tableObject$node$att2;
|
|
306
304
|
const tableObject = findTable(state.selection);
|
|
307
305
|
const pluginState = getPluginState(state);
|
|
308
306
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
@@ -310,54 +308,6 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
310
308
|
|
|
311
309
|
// We don't want to show floating toolbar while resizing the table
|
|
312
310
|
const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
313
|
-
const {
|
|
314
|
-
widthToWidest
|
|
315
|
-
} = pluginState;
|
|
316
|
-
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 : '';
|
|
317
|
-
if (options !== null && options !== void 0 && options.isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
|
|
318
|
-
const {
|
|
319
|
-
stickyScrollbar
|
|
320
|
-
} = getEditorFeatureFlags();
|
|
321
|
-
const nodeType = state.schema.nodes.table;
|
|
322
|
-
const getDomRef = editorView => {
|
|
323
|
-
let element;
|
|
324
|
-
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
325
|
-
const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
326
|
-
if (parent) {
|
|
327
|
-
const tableRef = parent.querySelector('table') || undefined;
|
|
328
|
-
if (tableRef) {
|
|
329
|
-
element = closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return element;
|
|
333
|
-
};
|
|
334
|
-
const fullWidthLabel = {
|
|
335
|
-
id: 'editor.table.fullWidthLabel',
|
|
336
|
-
type: 'custom',
|
|
337
|
-
fallback: [],
|
|
338
|
-
render: () => {
|
|
339
|
-
return jsx(FullWidthDisplay, {
|
|
340
|
-
key: 'full-width-label'
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
return {
|
|
345
|
-
title: 'Table floating label',
|
|
346
|
-
getDomRef,
|
|
347
|
-
nodeType,
|
|
348
|
-
key: 'full-width-label',
|
|
349
|
-
offset: [0, 18],
|
|
350
|
-
absoluteOffset: stickyScrollbar ? {
|
|
351
|
-
top: -6
|
|
352
|
-
} : {
|
|
353
|
-
top: 0
|
|
354
|
-
},
|
|
355
|
-
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
356
|
-
// Place the context menu slightly above the others
|
|
357
|
-
items: [fullWidthLabel],
|
|
358
|
-
scrollable: true
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
311
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
362
312
|
const nodeType = state.schema.nodes.table;
|
|
363
313
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
@@ -492,7 +442,8 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
492
442
|
const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
|
|
493
443
|
const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
|
|
494
444
|
const items = [];
|
|
495
|
-
const
|
|
445
|
+
const isNested = pluginState.tablePos && isTableNested(editorState, pluginState.tablePos);
|
|
446
|
+
const isTableScalingLockBtnEnabled = !isNested && isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
|
|
496
447
|
if (isTableScalingLockBtnEnabled) {
|
|
497
448
|
var _pluginState$tableNod;
|
|
498
449
|
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';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
+
export const FloatingToolbarLabel = /*#__PURE__*/React.memo(props => {
|
|
4
|
+
const {
|
|
5
|
+
target,
|
|
6
|
+
content,
|
|
7
|
+
alignX,
|
|
8
|
+
alignY,
|
|
9
|
+
zIndex,
|
|
10
|
+
forcePlacement,
|
|
11
|
+
stick,
|
|
12
|
+
offset
|
|
13
|
+
} = props;
|
|
14
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
15
|
+
target: target,
|
|
16
|
+
alignX: alignX,
|
|
17
|
+
alignY: alignY,
|
|
18
|
+
zIndex: zIndex,
|
|
19
|
+
stick: stick,
|
|
20
|
+
forcePlacement: forcePlacement,
|
|
21
|
+
offset: offset
|
|
22
|
+
}, content);
|
|
23
|
+
});
|
|
@@ -2,18 +2,31 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
height: "var(--ds-space-300, 24px)",
|
|
5
|
+
const tableFullWidthLabelWrapperStyles = xcss({
|
|
6
|
+
height: "var(--ds-space-400, 32px)",
|
|
8
7
|
display: 'flex',
|
|
9
|
-
|
|
8
|
+
backgroundColor: 'elevation.surface.overlay',
|
|
9
|
+
borderRadius: 'border.radius',
|
|
10
|
+
boxShadow: 'elevation.shadow.overlay',
|
|
11
|
+
lineHeight: 1,
|
|
12
|
+
boxSizing: 'border-box',
|
|
10
13
|
alignItems: 'center'
|
|
11
14
|
});
|
|
15
|
+
const tableFullWidthLabelStyles = xcss({
|
|
16
|
+
marginLeft: 'space.100',
|
|
17
|
+
marginRight: 'space.100',
|
|
18
|
+
paddingLeft: 'space.075',
|
|
19
|
+
paddingRight: 'space.075',
|
|
20
|
+
paddingTop: 'space.050',
|
|
21
|
+
paddingBottom: 'space.050'
|
|
22
|
+
});
|
|
12
23
|
export const FullWidthDisplay = () => {
|
|
13
24
|
const {
|
|
14
25
|
formatMessage
|
|
15
26
|
} = useIntl();
|
|
16
27
|
return /*#__PURE__*/React.createElement(Box, {
|
|
28
|
+
xcss: tableFullWidthLabelWrapperStyles
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Inline, {
|
|
17
30
|
xcss: tableFullWidthLabelStyles
|
|
18
|
-
},
|
|
31
|
+
}, formatMessage(messages.fullWidthLabel)));
|
|
19
32
|
};
|