@atlaskit/editor-plugin-table 7.24.5 → 7.24.6
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/plugin.js +7 -36
- package/dist/cjs/toDOM.js +75 -0
- package/dist/es2019/plugin.js +9 -38
- package/dist/es2019/toDOM.js +65 -0
- package/dist/esm/plugin.js +8 -37
- package/dist/esm/toDOM.js +68 -0
- package/dist/types/toDOM.d.ts +7 -0
- package/dist/types-ts4.5/toDOM.d.ts +7 -0
- package/package.json +2 -2
- package/src/plugin.tsx +11 -53
- package/src/toDOM.ts +135 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.24.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#127242](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127242)
|
|
8
|
+
[`508ee8b4dcbc8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/508ee8b4dcbc8) -
|
|
9
|
+
[ED-23944] Improve toDOM helper test
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 7.24.5
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
|
11
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
@@ -35,10 +34,10 @@ var _stickyHeaders = require("./pm-plugins/sticky-headers");
|
|
|
35
34
|
var _tableAnalytics = require("./pm-plugins/table-analytics");
|
|
36
35
|
var _tableLocalId = require("./pm-plugins/table-local-id");
|
|
37
36
|
var _tableResizing = require("./pm-plugins/table-resizing");
|
|
38
|
-
var _colgroup = require("./pm-plugins/table-resizing/utils/colgroup");
|
|
39
37
|
var _tableSelectionKeymap = require("./pm-plugins/table-selection-keymap");
|
|
40
38
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
41
39
|
var _viewModeSort = require("./pm-plugins/view-mode-sort");
|
|
40
|
+
var _toDOM = require("./toDOM");
|
|
42
41
|
var _toolbar = require("./toolbar");
|
|
43
42
|
var _FloatingContextualButton = _interopRequireDefault(require("./ui/FloatingContextualButton"));
|
|
44
43
|
var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingContextualMenu"));
|
|
@@ -56,39 +55,6 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
56
55
|
|
|
57
56
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
58
57
|
|
|
59
|
-
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
60
|
-
var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(tableOptions) {
|
|
61
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_lazy-node-views')) {
|
|
62
|
-
return _adfSchema.table;
|
|
63
|
-
}
|
|
64
|
-
return _objectSpread(_objectSpread({}, _adfSchema.table), {}, {
|
|
65
|
-
toDOM: function toDOM(node) {
|
|
66
|
-
var attrs = {
|
|
67
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
68
|
-
'data-layout': node.attrs.layout,
|
|
69
|
-
'data-autosize': node.attrs.__autoSize,
|
|
70
|
-
'data-table-local-id': node.attrs.localId,
|
|
71
|
-
'data-table-width': node.attrs.width
|
|
72
|
-
};
|
|
73
|
-
var colgroup = '';
|
|
74
|
-
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
75
|
-
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
76
|
-
if (allowColumnResizing) {
|
|
77
|
-
colgroup = ['colgroup', {}].concat((0, _toConsumableArray2.default)((0, _colgroup.generateColgroup)(node)));
|
|
78
|
-
}
|
|
79
|
-
return ['div', {
|
|
80
|
-
class: 'tableView-content-wrap'
|
|
81
|
-
}, ['div', {
|
|
82
|
-
class: 'pm-table-container'
|
|
83
|
-
}, ['div', {
|
|
84
|
-
class: 'pm-table-wrapper',
|
|
85
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
86
|
-
'data-layout': node.attrs.layout
|
|
87
|
-
}, ['table', attrs, colgroup, ['tbody', 0]]]]];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
|
|
92
58
|
/**
|
|
93
59
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
94
60
|
* from `@atlaskit/editor-core`.
|
|
@@ -172,9 +138,14 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
172
138
|
insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
173
139
|
},
|
|
174
140
|
nodes: function nodes() {
|
|
141
|
+
var _pluginConfig = (0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions),
|
|
142
|
+
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
175
143
|
return [{
|
|
176
144
|
name: 'table',
|
|
177
|
-
node:
|
|
145
|
+
node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
|
|
146
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
147
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled)
|
|
148
|
+
})
|
|
178
149
|
}, {
|
|
179
150
|
name: 'tableHeader',
|
|
180
151
|
node: _adfSchema.tableHeader
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.tableNodeSpecWithFixedToDOM = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _colgroup = require("./pm-plugins/table-resizing/utils/colgroup");
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
|
|
16
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_lazy-node-views')) {
|
|
17
|
+
return _adfSchema.table;
|
|
18
|
+
}
|
|
19
|
+
return _objectSpread(_objectSpread({}, _adfSchema.table), {}, {
|
|
20
|
+
toDOM: function toDOM(node) {
|
|
21
|
+
var attrs = {
|
|
22
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
23
|
+
'data-layout': node.attrs.layout,
|
|
24
|
+
'data-autosize': node.attrs.__autoSize,
|
|
25
|
+
'data-table-local-id': node.attrs.localId,
|
|
26
|
+
'data-table-width': node.attrs.width
|
|
27
|
+
};
|
|
28
|
+
var colgroup = '';
|
|
29
|
+
if (config.allowColumnResizing) {
|
|
30
|
+
colgroup = ['colgroup', {}].concat((0, _toConsumableArray2.default)((0, _colgroup.generateColgroup)(node)));
|
|
31
|
+
}
|
|
32
|
+
var tableContainerDiv = ['div', {
|
|
33
|
+
class: 'pm-table-container',
|
|
34
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
35
|
+
'data-layout': node.attrs.layout,
|
|
36
|
+
'data-testid': 'table-container'
|
|
37
|
+
}, ['div', {
|
|
38
|
+
class: 'pm-table-sticky-sentinel-top',
|
|
39
|
+
'data-testid': 'sticky-sentinel-top'
|
|
40
|
+
}], ['div', {
|
|
41
|
+
class: 'pm-table-row-controls-wrapper'
|
|
42
|
+
}, ['div']], ['div', {
|
|
43
|
+
class: 'pm-table-with-left-shadow'
|
|
44
|
+
}], ['div', {
|
|
45
|
+
class: 'pm-table-wrapper'
|
|
46
|
+
}, ['table', attrs, ['span', {
|
|
47
|
+
class: 'pm-table-shadow-sentinel-right'
|
|
48
|
+
}], ['span', {
|
|
49
|
+
class: 'pm-table-shadow-sentinel-left'
|
|
50
|
+
}], colgroup, ['tbody', 0]]], ['div', {
|
|
51
|
+
class: 'pm-table-with-right-shadow'
|
|
52
|
+
}], ['div', {
|
|
53
|
+
class: 'pm-table-sticky-sentinel-bottom',
|
|
54
|
+
'data-testid': 'sticky-sentinel-bottom'
|
|
55
|
+
}]];
|
|
56
|
+
if (!config.tableResizingEnabled) {
|
|
57
|
+
return ['div', {
|
|
58
|
+
class: 'tableView-content-wrap'
|
|
59
|
+
}, tableContainerDiv];
|
|
60
|
+
}
|
|
61
|
+
var tableResizingDiv = ['div', {
|
|
62
|
+
'data-testid': 'table-alignment-container'
|
|
63
|
+
}, ['div', {
|
|
64
|
+
class: 'pm-table-resizer-container'
|
|
65
|
+
}, ['div', {
|
|
66
|
+
class: 'resizer-item display-handle'
|
|
67
|
+
}, ['span', {
|
|
68
|
+
class: 'resizer-hover-zone'
|
|
69
|
+
}, tableContainerDiv]]]];
|
|
70
|
+
return ['div', {
|
|
71
|
+
class: 'tableView-content-wrap'
|
|
72
|
+
}, tableResizingDiv];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
5
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
@@ -26,10 +26,10 @@ import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pl
|
|
|
26
26
|
import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
|
|
27
27
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
28
28
|
import { createPlugin as createFlexiResizingPlugin, getPluginState as getFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
29
|
-
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
30
29
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
31
30
|
import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
32
31
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
32
|
+
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
33
33
|
import { getToolbarConfig } from './toolbar';
|
|
34
34
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
35
35
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
@@ -43,41 +43,6 @@ const defaultGetEditorFeatureFlags = () => ({});
|
|
|
43
43
|
|
|
44
44
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
45
45
|
|
|
46
|
-
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
47
|
-
const tableNodeSpecWithFixedToDOM = tableOptions => {
|
|
48
|
-
if (!fg('platform_editor_lazy-node-views')) {
|
|
49
|
-
return table;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
...table,
|
|
53
|
-
toDOM: node => {
|
|
54
|
-
const attrs = {
|
|
55
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
56
|
-
'data-layout': node.attrs.layout,
|
|
57
|
-
'data-autosize': node.attrs.__autoSize,
|
|
58
|
-
'data-table-local-id': node.attrs.localId,
|
|
59
|
-
'data-table-width': node.attrs.width
|
|
60
|
-
};
|
|
61
|
-
let colgroup = '';
|
|
62
|
-
const {
|
|
63
|
-
allowColumnResizing
|
|
64
|
-
} = pluginConfig(tableOptions);
|
|
65
|
-
if (allowColumnResizing) {
|
|
66
|
-
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
67
|
-
}
|
|
68
|
-
return ['div', {
|
|
69
|
-
class: 'tableView-content-wrap'
|
|
70
|
-
}, ['div', {
|
|
71
|
-
class: 'pm-table-container'
|
|
72
|
-
}, ['div', {
|
|
73
|
-
class: 'pm-table-wrapper',
|
|
74
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
75
|
-
'data-layout': node.attrs.layout
|
|
76
|
-
}, ['table', attrs, colgroup, ['tbody', 0]]]]];
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
46
|
/**
|
|
82
47
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
83
48
|
* from `@atlaskit/editor-core`.
|
|
@@ -162,9 +127,15 @@ const tablesPlugin = ({
|
|
|
162
127
|
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
163
128
|
},
|
|
164
129
|
nodes() {
|
|
130
|
+
const {
|
|
131
|
+
allowColumnResizing
|
|
132
|
+
} = pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions);
|
|
165
133
|
return [{
|
|
166
134
|
name: 'table',
|
|
167
|
-
node: tableNodeSpecWithFixedToDOM(
|
|
135
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
136
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
137
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled)
|
|
138
|
+
})
|
|
168
139
|
}, {
|
|
169
140
|
name: 'tableHeader',
|
|
170
141
|
node: tableHeader
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { table } from '@atlaskit/adf-schema';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
4
|
+
export const tableNodeSpecWithFixedToDOM = config => {
|
|
5
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
6
|
+
return table;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
...table,
|
|
10
|
+
toDOM: node => {
|
|
11
|
+
const attrs = {
|
|
12
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
13
|
+
'data-layout': node.attrs.layout,
|
|
14
|
+
'data-autosize': node.attrs.__autoSize,
|
|
15
|
+
'data-table-local-id': node.attrs.localId,
|
|
16
|
+
'data-table-width': node.attrs.width
|
|
17
|
+
};
|
|
18
|
+
let colgroup = '';
|
|
19
|
+
if (config.allowColumnResizing) {
|
|
20
|
+
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
21
|
+
}
|
|
22
|
+
const tableContainerDiv = ['div', {
|
|
23
|
+
class: 'pm-table-container',
|
|
24
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
25
|
+
'data-layout': node.attrs.layout,
|
|
26
|
+
'data-testid': 'table-container'
|
|
27
|
+
}, ['div', {
|
|
28
|
+
class: 'pm-table-sticky-sentinel-top',
|
|
29
|
+
'data-testid': 'sticky-sentinel-top'
|
|
30
|
+
}], ['div', {
|
|
31
|
+
class: 'pm-table-row-controls-wrapper'
|
|
32
|
+
}, ['div']], ['div', {
|
|
33
|
+
class: 'pm-table-with-left-shadow'
|
|
34
|
+
}], ['div', {
|
|
35
|
+
class: 'pm-table-wrapper'
|
|
36
|
+
}, ['table', attrs, ['span', {
|
|
37
|
+
class: 'pm-table-shadow-sentinel-right'
|
|
38
|
+
}], ['span', {
|
|
39
|
+
class: 'pm-table-shadow-sentinel-left'
|
|
40
|
+
}], colgroup, ['tbody', 0]]], ['div', {
|
|
41
|
+
class: 'pm-table-with-right-shadow'
|
|
42
|
+
}], ['div', {
|
|
43
|
+
class: 'pm-table-sticky-sentinel-bottom',
|
|
44
|
+
'data-testid': 'sticky-sentinel-bottom'
|
|
45
|
+
}]];
|
|
46
|
+
if (!config.tableResizingEnabled) {
|
|
47
|
+
return ['div', {
|
|
48
|
+
class: 'tableView-content-wrap'
|
|
49
|
+
}, tableContainerDiv];
|
|
50
|
+
}
|
|
51
|
+
const tableResizingDiv = ['div', {
|
|
52
|
+
'data-testid': 'table-alignment-container'
|
|
53
|
+
}, ['div', {
|
|
54
|
+
class: 'pm-table-resizer-container'
|
|
55
|
+
}, ['div', {
|
|
56
|
+
class: 'resizer-item display-handle'
|
|
57
|
+
}, ['span', {
|
|
58
|
+
class: 'resizer-hover-zone'
|
|
59
|
+
}, tableContainerDiv]]]];
|
|
60
|
+
return ['div', {
|
|
61
|
+
class: 'tableView-content-wrap'
|
|
62
|
+
}, tableResizingDiv];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
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; }
|
|
4
3
|
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) { _defineProperty(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; }
|
|
5
4
|
import React from 'react';
|
|
6
|
-
import {
|
|
5
|
+
import { tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
7
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
8
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
@@ -30,10 +29,10 @@ import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pl
|
|
|
30
29
|
import { createPlugin as createTableOverflowAnalyticsPlugin } from './pm-plugins/table-analytics';
|
|
31
30
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
32
31
|
import { createPlugin as createFlexiResizingPlugin, getPluginState as getFlexiResizingPlugin, pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
33
|
-
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
34
32
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
35
33
|
import { createPlugin as createTableWidthPlugin, pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
36
34
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
35
|
+
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
37
36
|
import { getToolbarConfig } from './toolbar';
|
|
38
37
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
39
38
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
@@ -49,39 +48,6 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
49
48
|
|
|
50
49
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
51
50
|
|
|
52
|
-
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
53
|
-
var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(tableOptions) {
|
|
54
|
-
if (!fg('platform_editor_lazy-node-views')) {
|
|
55
|
-
return table;
|
|
56
|
-
}
|
|
57
|
-
return _objectSpread(_objectSpread({}, table), {}, {
|
|
58
|
-
toDOM: function toDOM(node) {
|
|
59
|
-
var attrs = {
|
|
60
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
61
|
-
'data-layout': node.attrs.layout,
|
|
62
|
-
'data-autosize': node.attrs.__autoSize,
|
|
63
|
-
'data-table-local-id': node.attrs.localId,
|
|
64
|
-
'data-table-width': node.attrs.width
|
|
65
|
-
};
|
|
66
|
-
var colgroup = '';
|
|
67
|
-
var _pluginConfig = pluginConfig(tableOptions),
|
|
68
|
-
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
69
|
-
if (allowColumnResizing) {
|
|
70
|
-
colgroup = ['colgroup', {}].concat(_toConsumableArray(generateColgroup(node)));
|
|
71
|
-
}
|
|
72
|
-
return ['div', {
|
|
73
|
-
class: 'tableView-content-wrap'
|
|
74
|
-
}, ['div', {
|
|
75
|
-
class: 'pm-table-container'
|
|
76
|
-
}, ['div', {
|
|
77
|
-
class: 'pm-table-wrapper',
|
|
78
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
79
|
-
'data-layout': node.attrs.layout
|
|
80
|
-
}, ['table', attrs, colgroup, ['tbody', 0]]]]];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
|
|
85
51
|
/**
|
|
86
52
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
87
53
|
* from `@atlaskit/editor-core`.
|
|
@@ -165,9 +131,14 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
165
131
|
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.isTableAlignmentEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
166
132
|
},
|
|
167
133
|
nodes: function nodes() {
|
|
134
|
+
var _pluginConfig = pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions),
|
|
135
|
+
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
168
136
|
return [{
|
|
169
137
|
name: 'table',
|
|
170
|
-
node: tableNodeSpecWithFixedToDOM(
|
|
138
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
139
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
140
|
+
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableResizingEnabled)
|
|
141
|
+
})
|
|
171
142
|
}, {
|
|
172
143
|
name: 'tableHeader',
|
|
173
144
|
node: tableHeader
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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) { _defineProperty(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; }
|
|
5
|
+
import { table } from '@atlaskit/adf-schema';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
8
|
+
export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
|
|
9
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
10
|
+
return table;
|
|
11
|
+
}
|
|
12
|
+
return _objectSpread(_objectSpread({}, table), {}, {
|
|
13
|
+
toDOM: function toDOM(node) {
|
|
14
|
+
var attrs = {
|
|
15
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
16
|
+
'data-layout': node.attrs.layout,
|
|
17
|
+
'data-autosize': node.attrs.__autoSize,
|
|
18
|
+
'data-table-local-id': node.attrs.localId,
|
|
19
|
+
'data-table-width': node.attrs.width
|
|
20
|
+
};
|
|
21
|
+
var colgroup = '';
|
|
22
|
+
if (config.allowColumnResizing) {
|
|
23
|
+
colgroup = ['colgroup', {}].concat(_toConsumableArray(generateColgroup(node)));
|
|
24
|
+
}
|
|
25
|
+
var tableContainerDiv = ['div', {
|
|
26
|
+
class: 'pm-table-container',
|
|
27
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
28
|
+
'data-layout': node.attrs.layout,
|
|
29
|
+
'data-testid': 'table-container'
|
|
30
|
+
}, ['div', {
|
|
31
|
+
class: 'pm-table-sticky-sentinel-top',
|
|
32
|
+
'data-testid': 'sticky-sentinel-top'
|
|
33
|
+
}], ['div', {
|
|
34
|
+
class: 'pm-table-row-controls-wrapper'
|
|
35
|
+
}, ['div']], ['div', {
|
|
36
|
+
class: 'pm-table-with-left-shadow'
|
|
37
|
+
}], ['div', {
|
|
38
|
+
class: 'pm-table-wrapper'
|
|
39
|
+
}, ['table', attrs, ['span', {
|
|
40
|
+
class: 'pm-table-shadow-sentinel-right'
|
|
41
|
+
}], ['span', {
|
|
42
|
+
class: 'pm-table-shadow-sentinel-left'
|
|
43
|
+
}], colgroup, ['tbody', 0]]], ['div', {
|
|
44
|
+
class: 'pm-table-with-right-shadow'
|
|
45
|
+
}], ['div', {
|
|
46
|
+
class: 'pm-table-sticky-sentinel-bottom',
|
|
47
|
+
'data-testid': 'sticky-sentinel-bottom'
|
|
48
|
+
}]];
|
|
49
|
+
if (!config.tableResizingEnabled) {
|
|
50
|
+
return ['div', {
|
|
51
|
+
class: 'tableView-content-wrap'
|
|
52
|
+
}, tableContainerDiv];
|
|
53
|
+
}
|
|
54
|
+
var tableResizingDiv = ['div', {
|
|
55
|
+
'data-testid': 'table-alignment-container'
|
|
56
|
+
}, ['div', {
|
|
57
|
+
class: 'pm-table-resizer-container'
|
|
58
|
+
}, ['div', {
|
|
59
|
+
class: 'resizer-item display-handle'
|
|
60
|
+
}, ['span', {
|
|
61
|
+
class: 'resizer-hover-zone'
|
|
62
|
+
}, tableContainerDiv]]]];
|
|
63
|
+
return ['div', {
|
|
64
|
+
class: 'tableView-content-wrap'
|
|
65
|
+
}, tableResizingDiv];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.24.
|
|
3
|
+
"version": "7.24.6",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/adf-schema": "^40.3.0",
|
|
32
32
|
"@atlaskit/button": "^19.1.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.6.0",
|
|
34
|
-
"@atlaskit/editor-common": "^87.
|
|
34
|
+
"@atlaskit/editor-common": "^87.4.0",
|
|
35
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
36
36
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.6.0",
|
package/src/plugin.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
4
4
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import {
|
|
6
6
|
ACTION,
|
|
@@ -34,7 +34,6 @@ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
|
34
34
|
import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
35
35
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
36
36
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
37
|
-
import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
38
37
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
39
38
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
40
39
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -67,13 +66,13 @@ import {
|
|
|
67
66
|
getPluginState as getFlexiResizingPlugin,
|
|
68
67
|
pluginKey as tableResizingPluginKey,
|
|
69
68
|
} from './pm-plugins/table-resizing';
|
|
70
|
-
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
71
69
|
import { tableSelectionKeymapPlugin } from './pm-plugins/table-selection-keymap';
|
|
72
70
|
import {
|
|
73
71
|
createPlugin as createTableWidthPlugin,
|
|
74
72
|
pluginKey as tableWidthPluginKey,
|
|
75
73
|
} from './pm-plugins/table-width';
|
|
76
74
|
import { createPlugin as createViewModeSortPlugin } from './pm-plugins/view-mode-sort';
|
|
75
|
+
import { tableNodeSpecWithFixedToDOM } from './toDOM';
|
|
77
76
|
import { getToolbarConfig } from './toolbar';
|
|
78
77
|
import type { ColumnResizingPluginState, PluginConfig, TableSharedState } from './types';
|
|
79
78
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
@@ -145,55 +144,6 @@ export type TablePlugin = NextEditorPlugin<
|
|
|
145
144
|
}
|
|
146
145
|
>;
|
|
147
146
|
|
|
148
|
-
// TODO: ED-23944 Move this override to `toDOM` function on table adf-schema nodespec
|
|
149
|
-
const tableNodeSpecWithFixedToDOM = (tableOptions?: PluginConfig): typeof table => {
|
|
150
|
-
if (!fg('platform_editor_lazy-node-views')) {
|
|
151
|
-
return table;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
...table,
|
|
156
|
-
toDOM: (node: PMNode): DOMOutputSpec => {
|
|
157
|
-
const attrs = {
|
|
158
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
159
|
-
'data-layout': node.attrs.layout,
|
|
160
|
-
'data-autosize': node.attrs.__autoSize,
|
|
161
|
-
'data-table-local-id': node.attrs.localId,
|
|
162
|
-
'data-table-width': node.attrs.width,
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
let colgroup: DOMOutputSpec = '';
|
|
166
|
-
|
|
167
|
-
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
168
|
-
if (allowColumnResizing) {
|
|
169
|
-
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return [
|
|
173
|
-
'div',
|
|
174
|
-
{
|
|
175
|
-
class: 'tableView-content-wrap',
|
|
176
|
-
},
|
|
177
|
-
[
|
|
178
|
-
'div',
|
|
179
|
-
{
|
|
180
|
-
class: 'pm-table-container',
|
|
181
|
-
},
|
|
182
|
-
[
|
|
183
|
-
'div',
|
|
184
|
-
{
|
|
185
|
-
class: 'pm-table-wrapper',
|
|
186
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
187
|
-
'data-layout': node.attrs.layout,
|
|
188
|
-
},
|
|
189
|
-
['table', attrs, colgroup, ['tbody', 0]],
|
|
190
|
-
],
|
|
191
|
-
],
|
|
192
|
-
];
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
|
|
197
147
|
/**
|
|
198
148
|
* Table plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
199
149
|
* from `@atlaskit/editor-core`.
|
|
@@ -300,8 +250,16 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
300
250
|
},
|
|
301
251
|
|
|
302
252
|
nodes() {
|
|
253
|
+
const { allowColumnResizing } = pluginConfig(options?.tableOptions);
|
|
254
|
+
|
|
303
255
|
return [
|
|
304
|
-
{
|
|
256
|
+
{
|
|
257
|
+
name: 'table',
|
|
258
|
+
node: tableNodeSpecWithFixedToDOM({
|
|
259
|
+
allowColumnResizing: Boolean(allowColumnResizing),
|
|
260
|
+
tableResizingEnabled: Boolean(options?.tableResizingEnabled),
|
|
261
|
+
}),
|
|
262
|
+
},
|
|
305
263
|
{ name: 'tableHeader', node: tableHeader },
|
|
306
264
|
{ name: 'tableRow', node: tableRow },
|
|
307
265
|
{ name: 'tableCell', node: tableCell },
|
package/src/toDOM.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { table } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
|
|
5
|
+
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
6
|
+
|
|
7
|
+
type Config = {
|
|
8
|
+
allowColumnResizing: boolean;
|
|
9
|
+
tableResizingEnabled: boolean;
|
|
10
|
+
};
|
|
11
|
+
export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
|
|
12
|
+
if (!fg('platform_editor_lazy-node-views')) {
|
|
13
|
+
return table;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
...table,
|
|
18
|
+
toDOM: (node: PMNode): DOMOutputSpec => {
|
|
19
|
+
const attrs = {
|
|
20
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
21
|
+
'data-layout': node.attrs.layout,
|
|
22
|
+
'data-autosize': node.attrs.__autoSize,
|
|
23
|
+
'data-table-local-id': node.attrs.localId,
|
|
24
|
+
'data-table-width': node.attrs.width,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let colgroup: DOMOutputSpec = '';
|
|
28
|
+
|
|
29
|
+
if (config.allowColumnResizing) {
|
|
30
|
+
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const tableContainerDiv = [
|
|
34
|
+
'div',
|
|
35
|
+
{
|
|
36
|
+
class: 'pm-table-container',
|
|
37
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
38
|
+
'data-layout': node.attrs.layout,
|
|
39
|
+
'data-testid': 'table-container',
|
|
40
|
+
},
|
|
41
|
+
[
|
|
42
|
+
'div',
|
|
43
|
+
{
|
|
44
|
+
class: 'pm-table-sticky-sentinel-top',
|
|
45
|
+
'data-testid': 'sticky-sentinel-top',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
'div',
|
|
50
|
+
{
|
|
51
|
+
class: 'pm-table-row-controls-wrapper',
|
|
52
|
+
},
|
|
53
|
+
['div'],
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
'div',
|
|
57
|
+
{
|
|
58
|
+
class: 'pm-table-with-left-shadow',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
'div',
|
|
63
|
+
{
|
|
64
|
+
class: 'pm-table-wrapper',
|
|
65
|
+
},
|
|
66
|
+
[
|
|
67
|
+
'table',
|
|
68
|
+
attrs,
|
|
69
|
+
['span', { class: 'pm-table-shadow-sentinel-right' }],
|
|
70
|
+
['span', { class: 'pm-table-shadow-sentinel-left' }],
|
|
71
|
+
colgroup,
|
|
72
|
+
['tbody', 0],
|
|
73
|
+
],
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
'div',
|
|
77
|
+
{
|
|
78
|
+
class: 'pm-table-with-right-shadow',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
'div',
|
|
83
|
+
{
|
|
84
|
+
class: 'pm-table-sticky-sentinel-bottom',
|
|
85
|
+
'data-testid': 'sticky-sentinel-bottom',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
if (!config.tableResizingEnabled) {
|
|
91
|
+
return [
|
|
92
|
+
'div',
|
|
93
|
+
{
|
|
94
|
+
class: 'tableView-content-wrap',
|
|
95
|
+
},
|
|
96
|
+
tableContainerDiv,
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const tableResizingDiv = [
|
|
101
|
+
'div',
|
|
102
|
+
{
|
|
103
|
+
'data-testid': 'table-alignment-container',
|
|
104
|
+
},
|
|
105
|
+
[
|
|
106
|
+
'div',
|
|
107
|
+
{
|
|
108
|
+
class: 'pm-table-resizer-container',
|
|
109
|
+
},
|
|
110
|
+
[
|
|
111
|
+
'div',
|
|
112
|
+
{
|
|
113
|
+
class: 'resizer-item display-handle',
|
|
114
|
+
},
|
|
115
|
+
[
|
|
116
|
+
'span',
|
|
117
|
+
{
|
|
118
|
+
class: 'resizer-hover-zone',
|
|
119
|
+
},
|
|
120
|
+
tableContainerDiv,
|
|
121
|
+
],
|
|
122
|
+
],
|
|
123
|
+
],
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
return [
|
|
127
|
+
'div',
|
|
128
|
+
{
|
|
129
|
+
class: 'tableView-content-wrap',
|
|
130
|
+
},
|
|
131
|
+
tableResizingDiv,
|
|
132
|
+
];
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
};
|