@atlaskit/editor-plugin-table 2.10.7 → 2.11.0
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 +41 -0
- package/dist/cjs/plugins/table/commands/misc.js +58 -5
- package/dist/cjs/plugins/table/event-handlers.js +3 -6
- package/dist/cjs/plugins/table/index.js +66 -63
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +5 -5
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +13 -19
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +18 -5
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +6 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +7 -3
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
- package/dist/cjs/plugins/table/reducer.js +26 -2
- package/dist/cjs/plugins/table/types.js +1 -0
- package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +44 -0
- package/dist/cjs/plugins/table/ui/messages.js +5 -0
- package/dist/cjs/plugins/table/utils/decoration.js +17 -4
- package/dist/es2019/plugins/table/commands/misc.js +49 -5
- package/dist/es2019/plugins/table/event-handlers.js +3 -6
- package/dist/es2019/plugins/table/index.js +14 -10
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +5 -5
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +14 -17
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +12 -2
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/index.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -3
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
- package/dist/es2019/plugins/table/reducer.js +29 -2
- package/dist/es2019/plugins/table/types.js +1 -0
- package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +35 -0
- package/dist/es2019/plugins/table/ui/messages.js +5 -0
- package/dist/es2019/plugins/table/utils/decoration.js +16 -5
- package/dist/esm/plugins/table/commands/misc.js +56 -5
- package/dist/esm/plugins/table/event-handlers.js +3 -6
- package/dist/esm/plugins/table/index.js +66 -63
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +5 -5
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +13 -19
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +15 -3
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/index.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/main.js +8 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
- package/dist/esm/plugins/table/reducer.js +26 -2
- package/dist/esm/plugins/table/types.js +1 -0
- package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +35 -0
- package/dist/esm/plugins/table/ui/messages.js +5 -0
- package/dist/esm/plugins/table/utils/decoration.js +17 -4
- package/dist/types/plugins/table/commands/misc.d.ts +8 -6
- package/dist/types/plugins/table/event-handlers.d.ts +3 -3
- package/dist/types/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -2
- package/dist/types/plugins/table/pm-plugins/decorations/utils/index.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types/plugins/table/reducer.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +18 -0
- package/dist/types/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
- package/dist/types/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types/plugins/table/utils/decoration.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +8 -6
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/reducer.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -1
- package/package.json +4 -4
- package/src/__tests__/unit/event-handlers.ts +1 -1
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +6 -8
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +22 -15
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +9 -10
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +9 -9
- package/src/plugins/table/commands/misc.ts +84 -7
- package/src/plugins/table/event-handlers.ts +11 -16
- package/src/plugins/table/index.tsx +6 -4
- package/src/plugins/table/nodeviews/TableContainer.tsx +4 -4
- package/src/plugins/table/nodeviews/TableResizer.tsx +12 -20
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +34 -7
- package/src/plugins/table/pm-plugins/decorations/utils/index.ts +4 -1
- package/src/plugins/table/pm-plugins/main.ts +7 -1
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin.ts +3 -5
- package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +5 -3
- package/src/plugins/table/reducer.ts +51 -3
- package/src/plugins/table/types.ts +19 -0
- package/src/plugins/table/ui/ColumnResizeWidget/index.tsx +53 -0
- package/src/plugins/table/ui/messages.ts +5 -0
- package/src/plugins/table/utils/decoration.ts +27 -5
- package/tmp/api-report-tmp.d.ts +111 -0
|
@@ -65,10 +65,34 @@ var _default = function _default(pluginState, action) {
|
|
|
65
65
|
resizeHandleRowIndex: undefined
|
|
66
66
|
});
|
|
67
67
|
case 'ADD_RESIZE_HANDLE_DECORATIONS':
|
|
68
|
-
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex) {
|
|
68
|
+
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
|
|
69
69
|
return pluginState;
|
|
70
70
|
}
|
|
71
|
-
return _objectSpread(_objectSpread({}, pluginState), action.data)
|
|
71
|
+
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
|
|
72
|
+
isResizeHandleWidgetAdded: true
|
|
73
|
+
});
|
|
74
|
+
case 'UPDATE_RESIZE_HANDLE_DECORATIONS':
|
|
75
|
+
var _action$data = action.data,
|
|
76
|
+
resizeHandleColumnIndex = _action$data.resizeHandleColumnIndex,
|
|
77
|
+
resizeHandleRowIndex = _action$data.resizeHandleRowIndex,
|
|
78
|
+
resizeHandleIncludeTooltip = _action$data.resizeHandleIncludeTooltip;
|
|
79
|
+
if ((resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex || !Number.isFinite(resizeHandleColumnIndex)) && (resizeHandleRowIndex === pluginState.resizeHandleRowIndex || !Number.isFinite(resizeHandleRowIndex)) && (resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip || resizeHandleIncludeTooltip === undefined)) {
|
|
80
|
+
return pluginState;
|
|
81
|
+
}
|
|
82
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
83
|
+
resizeHandleColumnIndex: resizeHandleColumnIndex !== null && resizeHandleColumnIndex !== void 0 ? resizeHandleColumnIndex : pluginState.resizeHandleColumnIndex,
|
|
84
|
+
resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
|
|
85
|
+
resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
|
|
86
|
+
});
|
|
87
|
+
case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
|
|
88
|
+
if (!pluginState.isResizeHandleWidgetAdded) {
|
|
89
|
+
return pluginState;
|
|
90
|
+
}
|
|
91
|
+
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
|
|
92
|
+
resizeHandleColumnIndex: undefined,
|
|
93
|
+
resizeHandleRowIndex: undefined,
|
|
94
|
+
isResizeHandleWidgetAdded: false
|
|
95
|
+
});
|
|
72
96
|
case 'SET_TABLE_REF':
|
|
73
97
|
case 'HOVER_ROWS':
|
|
74
98
|
case 'HOVER_COLUMNS':
|
|
@@ -46,6 +46,7 @@ var TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
|
46
46
|
TableDecorations["COLUMN_CONTROLS_DECORATIONS"] = "COLUMN_CONTROLS_DECORATIONS";
|
|
47
47
|
TableDecorations["COLUMN_SELECTED"] = "COLUMN_SELECTED";
|
|
48
48
|
TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
|
|
49
|
+
TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
|
|
49
50
|
TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
|
|
50
51
|
TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
|
|
51
52
|
return TableDecorations;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ColumnResizeWidget = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _reactIntlNext = require("react-intl-next");
|
|
12
|
+
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
13
|
+
var _types = require("../../types");
|
|
14
|
+
var _messages = _interopRequireDefault(require("../messages"));
|
|
15
|
+
/** @jsx jsx */
|
|
16
|
+
|
|
17
|
+
var ColumnResizeWidget = function ColumnResizeWidget(_ref) {
|
|
18
|
+
var startIndex = _ref.startIndex,
|
|
19
|
+
endIndex = _ref.endIndex,
|
|
20
|
+
includeTooltip = _ref.includeTooltip;
|
|
21
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
22
|
+
formatMessage = _useIntl.formatMessage;
|
|
23
|
+
if (!includeTooltip) {
|
|
24
|
+
return (0, _react2.jsx)("div", {
|
|
25
|
+
className: _types.TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
26
|
+
"data-start-index": startIndex,
|
|
27
|
+
"data-end-index": endIndex
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return (0, _react2.jsx)(_tooltip.default, {
|
|
31
|
+
content: formatMessage(_messages.default.adjustColumns),
|
|
32
|
+
hideTooltipOnClick: true,
|
|
33
|
+
hideTooltipOnMouseDown: true,
|
|
34
|
+
position: "mouse",
|
|
35
|
+
mousePosition: "auto-start"
|
|
36
|
+
}, function (tooltipProps) {
|
|
37
|
+
return (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
38
|
+
className: _types.TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
39
|
+
"data-start-index": startIndex,
|
|
40
|
+
"data-end-index": endIndex
|
|
41
|
+
}, tooltipProps));
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.ColumnResizeWidget = ColumnResizeWidget;
|
|
@@ -60,6 +60,11 @@ var _default = (0, _reactIntlNext.defineMessages)({
|
|
|
60
60
|
id: 'fabric.editor.extension.sourceNoTitledName',
|
|
61
61
|
defaultMessage: 'this element',
|
|
62
62
|
description: 'The current element without preset name been selected'
|
|
63
|
+
},
|
|
64
|
+
adjustColumns: {
|
|
65
|
+
id: 'fabric.editor.tables.adjustColumn',
|
|
66
|
+
defaultMessage: 'Adjust column',
|
|
67
|
+
description: 'Tooltip displayed on table column resize handle'
|
|
63
68
|
}
|
|
64
69
|
});
|
|
65
70
|
exports.default = _default;
|
|
@@ -6,11 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.updateDecorations = exports.findControlsHoverDecoration = exports.findColumnControlSelectedDecoration = exports.createResizeHandleDecoration = exports.createControlsHoverDecoration = exports.createColumnSelectedDecoration = exports.createColumnLineResize = exports.createColumnControlsDecoration = exports.createCellHoverDecoration = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
|
+
var _reactIntlNext = require("react-intl-next");
|
|
9
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
13
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
14
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
12
15
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
13
16
|
var _types = require("../types");
|
|
17
|
+
var _ColumnResizeWidget = require("../ui/ColumnResizeWidget");
|
|
14
18
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
15
19
|
|
|
16
20
|
var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
|
|
@@ -270,6 +274,8 @@ var makeArray = function makeArray(n) {
|
|
|
270
274
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
271
275
|
*/
|
|
272
276
|
var createResizeHandleDecoration = function createResizeHandleDecoration(tr, rowIndexTarget, columnEndIndexTarget) {
|
|
277
|
+
var includeTooltip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
278
|
+
var getIntl = arguments.length > 4 ? arguments[4] : undefined;
|
|
273
279
|
var emptyResult = [[], []];
|
|
274
280
|
var table = (0, _utils2.findTable)(tr.selection);
|
|
275
281
|
if (!table || !table.node) {
|
|
@@ -283,12 +289,19 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
|
|
|
283
289
|
var position = cellPos + cellNode.nodeSize - 1;
|
|
284
290
|
return _view.Decoration.widget(position, function () {
|
|
285
291
|
var element = document.createElement('div');
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
292
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
293
|
+
value: getIntl()
|
|
294
|
+
}, /*#__PURE__*/(0, _react.createElement)(_ColumnResizeWidget.ColumnResizeWidget, {
|
|
295
|
+
startIndex: cellColumnPositioning.left,
|
|
296
|
+
endIndex: cellColumnPositioning.right,
|
|
297
|
+
includeTooltip: includeTooltip
|
|
298
|
+
})), element);
|
|
289
299
|
return element;
|
|
290
300
|
}, {
|
|
291
|
-
key: "".concat(_types.TableDecorations.
|
|
301
|
+
key: "".concat(_types.TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET, "_").concat(rowIndex, "_").concat(columnIndex, "_").concat(includeTooltip ? 'with' : 'no', "-tooltip"),
|
|
302
|
+
destroy: function destroy(node) {
|
|
303
|
+
_reactDom.default.unmountComponentAtNode(node);
|
|
304
|
+
}
|
|
292
305
|
});
|
|
293
306
|
};
|
|
294
307
|
var createLastCellElementDecoration = function createLastCellElementDecoration(cellColumnPositioning, cellPos, cellNode) {
|
|
@@ -6,7 +6,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
6
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
7
|
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumn as selectColumnTransform, selectionCell, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
8
8
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
9
|
-
import { buildColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
9
|
+
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
10
10
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
11
11
|
import { fixAutoSizedTable } from '../transforms';
|
|
12
12
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
@@ -321,12 +321,13 @@ export const showInsertRowButton = rowIndex => createCommand(_ => rowIndex > -1
|
|
|
321
321
|
export const hideInsertColumnOrRowButton = () => createCommand({
|
|
322
322
|
type: 'HIDE_INSERT_COLUMN_OR_ROW_BUTTON'
|
|
323
323
|
}, tr => tr.setMeta('addToHistory', false));
|
|
324
|
-
export const addResizeHandleDecorations = (rowIndex, columnIndex) => createCommand(state => {
|
|
324
|
+
export const addResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip) => createCommand(state => {
|
|
325
325
|
const tableNode = findTable(state.selection);
|
|
326
326
|
const {
|
|
327
327
|
pluginConfig: {
|
|
328
328
|
allowColumnResizing
|
|
329
|
-
}
|
|
329
|
+
},
|
|
330
|
+
getIntl
|
|
330
331
|
} = getPluginState(state);
|
|
331
332
|
if (!tableNode || !allowColumnResizing) {
|
|
332
333
|
return false;
|
|
@@ -334,15 +335,58 @@ export const addResizeHandleDecorations = (rowIndex, columnIndex) => createComma
|
|
|
334
335
|
return {
|
|
335
336
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
336
337
|
data: {
|
|
337
|
-
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex)({
|
|
338
|
+
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex, includeTooltip, getIntl)({
|
|
339
|
+
tr: state.tr,
|
|
340
|
+
decorationSet: getDecorations(state)
|
|
341
|
+
}),
|
|
342
|
+
resizeHandleRowIndex: rowIndex,
|
|
343
|
+
resizeHandleColumnIndex: columnIndex,
|
|
344
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
348
|
+
export const updateResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip) => createCommand(state => {
|
|
349
|
+
const tableNode = findTable(state.selection);
|
|
350
|
+
const {
|
|
351
|
+
resizeHandleRowIndex,
|
|
352
|
+
resizeHandleColumnIndex,
|
|
353
|
+
resizeHandleIncludeTooltip,
|
|
354
|
+
pluginConfig: {
|
|
355
|
+
allowColumnResizing
|
|
356
|
+
},
|
|
357
|
+
getIntl
|
|
358
|
+
} = getPluginState(state);
|
|
359
|
+
if (!tableNode || !allowColumnResizing) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
const resolvedRowIndex = rowIndex !== null && rowIndex !== void 0 ? rowIndex : resizeHandleRowIndex;
|
|
363
|
+
const resolvedColumnIndex = columnIndex !== null && columnIndex !== void 0 ? columnIndex : resizeHandleColumnIndex;
|
|
364
|
+
const resolvedIncludeTooltip = includeTooltip !== null && includeTooltip !== void 0 ? includeTooltip : resizeHandleIncludeTooltip;
|
|
365
|
+
if (resolvedRowIndex === undefined || resolvedColumnIndex === undefined || resolvedIncludeTooltip === undefined) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
type: 'UPDATE_RESIZE_HANDLE_DECORATIONS',
|
|
370
|
+
data: {
|
|
371
|
+
decorationSet: buildColumnResizingDecorations(resolvedRowIndex, resolvedColumnIndex, resolvedIncludeTooltip, getIntl)({
|
|
338
372
|
tr: state.tr,
|
|
339
373
|
decorationSet: getDecorations(state)
|
|
340
374
|
}),
|
|
341
375
|
resizeHandleRowIndex: rowIndex,
|
|
342
|
-
resizeHandleColumnIndex: columnIndex
|
|
376
|
+
resizeHandleColumnIndex: columnIndex,
|
|
377
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
343
378
|
}
|
|
344
379
|
};
|
|
345
380
|
}, tr => tr.setMeta('addToHistory', false));
|
|
381
|
+
export const removeResizeHandleDecorations = () => createCommand(state => ({
|
|
382
|
+
type: 'REMOVE_RESIZE_HANDLE_DECORATIONS',
|
|
383
|
+
data: {
|
|
384
|
+
decorationSet: clearColumnResizingDecorations()({
|
|
385
|
+
tr: state.tr,
|
|
386
|
+
decorationSet: getDecorations(state)
|
|
387
|
+
})
|
|
388
|
+
}
|
|
389
|
+
}), tr => tr.setMeta('addToHistory', false));
|
|
346
390
|
export const autoSizeTable = (view, node, table, basePos, opts) => {
|
|
347
391
|
if (typeof basePos !== 'number') {
|
|
348
392
|
return false;
|
|
@@ -236,7 +236,7 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
236
236
|
target: element,
|
|
237
237
|
columnEndIndexTarget
|
|
238
238
|
})) {
|
|
239
|
-
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget)(state, dispatch);
|
|
239
|
+
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true)(state, dispatch);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -321,11 +321,8 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
321
321
|
return tr;
|
|
322
322
|
};
|
|
323
323
|
export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
|
|
327
|
-
const hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
328
|
-
if (!hasTableNode || isDragging) {
|
|
324
|
+
var _getPluginState, _getResizePluginState;
|
|
325
|
+
if (!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) || !!((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging)) {
|
|
329
326
|
return false;
|
|
330
327
|
}
|
|
331
328
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
@@ -29,28 +29,31 @@ import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
|
29
29
|
import LayoutButton from './ui/LayoutButton';
|
|
30
30
|
import { isLayoutSupported } from './utils';
|
|
31
31
|
const defaultGetEditorFeatureFlags = () => ({});
|
|
32
|
-
const tablesPlugin = (
|
|
33
|
-
|
|
32
|
+
const tablesPlugin = ({
|
|
33
|
+
config: options,
|
|
34
|
+
api
|
|
35
|
+
}) => {
|
|
36
|
+
var _api$analytics;
|
|
34
37
|
const editorViewRef = {
|
|
35
38
|
current: null
|
|
36
39
|
};
|
|
37
40
|
const defaultGetEditorContainerWidth = () => {
|
|
38
|
-
var _document$body$offset, _document, _document$body, _api$
|
|
41
|
+
var _document$body$offset, _document, _document$body, _api$width$sharedStat;
|
|
39
42
|
const defaultState = {
|
|
40
43
|
width: (_document$body$offset = (_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) !== null && _document$body$offset !== void 0 ? _document$body$offset : 500
|
|
41
44
|
};
|
|
42
|
-
return (_api$
|
|
45
|
+
return (_api$width$sharedStat = api === null || api === void 0 ? void 0 : api.width.sharedState.currentState()) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : defaultState;
|
|
43
46
|
};
|
|
44
|
-
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$
|
|
47
|
+
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
45
48
|
return {
|
|
46
49
|
name: 'table',
|
|
47
50
|
actions: {
|
|
48
51
|
insertTable: analyticsPayload => (state, dispatch) => {
|
|
49
|
-
var _api$
|
|
52
|
+
var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
|
|
50
53
|
const node = createTable({
|
|
51
54
|
schema: state.schema
|
|
52
55
|
});
|
|
53
|
-
return (_api$
|
|
56
|
+
return (_api$contentInsertion = api === null || api === void 0 ? void 0 : (_api$contentInsertion2 = api.contentInsertion) === null || _api$contentInsertion2 === void 0 ? void 0 : (_api$contentInsertion3 = _api$contentInsertion2.actions) === null || _api$contentInsertion3 === void 0 ? void 0 : _api$contentInsertion3.insert({
|
|
54
57
|
state,
|
|
55
58
|
dispatch,
|
|
56
59
|
node,
|
|
@@ -58,7 +61,7 @@ const tablesPlugin = (options, api) => {
|
|
|
58
61
|
selectNodeInserted: false,
|
|
59
62
|
analyticsPayload
|
|
60
63
|
}
|
|
61
|
-
})) !== null && _api$
|
|
64
|
+
})) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
|
|
62
65
|
}
|
|
63
66
|
},
|
|
64
67
|
nodes() {
|
|
@@ -84,7 +87,8 @@ const tablesPlugin = (options, api) => {
|
|
|
84
87
|
dispatchAnalyticsEvent,
|
|
85
88
|
dispatch,
|
|
86
89
|
portalProviderAPI,
|
|
87
|
-
eventDispatcher
|
|
90
|
+
eventDispatcher,
|
|
91
|
+
getIntl
|
|
88
92
|
}) => {
|
|
89
93
|
const {
|
|
90
94
|
fullWidthEnabled,
|
|
@@ -94,7 +98,7 @@ const tablesPlugin = (options, api) => {
|
|
|
94
98
|
tableOptions,
|
|
95
99
|
getEditorFeatureFlags
|
|
96
100
|
} = options || {};
|
|
97
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
101
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
98
102
|
}
|
|
99
103
|
}, {
|
|
100
104
|
name: 'tablePMColResizing',
|
|
@@ -67,14 +67,14 @@ export const ResizableTableContainer = ({
|
|
|
67
67
|
}
|
|
68
68
|
}, [lineLength]);
|
|
69
69
|
const displayGuideline = useCallback(guidelines => {
|
|
70
|
-
var _pluginInjectionApi$
|
|
71
|
-
return (_pluginInjectionApi$
|
|
70
|
+
var _pluginInjectionApi$g, _pluginInjectionApi$g2, _pluginInjectionApi$g3;
|
|
71
|
+
return (_pluginInjectionApi$g = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$g2 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g2 === void 0 ? void 0 : (_pluginInjectionApi$g3 = _pluginInjectionApi$g2.actions) === null || _pluginInjectionApi$g3 === void 0 ? void 0 : _pluginInjectionApi$g3.displayGuideline(editorView)({
|
|
72
72
|
guidelines
|
|
73
|
-
})) !== null && _pluginInjectionApi$
|
|
73
|
+
})) !== null && _pluginInjectionApi$g !== void 0 ? _pluginInjectionApi$g : false;
|
|
74
74
|
}, [pluginInjectionApi, editorView]);
|
|
75
75
|
const attachAnalyticsEvent = useCallback(payload => {
|
|
76
|
-
var _pluginInjectionApi$
|
|
77
|
-
return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
76
|
+
var _pluginInjectionApi$a;
|
|
77
|
+
return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.attachAnalyticsEvent(payload);
|
|
78
78
|
}, [pluginInjectionApi]);
|
|
79
79
|
const tableWidth = getTableContainerWidth(node);
|
|
80
80
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import rafSchd from 'raf-schd';
|
|
3
|
+
import { defineMessages, useIntl } from 'react-intl-next';
|
|
3
4
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
4
5
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
5
|
-
import { resizerHandleShadowClassName } from '@atlaskit/editor-common/styles';
|
|
6
6
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
8
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
@@ -11,6 +11,13 @@ import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '
|
|
|
11
11
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
12
12
|
import { defaultGuidelines } from '../utils/guidelines';
|
|
13
13
|
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
14
|
+
const messages = defineMessages({
|
|
15
|
+
resizeTable: {
|
|
16
|
+
id: 'fabric.editor.tables.resizeTable',
|
|
17
|
+
defaultMessage: 'Resize table',
|
|
18
|
+
description: 'Tooltip displayed on custom table width resize hande'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
14
21
|
const handles = {
|
|
15
22
|
right: true
|
|
16
23
|
};
|
|
@@ -73,6 +80,9 @@ export const TableResizer = ({
|
|
|
73
80
|
var _findTable, _editorView$state;
|
|
74
81
|
const currentGap = useRef(0);
|
|
75
82
|
const [snappingEnabled, setSnappingEnabled] = useState(false);
|
|
83
|
+
const {
|
|
84
|
+
formatMessage
|
|
85
|
+
} = useIntl();
|
|
76
86
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
77
87
|
const handleHeightSize = getResizerHandleHeight(tableRef);
|
|
78
88
|
const {
|
|
@@ -177,20 +187,6 @@ export const TableResizer = ({
|
|
|
177
187
|
scheduleResize.cancel();
|
|
178
188
|
return newWidth;
|
|
179
189
|
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
180
|
-
const handleComponent = useMemo(() => ({
|
|
181
|
-
left: /*#__PURE__*/React.createElement("div", {
|
|
182
|
-
className: resizerHandleShadowClassName,
|
|
183
|
-
style: {
|
|
184
|
-
height: 'calc(100% - 24px)'
|
|
185
|
-
}
|
|
186
|
-
}),
|
|
187
|
-
right: /*#__PURE__*/React.createElement("div", {
|
|
188
|
-
className: resizerHandleShadowClassName,
|
|
189
|
-
style: {
|
|
190
|
-
height: 'calc(100% - 24px)'
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
}), []);
|
|
194
190
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
195
191
|
enable: handles,
|
|
196
192
|
width: width,
|
|
@@ -208,7 +204,8 @@ export const TableResizer = ({
|
|
|
208
204
|
handlePositioning: "adjacent",
|
|
209
205
|
innerPadding: tableHandlePosition,
|
|
210
206
|
isHandleVisible: ((_findTable = findTable((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos(),
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
appearance: isInDanger ? 'danger' : undefined,
|
|
208
|
+
handleHighlight: "shadow",
|
|
209
|
+
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
213
210
|
}, children);
|
|
214
211
|
};
|
|
@@ -5,18 +5,28 @@ const emptyDecorations = [[], []];
|
|
|
5
5
|
const updateColumnResizeHandle = columnResizesDecorations => ({
|
|
6
6
|
decorationSet,
|
|
7
7
|
tr
|
|
8
|
-
}) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.
|
|
8
|
+
}) => updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET);
|
|
9
9
|
const updateLastCellElement = lastCellElementsDecorations => ({
|
|
10
10
|
decorationSet,
|
|
11
11
|
tr
|
|
12
12
|
}) => updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
|
|
13
|
-
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex) => ({
|
|
13
|
+
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex, includeTooltip, getIntl) => ({
|
|
14
14
|
tr,
|
|
15
15
|
decorationSet
|
|
16
16
|
}) => {
|
|
17
17
|
const [columnResizesDecorations, lastCellElementsDecorations] = columnEndIndex < 0 ? emptyDecorations : createResizeHandleDecoration(tr, rowEndIndex, {
|
|
18
18
|
right: columnEndIndex
|
|
19
|
+
}, includeTooltip, getIntl);
|
|
20
|
+
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
21
|
+
decorationSet,
|
|
22
|
+
tr
|
|
19
23
|
});
|
|
24
|
+
};
|
|
25
|
+
export const clearColumnResizingDecorations = () => ({
|
|
26
|
+
tr,
|
|
27
|
+
decorationSet
|
|
28
|
+
}) => {
|
|
29
|
+
const [columnResizesDecorations, lastCellElementsDecorations] = emptyDecorations;
|
|
20
30
|
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
21
31
|
decorationSet,
|
|
22
32
|
tr
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration } from './column-controls';
|
|
2
|
-
export { buildColumnResizingDecorations } from './column-resizing';
|
|
2
|
+
export { buildColumnResizingDecorations, clearColumnResizingDecorations } from './column-resizing';
|
|
3
3
|
export { composeDecorations } from './compose-decorations';
|
|
@@ -7,7 +7,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
|
|
|
7
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
10
|
-
import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
10
|
+
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
11
11
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
12
12
|
import { createTableView } from '../nodeviews/table';
|
|
13
13
|
import TableCellNodeView from '../nodeviews/tableCell';
|
|
@@ -23,7 +23,7 @@ let isBreakoutEnabled;
|
|
|
23
23
|
let isFullWidthModeEnabled;
|
|
24
24
|
let wasFullWidthModeEnabled;
|
|
25
25
|
let isTableResizingEnabled;
|
|
26
|
-
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
|
|
26
|
+
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
|
|
27
27
|
var _window;
|
|
28
28
|
isBreakoutEnabled = breakoutEnabled;
|
|
29
29
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
@@ -36,7 +36,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
36
36
|
isFullWidthModeEnabled,
|
|
37
37
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
38
38
|
isHeaderColumnEnabled: false,
|
|
39
|
-
...defaultTableSelection
|
|
39
|
+
...defaultTableSelection,
|
|
40
|
+
getIntl
|
|
40
41
|
});
|
|
41
42
|
let elementContentRects = {};
|
|
42
43
|
const observer = (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(entries => {
|
|
@@ -136,6 +137,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
136
137
|
addBoldInEmptyHeaderCells(tableCellHeader)(state, dispatch);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
140
|
+
} else if (pluginState.isResizeHandleWidgetAdded) {
|
|
141
|
+
removeResizeHandleDecorations()(state, dispatch);
|
|
139
142
|
}
|
|
140
143
|
},
|
|
141
144
|
destroy: () => {
|
|
@@ -5,6 +5,7 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
8
9
|
import { updateColumnWidths } from '../../transforms';
|
|
9
10
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
10
11
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
@@ -60,6 +61,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
60
61
|
startX: event.clientX,
|
|
61
62
|
startWidth: width
|
|
62
63
|
})(state, dispatch);
|
|
64
|
+
|
|
65
|
+
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
66
|
+
// unnecessary tooltips being displayed during drag.
|
|
67
|
+
updateResizeHandleDecorations(undefined, undefined, false)(state, dispatch);
|
|
63
68
|
function finish(event) {
|
|
64
69
|
window.removeEventListener('mouseup', finish);
|
|
65
70
|
window.removeEventListener('mousemove', move);
|
|
@@ -7,6 +7,7 @@ import { getLayoutSize } from '../utils/misc';
|
|
|
7
7
|
import { reduceSpace } from '../utils/resize-logic';
|
|
8
8
|
import { adjustColumnsWidths, getResizeState, getTotalWidth, updateColgroup } from '../utils/resize-state';
|
|
9
9
|
import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
10
|
+
import { syncStickyRowToTable } from './dom';
|
|
10
11
|
// Base function to trigger the actual scale on a table node.
|
|
11
12
|
// Will only resize/scale if a table has been previously resized.
|
|
12
13
|
export const scale = (tableRef, options, domAtPos) => {
|
|
@@ -117,6 +118,7 @@ export const previewScaleTable = (tableRef, options, domAtPos) => {
|
|
|
117
118
|
tableRef.style.width = `${width}px`;
|
|
118
119
|
}
|
|
119
120
|
if (!hasTableBeenResized(node)) {
|
|
121
|
+
syncStickyRowToTable(tableRef);
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
124
|
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
|
|
@@ -76,12 +76,39 @@ export default ((pluginState, action) => {
|
|
|
76
76
|
resizeHandleRowIndex: undefined
|
|
77
77
|
};
|
|
78
78
|
case 'ADD_RESIZE_HANDLE_DECORATIONS':
|
|
79
|
-
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex) {
|
|
79
|
+
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
|
|
80
80
|
return pluginState;
|
|
81
81
|
}
|
|
82
82
|
return {
|
|
83
83
|
...pluginState,
|
|
84
|
-
...action.data
|
|
84
|
+
...action.data,
|
|
85
|
+
isResizeHandleWidgetAdded: true
|
|
86
|
+
};
|
|
87
|
+
case 'UPDATE_RESIZE_HANDLE_DECORATIONS':
|
|
88
|
+
const {
|
|
89
|
+
resizeHandleColumnIndex,
|
|
90
|
+
resizeHandleRowIndex,
|
|
91
|
+
resizeHandleIncludeTooltip
|
|
92
|
+
} = action.data;
|
|
93
|
+
if ((resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex || !Number.isFinite(resizeHandleColumnIndex)) && (resizeHandleRowIndex === pluginState.resizeHandleRowIndex || !Number.isFinite(resizeHandleRowIndex)) && (resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip || resizeHandleIncludeTooltip === undefined)) {
|
|
94
|
+
return pluginState;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
...pluginState,
|
|
98
|
+
resizeHandleColumnIndex: resizeHandleColumnIndex !== null && resizeHandleColumnIndex !== void 0 ? resizeHandleColumnIndex : pluginState.resizeHandleColumnIndex,
|
|
99
|
+
resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
|
|
100
|
+
resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
|
|
101
|
+
};
|
|
102
|
+
case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
|
|
103
|
+
if (!pluginState.isResizeHandleWidgetAdded) {
|
|
104
|
+
return pluginState;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
...pluginState,
|
|
108
|
+
...action.data,
|
|
109
|
+
resizeHandleColumnIndex: undefined,
|
|
110
|
+
resizeHandleRowIndex: undefined,
|
|
111
|
+
isResizeHandleWidgetAdded: false
|
|
85
112
|
};
|
|
86
113
|
case 'SET_TABLE_REF':
|
|
87
114
|
case 'HOVER_ROWS':
|
|
@@ -36,6 +36,7 @@ export let TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
|
36
36
|
TableDecorations["COLUMN_CONTROLS_DECORATIONS"] = "COLUMN_CONTROLS_DECORATIONS";
|
|
37
37
|
TableDecorations["COLUMN_SELECTED"] = "COLUMN_SELECTED";
|
|
38
38
|
TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
|
|
39
|
+
TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
|
|
39
40
|
TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
|
|
40
41
|
TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
|
|
41
42
|
return TableDecorations;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { useIntl } from 'react-intl-next';
|
|
6
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
7
|
+
import { TableCssClassName } from '../../types';
|
|
8
|
+
import messages from '../messages';
|
|
9
|
+
export const ColumnResizeWidget = ({
|
|
10
|
+
startIndex,
|
|
11
|
+
endIndex,
|
|
12
|
+
includeTooltip
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
formatMessage
|
|
16
|
+
} = useIntl();
|
|
17
|
+
if (!includeTooltip) {
|
|
18
|
+
return jsx("div", {
|
|
19
|
+
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
20
|
+
"data-start-index": startIndex,
|
|
21
|
+
"data-end-index": endIndex
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return jsx(Tooltip, {
|
|
25
|
+
content: formatMessage(messages.adjustColumns),
|
|
26
|
+
hideTooltipOnClick: true,
|
|
27
|
+
hideTooltipOnMouseDown: true,
|
|
28
|
+
position: "mouse",
|
|
29
|
+
mousePosition: "auto-start"
|
|
30
|
+
}, tooltipProps => jsx("div", _extends({
|
|
31
|
+
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
32
|
+
"data-start-index": startIndex,
|
|
33
|
+
"data-end-index": endIndex
|
|
34
|
+
}, tooltipProps)));
|
|
35
|
+
};
|
|
@@ -54,5 +54,10 @@ export default defineMessages({
|
|
|
54
54
|
id: 'fabric.editor.extension.sourceNoTitledName',
|
|
55
55
|
defaultMessage: 'this element',
|
|
56
56
|
description: 'The current element without preset name been selected'
|
|
57
|
+
},
|
|
58
|
+
adjustColumns: {
|
|
59
|
+
id: 'fabric.editor.tables.adjustColumn',
|
|
60
|
+
defaultMessage: 'Adjust column',
|
|
61
|
+
description: 'Tooltip displayed on table column resize handle'
|
|
57
62
|
}
|
|
58
63
|
});
|