@atlaskit/editor-plugin-table 7.31.0 → 7.31.1
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 +9 -0
- package/dist/cjs/commands/column-resize.js +10 -8
- package/dist/cjs/commands/misc.js +4 -4
- package/dist/cjs/event-handlers.js +69 -65
- package/dist/cjs/plugin.js +52 -48
- package/dist/cjs/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/cjs/pm-plugins/keymap.js +18 -15
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/cjs/pm-plugins/view-mode-sort/index.js +35 -10
- package/dist/cjs/utils/decoration.js +28 -8
- package/dist/es2019/commands/column-resize.js +10 -8
- package/dist/es2019/commands/misc.js +4 -4
- package/dist/es2019/event-handlers.js +4 -4
- package/dist/es2019/plugin.js +12 -7
- package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/es2019/pm-plugins/keymap.js +7 -4
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/es2019/pm-plugins/view-mode-sort/index.js +33 -10
- package/dist/es2019/utils/decoration.js +26 -9
- package/dist/esm/commands/column-resize.js +10 -8
- package/dist/esm/commands/misc.js +4 -4
- package/dist/esm/event-handlers.js +69 -65
- package/dist/esm/plugin.js +52 -48
- package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +2 -2
- package/dist/esm/pm-plugins/keymap.js +18 -15
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/esm/pm-plugins/view-mode-sort/index.js +35 -10
- package/dist/esm/utils/decoration.js +28 -8
- package/dist/types/commands/column-resize.d.ts +5 -2
- package/dist/types/commands/misc.d.ts +3 -2
- package/dist/types/event-handlers.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/utils/column-resizing.d.ts +2 -1
- package/dist/types/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
- package/dist/types/pm-plugins/table-resizing/plugin.d.ts +2 -1
- package/dist/types/pm-plugins/view-mode-sort/index.d.ts +2 -1
- package/dist/types/utils/decoration.d.ts +2 -1
- package/dist/types-ts4.5/commands/column-resize.d.ts +5 -2
- package/dist/types-ts4.5/commands/misc.d.ts +3 -2
- package/dist/types-ts4.5/event-handlers.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations/utils/column-resizing.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/index.d.ts +2 -1
- package/dist/types-ts4.5/utils/decoration.d.ts +2 -1
- package/package.json +9 -5
- package/src/commands/column-resize.ts +18 -1
- package/src/commands/misc.ts +5 -0
- package/src/event-handlers.ts +22 -20
- package/src/plugin.tsx +10 -4
- package/src/pm-plugins/decorations/utils/column-resizing.ts +3 -0
- package/src/pm-plugins/keymap.ts +5 -0
- package/src/pm-plugins/main.ts +2 -1
- package/src/pm-plugins/table-resizing/event-handlers.ts +8 -1
- package/src/pm-plugins/table-resizing/plugin.ts +3 -0
- package/src/pm-plugins/view-mode-sort/index.ts +73 -34
- package/src/utils/decoration.ts +39 -13
|
@@ -11,10 +11,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _react = require("react");
|
|
12
12
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
13
|
var _reactIntlNext = require("react-intl-next");
|
|
14
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
14
15
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
16
|
var _types = require("@atlaskit/editor-common/types");
|
|
16
17
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
17
18
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
19
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
20
|
var _SortingIconWrapper = require("../../ui/icons/SortingIconWrapper");
|
|
19
21
|
var _pluginFactory = require("../plugin-factory");
|
|
20
22
|
var _consts = require("./consts");
|
|
@@ -29,7 +31,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
29
31
|
* Instead of making changes to the ProseMirror document, the plugin sorts the table rows in the DOM. This allows the sorting to be
|
|
30
32
|
* visible to the user without affecting the document's content.
|
|
31
33
|
*/
|
|
32
|
-
var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
34
|
+
var createPlugin = exports.createPlugin = function createPlugin(api, nodeViewPortalProviderAPI) {
|
|
33
35
|
return new _safePlugin.SafePlugin({
|
|
34
36
|
state: {
|
|
35
37
|
init: function init() {
|
|
@@ -102,6 +104,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
102
104
|
var map = _tableMap.TableMap.get(tableNode);
|
|
103
105
|
var hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
104
106
|
map.mapByRow[0].forEach(function (cell, index) {
|
|
107
|
+
var decorationRenderKey = (0, _v.default)();
|
|
105
108
|
decs.push(_view.Decoration.widget(cell + pos + 2, function () {
|
|
106
109
|
var _sort$tableId;
|
|
107
110
|
var element = document.createElement('div');
|
|
@@ -119,16 +122,38 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
119
122
|
}
|
|
120
123
|
var _getPluginState = (0, _pluginFactory.getPluginState)(oldState),
|
|
121
124
|
getIntl = _getPluginState.getIntl;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
126
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
127
|
+
return /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
128
|
+
value: getIntl()
|
|
129
|
+
}, /*#__PURE__*/(0, _react.createElement)(_SortingIconWrapper.SortingIconWrapper, {
|
|
130
|
+
isSortingAllowed: !hasMergedCells,
|
|
131
|
+
sortOrdered: sortOrdered,
|
|
132
|
+
onClick: function onClick() {},
|
|
133
|
+
onKeyDown: function onKeyDown() {},
|
|
134
|
+
api: api
|
|
135
|
+
}));
|
|
136
|
+
}, element, decorationRenderKey);
|
|
137
|
+
} else {
|
|
138
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
139
|
+
value: getIntl()
|
|
140
|
+
}, /*#__PURE__*/(0, _react.createElement)(_SortingIconWrapper.SortingIconWrapper, {
|
|
141
|
+
isSortingAllowed: !hasMergedCells,
|
|
142
|
+
sortOrdered: sortOrdered,
|
|
143
|
+
onClick: function onClick() {},
|
|
144
|
+
onKeyDown: function onKeyDown() {},
|
|
145
|
+
api: api
|
|
146
|
+
})), element);
|
|
147
|
+
}
|
|
131
148
|
return element;
|
|
149
|
+
}, {
|
|
150
|
+
destroy: function destroy(node) {
|
|
151
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
152
|
+
nodeViewPortalProviderAPI.remove(decorationRenderKey);
|
|
153
|
+
} else {
|
|
154
|
+
_reactDom.default.unmountComponentAtNode(node);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
132
157
|
}));
|
|
133
158
|
});
|
|
134
159
|
});
|
|
@@ -9,10 +9,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
11
|
var _reactIntlNext = require("react-intl-next");
|
|
12
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
12
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
14
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
14
15
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
15
16
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
18
|
var _types = require("../types");
|
|
17
19
|
var _ColumnResizeWidget = require("../ui/ColumnResizeWidget");
|
|
18
20
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
@@ -251,6 +253,7 @@ var makeArray = function makeArray(n) {
|
|
|
251
253
|
var createResizeHandleDecoration = exports.createResizeHandleDecoration = function createResizeHandleDecoration(tr, rowIndexTarget, columnEndIndexTarget) {
|
|
252
254
|
var includeTooltip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
253
255
|
var getIntl = arguments.length > 4 ? arguments[4] : undefined;
|
|
256
|
+
var nodeViewPortalProviderAPI = arguments.length > 5 ? arguments[5] : undefined;
|
|
254
257
|
var emptyResult = [[], []];
|
|
255
258
|
var table = (0, _utils2.findTable)(tr.selection);
|
|
256
259
|
if (!table || !table.node) {
|
|
@@ -261,21 +264,38 @@ var createResizeHandleDecoration = exports.createResizeHandleDecoration = functi
|
|
|
261
264
|
return emptyResult;
|
|
262
265
|
}
|
|
263
266
|
var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
|
|
267
|
+
var decorationRenderKey = (0, _v.default)();
|
|
264
268
|
var position = cellPos + cellNode.nodeSize - 1;
|
|
265
269
|
return _view.Decoration.widget(position, function () {
|
|
266
270
|
var element = document.createElement('div');
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
272
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
273
|
+
return /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
274
|
+
value: getIntl()
|
|
275
|
+
}, /*#__PURE__*/(0, _react.createElement)(_ColumnResizeWidget.ColumnResizeWidget, {
|
|
276
|
+
startIndex: cellColumnPositioning.left,
|
|
277
|
+
endIndex: cellColumnPositioning.right,
|
|
278
|
+
includeTooltip: includeTooltip
|
|
279
|
+
}));
|
|
280
|
+
}, element, decorationRenderKey);
|
|
281
|
+
} else {
|
|
282
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
283
|
+
value: getIntl()
|
|
284
|
+
}, /*#__PURE__*/(0, _react.createElement)(_ColumnResizeWidget.ColumnResizeWidget, {
|
|
285
|
+
startIndex: cellColumnPositioning.left,
|
|
286
|
+
endIndex: cellColumnPositioning.right,
|
|
287
|
+
includeTooltip: includeTooltip
|
|
288
|
+
})), element);
|
|
289
|
+
}
|
|
274
290
|
return element;
|
|
275
291
|
}, {
|
|
276
292
|
key: "".concat(_types.TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET, "_").concat(rowIndex, "_").concat(columnIndex, "_").concat(includeTooltip ? 'with' : 'no', "-tooltip"),
|
|
277
293
|
destroy: function destroy(node) {
|
|
278
|
-
|
|
294
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
295
|
+
nodeViewPortalProviderAPI.remove(decorationRenderKey);
|
|
296
|
+
} else {
|
|
297
|
+
_reactDom.default.unmountComponentAtNode(node);
|
|
298
|
+
}
|
|
279
299
|
}
|
|
280
300
|
});
|
|
281
301
|
};
|
|
@@ -15,7 +15,7 @@ import { createColumnLineResize, getSelectedColumnIndexes, updateDecorations } f
|
|
|
15
15
|
const getTablePluginCommand = (actionPayload, originalTr) => {
|
|
16
16
|
return createCommand(() => actionPayload, tr => (originalTr || tr).setMeta('addToHistory', false));
|
|
17
17
|
};
|
|
18
|
-
const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHandlePos) => (state, dispatch) => {
|
|
18
|
+
const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHandlePos, nodeViewPortalProviderAPI) => (state, dispatch) => {
|
|
19
19
|
let customTr = state.tr;
|
|
20
20
|
const {
|
|
21
21
|
pluginConfig: {
|
|
@@ -29,7 +29,7 @@ const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHan
|
|
|
29
29
|
if (!allowColumnResizing) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
|
-
const decorationsWithWidget = buildColumnResizingDecorations(rowIndex, columnIndex, true, getIntl)({
|
|
32
|
+
const decorationsWithWidget = buildColumnResizingDecorations(rowIndex, columnIndex, true, getIntl, nodeViewPortalProviderAPI)({
|
|
33
33
|
tr: customTr,
|
|
34
34
|
decorationSet: getDecorations(state)
|
|
35
35
|
});
|
|
@@ -60,7 +60,8 @@ const updateResizeHandleAndStatePosition = (rowIndex, columnIndex, nextResizeHan
|
|
|
60
60
|
};
|
|
61
61
|
export const initiateKeyboardColumnResizing = ({
|
|
62
62
|
ariaNotify,
|
|
63
|
-
getIntl
|
|
63
|
+
getIntl,
|
|
64
|
+
nodeViewPortalProviderAPI
|
|
64
65
|
}) => (state, dispatch, view) => {
|
|
65
66
|
const {
|
|
66
67
|
selection
|
|
@@ -73,14 +74,15 @@ export const initiateKeyboardColumnResizing = ({
|
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
if (selectionRect && cell && view) {
|
|
76
|
-
return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
|
|
77
|
+
return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos, nodeViewPortalProviderAPI)(state, dispatch);
|
|
77
78
|
}
|
|
78
79
|
return false;
|
|
79
80
|
};
|
|
80
81
|
export const activateNextResizeArea = ({
|
|
81
82
|
direction,
|
|
82
83
|
ariaNotify,
|
|
83
|
-
getIntl
|
|
84
|
+
getIntl,
|
|
85
|
+
nodeViewPortalProviderAPI
|
|
84
86
|
}) => (state, dispatch, view) => {
|
|
85
87
|
const {
|
|
86
88
|
resizeHandlePos
|
|
@@ -129,17 +131,17 @@ export const activateNextResizeArea = ({
|
|
|
129
131
|
// we are somewhere in between the side columns of the table
|
|
130
132
|
const offset = $nextCell.pos - $nextCell.start(-1);
|
|
131
133
|
const rectForNextCell = tableMap.findCell(offset);
|
|
132
|
-
return updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch, view);
|
|
134
|
+
return updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos, nodeViewPortalProviderAPI)(state, dispatch, view);
|
|
133
135
|
} else {
|
|
134
136
|
// current position is in the one of the side columns of the table(left or right)
|
|
135
137
|
if (currentCellRect.left === 0) {
|
|
136
138
|
const lastCellInCurrentRow = tableMap.positionAt(currentCellRect.top, tableMap.width - 1, tableNode) + closestTable.start;
|
|
137
139
|
const $lastCell = state.doc.resolve(lastCellInCurrentRow);
|
|
138
|
-
return updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch, view);
|
|
140
|
+
return updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos, nodeViewPortalProviderAPI)(state, dispatch, view);
|
|
139
141
|
} else if (tableMap.width === currentCellRect.right) {
|
|
140
142
|
const firsCellInCurrentRow = tableMap.positionAt(currentCellRect.top, 0, tableNode) + closestTable.start;
|
|
141
143
|
const $nextCell = state.doc.resolve(firsCellInCurrentRow);
|
|
142
|
-
return updateResizeHandleAndStatePosition(currentCellRect.top, 1, $nextCell.pos)(state, dispatch);
|
|
144
|
+
return updateResizeHandleAndStatePosition(currentCellRect.top, 1, $nextCell.pos, nodeViewPortalProviderAPI)(state, dispatch);
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
return false;
|
|
@@ -437,7 +437,7 @@ export const showInsertRowButton = rowIndex => createCommand(_ => rowIndex > -1
|
|
|
437
437
|
export const hideInsertColumnOrRowButton = () => createCommand({
|
|
438
438
|
type: 'HIDE_INSERT_COLUMN_OR_ROW_BUTTON'
|
|
439
439
|
}, tr => tr.setMeta('addToHistory', false));
|
|
440
|
-
export const addResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip, isKeyboardResize) => createCommand(state => {
|
|
440
|
+
export const addResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip, nodeViewPortalProviderAPI, isKeyboardResize) => createCommand(state => {
|
|
441
441
|
const tableNode = findTable(state.selection);
|
|
442
442
|
const {
|
|
443
443
|
pluginConfig: {
|
|
@@ -451,7 +451,7 @@ export const addResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip
|
|
|
451
451
|
return {
|
|
452
452
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS',
|
|
453
453
|
data: {
|
|
454
|
-
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex, includeTooltip, getIntl)({
|
|
454
|
+
decorationSet: buildColumnResizingDecorations(rowIndex, columnIndex, includeTooltip, getIntl, nodeViewPortalProviderAPI)({
|
|
455
455
|
tr: state.tr,
|
|
456
456
|
decorationSet: getDecorations(state)
|
|
457
457
|
}),
|
|
@@ -462,7 +462,7 @@ export const addResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip
|
|
|
462
462
|
}
|
|
463
463
|
};
|
|
464
464
|
}, tr => tr.setMeta('addToHistory', false));
|
|
465
|
-
export const updateResizeHandleDecorations = (rowIndex, columnIndex, includeTooltip) => createCommand(state => {
|
|
465
|
+
export const updateResizeHandleDecorations = (nodeViewPortalProviderAPI, rowIndex, columnIndex, includeTooltip) => createCommand(state => {
|
|
466
466
|
const tableNode = findTable(state.selection);
|
|
467
467
|
const {
|
|
468
468
|
resizeHandleRowIndex,
|
|
@@ -485,7 +485,7 @@ export const updateResizeHandleDecorations = (rowIndex, columnIndex, includeTool
|
|
|
485
485
|
return {
|
|
486
486
|
type: 'UPDATE_RESIZE_HANDLE_DECORATIONS',
|
|
487
487
|
data: {
|
|
488
|
-
decorationSet: buildColumnResizingDecorations(resolvedRowIndex, resolvedColumnIndex, resolvedIncludeTooltip, getIntl)({
|
|
488
|
+
decorationSet: buildColumnResizingDecorations(resolvedRowIndex, resolvedColumnIndex, resolvedIncludeTooltip, getIntl, nodeViewPortalProviderAPI)({
|
|
489
489
|
tr: state.tr,
|
|
490
490
|
decorationSet: getDecorations(state)
|
|
491
491
|
}),
|
|
@@ -257,7 +257,7 @@ export const handleMouseLeave = (view, event) => {
|
|
|
257
257
|
|
|
258
258
|
// IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
|
|
259
259
|
// need to access the mouse event offset position and also the target clientWidth vallue.
|
|
260
|
-
const handleMouseMoveDebounce = rafSchedule((view, event, offsetX) => {
|
|
260
|
+
const handleMouseMoveDebounce = nodeViewPortalProviderAPI => rafSchedule((view, event, offsetX) => {
|
|
261
261
|
if (!(event.target instanceof HTMLElement)) {
|
|
262
262
|
return false;
|
|
263
263
|
}
|
|
@@ -313,14 +313,14 @@ const handleMouseMoveDebounce = rafSchedule((view, event, offsetX) => {
|
|
|
313
313
|
columnEndIndexTarget
|
|
314
314
|
})) && !isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
|
|
315
315
|
) {
|
|
316
|
-
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true)(state, dispatch);
|
|
316
|
+
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true, nodeViewPortalProviderAPI)(state, dispatch);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
return false;
|
|
322
322
|
});
|
|
323
|
-
export const handleMouseMove = (view, event) => {
|
|
323
|
+
export const handleMouseMove = nodeViewPortalProviderAPI => (view, event) => {
|
|
324
324
|
if (!(event.target instanceof HTMLElement)) {
|
|
325
325
|
return false;
|
|
326
326
|
}
|
|
@@ -330,7 +330,7 @@ export const handleMouseMove = (view, event) => {
|
|
|
330
330
|
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
331
331
|
// in the deferred callback handler.
|
|
332
332
|
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
333
|
-
handleMouseMoveDebounce(view, event, browser.gecko ? event.offsetX : NaN);
|
|
333
|
+
handleMouseMoveDebounce(nodeViewPortalProviderAPI)(view, event, browser.gecko ? event.offsetX : NaN);
|
|
334
334
|
return false;
|
|
335
335
|
};
|
|
336
336
|
export function handleTripleClick(view, pos) {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -198,6 +198,7 @@ const tablesPlugin = ({
|
|
|
198
198
|
dispatchAnalyticsEvent,
|
|
199
199
|
dispatch,
|
|
200
200
|
portalProviderAPI,
|
|
201
|
+
nodeViewPortalProviderAPI,
|
|
201
202
|
eventDispatcher,
|
|
202
203
|
getIntl
|
|
203
204
|
}) => {
|
|
@@ -213,12 +214,13 @@ const tablesPlugin = ({
|
|
|
213
214
|
isCommentEditor,
|
|
214
215
|
isChromelessEditor
|
|
215
216
|
} = options || {};
|
|
216
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor);
|
|
217
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor);
|
|
217
218
|
}
|
|
218
219
|
}, {
|
|
219
220
|
name: 'tablePMColResizing',
|
|
220
221
|
plugin: ({
|
|
221
|
-
dispatch
|
|
222
|
+
dispatch,
|
|
223
|
+
nodeViewPortalProviderAPI
|
|
222
224
|
}) => {
|
|
223
225
|
const {
|
|
224
226
|
fullWidthEnabled,
|
|
@@ -233,7 +235,7 @@ const tablesPlugin = ({
|
|
|
233
235
|
} = pluginConfig(tableOptions);
|
|
234
236
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
235
237
|
lastColumnResizable: !fullWidthEnabled
|
|
236
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, isTableAlignmentEnabled, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
238
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, isNewColumnResizingEnabled, isTableAlignmentEnabled, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
237
239
|
}
|
|
238
240
|
}, {
|
|
239
241
|
name: 'tableEditing',
|
|
@@ -244,7 +246,8 @@ const tablesPlugin = ({
|
|
|
244
246
|
{
|
|
245
247
|
name: 'tableKeymap',
|
|
246
248
|
plugin: ({
|
|
247
|
-
getIntl
|
|
249
|
+
getIntl,
|
|
250
|
+
nodeViewPortalProviderAPI
|
|
248
251
|
}) => {
|
|
249
252
|
const {
|
|
250
253
|
dragAndDropEnabled,
|
|
@@ -255,7 +258,7 @@ const tablesPlugin = ({
|
|
|
255
258
|
isChromelessEditor = false,
|
|
256
259
|
tableResizingEnabled = false
|
|
257
260
|
} = options || {};
|
|
258
|
-
return keymapPlugin(defaultGetEditorContainerWidth, api, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, tableResizingEnabled);
|
|
261
|
+
return keymapPlugin(defaultGetEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, isTableAlignmentEnabled, fullWidthEnabled, api, getIntl, isCellBackgroundDuplicated, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, tableResizingEnabled);
|
|
259
262
|
}
|
|
260
263
|
}, {
|
|
261
264
|
name: 'tableSelectionKeymap',
|
|
@@ -301,8 +304,10 @@ const tablesPlugin = ({
|
|
|
301
304
|
}
|
|
302
305
|
}, {
|
|
303
306
|
name: 'tableViewModeSort',
|
|
304
|
-
plugin: (
|
|
305
|
-
|
|
307
|
+
plugin: ({
|
|
308
|
+
nodeViewPortalProviderAPI
|
|
309
|
+
}) => {
|
|
310
|
+
return api !== null && api !== void 0 && api.editorViewMode ? createViewModeSortPlugin(api, nodeViewPortalProviderAPI) : undefined;
|
|
306
311
|
}
|
|
307
312
|
}, {
|
|
308
313
|
name: 'tableLocalId',
|
|
@@ -10,13 +10,13 @@ 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, includeTooltip, getIntl) => ({
|
|
13
|
+
export const buildColumnResizingDecorations = (rowEndIndex, columnEndIndex, includeTooltip, getIntl, nodeViewPortalProviderAPI) => ({
|
|
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);
|
|
19
|
+
}, includeTooltip, getIntl, nodeViewPortalProviderAPI);
|
|
20
20
|
return composeDecorations([updateColumnResizeHandle(columnResizesDecorations), updateLastCellElement(lastCellElementsDecorations)])({
|
|
21
21
|
decorationSet,
|
|
22
22
|
tr
|
|
@@ -7,7 +7,7 @@ import { addRowAroundSelection, changeColumnWidthByStepWithAnalytics, deleteSele
|
|
|
7
7
|
import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
8
8
|
import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand, createTable } from '../commands/insert';
|
|
9
9
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
10
|
-
export function keymapPlugin(getEditorContainerWidth, api, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, isTableResizingEnabled) {
|
|
10
|
+
export function keymapPlugin(getEditorContainerWidth, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isTableAlignmentEnabled = false, isFullWidthEnabled, pluginInjectionApi, getIntl, isCellBackgroundDuplicated = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, isTableResizingEnabled) {
|
|
11
11
|
var _pluginInjectionApi$a;
|
|
12
12
|
const list = {};
|
|
13
13
|
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
|
|
@@ -46,17 +46,20 @@ export function keymapPlugin(getEditorContainerWidth, api, editorAnalyticsAPI, d
|
|
|
46
46
|
}
|
|
47
47
|
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing({
|
|
48
48
|
ariaNotify: ariaNotifyPlugin,
|
|
49
|
-
getIntl: getIntl
|
|
49
|
+
getIntl: getIntl,
|
|
50
|
+
nodeViewPortalProviderAPI
|
|
50
51
|
}), list);
|
|
51
52
|
bindKeymapWithCommand(moveRight.common, activateNextResizeArea({
|
|
52
53
|
direction: 1,
|
|
53
54
|
ariaNotify: ariaNotifyPlugin,
|
|
54
|
-
getIntl: getIntl
|
|
55
|
+
getIntl: getIntl,
|
|
56
|
+
nodeViewPortalProviderAPI
|
|
55
57
|
}), list);
|
|
56
58
|
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea({
|
|
57
59
|
direction: -1,
|
|
58
60
|
ariaNotify: ariaNotifyPlugin,
|
|
59
|
-
getIntl: getIntl
|
|
61
|
+
getIntl: getIntl,
|
|
62
|
+
nodeViewPortalProviderAPI
|
|
60
63
|
}), list);
|
|
61
64
|
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI, api)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, !!isCommentEditor, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
62
65
|
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI, api)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, !!isCommentEditor, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
@@ -19,7 +19,7 @@ import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '.
|
|
|
19
19
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
20
20
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
21
21
|
import { pluginKey } from './plugin-key';
|
|
22
|
-
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor) => {
|
|
22
|
+
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor) => {
|
|
23
23
|
var _accessibilityUtils;
|
|
24
24
|
const state = createPluginState(dispatch, {
|
|
25
25
|
pluginConfig,
|
|
@@ -283,7 +283,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
283
283
|
blur: handleBlur,
|
|
284
284
|
mousedown: withCellTracking(handleMouseDown),
|
|
285
285
|
mouseleave: handleMouseLeave,
|
|
286
|
-
mousemove: whenTableInFocus(handleMouseMove),
|
|
286
|
+
mousemove: whenTableInFocus(handleMouseMove(nodeViewPortalProviderAPI)),
|
|
287
287
|
mouseenter: handleMouseEnter,
|
|
288
288
|
mouseup: whenTableInFocus(handleMouseUp),
|
|
289
289
|
click: withCellTracking(whenTableInFocus(handleClick))
|
|
@@ -15,7 +15,7 @@ import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resize
|
|
|
15
15
|
import { TABLE_OFFSET_IN_COMMENT_EDITOR } from './utils/consts';
|
|
16
16
|
import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './utils/misc';
|
|
17
17
|
import { scaleResizeState } from './utils/resize-column';
|
|
18
|
-
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
18
|
+
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
19
19
|
var _originalTable$attrs;
|
|
20
20
|
const {
|
|
21
21
|
state,
|
|
@@ -104,7 +104,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
104
104
|
|
|
105
105
|
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
106
106
|
// unnecessary tooltips being displayed during drag.
|
|
107
|
-
updateResizeHandleDecorations(undefined, undefined, false)(state, dispatch);
|
|
107
|
+
updateResizeHandleDecorations(nodeViewPortalProviderAPI, undefined, undefined, false)(state, dispatch);
|
|
108
108
|
|
|
109
109
|
// for new column resizing, take the current scaled version of table widths and use those as the basis for resizing
|
|
110
110
|
// implication: the scaled version of the table becomes the source of truth
|
|
@@ -9,7 +9,7 @@ import { pluginKey } from './plugin-key';
|
|
|
9
9
|
import { getResizeCellPos } from './utils';
|
|
10
10
|
export function createPlugin(dispatch, {
|
|
11
11
|
lastColumnResizable = true
|
|
12
|
-
}, getEditorContainerWidth, getEditorFeatureFlags, api, editorAnalyticsAPI, isTableScalingEnabled, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) {
|
|
12
|
+
}, getEditorContainerWidth, getEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor) {
|
|
13
13
|
return new SafePlugin({
|
|
14
14
|
key: pluginKey,
|
|
15
15
|
state: createPluginState(dispatch, {
|
|
@@ -51,7 +51,7 @@ export function createPlugin(dispatch, {
|
|
|
51
51
|
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
52
52
|
}
|
|
53
53
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
54
|
-
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor)) {
|
|
54
|
+
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor)) {
|
|
55
55
|
const {
|
|
56
56
|
state,
|
|
57
57
|
dispatch
|
|
@@ -7,16 +7,18 @@
|
|
|
7
7
|
import { createElement } from 'react';
|
|
8
8
|
import ReactDOM from 'react-dom';
|
|
9
9
|
import { RawIntlProvider } from 'react-intl-next';
|
|
10
|
+
import uuid from 'uuid/v4';
|
|
10
11
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
11
12
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
12
13
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
13
14
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
16
|
import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
|
|
15
17
|
import { getPluginState } from '../plugin-factory';
|
|
16
18
|
import { IS_DISABLED_CLASS_NAME, SORT_INDEX_DATA_ATTRIBUTE, SORTING_ICON_CLASS_NAME } from './consts';
|
|
17
19
|
import { tableViewModeSortPluginKey as key } from './plugin-key';
|
|
18
20
|
import { getTableElements, toggleSort } from './utils';
|
|
19
|
-
export const createPlugin = api => {
|
|
21
|
+
export const createPlugin = (api, nodeViewPortalProviderAPI) => {
|
|
20
22
|
return new SafePlugin({
|
|
21
23
|
state: {
|
|
22
24
|
init: () => ({
|
|
@@ -78,6 +80,7 @@ export const createPlugin = api => {
|
|
|
78
80
|
const map = TableMap.get(tableNode);
|
|
79
81
|
const hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
80
82
|
map.mapByRow[0].forEach((cell, index) => {
|
|
83
|
+
const decorationRenderKey = uuid();
|
|
81
84
|
decs.push(Decoration.widget(cell + pos + 2, () => {
|
|
82
85
|
var _sort$tableId;
|
|
83
86
|
const element = document.createElement('div');
|
|
@@ -96,16 +99,36 @@ export const createPlugin = api => {
|
|
|
96
99
|
const {
|
|
97
100
|
getIntl
|
|
98
101
|
} = getPluginState(oldState);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
103
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(RawIntlProvider, {
|
|
104
|
+
value: getIntl()
|
|
105
|
+
}, /*#__PURE__*/createElement(SortingIconWrapper, {
|
|
106
|
+
isSortingAllowed: !hasMergedCells,
|
|
107
|
+
sortOrdered,
|
|
108
|
+
onClick: () => {},
|
|
109
|
+
onKeyDown: () => {},
|
|
110
|
+
api
|
|
111
|
+
})), element, decorationRenderKey);
|
|
112
|
+
} else {
|
|
113
|
+
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
114
|
+
value: getIntl()
|
|
115
|
+
}, /*#__PURE__*/createElement(SortingIconWrapper, {
|
|
116
|
+
isSortingAllowed: !hasMergedCells,
|
|
117
|
+
sortOrdered,
|
|
118
|
+
onClick: () => {},
|
|
119
|
+
onKeyDown: () => {},
|
|
120
|
+
api
|
|
121
|
+
})), element);
|
|
122
|
+
}
|
|
108
123
|
return element;
|
|
124
|
+
}, {
|
|
125
|
+
destroy: node => {
|
|
126
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
127
|
+
nodeViewPortalProviderAPI.remove(decorationRenderKey);
|
|
128
|
+
} else {
|
|
129
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
109
132
|
}));
|
|
110
133
|
});
|
|
111
134
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import { RawIntlProvider } from 'react-intl-next';
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
4
5
|
import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
5
6
|
|
|
6
7
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
@@ -8,6 +9,7 @@ import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
|
8
9
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
9
10
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
10
11
|
import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
13
|
import { TableCssClassName as ClassName, TableDecorations } from '../types';
|
|
12
14
|
import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
|
|
13
15
|
const filterDecorationByKey = (key, decorationSet) => decorationSet.find(undefined, undefined, spec => spec.key.indexOf(key) > -1);
|
|
@@ -221,7 +223,7 @@ const makeArray = n => Array.from(Array(n).keys());
|
|
|
221
223
|
* we will add a new class on the last item for each cell,
|
|
222
224
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
223
225
|
*/
|
|
224
|
-
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget, includeTooltip = false, getIntl) => {
|
|
226
|
+
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget, includeTooltip = false, getIntl, nodeViewPortalProviderAPI) => {
|
|
225
227
|
const emptyResult = [[], []];
|
|
226
228
|
const table = findTable(tr.selection);
|
|
227
229
|
if (!table || !table.node) {
|
|
@@ -232,21 +234,36 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
|
|
|
232
234
|
return emptyResult;
|
|
233
235
|
}
|
|
234
236
|
const createResizerHandleDecoration = (cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) => {
|
|
237
|
+
const decorationRenderKey = uuid();
|
|
235
238
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
236
239
|
return Decoration.widget(position, () => {
|
|
237
240
|
const element = document.createElement('div');
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
242
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(RawIntlProvider, {
|
|
243
|
+
value: getIntl()
|
|
244
|
+
}, /*#__PURE__*/createElement(ColumnResizeWidget, {
|
|
245
|
+
startIndex: cellColumnPositioning.left,
|
|
246
|
+
endIndex: cellColumnPositioning.right,
|
|
247
|
+
includeTooltip
|
|
248
|
+
})), element, decorationRenderKey);
|
|
249
|
+
} else {
|
|
250
|
+
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
251
|
+
value: getIntl()
|
|
252
|
+
}, /*#__PURE__*/createElement(ColumnResizeWidget, {
|
|
253
|
+
startIndex: cellColumnPositioning.left,
|
|
254
|
+
endIndex: cellColumnPositioning.right,
|
|
255
|
+
includeTooltip
|
|
256
|
+
})), element);
|
|
257
|
+
}
|
|
245
258
|
return element;
|
|
246
259
|
}, {
|
|
247
260
|
key: `${TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET}_${rowIndex}_${columnIndex}_${includeTooltip ? 'with' : 'no'}-tooltip`,
|
|
248
261
|
destroy: node => {
|
|
249
|
-
|
|
262
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
263
|
+
nodeViewPortalProviderAPI.remove(decorationRenderKey);
|
|
264
|
+
} else {
|
|
265
|
+
ReactDOM.unmountComponentAtNode(node);
|
|
266
|
+
}
|
|
250
267
|
}
|
|
251
268
|
});
|
|
252
269
|
};
|