@atlaskit/editor-plugin-table 7.5.15 → 7.5.16
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 +6 -0
- package/dist/cjs/toolbar.js +58 -12
- package/dist/cjs/ui/TableFullWidthLabel/index.js +25 -0
- package/dist/es2019/toolbar.js +49 -0
- package/dist/es2019/ui/TableFullWidthLabel/index.js +19 -0
- package/dist/esm/toolbar.js +58 -12
- package/dist/esm/ui/TableFullWidthLabel/index.js +18 -0
- package/dist/types/ui/TableFullWidthLabel/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableFullWidthLabel/index.d.ts +2 -0
- package/package.json +2 -2
- package/src/toolbar.tsx +50 -0
- package/src/ui/TableFullWidthLabel/index.tsx +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.5.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#83148](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83148) [`c7e46e32cf2d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c7e46e32cf2d) - [ux] add label in floating toolbar when table resize to widest guideline
|
|
8
|
+
|
|
3
9
|
## 7.5.15
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -31,6 +31,7 @@ var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
|
|
|
31
31
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
32
32
|
var _transforms = require("./transforms");
|
|
33
33
|
var _types = require("./types");
|
|
34
|
+
var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
|
|
34
35
|
var _utils4 = require("./utils");
|
|
35
36
|
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); }
|
|
36
37
|
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; }
|
|
@@ -307,16 +308,61 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
307
308
|
|
|
308
309
|
// We don't want to show floating toolbar while resizing the table
|
|
309
310
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
310
|
-
|
|
311
|
+
var isTableScalingEnabled = pluginState.isTableScalingEnabled,
|
|
312
|
+
widthToWidest = pluginState.widthToWidest;
|
|
313
|
+
if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
|
|
314
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
315
|
+
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
311
316
|
var nodeType = state.schema.nodes.table;
|
|
317
|
+
var getDomRef = function getDomRef(editorView) {
|
|
318
|
+
var element;
|
|
319
|
+
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
320
|
+
var parent = (0, _utils2.findParentDomRefOfType)(nodeType, domAtPos)(state.selection);
|
|
321
|
+
if (parent) {
|
|
322
|
+
var tableRef = parent.querySelector('table') || undefined;
|
|
323
|
+
if (tableRef) {
|
|
324
|
+
element = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return element;
|
|
328
|
+
};
|
|
329
|
+
var fullWidthLabel = {
|
|
330
|
+
id: 'editor.table.fullWidthLabel',
|
|
331
|
+
type: 'custom',
|
|
332
|
+
fallback: [],
|
|
333
|
+
render: function render() {
|
|
334
|
+
return (0, _react.jsx)(_TableFullWidthLabel.FullWidthDisplay, {
|
|
335
|
+
key: 'full-width-label'
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
return {
|
|
340
|
+
title: 'Table floating label',
|
|
341
|
+
getDomRef: getDomRef,
|
|
342
|
+
nodeType: nodeType,
|
|
343
|
+
key: 'full-width-label',
|
|
344
|
+
offset: [0, 18],
|
|
345
|
+
absoluteOffset: stickyScrollbar ? {
|
|
346
|
+
top: -6
|
|
347
|
+
} : {
|
|
348
|
+
top: 0
|
|
349
|
+
},
|
|
350
|
+
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
351
|
+
// Place the context menu slightly above the others
|
|
352
|
+
items: [fullWidthLabel],
|
|
353
|
+
scrollable: true
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
357
|
+
var _nodeType = state.schema.nodes.table;
|
|
312
358
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
313
359
|
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
314
360
|
_getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
|
|
315
|
-
|
|
361
|
+
_isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
|
|
316
362
|
var cellItems;
|
|
317
|
-
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI,
|
|
363
|
+
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
|
|
318
364
|
var columnSettingsItems;
|
|
319
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI,
|
|
365
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
|
|
320
366
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
321
367
|
|
|
322
368
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -343,10 +389,10 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
343
389
|
};
|
|
344
390
|
};
|
|
345
391
|
}
|
|
346
|
-
var
|
|
392
|
+
var _getDomRef = function _getDomRef(editorView) {
|
|
347
393
|
var element;
|
|
348
394
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
349
|
-
var parent = (0, _utils2.findParentDomRefOfType)(
|
|
395
|
+
var parent = (0, _utils2.findParentDomRefOfType)(_nodeType, domAtPos)(state.selection);
|
|
350
396
|
if (parent) {
|
|
351
397
|
var tableRef = parent.querySelector('table') || undefined;
|
|
352
398
|
if (tableRef) {
|
|
@@ -355,14 +401,14 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
355
401
|
}
|
|
356
402
|
return element;
|
|
357
403
|
};
|
|
358
|
-
var
|
|
359
|
-
|
|
404
|
+
var _getEditorFeatureFlag2 = getEditorFeatureFlags(),
|
|
405
|
+
_stickyScrollbar = _getEditorFeatureFlag2.stickyScrollbar;
|
|
360
406
|
return {
|
|
361
407
|
title: 'Table floating controls',
|
|
362
|
-
getDomRef:
|
|
363
|
-
nodeType:
|
|
408
|
+
getDomRef: _getDomRef,
|
|
409
|
+
nodeType: _nodeType,
|
|
364
410
|
offset: [0, 18],
|
|
365
|
-
absoluteOffset:
|
|
411
|
+
absoluteOffset: _stickyScrollbar ? {
|
|
366
412
|
top: -6
|
|
367
413
|
} : {
|
|
368
414
|
top: 0
|
|
@@ -377,7 +423,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
377
423
|
items: [{
|
|
378
424
|
state: state,
|
|
379
425
|
formatMessage: intl.formatMessage,
|
|
380
|
-
nodeType:
|
|
426
|
+
nodeType: _nodeType,
|
|
381
427
|
onMouseEnter: (0, _commands.hoverTable)(false, true),
|
|
382
428
|
onMouseLeave: (0, _commands.clearHoverSelection)(),
|
|
383
429
|
onFocus: (0, _commands.hoverTable)(false, true),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FullWidthDisplay = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
+
var _primitives = require("@atlaskit/primitives");
|
|
12
|
+
var tableFullWidthLabelStyles = (0, _primitives.xcss)({
|
|
13
|
+
minWidth: '120px',
|
|
14
|
+
height: "var(--ds-space-300, 24px)",
|
|
15
|
+
display: 'flex',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
alignItems: 'center'
|
|
18
|
+
});
|
|
19
|
+
var FullWidthDisplay = exports.FullWidthDisplay = function FullWidthDisplay() {
|
|
20
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
21
|
+
formatMessage = _useIntl.formatMessage;
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
23
|
+
xcss: tableFullWidthLabelStyles
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(_primitives.Inline, null, formatMessage(_messages.tableMessages.fullWidthLabel)));
|
|
25
|
+
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -23,6 +23,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
|
|
|
23
23
|
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
24
24
|
import { canMergeCells } from './transforms';
|
|
25
25
|
import { TableCssClassName } from './types';
|
|
26
|
+
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
26
27
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
|
|
27
28
|
export const getToolbarMenuConfig = (config, state, {
|
|
28
29
|
formatMessage
|
|
@@ -293,6 +294,54 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
293
294
|
|
|
294
295
|
// We don't want to show floating toolbar while resizing the table
|
|
295
296
|
const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
297
|
+
const {
|
|
298
|
+
isTableScalingEnabled,
|
|
299
|
+
widthToWidest
|
|
300
|
+
} = pluginState;
|
|
301
|
+
if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
|
|
302
|
+
const {
|
|
303
|
+
stickyScrollbar
|
|
304
|
+
} = getEditorFeatureFlags();
|
|
305
|
+
const nodeType = state.schema.nodes.table;
|
|
306
|
+
const getDomRef = editorView => {
|
|
307
|
+
let element;
|
|
308
|
+
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
309
|
+
const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
310
|
+
if (parent) {
|
|
311
|
+
const tableRef = parent.querySelector('table') || undefined;
|
|
312
|
+
if (tableRef) {
|
|
313
|
+
element = closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return element;
|
|
317
|
+
};
|
|
318
|
+
const fullWidthLabel = {
|
|
319
|
+
id: 'editor.table.fullWidthLabel',
|
|
320
|
+
type: 'custom',
|
|
321
|
+
fallback: [],
|
|
322
|
+
render: () => {
|
|
323
|
+
return jsx(FullWidthDisplay, {
|
|
324
|
+
key: 'full-width-label'
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
return {
|
|
329
|
+
title: 'Table floating label',
|
|
330
|
+
getDomRef,
|
|
331
|
+
nodeType,
|
|
332
|
+
key: 'full-width-label',
|
|
333
|
+
offset: [0, 18],
|
|
334
|
+
absoluteOffset: stickyScrollbar ? {
|
|
335
|
+
top: -6
|
|
336
|
+
} : {
|
|
337
|
+
top: 0
|
|
338
|
+
},
|
|
339
|
+
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
340
|
+
// Place the context menu slightly above the others
|
|
341
|
+
items: [fullWidthLabel],
|
|
342
|
+
scrollable: true
|
|
343
|
+
};
|
|
344
|
+
}
|
|
296
345
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
297
346
|
const nodeType = state.schema.nodes.table;
|
|
298
347
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
5
|
+
const tableFullWidthLabelStyles = xcss({
|
|
6
|
+
minWidth: '120px',
|
|
7
|
+
height: "var(--ds-space-300, 24px)",
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center'
|
|
11
|
+
});
|
|
12
|
+
export const FullWidthDisplay = () => {
|
|
13
|
+
const {
|
|
14
|
+
formatMessage
|
|
15
|
+
} = useIntl();
|
|
16
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
17
|
+
xcss: tableFullWidthLabelStyles
|
|
18
|
+
}, /*#__PURE__*/React.createElement(Inline, null, formatMessage(messages.fullWidthLabel)));
|
|
19
|
+
};
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -24,6 +24,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
|
|
|
24
24
|
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
25
25
|
import { canMergeCells } from './transforms';
|
|
26
26
|
import { TableCssClassName } from './types';
|
|
27
|
+
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
27
28
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
|
|
28
29
|
export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
|
|
29
30
|
var formatMessage = _ref.formatMessage;
|
|
@@ -296,16 +297,61 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
296
297
|
|
|
297
298
|
// We don't want to show floating toolbar while resizing the table
|
|
298
299
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
299
|
-
|
|
300
|
+
var isTableScalingEnabled = pluginState.isTableScalingEnabled,
|
|
301
|
+
widthToWidest = pluginState.widthToWidest;
|
|
302
|
+
if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
|
|
303
|
+
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
304
|
+
stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
|
|
300
305
|
var nodeType = state.schema.nodes.table;
|
|
306
|
+
var getDomRef = function getDomRef(editorView) {
|
|
307
|
+
var element;
|
|
308
|
+
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
309
|
+
var parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
|
|
310
|
+
if (parent) {
|
|
311
|
+
var tableRef = parent.querySelector('table') || undefined;
|
|
312
|
+
if (tableRef) {
|
|
313
|
+
element = closestElement(tableRef, ".".concat(TableCssClassName.TABLE_NODE_WRAPPER)) || undefined;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return element;
|
|
317
|
+
};
|
|
318
|
+
var fullWidthLabel = {
|
|
319
|
+
id: 'editor.table.fullWidthLabel',
|
|
320
|
+
type: 'custom',
|
|
321
|
+
fallback: [],
|
|
322
|
+
render: function render() {
|
|
323
|
+
return jsx(FullWidthDisplay, {
|
|
324
|
+
key: 'full-width-label'
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
return {
|
|
329
|
+
title: 'Table floating label',
|
|
330
|
+
getDomRef: getDomRef,
|
|
331
|
+
nodeType: nodeType,
|
|
332
|
+
key: 'full-width-label',
|
|
333
|
+
offset: [0, 18],
|
|
334
|
+
absoluteOffset: stickyScrollbar ? {
|
|
335
|
+
top: -6
|
|
336
|
+
} : {
|
|
337
|
+
top: 0
|
|
338
|
+
},
|
|
339
|
+
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
340
|
+
// Place the context menu slightly above the others
|
|
341
|
+
items: [fullWidthLabel],
|
|
342
|
+
scrollable: true
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
346
|
+
var _nodeType = state.schema.nodes.table;
|
|
301
347
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
302
348
|
var _getPluginState2 = getPluginState(state),
|
|
303
349
|
_getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
|
|
304
|
-
|
|
350
|
+
_isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
|
|
305
351
|
var cellItems;
|
|
306
|
-
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI,
|
|
352
|
+
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
|
|
307
353
|
var columnSettingsItems;
|
|
308
|
-
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI,
|
|
354
|
+
columnSettingsItems = pluginState.isDragAndDropEnabled && getBooleanFF('platform.editor.table.new-cell-context-menu-styling') ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
|
|
309
355
|
var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
|
|
310
356
|
|
|
311
357
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -332,10 +378,10 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
332
378
|
};
|
|
333
379
|
};
|
|
334
380
|
}
|
|
335
|
-
var
|
|
381
|
+
var _getDomRef = function _getDomRef(editorView) {
|
|
336
382
|
var element;
|
|
337
383
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
338
|
-
var parent = findParentDomRefOfType(
|
|
384
|
+
var parent = findParentDomRefOfType(_nodeType, domAtPos)(state.selection);
|
|
339
385
|
if (parent) {
|
|
340
386
|
var tableRef = parent.querySelector('table') || undefined;
|
|
341
387
|
if (tableRef) {
|
|
@@ -344,14 +390,14 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
344
390
|
}
|
|
345
391
|
return element;
|
|
346
392
|
};
|
|
347
|
-
var
|
|
348
|
-
|
|
393
|
+
var _getEditorFeatureFlag2 = getEditorFeatureFlags(),
|
|
394
|
+
_stickyScrollbar = _getEditorFeatureFlag2.stickyScrollbar;
|
|
349
395
|
return {
|
|
350
396
|
title: 'Table floating controls',
|
|
351
|
-
getDomRef:
|
|
352
|
-
nodeType:
|
|
397
|
+
getDomRef: _getDomRef,
|
|
398
|
+
nodeType: _nodeType,
|
|
353
399
|
offset: [0, 18],
|
|
354
|
-
absoluteOffset:
|
|
400
|
+
absoluteOffset: _stickyScrollbar ? {
|
|
355
401
|
top: -6
|
|
356
402
|
} : {
|
|
357
403
|
top: 0
|
|
@@ -366,7 +412,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
366
412
|
items: [{
|
|
367
413
|
state: state,
|
|
368
414
|
formatMessage: intl.formatMessage,
|
|
369
|
-
nodeType:
|
|
415
|
+
nodeType: _nodeType,
|
|
370
416
|
onMouseEnter: hoverTable(false, true),
|
|
371
417
|
onMouseLeave: clearHoverSelection(),
|
|
372
418
|
onFocus: hoverTable(false, true),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
5
|
+
var tableFullWidthLabelStyles = xcss({
|
|
6
|
+
minWidth: '120px',
|
|
7
|
+
height: "var(--ds-space-300, 24px)",
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center'
|
|
11
|
+
});
|
|
12
|
+
export var FullWidthDisplay = function FullWidthDisplay() {
|
|
13
|
+
var _useIntl = useIntl(),
|
|
14
|
+
formatMessage = _useIntl.formatMessage;
|
|
15
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
16
|
+
xcss: tableFullWidthLabelStyles
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Inline, null, formatMessage(messages.fullWidthLabel)));
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.16",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.7.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.0.16",
|
|
33
|
-
"@atlaskit/editor-common": "^78.
|
|
33
|
+
"@atlaskit/editor-common": "^78.19.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.5.3",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-content-insertion": "^1.0.0",
|
package/src/toolbar.tsx
CHANGED
|
@@ -90,6 +90,7 @@ import type {
|
|
|
90
90
|
ToolbarMenuState,
|
|
91
91
|
} from './types';
|
|
92
92
|
import { TableCssClassName } from './types';
|
|
93
|
+
import { FullWidthDisplay } from './ui/TableFullWidthLabel';
|
|
93
94
|
import {
|
|
94
95
|
getMergedCellsPositions,
|
|
95
96
|
getSelectedColumnIndexes,
|
|
@@ -452,6 +453,55 @@ export const getToolbarConfig =
|
|
|
452
453
|
// We don't want to show floating toolbar while resizing the table
|
|
453
454
|
const isWidthResizing = tableWidthState?.resizing;
|
|
454
455
|
|
|
456
|
+
const { isTableScalingEnabled, widthToWidest } = pluginState;
|
|
457
|
+
|
|
458
|
+
if (isTableScalingEnabled && isWidthResizing && widthToWidest) {
|
|
459
|
+
const { stickyScrollbar } = getEditorFeatureFlags();
|
|
460
|
+
|
|
461
|
+
const nodeType = state.schema.nodes.table;
|
|
462
|
+
const getDomRef = (editorView: EditorView) => {
|
|
463
|
+
let element: HTMLElement | undefined;
|
|
464
|
+
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
465
|
+
const parent = findParentDomRefOfType(
|
|
466
|
+
nodeType,
|
|
467
|
+
domAtPos,
|
|
468
|
+
)(state.selection);
|
|
469
|
+
if (parent) {
|
|
470
|
+
const tableRef =
|
|
471
|
+
(parent as HTMLElement).querySelector<HTMLTableElement>('table') ||
|
|
472
|
+
undefined;
|
|
473
|
+
if (tableRef) {
|
|
474
|
+
element =
|
|
475
|
+
closestElement(
|
|
476
|
+
tableRef,
|
|
477
|
+
`.${TableCssClassName.TABLE_NODE_WRAPPER}`,
|
|
478
|
+
) || undefined;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return element;
|
|
482
|
+
};
|
|
483
|
+
const fullWidthLabel = {
|
|
484
|
+
id: 'editor.table.fullWidthLabel',
|
|
485
|
+
type: 'custom',
|
|
486
|
+
fallback: [],
|
|
487
|
+
render: () => {
|
|
488
|
+
return <FullWidthDisplay key={'full-width-label'} />;
|
|
489
|
+
},
|
|
490
|
+
} as FloatingToolbarItem<Command>;
|
|
491
|
+
|
|
492
|
+
return {
|
|
493
|
+
title: 'Table floating label',
|
|
494
|
+
getDomRef,
|
|
495
|
+
nodeType,
|
|
496
|
+
key: 'full-width-label',
|
|
497
|
+
offset: [0, 18],
|
|
498
|
+
absoluteOffset: stickyScrollbar ? { top: -6 } : { top: 0 },
|
|
499
|
+
zIndex: akEditorFloatingPanelZIndex + 1, // Place the context menu slightly above the others
|
|
500
|
+
items: [fullWidthLabel],
|
|
501
|
+
scrollable: true,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
455
505
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
456
506
|
const nodeType = state.schema.nodes.table;
|
|
457
507
|
const menu = getToolbarMenuConfig(
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
4
|
+
|
|
5
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
7
|
+
import { token } from '@atlaskit/tokens';
|
|
8
|
+
|
|
9
|
+
const tableFullWidthLabelStyles = xcss({
|
|
10
|
+
minWidth: '120px',
|
|
11
|
+
height: token('space.300', '24px'),
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const FullWidthDisplay = () => {
|
|
18
|
+
const { formatMessage } = useIntl();
|
|
19
|
+
return (
|
|
20
|
+
<Box xcss={tableFullWidthLabelStyles}>
|
|
21
|
+
<Inline>{formatMessage(messages.fullWidthLabel)}</Inline>
|
|
22
|
+
</Box>
|
|
23
|
+
);
|
|
24
|
+
};
|