@atlaskit/editor-plugin-table 2.10.8 → 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 +11 -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 +3 -2
- 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 +3 -2
- 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 +3 -2
- 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 +2 -2
- package/src/__tests__/unit/event-handlers.ts +1 -1
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +17 -8
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
- package/src/plugins/table/commands/misc.ts +84 -7
- package/src/plugins/table/event-handlers.ts +11 -16
- package/src/plugins/table/index.tsx +2 -0
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b08849ad727`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b08849ad727) - [ux] Added tooltip to table column resize handles, also added a tooltip to the custom table width table resizer handle
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`8b78535f8bd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8b78535f8bd) - Fix sticky header not resize with table
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 2.10.8
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.moveCursorBackward = exports.hideInsertColumnOrRowButton = exports.deleteTableIfSelected = exports.deleteTable = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
7
|
+
exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.hideInsertColumnOrRowButton = exports.deleteTableIfSelected = exports.deleteTable = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -357,23 +357,25 @@ var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton() {
|
|
|
357
357
|
});
|
|
358
358
|
};
|
|
359
359
|
exports.hideInsertColumnOrRowButton = hideInsertColumnOrRowButton;
|
|
360
|
-
var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex) {
|
|
360
|
+
var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
361
361
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
362
362
|
var tableNode = (0, _utils2.findTable)(state.selection);
|
|
363
363
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
364
|
-
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing
|
|
364
|
+
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
|
|
365
|
+
getIntl = _getPluginState.getIntl;
|
|
365
366
|
if (!tableNode || !allowColumnResizing) {
|
|
366
367
|
return false;
|
|
367
368
|
}
|
|
368
369
|
return {
|
|
369
370
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
370
371
|
data: {
|
|
371
|
-
decorationSet: (0, _utils3.buildColumnResizingDecorations)(rowIndex, columnIndex)({
|
|
372
|
+
decorationSet: (0, _utils3.buildColumnResizingDecorations)(rowIndex, columnIndex, includeTooltip, getIntl)({
|
|
372
373
|
tr: state.tr,
|
|
373
374
|
decorationSet: (0, _plugin.getDecorations)(state)
|
|
374
375
|
}),
|
|
375
376
|
resizeHandleRowIndex: rowIndex,
|
|
376
|
-
resizeHandleColumnIndex: columnIndex
|
|
377
|
+
resizeHandleColumnIndex: columnIndex,
|
|
378
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
377
379
|
}
|
|
378
380
|
};
|
|
379
381
|
}, function (tr) {
|
|
@@ -381,6 +383,57 @@ var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, c
|
|
|
381
383
|
});
|
|
382
384
|
};
|
|
383
385
|
exports.addResizeHandleDecorations = addResizeHandleDecorations;
|
|
386
|
+
var updateResizeHandleDecorations = function updateResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
387
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
388
|
+
var tableNode = (0, _utils2.findTable)(state.selection);
|
|
389
|
+
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
390
|
+
resizeHandleRowIndex = _getPluginState2.resizeHandleRowIndex,
|
|
391
|
+
resizeHandleColumnIndex = _getPluginState2.resizeHandleColumnIndex,
|
|
392
|
+
resizeHandleIncludeTooltip = _getPluginState2.resizeHandleIncludeTooltip,
|
|
393
|
+
allowColumnResizing = _getPluginState2.pluginConfig.allowColumnResizing,
|
|
394
|
+
getIntl = _getPluginState2.getIntl;
|
|
395
|
+
if (!tableNode || !allowColumnResizing) {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
var resolvedRowIndex = rowIndex !== null && rowIndex !== void 0 ? rowIndex : resizeHandleRowIndex;
|
|
399
|
+
var resolvedColumnIndex = columnIndex !== null && columnIndex !== void 0 ? columnIndex : resizeHandleColumnIndex;
|
|
400
|
+
var resolvedIncludeTooltip = includeTooltip !== null && includeTooltip !== void 0 ? includeTooltip : resizeHandleIncludeTooltip;
|
|
401
|
+
if (resolvedRowIndex === undefined || resolvedColumnIndex === undefined || resolvedIncludeTooltip === undefined) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
type: 'UPDATE_RESIZE_HANDLE_DECORATIONS',
|
|
406
|
+
data: {
|
|
407
|
+
decorationSet: (0, _utils3.buildColumnResizingDecorations)(resolvedRowIndex, resolvedColumnIndex, resolvedIncludeTooltip, getIntl)({
|
|
408
|
+
tr: state.tr,
|
|
409
|
+
decorationSet: (0, _plugin.getDecorations)(state)
|
|
410
|
+
}),
|
|
411
|
+
resizeHandleRowIndex: rowIndex,
|
|
412
|
+
resizeHandleColumnIndex: columnIndex,
|
|
413
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}, function (tr) {
|
|
417
|
+
return tr.setMeta('addToHistory', false);
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
exports.updateResizeHandleDecorations = updateResizeHandleDecorations;
|
|
421
|
+
var removeResizeHandleDecorations = function removeResizeHandleDecorations() {
|
|
422
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
423
|
+
return {
|
|
424
|
+
type: 'REMOVE_RESIZE_HANDLE_DECORATIONS',
|
|
425
|
+
data: {
|
|
426
|
+
decorationSet: (0, _utils3.clearColumnResizingDecorations)()({
|
|
427
|
+
tr: state.tr,
|
|
428
|
+
decorationSet: (0, _plugin.getDecorations)(state)
|
|
429
|
+
})
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}, function (tr) {
|
|
433
|
+
return tr.setMeta('addToHistory', false);
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
exports.removeResizeHandleDecorations = removeResizeHandleDecorations;
|
|
384
437
|
var autoSizeTable = function autoSizeTable(view, node, table, basePos, opts) {
|
|
385
438
|
if (typeof basePos !== 'number') {
|
|
386
439
|
return false;
|
|
@@ -241,7 +241,7 @@ var handleMouseMove = function handleMouseMove(view, event, elementContentRects)
|
|
|
241
241
|
target: element,
|
|
242
242
|
columnEndIndexTarget: columnEndIndexTarget
|
|
243
243
|
})) {
|
|
244
|
-
return (0, _commands.addResizeHandleDecorations)(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
|
|
244
|
+
return (0, _commands.addResizeHandleDecorations)(rowIndexTarget, columnEndIndexTarget, true)(_state4, _dispatch5);
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -321,11 +321,8 @@ var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI
|
|
|
321
321
|
exports.handleCut = handleCut;
|
|
322
322
|
var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
|
|
323
323
|
return function (view, mouseEvent) {
|
|
324
|
-
var
|
|
325
|
-
|
|
326
|
-
var isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
|
|
327
|
-
var hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
328
|
-
if (!hasTableNode || isDragging) {
|
|
324
|
+
var _getPluginState7, _getResizePluginState;
|
|
325
|
+
if (!((_getPluginState7 = (0, _pluginFactory.getPluginState)(view.state)) !== null && _getPluginState7 !== void 0 && _getPluginState7.tableNode) || !!((_getResizePluginState = (0, _pluginFactory2.getPluginState)(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging)) {
|
|
329
326
|
return false;
|
|
330
327
|
}
|
|
331
328
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
@@ -97,7 +97,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
97
97
|
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
98
98
|
dispatch = _ref2.dispatch,
|
|
99
99
|
portalProviderAPI = _ref2.portalProviderAPI,
|
|
100
|
-
eventDispatcher = _ref2.eventDispatcher
|
|
100
|
+
eventDispatcher = _ref2.eventDispatcher,
|
|
101
|
+
getIntl = _ref2.getIntl;
|
|
101
102
|
var _ref3 = options || {},
|
|
102
103
|
fullWidthEnabled = _ref3.fullWidthEnabled,
|
|
103
104
|
wasFullWidthEnabled = _ref3.wasFullWidthEnabled,
|
|
@@ -105,7 +106,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
105
106
|
breakoutEnabled = _ref3.breakoutEnabled,
|
|
106
107
|
tableOptions = _ref3.tableOptions,
|
|
107
108
|
getEditorFeatureFlags = _ref3.getEditorFeatureFlags;
|
|
108
|
-
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
109
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
109
110
|
}
|
|
110
111
|
}, {
|
|
111
112
|
name: 'tablePMColResizing',
|
|
@@ -10,9 +10,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
13
|
+
var _reactIntlNext = require("react-intl-next");
|
|
13
14
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
14
15
|
var _resizer = require("@atlaskit/editor-common/resizer");
|
|
15
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
16
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
17
17
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
18
18
|
var _utils2 = require("../pm-plugins/table-resizing/utils");
|
|
@@ -25,6 +25,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
28
|
+
var messages = (0, _reactIntlNext.defineMessages)({
|
|
29
|
+
resizeTable: {
|
|
30
|
+
id: 'fabric.editor.tables.resizeTable',
|
|
31
|
+
defaultMessage: 'Resize table',
|
|
32
|
+
description: 'Tooltip displayed on custom table width resize hande'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
28
35
|
var handles = {
|
|
29
36
|
right: true
|
|
30
37
|
};
|
|
@@ -89,6 +96,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
89
96
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
90
97
|
snappingEnabled = _useState2[0],
|
|
91
98
|
setSnappingEnabled = _useState2[1];
|
|
99
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
100
|
+
formatMessage = _useIntl.formatMessage;
|
|
92
101
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
93
102
|
var handleHeightSize = getResizerHandleHeight(tableRef);
|
|
94
103
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
@@ -187,22 +196,6 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
187
196
|
scheduleResize.cancel();
|
|
188
197
|
return newWidth;
|
|
189
198
|
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
190
|
-
var handleComponent = (0, _react.useMemo)(function () {
|
|
191
|
-
return {
|
|
192
|
-
left: /*#__PURE__*/_react.default.createElement("div", {
|
|
193
|
-
className: _styles.resizerHandleShadowClassName,
|
|
194
|
-
style: {
|
|
195
|
-
height: 'calc(100% - 24px)'
|
|
196
|
-
}
|
|
197
|
-
}),
|
|
198
|
-
right: /*#__PURE__*/_react.default.createElement("div", {
|
|
199
|
-
className: _styles.resizerHandleShadowClassName,
|
|
200
|
-
style: {
|
|
201
|
-
height: 'calc(100% - 24px)'
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
};
|
|
205
|
-
}, []);
|
|
206
199
|
return /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
|
|
207
200
|
enable: handles,
|
|
208
201
|
width: width,
|
|
@@ -220,8 +213,9 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
220
213
|
handlePositioning: "adjacent",
|
|
221
214
|
innerPadding: tableHandlePosition,
|
|
222
215
|
isHandleVisible: ((_findTable = (0, _utils.findTable)((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos(),
|
|
223
|
-
|
|
224
|
-
|
|
216
|
+
appearance: isInDanger ? 'danger' : undefined,
|
|
217
|
+
handleHighlight: "shadow",
|
|
218
|
+
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
225
219
|
}, children);
|
|
226
220
|
};
|
|
227
221
|
exports.TableResizer = TableResizer;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.buildColumnResizingDecorations = void 0;
|
|
7
|
+
exports.clearColumnResizingDecorations = exports.buildColumnResizingDecorations = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _types = require("../../../types");
|
|
10
10
|
var _decoration = require("../../../utils/decoration");
|
|
@@ -14,7 +14,7 @@ var updateColumnResizeHandle = function updateColumnResizeHandle(columnResizesDe
|
|
|
14
14
|
return function (_ref) {
|
|
15
15
|
var decorationSet = _ref.decorationSet,
|
|
16
16
|
tr = _ref.tr;
|
|
17
|
-
return (0, _decoration.updateDecorations)(tr.doc, decorationSet, columnResizesDecorations, _types.TableDecorations.
|
|
17
|
+
return (0, _decoration.updateDecorations)(tr.doc, decorationSet, columnResizesDecorations, _types.TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET);
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
var updateLastCellElement = function updateLastCellElement(lastCellElementsDecorations) {
|
|
@@ -24,13 +24,13 @@ var updateLastCellElement = function updateLastCellElement(lastCellElementsDecor
|
|
|
24
24
|
return (0, _decoration.updateDecorations)(tr.doc, decorationSet, lastCellElementsDecorations, _types.TableDecorations.LAST_CELL_ELEMENT);
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex) {
|
|
27
|
+
var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex, includeTooltip, getIntl) {
|
|
28
28
|
return function (_ref3) {
|
|
29
29
|
var tr = _ref3.tr,
|
|
30
30
|
decorationSet = _ref3.decorationSet;
|
|
31
31
|
var _ref4 = columnEndIndex < 0 ? emptyDecorations : (0, _decoration.createResizeHandleDecoration)(tr, rowEndIndex, {
|
|
32
32
|
right: columnEndIndex
|
|
33
|
-
}),
|
|
33
|
+
}, includeTooltip, getIntl),
|
|
34
34
|
_ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
35
35
|
columnResizesDecorations = _ref5[0],
|
|
36
36
|
lastCellElementsDecorations = _ref5[1];
|
|
@@ -40,4 +40,17 @@ var buildColumnResizingDecorations = function buildColumnResizingDecorations(row
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
exports.buildColumnResizingDecorations = buildColumnResizingDecorations;
|
|
43
|
+
exports.buildColumnResizingDecorations = buildColumnResizingDecorations;
|
|
44
|
+
var clearColumnResizingDecorations = function clearColumnResizingDecorations() {
|
|
45
|
+
return function (_ref6) {
|
|
46
|
+
var tr = _ref6.tr,
|
|
47
|
+
decorationSet = _ref6.decorationSet;
|
|
48
|
+
var columnResizesDecorations = emptyDecorations[0],
|
|
49
|
+
lastCellElementsDecorations = emptyDecorations[1];
|
|
50
|
+
return (0, _composeDecorations.composeDecorations)([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
51
|
+
decorationSet: decorationSet,
|
|
52
|
+
tr: tr
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.clearColumnResizingDecorations = clearColumnResizingDecorations;
|
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "buildColumnResizingDecorations", {
|
|
|
15
15
|
return _columnResizing.buildColumnResizingDecorations;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "clearColumnResizingDecorations", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _columnResizing.clearColumnResizingDecorations;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "composeDecorations", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
@@ -33,20 +33,22 @@ var isBreakoutEnabled;
|
|
|
33
33
|
var isFullWidthModeEnabled;
|
|
34
34
|
var wasFullWidthModeEnabled;
|
|
35
35
|
var isTableResizingEnabled;
|
|
36
|
-
var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
36
|
+
var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
37
37
|
var _window;
|
|
38
38
|
isBreakoutEnabled = breakoutEnabled;
|
|
39
39
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
40
40
|
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
41
41
|
isTableResizingEnabled = tableResizingEnabled;
|
|
42
|
-
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread({
|
|
42
|
+
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread({
|
|
43
43
|
pluginConfig: pluginConfig,
|
|
44
44
|
insertColumnButtonIndex: undefined,
|
|
45
45
|
insertRowButtonIndex: undefined,
|
|
46
46
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
47
47
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
48
48
|
isHeaderColumnEnabled: false
|
|
49
|
-
}, _defaultTableSelection.defaultTableSelection)
|
|
49
|
+
}, _defaultTableSelection.defaultTableSelection), {}, {
|
|
50
|
+
getIntl: getIntl
|
|
51
|
+
}));
|
|
50
52
|
var elementContentRects = {};
|
|
51
53
|
var observer = (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(function (entries) {
|
|
52
54
|
entries.forEach(function (entry) {
|
|
@@ -150,6 +152,8 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
|
|
|
150
152
|
(0, _commands.addBoldInEmptyHeaderCells)(tableCellHeader)(state, dispatch);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
155
|
+
} else if (pluginState.isResizeHandleWidgetAdded) {
|
|
156
|
+
(0, _misc.removeResizeHandleDecorations)()(state, dispatch);
|
|
153
157
|
}
|
|
154
158
|
},
|
|
155
159
|
destroy: function destroy() {
|
|
@@ -11,6 +11,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
11
11
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
12
12
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
13
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
+
var _misc = require("../../commands/misc");
|
|
14
15
|
var _transforms = require("../../transforms");
|
|
15
16
|
var _utils2 = require("../../utils");
|
|
16
17
|
var _commands = require("./commands");
|
|
@@ -64,6 +65,10 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
|
|
|
64
65
|
startX: event.clientX,
|
|
65
66
|
startWidth: width
|
|
66
67
|
})(state, dispatch);
|
|
68
|
+
|
|
69
|
+
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
70
|
+
// unnecessary tooltips being displayed during drag.
|
|
71
|
+
(0, _misc.updateResizeHandleDecorations)(undefined, undefined, false)(state, dispatch);
|
|
67
72
|
function finish(event) {
|
|
68
73
|
window.removeEventListener('mouseup', finish);
|
|
69
74
|
window.removeEventListener('mousemove', move);
|
|
@@ -17,6 +17,7 @@ var _misc = require("../utils/misc");
|
|
|
17
17
|
var _resizeLogic = require("../utils/resize-logic");
|
|
18
18
|
var _resizeState = require("../utils/resize-state");
|
|
19
19
|
var _colgroup = require("./colgroup");
|
|
20
|
+
var _dom = require("./dom");
|
|
20
21
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
23
|
// Base function to trigger the actual scale on a table node.
|
|
@@ -123,6 +124,7 @@ var previewScaleTable = function previewScaleTable(tableRef, options, domAtPos)
|
|
|
123
124
|
tableRef.style.width = "".concat(width, "px");
|
|
124
125
|
}
|
|
125
126
|
if (!(0, _colgroup.hasTableBeenResized)(node)) {
|
|
127
|
+
(0, _dom.syncStickyRowToTable)(tableRef);
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
128
130
|
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
|
|
@@ -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);
|