@atlaskit/editor-plugin-table 10.8.0 → 10.8.2
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 +22 -0
- package/dist/cjs/nodeviews/TableRow.js +68 -28
- package/dist/cjs/nodeviews/table.js +1 -1
- package/dist/cjs/nodeviews/toDOM.js +4 -2
- package/dist/cjs/pm-plugins/table-size-selector.js +40 -0
- package/dist/cjs/tablePlugin.js +63 -32
- package/dist/cjs/ui/SizeSelector/index.js +65 -0
- package/dist/es2019/nodeviews/TableRow.js +65 -24
- package/dist/es2019/nodeviews/table.js +1 -1
- package/dist/es2019/nodeviews/toDOM.js +4 -2
- package/dist/es2019/pm-plugins/table-size-selector.js +31 -0
- package/dist/es2019/tablePlugin.js +33 -3
- package/dist/es2019/ui/SizeSelector/index.js +61 -0
- package/dist/esm/nodeviews/TableRow.js +68 -28
- package/dist/esm/nodeviews/table.js +1 -1
- package/dist/esm/nodeviews/toDOM.js +4 -2
- package/dist/esm/pm-plugins/table-size-selector.js +33 -0
- package/dist/esm/tablePlugin.js +63 -32
- package/dist/esm/ui/SizeSelector/index.js +58 -0
- package/dist/types/nodeviews/TableRow.d.ts +1 -0
- package/dist/types/pm-plugins/table-size-selector.d.ts +10 -0
- package/dist/types/ui/SizeSelector/index.d.ts +9 -0
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-size-selector.d.ts +10 -0
- package/dist/types-ts4.5/ui/SizeSelector/index.d.ts +9 -0
- package/package.json +10 -4
- package/src/nodeviews/TableRow.ts +72 -30
- package/src/nodeviews/table.tsx +1 -1
- package/src/nodeviews/toDOM.ts +2 -0
- package/src/pm-plugins/table-size-selector.ts +39 -0
- package/src/tablePlugin.tsx +49 -0
- package/src/ui/SizeSelector/index.tsx +74 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 10.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#142852](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142852)
|
|
8
|
+
[`ca0f841e860ab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ca0f841e860ab) -
|
|
9
|
+
[ux] [ED-27466] When table option in quick insert typeahead is selected, shows table size picker
|
|
10
|
+
allow user selecting the table size before inserting
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 10.8.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#140847](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/140847)
|
|
18
|
+
[`edf99b41dbfcb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/edf99b41dbfcb) -
|
|
19
|
+
ED-27529: The fix introduced to resolve tables flashing unstyled on init when R18 concurrent mode
|
|
20
|
+
was enabled resulted in sticky headers being broken for tables. In short, the logic for sticky
|
|
21
|
+
headers was not set up to handle initial prosemirror table structure being replaced with the
|
|
22
|
+
rendered react table node. This meant the sentinels for sticky headers were only setup on the
|
|
23
|
+
initial prosemirror table structure, which is removed once react is ready.
|
|
24
|
+
|
|
3
25
|
## 10.8.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
31
31
|
// limit scroll event calls
|
|
32
32
|
var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
33
33
|
|
|
34
|
-
// timeout for resetting the scroll class - if it
|
|
34
|
+
// timeout for resetting the scroll class - if it's too long then users won't be able to click on the header cells,
|
|
35
35
|
// if too short it would trigger too many dom updates.
|
|
36
36
|
var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
37
37
|
var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
@@ -144,6 +144,9 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
144
144
|
}
|
|
145
145
|
this.emitOff(true);
|
|
146
146
|
}
|
|
147
|
+
if (this.tableContainerObserver) {
|
|
148
|
+
this.tableContainerObserver.disconnect();
|
|
149
|
+
}
|
|
147
150
|
}
|
|
148
151
|
}, {
|
|
149
152
|
key: "ignoreMutation",
|
|
@@ -252,26 +255,29 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
252
255
|
this.resizeObserver.observe(this.editorScrollableElement);
|
|
253
256
|
}
|
|
254
257
|
window.requestAnimationFrame(function () {
|
|
255
|
-
var
|
|
258
|
+
var getTableContainer = function getTableContainer() {
|
|
259
|
+
var _getTree;
|
|
260
|
+
return (_getTree = (0, _dom2.getTree)(_this2.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
|
|
261
|
+
};
|
|
262
|
+
|
|
256
263
|
// we expect tree to be defined after animation frame
|
|
257
|
-
var tableContainer = (
|
|
264
|
+
var tableContainer = getTableContainer();
|
|
258
265
|
if (tableContainer) {
|
|
259
266
|
var getSentinelTop = function getSentinelTop() {
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
);
|
|
267
|
+
return tableContainer &&
|
|
268
|
+
// Ignored via go/ees005
|
|
269
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
270
|
+
tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
|
|
265
271
|
};
|
|
266
272
|
var getSentinelBottom = function getSentinelBottom() {
|
|
267
273
|
// Multiple bottom sentinels may be found if there are nested tables.
|
|
268
274
|
// We need to make sure we get the last one which will belong to the parent table.
|
|
269
|
-
var bottomSentinels = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM);
|
|
275
|
+
var bottomSentinels = tableContainer && tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM);
|
|
270
276
|
// Ignored via go/ees005
|
|
271
277
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
272
278
|
return (0, _platformFeatureFlags.fg)('platform_editor_nested_tables_bottom_sentinel') ?
|
|
273
279
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
274
|
-
bottomSentinels.item(bottomSentinels.length - 1) :
|
|
280
|
+
bottomSentinels && bottomSentinels.item(bottomSentinels.length - 1) : tableContainer &&
|
|
275
281
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
276
282
|
tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
|
|
277
283
|
};
|
|
@@ -291,26 +297,60 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
291
297
|
}
|
|
292
298
|
});
|
|
293
299
|
};
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
300
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_initial_load_fix')) {
|
|
301
|
+
var isInitialProsemirrorToDomRender = tableContainer.hasAttribute('data-prosemirror-initial-toDOM-render');
|
|
302
|
+
|
|
303
|
+
// Sentinels may be in the DOM but they're part of the prosemirror placeholder structure which is replaced with the fully rendered React node.
|
|
304
|
+
if (sentinelsInDom() && !isInitialProsemirrorToDomRender) {
|
|
305
|
+
// great - DOM ready, observe as normal
|
|
306
|
+
observeStickySentinels();
|
|
307
|
+
} else {
|
|
308
|
+
// concurrent loading issue - here TableRow is too eager trying to
|
|
309
|
+
// observe sentinels before they are in the DOM, use MutationObserver
|
|
310
|
+
// to wait for sentinels to be added to the parent Table node DOM
|
|
311
|
+
// then attach the IntersectionObserver
|
|
312
|
+
_this2.tableContainerObserver = new MutationObserver(function () {
|
|
313
|
+
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
314
|
+
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
315
|
+
if (!tableContainer || !tableContainer.isConnected) {
|
|
316
|
+
tableContainer = getTableContainer();
|
|
317
|
+
}
|
|
318
|
+
if (sentinelsInDom()) {
|
|
319
|
+
var _this2$tableContainer;
|
|
320
|
+
observeStickySentinels();
|
|
321
|
+
(_this2$tableContainer = _this2.tableContainerObserver) === null || _this2$tableContainer === void 0 || _this2$tableContainer.disconnect();
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
var mutatingNode = tableContainer;
|
|
325
|
+
if (mutatingNode && _this2.tableContainerObserver) {
|
|
326
|
+
_this2.tableContainerObserver.observe(mutatingNode, {
|
|
327
|
+
subtree: true,
|
|
328
|
+
childList: true
|
|
329
|
+
});
|
|
306
330
|
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
if (sentinelsInDom()) {
|
|
334
|
+
// great - DOM ready, observe as normal
|
|
335
|
+
observeStickySentinels();
|
|
336
|
+
} else {
|
|
337
|
+
// concurrent loading issue - here TableRow is too eager trying to
|
|
338
|
+
// observe sentinels before they are in the DOM, use MutationObserver
|
|
339
|
+
// to wait for sentinels to be added to the parent Table node DOM
|
|
340
|
+
// then attach the IntersectionObserver
|
|
341
|
+
var tableContainerObserver = new MutationObserver(function () {
|
|
342
|
+
if (sentinelsInDom()) {
|
|
343
|
+
observeStickySentinels();
|
|
344
|
+
tableContainerObserver.disconnect();
|
|
345
|
+
}
|
|
313
346
|
});
|
|
347
|
+
var _mutatingNode = tableContainer;
|
|
348
|
+
if (_mutatingNode) {
|
|
349
|
+
tableContainerObserver.observe(_mutatingNode, {
|
|
350
|
+
subtree: true,
|
|
351
|
+
childList: true
|
|
352
|
+
});
|
|
353
|
+
}
|
|
314
354
|
}
|
|
315
355
|
}
|
|
316
356
|
}
|
|
@@ -68,7 +68,7 @@ var handleInlineTableWidth = function handleInlineTableWidth(table, width) {
|
|
|
68
68
|
table.style.setProperty('width', "".concat(width, "px"));
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
//
|
|
71
|
+
// Remove after removing the platform_editor_table_initial_load_fix flag.
|
|
72
72
|
var toDOM = function toDOM(node, props) {
|
|
73
73
|
var colgroup = '';
|
|
74
74
|
if (props.allowColumnResizing) {
|
|
@@ -68,7 +68,8 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
68
68
|
}]];
|
|
69
69
|
if (!config.tableResizingEnabled) {
|
|
70
70
|
return ['div', {
|
|
71
|
-
class: 'tableView-content-wrap'
|
|
71
|
+
class: 'tableView-content-wrap',
|
|
72
|
+
'data-prosemirror-initial-toDOM-render': 'true'
|
|
72
73
|
}, tableContainerDiv];
|
|
73
74
|
}
|
|
74
75
|
var tableWidthAttribute = node.attrs.width ? "".concat(node.attrs.width, "px") : "100%";
|
|
@@ -95,7 +96,8 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
95
96
|
class: 'resizer-hover-zone'
|
|
96
97
|
}, tableContainerDiv]]]];
|
|
97
98
|
return ['div', {
|
|
98
|
-
class: 'tableView-content-wrap'
|
|
99
|
+
class: 'tableView-content-wrap',
|
|
100
|
+
'data-prosemirror-initial-toDOM-render': 'true'
|
|
99
101
|
}, tableResizingDiv];
|
|
100
102
|
}
|
|
101
103
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.pluginKey = exports.createPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
var pluginKey = exports.pluginKey = new _state.PluginKey('tableSizeSelectorPlugin');
|
|
14
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatch) {
|
|
15
|
+
return new _safePlugin.SafePlugin({
|
|
16
|
+
key: pluginKey,
|
|
17
|
+
state: {
|
|
18
|
+
init: function init() {
|
|
19
|
+
return {
|
|
20
|
+
isSelectorOpen: false
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
apply: function apply(tr, currentPluginState) {
|
|
24
|
+
var meta = tr.getMeta(pluginKey);
|
|
25
|
+
if (meta) {
|
|
26
|
+
var keys = Object.keys(meta);
|
|
27
|
+
var changed = keys.some(function (key) {
|
|
28
|
+
return currentPluginState[key] !== meta[key];
|
|
29
|
+
});
|
|
30
|
+
if (changed) {
|
|
31
|
+
var newState = _objectSpread(_objectSpread({}, currentPluginState), meta);
|
|
32
|
+
dispatch(pluginKey, newState);
|
|
33
|
+
return newState;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return currentPluginState;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
package/dist/cjs/tablePlugin.js
CHANGED
|
@@ -12,6 +12,7 @@ var _adfSchema = require("@atlaskit/adf-schema");
|
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
13
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
14
14
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
15
|
+
var _getDomRefFromSelection = require("@atlaskit/editor-common/get-dom-ref-from-selection");
|
|
15
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
16
17
|
var _icons = require("@atlaskit/editor-common/icons");
|
|
17
18
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
@@ -48,6 +49,7 @@ var _plugin5 = require("./pm-plugins/table-resizing/plugin");
|
|
|
48
49
|
var _pluginFactory2 = require("./pm-plugins/table-resizing/plugin-factory");
|
|
49
50
|
var _pluginKey5 = require("./pm-plugins/table-resizing/plugin-key");
|
|
50
51
|
var _tableSelectionKeymap = require("./pm-plugins/table-selection-keymap");
|
|
52
|
+
var _tableSizeSelector = require("./pm-plugins/table-size-selector");
|
|
51
53
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
52
54
|
var _tableWidthInCommentFix = require("./pm-plugins/table-width-in-comment-fix");
|
|
53
55
|
var _create = require("./pm-plugins/utils/create");
|
|
@@ -59,6 +61,7 @@ var _FloatingDragMenu = _interopRequireDefault(require("./ui/FloatingDragMenu"))
|
|
|
59
61
|
var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertButton"));
|
|
60
62
|
var _FloatingToolbarLabel = require("./ui/FloatingToolbarLabel/FloatingToolbarLabel");
|
|
61
63
|
var _globalStyles = require("./ui/global-styles");
|
|
64
|
+
var _SizeSelector = require("./ui/SizeSelector");
|
|
62
65
|
var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
|
|
63
66
|
var _toolbar = require("./ui/toolbar");
|
|
64
67
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -75,7 +78,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
75
78
|
* from `@atlaskit/editor-core`.
|
|
76
79
|
*/
|
|
77
80
|
var tablePlugin = function tablePlugin(_ref) {
|
|
78
|
-
var _api$analytics, _api$accessibilityUti, _options$getEditorFea, _api$analytics2;
|
|
81
|
+
var _api$analytics, _api$accessibilityUti, _options$getEditorFea, _options$getEditorFea2, _api$analytics2;
|
|
79
82
|
var options = _ref.config,
|
|
80
83
|
api = _ref.api;
|
|
81
84
|
var editorViewRef = {
|
|
@@ -92,6 +95,9 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
92
95
|
var isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 || (_options$getEditorFea = options.getEditorFeatureFlags) === null || _options$getEditorFea === void 0 ? void 0 : _options$getEditorFea.call(options).tableWithFixedColumnWidthsOption) || false;
|
|
93
96
|
var shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (isTableFixedColumnWidthsOptionEnabled || ( // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
94
97
|
options === null || options === void 0 ? void 0 : options.isCommentEditor));
|
|
98
|
+
var isTableSelectorEnabled =
|
|
99
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
100
|
+
!(options !== null && options !== void 0 && options.isChromelessEditor) && !(options !== null && options !== void 0 && options.isCommentEditor) && (options === null || options === void 0 || (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableSelector) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_table_picker');
|
|
95
101
|
return {
|
|
96
102
|
name: 'table',
|
|
97
103
|
// Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
|
|
@@ -395,6 +401,12 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
395
401
|
}
|
|
396
402
|
});
|
|
397
403
|
}
|
|
404
|
+
}, {
|
|
405
|
+
name: 'tableSizeSelectorPlugin',
|
|
406
|
+
plugin: function plugin(_ref19) {
|
|
407
|
+
var dispatch = _ref19.dispatch;
|
|
408
|
+
return isTableSelectorEnabled ? (0, _tableSizeSelector.createPlugin)(dispatch) : undefined;
|
|
409
|
+
}
|
|
398
410
|
}];
|
|
399
411
|
|
|
400
412
|
// Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
|
|
@@ -409,13 +421,13 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
409
421
|
}
|
|
410
422
|
return plugins;
|
|
411
423
|
},
|
|
412
|
-
contentComponent: function contentComponent(
|
|
424
|
+
contentComponent: function contentComponent(_ref20) {
|
|
413
425
|
var _api$featureFlags;
|
|
414
|
-
var editorView =
|
|
415
|
-
popupsMountPoint =
|
|
416
|
-
popupsBoundariesElement =
|
|
417
|
-
popupsScrollableElement =
|
|
418
|
-
dispatchAnalyticsEvent =
|
|
426
|
+
var editorView = _ref20.editorView,
|
|
427
|
+
popupsMountPoint = _ref20.popupsMountPoint,
|
|
428
|
+
popupsBoundariesElement = _ref20.popupsBoundariesElement,
|
|
429
|
+
popupsScrollableElement = _ref20.popupsScrollableElement,
|
|
430
|
+
dispatchAnalyticsEvent = _ref20.dispatchAnalyticsEvent;
|
|
419
431
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
420
432
|
component: _analytics.ACTION_SUBJECT.TABLES_PLUGIN,
|
|
421
433
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -431,34 +443,38 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
431
443
|
tableWidthPluginState: _tableWidth.pluginKey,
|
|
432
444
|
tableResizingPluginState: _pluginKey5.pluginKey,
|
|
433
445
|
stickyHeadersState: _pluginKey4.pluginKey,
|
|
434
|
-
dragAndDropState: _pluginKey2.pluginKey
|
|
446
|
+
dragAndDropState: _pluginKey2.pluginKey,
|
|
447
|
+
sizeSelectorPluginState: _tableSizeSelector.pluginKey
|
|
435
448
|
},
|
|
436
|
-
render: function render(
|
|
437
|
-
var
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
449
|
+
render: function render(_ref21) {
|
|
450
|
+
var _sizeSelectorPluginSt, _api$analytics3;
|
|
451
|
+
var resizingPluginState = _ref21.tableResizingPluginState,
|
|
452
|
+
stickyHeadersState = _ref21.stickyHeadersState,
|
|
453
|
+
tablePluginState = _ref21.tablePluginState,
|
|
454
|
+
tableWidthPluginState = _ref21.tableWidthPluginState,
|
|
455
|
+
dragAndDropState = _ref21.dragAndDropState,
|
|
456
|
+
sizeSelectorPluginState = _ref21.sizeSelectorPluginState;
|
|
442
457
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
443
458
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
444
459
|
var resizingTableLocalId = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableLocalId;
|
|
445
460
|
var resizingTableRef = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.tableRef;
|
|
446
461
|
var isResizing = isColumnResizing || isTableResizing;
|
|
447
462
|
var widthToWidest = tablePluginState === null || tablePluginState === void 0 ? void 0 : tablePluginState.widthToWidest;
|
|
448
|
-
var
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
463
|
+
var isSizeSelectorOpen = sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.isSelectorOpen;
|
|
464
|
+
var _ref22 = tablePluginState,
|
|
465
|
+
tableNode = _ref22.tableNode,
|
|
466
|
+
tablePos = _ref22.tablePos,
|
|
467
|
+
targetCellPosition = _ref22.targetCellPosition,
|
|
468
|
+
isContextualMenuOpen = _ref22.isContextualMenuOpen,
|
|
469
|
+
tableRef = _ref22.tableRef,
|
|
470
|
+
pluginConfig = _ref22.pluginConfig,
|
|
471
|
+
insertColumnButtonIndex = _ref22.insertColumnButtonIndex,
|
|
472
|
+
insertRowButtonIndex = _ref22.insertRowButtonIndex,
|
|
473
|
+
isHeaderColumnEnabled = _ref22.isHeaderColumnEnabled,
|
|
474
|
+
isHeaderRowEnabled = _ref22.isHeaderRowEnabled,
|
|
475
|
+
isDragAndDropEnabled = _ref22.isDragAndDropEnabled,
|
|
476
|
+
tableWrapperTarget = _ref22.tableWrapperTarget,
|
|
477
|
+
isCellMenuOpenByKeyboard = _ref22.isCellMenuOpenByKeyboard;
|
|
462
478
|
var allowControls = pluginConfig.allowControls;
|
|
463
479
|
var stickyHeader = stickyHeadersState ? (0, _util.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
|
|
464
480
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, targetCellPosition && (tableRef || isCellMenuOpenByKeyboard) && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/_react.default.createElement(_FloatingContextualButton.default, {
|
|
@@ -548,13 +564,20 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
548
564
|
forcePlacement: true,
|
|
549
565
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex,
|
|
550
566
|
offset: [0, 10]
|
|
567
|
+
}), isTableSelectorEnabled && isSizeSelectorOpen && /*#__PURE__*/_react.default.createElement(_SizeSelector.SizeSelector, {
|
|
568
|
+
api: api,
|
|
569
|
+
isOpenedByKeyboard: false,
|
|
570
|
+
popupsMountPoint: popupsMountPoint,
|
|
571
|
+
target: (_sizeSelectorPluginSt = sizeSelectorPluginState === null || sizeSelectorPluginState === void 0 ? void 0 : sizeSelectorPluginState.targetRef) !== null && _sizeSelectorPluginSt !== void 0 ? _sizeSelectorPluginSt : (0, _getDomRefFromSelection.getDomRefFromSelection)(editorView, _analytics.ACTION_SUBJECT_ID.PICKER_TABLE_SIZE, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent),
|
|
572
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
573
|
+
popupsScrollableElement: popupsScrollableElement
|
|
551
574
|
}));
|
|
552
575
|
}
|
|
553
576
|
}));
|
|
554
577
|
},
|
|
555
578
|
pluginsOptions: {
|
|
556
|
-
quickInsert: function quickInsert(
|
|
557
|
-
var formatMessage =
|
|
579
|
+
quickInsert: function quickInsert(_ref23) {
|
|
580
|
+
var formatMessage = _ref23.formatMessage;
|
|
558
581
|
return [{
|
|
559
582
|
id: 'table',
|
|
560
583
|
title: formatMessage(_messages.toolbarInsertBlockMessages.table),
|
|
@@ -567,6 +590,14 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
567
590
|
},
|
|
568
591
|
action: function action(insert, state) {
|
|
569
592
|
var _api$table, _options$tableOptions6;
|
|
593
|
+
if (isTableSelectorEnabled) {
|
|
594
|
+
var _tr = insert('');
|
|
595
|
+
_tr.setMeta(_tableSizeSelector.pluginKey, {
|
|
596
|
+
isSelectorOpen: true
|
|
597
|
+
});
|
|
598
|
+
return _tr;
|
|
599
|
+
}
|
|
600
|
+
|
|
570
601
|
// see comment on tablesPlugin.getSharedState on usage
|
|
571
602
|
var tableState = api === null || api === void 0 || (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
572
603
|
var tableNodeProps = {
|
|
@@ -617,8 +648,8 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
617
648
|
return editorViewRef.current;
|
|
618
649
|
}, options, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
619
650
|
},
|
|
620
|
-
usePluginHook: function usePluginHook(
|
|
621
|
-
var editorView =
|
|
651
|
+
usePluginHook: function usePluginHook(_ref24) {
|
|
652
|
+
var editorView = _ref24.editorView;
|
|
622
653
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['editorViewMode']),
|
|
623
654
|
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
624
655
|
var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SizeSelector = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _react2 = require("@emotion/react");
|
|
9
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
+
var _tableSizeSelector = require("../../pm-plugins/table-size-selector");
|
|
11
|
+
/**
|
|
12
|
+
* @jsxRuntime classic
|
|
13
|
+
* @jsx jsx
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
17
|
+
|
|
18
|
+
var DEFAULT_TABLE_SELECTOR_COLS = 3;
|
|
19
|
+
var DEFAULT_TABLE_SELECTOR_ROWS = 3;
|
|
20
|
+
var SizeSelector = exports.SizeSelector = function SizeSelector(_ref) {
|
|
21
|
+
var api = _ref.api,
|
|
22
|
+
target = _ref.target,
|
|
23
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
24
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
25
|
+
popupsScrollableElement = _ref.popupsScrollableElement;
|
|
26
|
+
var closeSelectorPopup = (0, _react.useCallback)(function () {
|
|
27
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
28
|
+
var tr = _ref2.tr;
|
|
29
|
+
tr.setMeta(_tableSizeSelector.pluginKey, {
|
|
30
|
+
isSelectorOpen: false
|
|
31
|
+
});
|
|
32
|
+
return tr;
|
|
33
|
+
});
|
|
34
|
+
}, [api]);
|
|
35
|
+
var onSelection = (0, _react.useCallback)(function (rowsCount, colsCount) {
|
|
36
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
37
|
+
var tr = _ref3.tr;
|
|
38
|
+
api === null || api === void 0 || api.table.commands.insertTableWithSize(rowsCount, colsCount)({
|
|
39
|
+
tr: tr
|
|
40
|
+
});
|
|
41
|
+
tr.setMeta(_tableSizeSelector.pluginKey, {
|
|
42
|
+
isSelectorOpen: false
|
|
43
|
+
});
|
|
44
|
+
return tr;
|
|
45
|
+
});
|
|
46
|
+
}, [api]);
|
|
47
|
+
var onUnmount = function onUnmount() {
|
|
48
|
+
api === null || api === void 0 || api.core.actions.focus();
|
|
49
|
+
};
|
|
50
|
+
return (0, _react2.jsx)(_ui.TableSelectorPopup, {
|
|
51
|
+
defaultSize: {
|
|
52
|
+
row: DEFAULT_TABLE_SELECTOR_ROWS,
|
|
53
|
+
col: DEFAULT_TABLE_SELECTOR_COLS
|
|
54
|
+
},
|
|
55
|
+
target: target,
|
|
56
|
+
onUnmount: onUnmount,
|
|
57
|
+
onSelection: onSelection,
|
|
58
|
+
popupsMountPoint: popupsMountPoint,
|
|
59
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
60
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
61
|
+
isOpenedByKeyboard: true,
|
|
62
|
+
handleClickOutside: closeSelectorPopup,
|
|
63
|
+
handleEscapeKeydown: closeSelectorPopup
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -17,7 +17,7 @@ import TableNodeView from './TableNodeViewBase';
|
|
|
17
17
|
// limit scroll event calls
|
|
18
18
|
const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
19
19
|
|
|
20
|
-
// timeout for resetting the scroll class - if it
|
|
20
|
+
// timeout for resetting the scroll class - if it's too long then users won't be able to click on the header cells,
|
|
21
21
|
// if too short it would trigger too many dom updates.
|
|
22
22
|
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
23
23
|
export default class TableRow extends TableNodeView {
|
|
@@ -123,6 +123,9 @@ export default class TableRow extends TableNodeView {
|
|
|
123
123
|
}
|
|
124
124
|
this.emitOff(true);
|
|
125
125
|
}
|
|
126
|
+
if (this.tableContainerObserver) {
|
|
127
|
+
this.tableContainerObserver.disconnect();
|
|
128
|
+
}
|
|
126
129
|
}
|
|
127
130
|
ignoreMutation(mutationRecord) {
|
|
128
131
|
/* tableRows are not directly editable by the user
|
|
@@ -222,23 +225,27 @@ export default class TableRow extends TableNodeView {
|
|
|
222
225
|
this.resizeObserver.observe(this.editorScrollableElement);
|
|
223
226
|
}
|
|
224
227
|
window.requestAnimationFrame(() => {
|
|
225
|
-
|
|
228
|
+
const getTableContainer = () => {
|
|
229
|
+
var _getTree;
|
|
230
|
+
return (_getTree = getTree(this.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(`.${TableCssClassName.NODEVIEW_WRAPPER}`);
|
|
231
|
+
};
|
|
232
|
+
|
|
226
233
|
// we expect tree to be defined after animation frame
|
|
227
|
-
|
|
234
|
+
let tableContainer = getTableContainer();
|
|
228
235
|
if (tableContainer) {
|
|
229
|
-
const getSentinelTop = () =>
|
|
236
|
+
const getSentinelTop = () => tableContainer &&
|
|
230
237
|
// Ignored via go/ees005
|
|
231
238
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
232
239
|
tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
|
|
233
240
|
const getSentinelBottom = () => {
|
|
234
241
|
// Multiple bottom sentinels may be found if there are nested tables.
|
|
235
242
|
// We need to make sure we get the last one which will belong to the parent table.
|
|
236
|
-
const bottomSentinels = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM);
|
|
243
|
+
const bottomSentinels = tableContainer && tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM);
|
|
237
244
|
// Ignored via go/ees005
|
|
238
245
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
239
246
|
return fg('platform_editor_nested_tables_bottom_sentinel') ?
|
|
240
247
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
241
|
-
bottomSentinels.item(bottomSentinels.length - 1) :
|
|
248
|
+
bottomSentinels && bottomSentinels.item(bottomSentinels.length - 1) : tableContainer &&
|
|
242
249
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
243
250
|
tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
|
|
244
251
|
};
|
|
@@ -256,26 +263,60 @@ export default class TableRow extends TableNodeView {
|
|
|
256
263
|
}
|
|
257
264
|
});
|
|
258
265
|
};
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
266
|
+
if (fg('platform_editor_table_initial_load_fix')) {
|
|
267
|
+
const isInitialProsemirrorToDomRender = tableContainer.hasAttribute('data-prosemirror-initial-toDOM-render');
|
|
268
|
+
|
|
269
|
+
// Sentinels may be in the DOM but they're part of the prosemirror placeholder structure which is replaced with the fully rendered React node.
|
|
270
|
+
if (sentinelsInDom() && !isInitialProsemirrorToDomRender) {
|
|
271
|
+
// great - DOM ready, observe as normal
|
|
272
|
+
observeStickySentinels();
|
|
273
|
+
} else {
|
|
274
|
+
// concurrent loading issue - here TableRow is too eager trying to
|
|
275
|
+
// observe sentinels before they are in the DOM, use MutationObserver
|
|
276
|
+
// to wait for sentinels to be added to the parent Table node DOM
|
|
277
|
+
// then attach the IntersectionObserver
|
|
278
|
+
this.tableContainerObserver = new MutationObserver(() => {
|
|
279
|
+
// Check if the tableContainer is still connected to the DOM. It can become disconnected when the placholder
|
|
280
|
+
// prosemirror node is replaced with the fully rendered React node (see _handleTableRef).
|
|
281
|
+
if (!tableContainer || !tableContainer.isConnected) {
|
|
282
|
+
tableContainer = getTableContainer();
|
|
283
|
+
}
|
|
284
|
+
if (sentinelsInDom()) {
|
|
285
|
+
var _this$tableContainerO;
|
|
286
|
+
observeStickySentinels();
|
|
287
|
+
(_this$tableContainerO = this.tableContainerObserver) === null || _this$tableContainerO === void 0 ? void 0 : _this$tableContainerO.disconnect();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const mutatingNode = tableContainer;
|
|
291
|
+
if (mutatingNode && this.tableContainerObserver) {
|
|
292
|
+
this.tableContainerObserver.observe(mutatingNode, {
|
|
293
|
+
subtree: true,
|
|
294
|
+
childList: true
|
|
295
|
+
});
|
|
271
296
|
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
if (sentinelsInDom()) {
|
|
300
|
+
// great - DOM ready, observe as normal
|
|
301
|
+
observeStickySentinels();
|
|
302
|
+
} else {
|
|
303
|
+
// concurrent loading issue - here TableRow is too eager trying to
|
|
304
|
+
// observe sentinels before they are in the DOM, use MutationObserver
|
|
305
|
+
// to wait for sentinels to be added to the parent Table node DOM
|
|
306
|
+
// then attach the IntersectionObserver
|
|
307
|
+
const tableContainerObserver = new MutationObserver(() => {
|
|
308
|
+
if (sentinelsInDom()) {
|
|
309
|
+
observeStickySentinels();
|
|
310
|
+
tableContainerObserver.disconnect();
|
|
311
|
+
}
|
|
278
312
|
});
|
|
313
|
+
const mutatingNode = tableContainer;
|
|
314
|
+
if (mutatingNode) {
|
|
315
|
+
tableContainerObserver.observe(mutatingNode, {
|
|
316
|
+
subtree: true,
|
|
317
|
+
childList: true
|
|
318
|
+
});
|
|
319
|
+
}
|
|
279
320
|
}
|
|
280
321
|
}
|
|
281
322
|
}
|
|
@@ -50,7 +50,7 @@ const handleInlineTableWidth = (table, width) => {
|
|
|
50
50
|
table.style.setProperty('width', `${width}px`);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
//
|
|
53
|
+
// Remove after removing the platform_editor_table_initial_load_fix flag.
|
|
54
54
|
const toDOM = (node, props) => {
|
|
55
55
|
let colgroup = '';
|
|
56
56
|
if (props.allowColumnResizing) {
|