@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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { RawIntlProvider } from 'react-intl-next';
|
|
1
4
|
import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
2
5
|
|
|
3
6
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
@@ -6,6 +9,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
9
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
10
|
import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
11
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
12
|
+
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
9
13
|
const filterDecorationByKey = (key, decorationSet) => decorationSet.find(undefined, undefined, spec => spec.key.indexOf(key) > -1);
|
|
10
14
|
export const findColumnControlSelectedDecoration = decorationSet => filterDecorationByKey(TableDecorations.COLUMN_SELECTED, decorationSet);
|
|
11
15
|
export const findControlsHoverDecoration = decorationSet => filterDecorationByKey(TableDecorations.ALL_CONTROLS_HOVER, decorationSet);
|
|
@@ -235,7 +239,7 @@ const makeArray = n => Array.from(Array(n).keys());
|
|
|
235
239
|
* we will add a new class on the last item for each cell,
|
|
236
240
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
237
241
|
*/
|
|
238
|
-
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget) => {
|
|
242
|
+
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget, includeTooltip = false, getIntl) => {
|
|
239
243
|
const emptyResult = [[], []];
|
|
240
244
|
const table = findTable(tr.selection);
|
|
241
245
|
if (!table || !table.node) {
|
|
@@ -249,12 +253,19 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
|
|
|
249
253
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
250
254
|
return Decoration.widget(position, () => {
|
|
251
255
|
const element = document.createElement('div');
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
257
|
+
value: getIntl()
|
|
258
|
+
}, /*#__PURE__*/createElement(ColumnResizeWidget, {
|
|
259
|
+
startIndex: cellColumnPositioning.left,
|
|
260
|
+
endIndex: cellColumnPositioning.right,
|
|
261
|
+
includeTooltip
|
|
262
|
+
})), element);
|
|
255
263
|
return element;
|
|
256
264
|
}, {
|
|
257
|
-
key: `${TableDecorations.
|
|
265
|
+
key: `${TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET}_${rowIndex}_${columnIndex}_${includeTooltip ? 'with' : 'no'}-tooltip`,
|
|
266
|
+
destroy: node => {
|
|
267
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
268
|
+
}
|
|
258
269
|
});
|
|
259
270
|
};
|
|
260
271
|
const createLastCellElementDecoration = (cellColumnPositioning, cellPos, cellNode) => {
|
|
@@ -9,7 +9,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
9
9
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
10
|
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumn as selectColumnTransform, selectionCell, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
12
|
-
import { buildColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
12
|
+
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
13
13
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
14
14
|
import { fixAutoSizedTable } from '../transforms';
|
|
15
15
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
@@ -335,23 +335,74 @@ export var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton()
|
|
|
335
335
|
return tr.setMeta('addToHistory', false);
|
|
336
336
|
});
|
|
337
337
|
};
|
|
338
|
-
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex) {
|
|
338
|
+
export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
339
339
|
return createCommand(function (state) {
|
|
340
340
|
var tableNode = findTable(state.selection);
|
|
341
341
|
var _getPluginState = getPluginState(state),
|
|
342
|
-
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing
|
|
342
|
+
allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
|
|
343
|
+
getIntl = _getPluginState.getIntl;
|
|
343
344
|
if (!tableNode || !allowColumnResizing) {
|
|
344
345
|
return false;
|
|
345
346
|
}
|
|
346
347
|
return {
|
|
347
348
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
348
349
|
data: {
|
|
349
|
-
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex)({
|
|
350
|
+
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex, includeTooltip, getIntl)({
|
|
350
351
|
tr: state.tr,
|
|
351
352
|
decorationSet: getDecorations(state)
|
|
352
353
|
}),
|
|
353
354
|
resizeHandleRowIndex: rowIndex,
|
|
354
|
-
resizeHandleColumnIndex: columnIndex
|
|
355
|
+
resizeHandleColumnIndex: columnIndex,
|
|
356
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}, function (tr) {
|
|
360
|
+
return tr.setMeta('addToHistory', false);
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
export var updateResizeHandleDecorations = function updateResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
|
|
364
|
+
return createCommand(function (state) {
|
|
365
|
+
var tableNode = findTable(state.selection);
|
|
366
|
+
var _getPluginState2 = getPluginState(state),
|
|
367
|
+
resizeHandleRowIndex = _getPluginState2.resizeHandleRowIndex,
|
|
368
|
+
resizeHandleColumnIndex = _getPluginState2.resizeHandleColumnIndex,
|
|
369
|
+
resizeHandleIncludeTooltip = _getPluginState2.resizeHandleIncludeTooltip,
|
|
370
|
+
allowColumnResizing = _getPluginState2.pluginConfig.allowColumnResizing,
|
|
371
|
+
getIntl = _getPluginState2.getIntl;
|
|
372
|
+
if (!tableNode || !allowColumnResizing) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
var resolvedRowIndex = rowIndex !== null && rowIndex !== void 0 ? rowIndex : resizeHandleRowIndex;
|
|
376
|
+
var resolvedColumnIndex = columnIndex !== null && columnIndex !== void 0 ? columnIndex : resizeHandleColumnIndex;
|
|
377
|
+
var resolvedIncludeTooltip = includeTooltip !== null && includeTooltip !== void 0 ? includeTooltip : resizeHandleIncludeTooltip;
|
|
378
|
+
if (resolvedRowIndex === undefined || resolvedColumnIndex === undefined || resolvedIncludeTooltip === undefined) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
type: 'UPDATE_RESIZE_HANDLE_DECORATIONS',
|
|
383
|
+
data: {
|
|
384
|
+
decorationSet: buildColumnResizingDecorations(resolvedRowIndex, resolvedColumnIndex, resolvedIncludeTooltip, getIntl)({
|
|
385
|
+
tr: state.tr,
|
|
386
|
+
decorationSet: getDecorations(state)
|
|
387
|
+
}),
|
|
388
|
+
resizeHandleRowIndex: rowIndex,
|
|
389
|
+
resizeHandleColumnIndex: columnIndex,
|
|
390
|
+
resizeHandleIncludeTooltip: includeTooltip
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}, function (tr) {
|
|
394
|
+
return tr.setMeta('addToHistory', false);
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
export var removeResizeHandleDecorations = function removeResizeHandleDecorations() {
|
|
398
|
+
return createCommand(function (state) {
|
|
399
|
+
return {
|
|
400
|
+
type: 'REMOVE_RESIZE_HANDLE_DECORATIONS',
|
|
401
|
+
data: {
|
|
402
|
+
decorationSet: clearColumnResizingDecorations()({
|
|
403
|
+
tr: state.tr,
|
|
404
|
+
decorationSet: getDecorations(state)
|
|
405
|
+
})
|
|
355
406
|
}
|
|
356
407
|
};
|
|
357
408
|
}, function (tr) {
|
|
@@ -225,7 +225,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
225
225
|
target: element,
|
|
226
226
|
columnEndIndexTarget: columnEndIndexTarget
|
|
227
227
|
})) {
|
|
228
|
-
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
|
|
228
|
+
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true)(_state4, _dispatch5);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
}
|
|
@@ -303,11 +303,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
|
|
|
303
303
|
};
|
|
304
304
|
export var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
|
|
305
305
|
return function (view, mouseEvent) {
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
var isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
|
|
309
|
-
var hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
310
|
-
if (!hasTableNode || isDragging) {
|
|
306
|
+
var _getPluginState7, _getResizePluginState;
|
|
307
|
+
if (!((_getPluginState7 = getPluginState(view.state)) !== null && _getPluginState7 !== void 0 && _getPluginState7.tableNode) || !!((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging)) {
|
|
311
308
|
return false;
|
|
312
309
|
}
|
|
313
310
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
@@ -31,29 +31,31 @@ import { isLayoutSupported } from './utils';
|
|
|
31
31
|
var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
32
32
|
return {};
|
|
33
33
|
};
|
|
34
|
-
var tablesPlugin = function tablesPlugin(
|
|
35
|
-
var _api$
|
|
34
|
+
var tablesPlugin = function tablesPlugin(_ref) {
|
|
35
|
+
var _api$analytics;
|
|
36
|
+
var options = _ref.config,
|
|
37
|
+
api = _ref.api;
|
|
36
38
|
var editorViewRef = {
|
|
37
39
|
current: null
|
|
38
40
|
};
|
|
39
41
|
var defaultGetEditorContainerWidth = function defaultGetEditorContainerWidth() {
|
|
40
|
-
var _document$body$offset, _document, _document$body, _api$
|
|
42
|
+
var _document$body$offset, _document, _document$body, _api$width$sharedStat;
|
|
41
43
|
var defaultState = {
|
|
42
44
|
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
|
|
43
45
|
};
|
|
44
|
-
return (_api$
|
|
46
|
+
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;
|
|
45
47
|
};
|
|
46
|
-
var editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$
|
|
48
|
+
var editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
47
49
|
return {
|
|
48
50
|
name: 'table',
|
|
49
51
|
actions: {
|
|
50
52
|
insertTable: function insertTable(analyticsPayload) {
|
|
51
53
|
return function (state, dispatch) {
|
|
52
|
-
var _api$
|
|
54
|
+
var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
|
|
53
55
|
var node = createTable({
|
|
54
56
|
schema: state.schema
|
|
55
57
|
});
|
|
56
|
-
return (_api$
|
|
58
|
+
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({
|
|
57
59
|
state: state,
|
|
58
60
|
dispatch: dispatch,
|
|
59
61
|
node: node,
|
|
@@ -61,7 +63,7 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
61
63
|
selectNodeInserted: false,
|
|
62
64
|
analyticsPayload: analyticsPayload
|
|
63
65
|
}
|
|
64
|
-
})) !== null && _api$
|
|
66
|
+
})) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
},
|
|
@@ -84,28 +86,29 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
84
86
|
pmPlugins: function pmPlugins() {
|
|
85
87
|
var plugins = [{
|
|
86
88
|
name: 'table',
|
|
87
|
-
plugin: function plugin(
|
|
88
|
-
var dispatchAnalyticsEvent =
|
|
89
|
-
dispatch =
|
|
90
|
-
portalProviderAPI =
|
|
91
|
-
eventDispatcher =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
plugin: function plugin(_ref2) {
|
|
90
|
+
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
91
|
+
dispatch = _ref2.dispatch,
|
|
92
|
+
portalProviderAPI = _ref2.portalProviderAPI,
|
|
93
|
+
eventDispatcher = _ref2.eventDispatcher,
|
|
94
|
+
getIntl = _ref2.getIntl;
|
|
95
|
+
var _ref3 = options || {},
|
|
96
|
+
fullWidthEnabled = _ref3.fullWidthEnabled,
|
|
97
|
+
wasFullWidthEnabled = _ref3.wasFullWidthEnabled,
|
|
98
|
+
tableResizingEnabled = _ref3.tableResizingEnabled,
|
|
99
|
+
breakoutEnabled = _ref3.breakoutEnabled,
|
|
100
|
+
tableOptions = _ref3.tableOptions,
|
|
101
|
+
getEditorFeatureFlags = _ref3.getEditorFeatureFlags;
|
|
102
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
100
103
|
}
|
|
101
104
|
}, {
|
|
102
105
|
name: 'tablePMColResizing',
|
|
103
|
-
plugin: function plugin(
|
|
104
|
-
var dispatch =
|
|
105
|
-
var
|
|
106
|
-
fullWidthEnabled =
|
|
107
|
-
tableOptions =
|
|
108
|
-
getEditorFeatureFlags =
|
|
106
|
+
plugin: function plugin(_ref4) {
|
|
107
|
+
var dispatch = _ref4.dispatch;
|
|
108
|
+
var _ref5 = options || {},
|
|
109
|
+
fullWidthEnabled = _ref5.fullWidthEnabled,
|
|
110
|
+
tableOptions = _ref5.tableOptions,
|
|
111
|
+
getEditorFeatureFlags = _ref5.getEditorFeatureFlags;
|
|
109
112
|
var _pluginConfig = pluginConfig(tableOptions),
|
|
110
113
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
111
114
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
@@ -134,9 +137,9 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
134
137
|
name: 'tableEditing',
|
|
135
138
|
plugin: function plugin() {
|
|
136
139
|
return tableEditing({
|
|
137
|
-
reportFixedTable: function reportFixedTable(
|
|
138
|
-
var tr =
|
|
139
|
-
reason =
|
|
140
|
+
reportFixedTable: function reportFixedTable(_ref6) {
|
|
141
|
+
var tr = _ref6.tr,
|
|
142
|
+
reason = _ref6.reason;
|
|
140
143
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
141
144
|
action: TABLE_ACTION.FIXED,
|
|
142
145
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -151,24 +154,24 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
151
154
|
}
|
|
152
155
|
}, {
|
|
153
156
|
name: 'tableStickyHeaders',
|
|
154
|
-
plugin: function plugin(
|
|
155
|
-
var dispatch =
|
|
156
|
-
eventDispatcher =
|
|
157
|
+
plugin: function plugin(_ref7) {
|
|
158
|
+
var dispatch = _ref7.dispatch,
|
|
159
|
+
eventDispatcher = _ref7.eventDispatcher;
|
|
157
160
|
return options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, function () {
|
|
158
161
|
return [];
|
|
159
162
|
}, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
|
|
160
163
|
}
|
|
161
164
|
}, {
|
|
162
165
|
name: 'tableLocalId',
|
|
163
|
-
plugin: function plugin(
|
|
164
|
-
var dispatch =
|
|
166
|
+
plugin: function plugin(_ref8) {
|
|
167
|
+
var dispatch = _ref8.dispatch;
|
|
165
168
|
return createTableLocalIdPlugin(dispatch);
|
|
166
169
|
}
|
|
167
170
|
}, {
|
|
168
171
|
name: 'tableWidth',
|
|
169
|
-
plugin: function plugin(
|
|
172
|
+
plugin: function plugin(_ref9) {
|
|
170
173
|
var _options$fullWidthEna;
|
|
171
|
-
var dispatch =
|
|
174
|
+
var dispatch = _ref9.dispatch;
|
|
172
175
|
return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false) : undefined;
|
|
173
176
|
}
|
|
174
177
|
}, {
|
|
@@ -199,12 +202,12 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
199
202
|
}
|
|
200
203
|
return plugins;
|
|
201
204
|
},
|
|
202
|
-
contentComponent: function contentComponent(
|
|
203
|
-
var editorView =
|
|
204
|
-
popupsMountPoint =
|
|
205
|
-
popupsBoundariesElement =
|
|
206
|
-
popupsScrollableElement =
|
|
207
|
-
dispatchAnalyticsEvent =
|
|
205
|
+
contentComponent: function contentComponent(_ref10) {
|
|
206
|
+
var editorView = _ref10.editorView,
|
|
207
|
+
popupsMountPoint = _ref10.popupsMountPoint,
|
|
208
|
+
popupsBoundariesElement = _ref10.popupsBoundariesElement,
|
|
209
|
+
popupsScrollableElement = _ref10.popupsScrollableElement,
|
|
210
|
+
dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
|
|
208
211
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
209
212
|
component: ACTION_SUBJECT.TABLES_PLUGIN,
|
|
210
213
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -216,28 +219,28 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
216
219
|
tableResizingPluginState: tableResizingPluginKey,
|
|
217
220
|
stickyHeadersState: stickyHeadersPluginKey
|
|
218
221
|
},
|
|
219
|
-
render: function render(
|
|
220
|
-
var resizingPluginState =
|
|
221
|
-
stickyHeadersState =
|
|
222
|
-
tablePluginState =
|
|
223
|
-
tableWidthPluginState =
|
|
222
|
+
render: function render(_ref11) {
|
|
223
|
+
var resizingPluginState = _ref11.tableResizingPluginState,
|
|
224
|
+
stickyHeadersState = _ref11.stickyHeadersState,
|
|
225
|
+
tablePluginState = _ref11.tablePluginState,
|
|
226
|
+
tableWidthPluginState = _ref11.tableWidthPluginState;
|
|
224
227
|
var state = editorView.state;
|
|
225
228
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
226
229
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
227
230
|
var isResizing = isColumnResizing || isTableResizing;
|
|
228
|
-
var
|
|
229
|
-
tableNode =
|
|
230
|
-
tablePos =
|
|
231
|
-
targetCellPosition =
|
|
232
|
-
isContextualMenuOpen =
|
|
233
|
-
layout =
|
|
234
|
-
tableRef =
|
|
235
|
-
pluginConfig =
|
|
236
|
-
insertColumnButtonIndex =
|
|
237
|
-
insertRowButtonIndex =
|
|
238
|
-
isHeaderColumnEnabled =
|
|
239
|
-
isHeaderRowEnabled =
|
|
240
|
-
tableWrapperTarget =
|
|
231
|
+
var _ref12 = tablePluginState,
|
|
232
|
+
tableNode = _ref12.tableNode,
|
|
233
|
+
tablePos = _ref12.tablePos,
|
|
234
|
+
targetCellPosition = _ref12.targetCellPosition,
|
|
235
|
+
isContextualMenuOpen = _ref12.isContextualMenuOpen,
|
|
236
|
+
layout = _ref12.layout,
|
|
237
|
+
tableRef = _ref12.tableRef,
|
|
238
|
+
pluginConfig = _ref12.pluginConfig,
|
|
239
|
+
insertColumnButtonIndex = _ref12.insertColumnButtonIndex,
|
|
240
|
+
insertRowButtonIndex = _ref12.insertRowButtonIndex,
|
|
241
|
+
isHeaderColumnEnabled = _ref12.isHeaderColumnEnabled,
|
|
242
|
+
isHeaderRowEnabled = _ref12.isHeaderRowEnabled,
|
|
243
|
+
tableWrapperTarget = _ref12.tableWrapperTarget;
|
|
241
244
|
var allowControls = pluginConfig.allowControls;
|
|
242
245
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
243
246
|
var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
|
|
@@ -303,8 +306,8 @@ var tablesPlugin = function tablesPlugin(options, api) {
|
|
|
303
306
|
}));
|
|
304
307
|
},
|
|
305
308
|
pluginsOptions: {
|
|
306
|
-
quickInsert: function quickInsert(
|
|
307
|
-
var formatMessage =
|
|
309
|
+
quickInsert: function quickInsert(_ref13) {
|
|
310
|
+
var formatMessage = _ref13.formatMessage;
|
|
308
311
|
return [{
|
|
309
312
|
id: 'table',
|
|
310
313
|
title: formatMessage(messages.table),
|
|
@@ -65,14 +65,14 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref2) {
|
|
|
65
65
|
}
|
|
66
66
|
}, [lineLength]);
|
|
67
67
|
var displayGuideline = useCallback(function (guidelines) {
|
|
68
|
-
var _pluginInjectionApi$
|
|
69
|
-
return (_pluginInjectionApi$
|
|
68
|
+
var _pluginInjectionApi$g, _pluginInjectionApi$g2, _pluginInjectionApi$g3;
|
|
69
|
+
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)({
|
|
70
70
|
guidelines: guidelines
|
|
71
|
-
})) !== null && _pluginInjectionApi$
|
|
71
|
+
})) !== null && _pluginInjectionApi$g !== void 0 ? _pluginInjectionApi$g : false;
|
|
72
72
|
}, [pluginInjectionApi, editorView]);
|
|
73
73
|
var attachAnalyticsEvent = useCallback(function (payload) {
|
|
74
|
-
var _pluginInjectionApi$
|
|
75
|
-
return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
74
|
+
var _pluginInjectionApi$a;
|
|
75
|
+
return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.attachAnalyticsEvent(payload);
|
|
76
76
|
}, [pluginInjectionApi]);
|
|
77
77
|
var tableWidth = getTableContainerWidth(node);
|
|
78
78
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
@@ -4,9 +4,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
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) { _defineProperty(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; }
|
|
5
5
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import rafSchd from 'raf-schd';
|
|
7
|
+
import { defineMessages, useIntl } from 'react-intl-next';
|
|
7
8
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
8
9
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
9
|
-
import { resizerHandleShadowClassName } from '@atlaskit/editor-common/styles';
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
12
12
|
import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils';
|
|
@@ -15,6 +15,13 @@ import { TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE, TABLE_SNAP_GAP } from '
|
|
|
15
15
|
import { generateResizedPayload, generateResizeFrameRatePayloads, useMeasureFramerate } from '../utils/analytics';
|
|
16
16
|
import { defaultGuidelines } from '../utils/guidelines';
|
|
17
17
|
import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
18
|
+
var messages = defineMessages({
|
|
19
|
+
resizeTable: {
|
|
20
|
+
id: 'fabric.editor.tables.resizeTable',
|
|
21
|
+
defaultMessage: 'Resize table',
|
|
22
|
+
description: 'Tooltip displayed on custom table width resize hande'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
18
25
|
var handles = {
|
|
19
26
|
right: true
|
|
20
27
|
};
|
|
@@ -79,6 +86,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
79
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
80
87
|
snappingEnabled = _useState2[0],
|
|
81
88
|
setSnappingEnabled = _useState2[1];
|
|
89
|
+
var _useIntl = useIntl(),
|
|
90
|
+
formatMessage = _useIntl.formatMessage;
|
|
82
91
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
83
92
|
var handleHeightSize = getResizerHandleHeight(tableRef);
|
|
84
93
|
var _getPluginState = getPluginState(editorView.state),
|
|
@@ -177,22 +186,6 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
177
186
|
scheduleResize.cancel();
|
|
178
187
|
return newWidth;
|
|
179
188
|
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
180
|
-
var handleComponent = useMemo(function () {
|
|
181
|
-
return {
|
|
182
|
-
left: /*#__PURE__*/React.createElement("div", {
|
|
183
|
-
className: resizerHandleShadowClassName,
|
|
184
|
-
style: {
|
|
185
|
-
height: 'calc(100% - 24px)'
|
|
186
|
-
}
|
|
187
|
-
}),
|
|
188
|
-
right: /*#__PURE__*/React.createElement("div", {
|
|
189
|
-
className: resizerHandleShadowClassName,
|
|
190
|
-
style: {
|
|
191
|
-
height: 'calc(100% - 24px)'
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
};
|
|
195
|
-
}, []);
|
|
196
189
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
197
190
|
enable: handles,
|
|
198
191
|
width: width,
|
|
@@ -210,7 +203,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
210
203
|
handlePositioning: "adjacent",
|
|
211
204
|
innerPadding: tableHandlePosition,
|
|
212
205
|
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(),
|
|
213
|
-
|
|
214
|
-
|
|
206
|
+
appearance: isInDanger ? 'danger' : undefined,
|
|
207
|
+
handleHighlight: "shadow",
|
|
208
|
+
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
215
209
|
}, children);
|
|
216
210
|
};
|
|
@@ -7,7 +7,7 @@ var updateColumnResizeHandle = function updateColumnResizeHandle(columnResizesDe
|
|
|
7
7
|
return function (_ref) {
|
|
8
8
|
var decorationSet = _ref.decorationSet,
|
|
9
9
|
tr = _ref.tr;
|
|
10
|
-
return updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.
|
|
10
|
+
return updateDecorations(tr.doc, decorationSet, columnResizesDecorations, TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET);
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
var updateLastCellElement = function updateLastCellElement(lastCellElementsDecorations) {
|
|
@@ -17,13 +17,13 @@ var updateLastCellElement = function updateLastCellElement(lastCellElementsDecor
|
|
|
17
17
|
return updateDecorations(tr.doc, decorationSet, lastCellElementsDecorations, TableDecorations.LAST_CELL_ELEMENT);
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex) {
|
|
20
|
+
export var buildColumnResizingDecorations = function buildColumnResizingDecorations(rowEndIndex, columnEndIndex, includeTooltip, getIntl) {
|
|
21
21
|
return function (_ref3) {
|
|
22
22
|
var tr = _ref3.tr,
|
|
23
23
|
decorationSet = _ref3.decorationSet;
|
|
24
24
|
var _ref4 = columnEndIndex < 0 ? emptyDecorations : createResizeHandleDecoration(tr, rowEndIndex, {
|
|
25
25
|
right: columnEndIndex
|
|
26
|
-
}),
|
|
26
|
+
}, includeTooltip, getIntl),
|
|
27
27
|
_ref5 = _slicedToArray(_ref4, 2),
|
|
28
28
|
columnResizesDecorations = _ref5[0],
|
|
29
29
|
lastCellElementsDecorations = _ref5[1];
|
|
@@ -32,4 +32,16 @@ export var buildColumnResizingDecorations = function buildColumnResizingDecorati
|
|
|
32
32
|
tr: tr
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
+
};
|
|
36
|
+
export var clearColumnResizingDecorations = function clearColumnResizingDecorations() {
|
|
37
|
+
return function (_ref6) {
|
|
38
|
+
var tr = _ref6.tr,
|
|
39
|
+
decorationSet = _ref6.decorationSet;
|
|
40
|
+
var columnResizesDecorations = emptyDecorations[0],
|
|
41
|
+
lastCellElementsDecorations = emptyDecorations[1];
|
|
42
|
+
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
43
|
+
decorationSet: decorationSet,
|
|
44
|
+
tr: tr
|
|
45
|
+
});
|
|
46
|
+
};
|
|
35
47
|
};
|
|
@@ -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';
|
|
@@ -10,7 +10,7 @@ import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-p
|
|
|
10
10
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
13
|
-
import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
13
|
+
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
14
14
|
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
|
|
15
15
|
import { createTableView } from '../nodeviews/table';
|
|
16
16
|
import TableCellNodeView from '../nodeviews/tableCell';
|
|
@@ -26,20 +26,22 @@ var isBreakoutEnabled;
|
|
|
26
26
|
var isFullWidthModeEnabled;
|
|
27
27
|
var wasFullWidthModeEnabled;
|
|
28
28
|
var isTableResizingEnabled;
|
|
29
|
-
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
29
|
+
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
30
30
|
var _window;
|
|
31
31
|
isBreakoutEnabled = breakoutEnabled;
|
|
32
32
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
33
33
|
wasFullWidthModeEnabled = previousFullWidthModeEnabled;
|
|
34
34
|
isTableResizingEnabled = tableResizingEnabled;
|
|
35
|
-
var state = createPluginState(dispatch, _objectSpread({
|
|
35
|
+
var state = createPluginState(dispatch, _objectSpread(_objectSpread({
|
|
36
36
|
pluginConfig: pluginConfig,
|
|
37
37
|
insertColumnButtonIndex: undefined,
|
|
38
38
|
insertRowButtonIndex: undefined,
|
|
39
39
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
40
40
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
41
41
|
isHeaderColumnEnabled: false
|
|
42
|
-
}, defaultTableSelection)
|
|
42
|
+
}, defaultTableSelection), {}, {
|
|
43
|
+
getIntl: getIntl
|
|
44
|
+
}));
|
|
43
45
|
var elementContentRects = {};
|
|
44
46
|
var observer = (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(function (entries) {
|
|
45
47
|
entries.forEach(function (entry) {
|
|
@@ -143,6 +145,8 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
143
145
|
addBoldInEmptyHeaderCells(tableCellHeader)(state, dispatch);
|
|
144
146
|
}
|
|
145
147
|
}
|
|
148
|
+
} else if (pluginState.isResizeHandleWidgetAdded) {
|
|
149
|
+
removeResizeHandleDecorations()(state, dispatch);
|
|
146
150
|
}
|
|
147
151
|
},
|
|
148
152
|
destroy: function 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';
|
|
@@ -58,6 +59,10 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
58
59
|
startX: event.clientX,
|
|
59
60
|
startWidth: width
|
|
60
61
|
})(state, dispatch);
|
|
62
|
+
|
|
63
|
+
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
64
|
+
// unnecessary tooltips being displayed during drag.
|
|
65
|
+
updateResizeHandleDecorations(undefined, undefined, false)(state, dispatch);
|
|
61
66
|
function finish(event) {
|
|
62
67
|
window.removeEventListener('mouseup', finish);
|
|
63
68
|
window.removeEventListener('mousemove', move);
|
|
@@ -10,6 +10,7 @@ import { getLayoutSize } from '../utils/misc';
|
|
|
10
10
|
import { reduceSpace } from '../utils/resize-logic';
|
|
11
11
|
import { adjustColumnsWidths, getResizeState, getTotalWidth, updateColgroup } from '../utils/resize-state';
|
|
12
12
|
import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
13
|
+
import { syncStickyRowToTable } from './dom';
|
|
13
14
|
// Base function to trigger the actual scale on a table node.
|
|
14
15
|
// Will only resize/scale if a table has been previously resized.
|
|
15
16
|
export var scale = function scale(tableRef, options, domAtPos) {
|
|
@@ -112,6 +113,7 @@ export var previewScaleTable = function previewScaleTable(tableRef, options, dom
|
|
|
112
113
|
tableRef.style.width = "".concat(width, "px");
|
|
113
114
|
}
|
|
114
115
|
if (!hasTableBeenResized(node)) {
|
|
116
|
+
syncStickyRowToTable(tableRef);
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
117
119
|
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
|
|
@@ -58,10 +58,34 @@ export default (function (pluginState, action) {
|
|
|
58
58
|
resizeHandleRowIndex: undefined
|
|
59
59
|
});
|
|
60
60
|
case 'ADD_RESIZE_HANDLE_DECORATIONS':
|
|
61
|
-
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex) {
|
|
61
|
+
if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
|
|
62
62
|
return pluginState;
|
|
63
63
|
}
|
|
64
|
-
return _objectSpread(_objectSpread({}, pluginState), action.data)
|
|
64
|
+
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
|
|
65
|
+
isResizeHandleWidgetAdded: true
|
|
66
|
+
});
|
|
67
|
+
case 'UPDATE_RESIZE_HANDLE_DECORATIONS':
|
|
68
|
+
var _action$data = action.data,
|
|
69
|
+
resizeHandleColumnIndex = _action$data.resizeHandleColumnIndex,
|
|
70
|
+
resizeHandleRowIndex = _action$data.resizeHandleRowIndex,
|
|
71
|
+
resizeHandleIncludeTooltip = _action$data.resizeHandleIncludeTooltip;
|
|
72
|
+
if ((resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex || !Number.isFinite(resizeHandleColumnIndex)) && (resizeHandleRowIndex === pluginState.resizeHandleRowIndex || !Number.isFinite(resizeHandleRowIndex)) && (resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip || resizeHandleIncludeTooltip === undefined)) {
|
|
73
|
+
return pluginState;
|
|
74
|
+
}
|
|
75
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
76
|
+
resizeHandleColumnIndex: resizeHandleColumnIndex !== null && resizeHandleColumnIndex !== void 0 ? resizeHandleColumnIndex : pluginState.resizeHandleColumnIndex,
|
|
77
|
+
resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
|
|
78
|
+
resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
|
|
79
|
+
});
|
|
80
|
+
case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
|
|
81
|
+
if (!pluginState.isResizeHandleWidgetAdded) {
|
|
82
|
+
return pluginState;
|
|
83
|
+
}
|
|
84
|
+
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
|
|
85
|
+
resizeHandleColumnIndex: undefined,
|
|
86
|
+
resizeHandleRowIndex: undefined,
|
|
87
|
+
isResizeHandleWidgetAdded: false
|
|
88
|
+
});
|
|
65
89
|
case 'SET_TABLE_REF':
|
|
66
90
|
case 'HOVER_ROWS':
|
|
67
91
|
case 'HOVER_COLUMNS':
|