@atlaskit/editor-plugin-table 7.24.5 → 7.24.7
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 +18 -0
- package/dist/cjs/nodeviews/TableCell.js +12 -3
- package/dist/cjs/nodeviews/lazy-node-views.js +12 -6
- package/dist/cjs/plugin.js +7 -36
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/toDOM.js +75 -0
- package/dist/es2019/nodeviews/TableCell.js +12 -3
- package/dist/es2019/nodeviews/lazy-node-views.js +12 -6
- package/dist/es2019/plugin.js +9 -38
- package/dist/es2019/pm-plugins/main.js +4 -2
- package/dist/es2019/toDOM.js +65 -0
- package/dist/esm/nodeviews/TableCell.js +12 -3
- package/dist/esm/nodeviews/lazy-node-views.js +12 -6
- package/dist/esm/plugin.js +8 -37
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/toDOM.js +68 -0
- package/dist/types/nodeviews/TableCell.d.ts +2 -1
- package/dist/types/nodeviews/lazy-node-views.d.ts +1 -0
- package/dist/types/toDOM.d.ts +7 -0
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +1 -0
- package/dist/types-ts4.5/toDOM.d.ts +7 -0
- package/package.json +2 -2
- package/src/nodeviews/TableCell.ts +18 -6
- package/src/nodeviews/lazy-node-views.ts +31 -6
- package/src/plugin.tsx +11 -53
- package/src/pm-plugins/main.ts +2 -2
- package/src/toDOM.ts +135 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.24.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#127699](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127699)
|
|
8
|
+
[`7fa3a110dc3b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7fa3a110dc3b6) -
|
|
9
|
+
Add analytics to track usage of dark mode header cell fix.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 7.24.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#127242](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127242)
|
|
17
|
+
[`508ee8b4dcbc8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/508ee8b4dcbc8) -
|
|
18
|
+
[ED-23944] Improve toDOM helper test
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 7.24.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
17
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
17
18
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
19
|
var _TableNodeViewBase = _interopRequireDefault(require("./TableNodeViewBase"));
|
|
19
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -45,7 +46,7 @@ var cssVariablePattern = /^VAR\(--.*\)$/;
|
|
|
45
46
|
var TableCell = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
46
47
|
(0, _inherits2.default)(TableCell, _TableNodeView);
|
|
47
48
|
var _super = _createSuper(TableCell);
|
|
48
|
-
function TableCell(node, view, getPos, eventDispatcher) {
|
|
49
|
+
function TableCell(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
|
|
49
50
|
var _this;
|
|
50
51
|
(0, _classCallCheck2.default)(this, TableCell);
|
|
51
52
|
_this = _super.call(this, node, view, getPos, eventDispatcher);
|
|
@@ -72,9 +73,17 @@ var TableCell = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
72
73
|
_this.delayHandle = delayUntilIdle(function () {
|
|
73
74
|
var pos = getPos();
|
|
74
75
|
if (pos) {
|
|
75
|
-
view.
|
|
76
|
+
var tr = view.state.tr;
|
|
77
|
+
tr.setNodeAttribute(pos, 'background', node.attrs.background.toLowerCase())
|
|
76
78
|
// Ensures dispatch does not contribute to undo history (otherwise user requires multiple undo's to revert table)
|
|
77
|
-
.setMeta('addToHistory', false)
|
|
79
|
+
.setMeta('addToHistory', false);
|
|
80
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
81
|
+
action: _analytics.TABLE_ACTION.TABLE_CELL_BACKGROUND_FIXED,
|
|
82
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
83
|
+
actionSubjectId: null,
|
|
84
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
85
|
+
})(tr);
|
|
86
|
+
view.dispatch(tr);
|
|
78
87
|
}
|
|
79
88
|
});
|
|
80
89
|
}
|
|
@@ -52,7 +52,8 @@ var lazyTableView = exports.lazyTableView = function lazyTableView(options) {
|
|
|
52
52
|
var lazyTableCellView = exports.lazyTableCellView = function lazyTableCellView(options) {
|
|
53
53
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_lazy-node-views')) {
|
|
54
54
|
return function (node, view, getPos) {
|
|
55
|
-
|
|
55
|
+
var _options$pluginInject;
|
|
56
|
+
return new _TableCell.default(node, view, getPos, options.eventDispatcher, (_options$pluginInject = options.pluginInjectionApi) === null || _options$pluginInject === void 0 || (_options$pluginInject = _options$pluginInject.analytics) === null || _options$pluginInject === void 0 ? void 0 : _options$pluginInject.actions);
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
var loader = function loader() {
|
|
@@ -62,9 +63,11 @@ var lazyTableCellView = exports.lazyTableCellView = function lazyTableCellView(o
|
|
|
62
63
|
}).then(function (_ref2) {
|
|
63
64
|
var TableCell = _ref2.default;
|
|
64
65
|
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
66
|
+
var _pluginInjectionApi$a;
|
|
65
67
|
var _getNodeViewOptions2 = getNodeViewOptions(),
|
|
66
|
-
eventDispatcher = _getNodeViewOptions2.eventDispatcher
|
|
67
|
-
|
|
68
|
+
eventDispatcher = _getNodeViewOptions2.eventDispatcher,
|
|
69
|
+
pluginInjectionApi = _getNodeViewOptions2.pluginInjectionApi;
|
|
70
|
+
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
|
|
68
71
|
};
|
|
69
72
|
});
|
|
70
73
|
return result;
|
|
@@ -80,7 +83,8 @@ var lazyTableCellView = exports.lazyTableCellView = function lazyTableCellView(o
|
|
|
80
83
|
var lazyTableHeaderView = exports.lazyTableHeaderView = function lazyTableHeaderView(options) {
|
|
81
84
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_lazy-node-views')) {
|
|
82
85
|
return function (node, view, getPos) {
|
|
83
|
-
|
|
86
|
+
var _options$pluginInject2;
|
|
87
|
+
return new _TableCell.default(node, view, getPos, options.eventDispatcher, (_options$pluginInject2 = options.pluginInjectionApi) === null || _options$pluginInject2 === void 0 || (_options$pluginInject2 = _options$pluginInject2.analytics) === null || _options$pluginInject2 === void 0 ? void 0 : _options$pluginInject2.actions);
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
var loader = function loader() {
|
|
@@ -90,9 +94,11 @@ var lazyTableHeaderView = exports.lazyTableHeaderView = function lazyTableHeader
|
|
|
90
94
|
}).then(function (_ref3) {
|
|
91
95
|
var TableCell = _ref3.default;
|
|
92
96
|
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
97
|
+
var _pluginInjectionApi$a2;
|
|
93
98
|
var _getNodeViewOptions3 = getNodeViewOptions(),
|
|
94
|
-
eventDispatcher = _getNodeViewOptions3.eventDispatcher
|
|
95
|
-
|
|
99
|
+
eventDispatcher = _getNodeViewOptions3.eventDispatcher,
|
|
100
|
+
pluginInjectionApi = _getNodeViewOptions3.pluginInjectionApi;
|
|
101
|
+
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions);
|
|
96
102
|
};
|
|
97
103
|
});
|
|
98
104
|
return result;
|
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
|
|
@@ -267,10 +267,12 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
267
267
|
eventDispatcher: eventDispatcher
|
|
268
268
|
}),
|
|
269
269
|
tableCell: (0, _lazyNodeViews.lazyTableCellView)({
|
|
270
|
-
eventDispatcher: eventDispatcher
|
|
270
|
+
eventDispatcher: eventDispatcher,
|
|
271
|
+
pluginInjectionApi: pluginInjectionApi
|
|
271
272
|
}),
|
|
272
273
|
tableHeader: (0, _lazyNodeViews.lazyTableHeaderView)({
|
|
273
|
-
eventDispatcher: eventDispatcher
|
|
274
|
+
eventDispatcher: eventDispatcher,
|
|
275
|
+
pluginInjectionApi: pluginInjectionApi
|
|
274
276
|
})
|
|
275
277
|
},
|
|
276
278
|
handleDOMEvents: {
|
|
@@ -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
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
3
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import TableNodeView from './TableNodeViewBase';
|
|
5
6
|
const DEFAULT_COL_SPAN = 1;
|
|
@@ -23,7 +24,7 @@ function delayUntilIdle(cb) {
|
|
|
23
24
|
}
|
|
24
25
|
const cssVariablePattern = /^VAR\(--.*\)$/;
|
|
25
26
|
export default class TableCell extends TableNodeView {
|
|
26
|
-
constructor(node, view, getPos, eventDispatcher) {
|
|
27
|
+
constructor(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
|
|
27
28
|
super(node, view, getPos, eventDispatcher);
|
|
28
29
|
|
|
29
30
|
// CONFCLOUD-78239: Previously we had a bug which tried to invert the heading colour of a table
|
|
@@ -48,9 +49,17 @@ export default class TableCell extends TableNodeView {
|
|
|
48
49
|
this.delayHandle = delayUntilIdle(() => {
|
|
49
50
|
const pos = getPos();
|
|
50
51
|
if (pos) {
|
|
51
|
-
view.
|
|
52
|
+
const tr = view.state.tr;
|
|
53
|
+
tr.setNodeAttribute(pos, 'background', node.attrs.background.toLowerCase())
|
|
52
54
|
// Ensures dispatch does not contribute to undo history (otherwise user requires multiple undo's to revert table)
|
|
53
|
-
.setMeta('addToHistory', false)
|
|
55
|
+
.setMeta('addToHistory', false);
|
|
56
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
57
|
+
action: TABLE_ACTION.TABLE_CELL_BACKGROUND_FIXED,
|
|
58
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
59
|
+
actionSubjectId: null,
|
|
60
|
+
eventType: EVENT_TYPE.TRACK
|
|
61
|
+
})(tr);
|
|
62
|
+
view.dispatch(tr);
|
|
54
63
|
}
|
|
55
64
|
});
|
|
56
65
|
}
|
|
@@ -41,7 +41,8 @@ export const lazyTableView = options => {
|
|
|
41
41
|
export const lazyTableCellView = options => {
|
|
42
42
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
43
43
|
return (node, view, getPos) => {
|
|
44
|
-
|
|
44
|
+
var _options$pluginInject, _options$pluginInject2;
|
|
45
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject = options.pluginInjectionApi) === null || _options$pluginInject === void 0 ? void 0 : (_options$pluginInject2 = _options$pluginInject.analytics) === null || _options$pluginInject2 === void 0 ? void 0 : _options$pluginInject2.actions);
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
const loader = () => {
|
|
@@ -50,10 +51,12 @@ export const lazyTableCellView = options => {
|
|
|
50
51
|
default: TableCell
|
|
51
52
|
}) => {
|
|
52
53
|
return (node, view, getPos, decorations, getNodeViewOptions) => {
|
|
54
|
+
var _pluginInjectionApi$a;
|
|
53
55
|
const {
|
|
54
|
-
eventDispatcher
|
|
56
|
+
eventDispatcher,
|
|
57
|
+
pluginInjectionApi
|
|
55
58
|
} = getNodeViewOptions();
|
|
56
|
-
return new TableCell(node, view, getPos, eventDispatcher);
|
|
59
|
+
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
|
|
57
60
|
};
|
|
58
61
|
});
|
|
59
62
|
return result;
|
|
@@ -67,7 +70,8 @@ export const lazyTableCellView = options => {
|
|
|
67
70
|
export const lazyTableHeaderView = options => {
|
|
68
71
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
69
72
|
return (node, view, getPos) => {
|
|
70
|
-
|
|
73
|
+
var _options$pluginInject3, _options$pluginInject4;
|
|
74
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject3 = options.pluginInjectionApi) === null || _options$pluginInject3 === void 0 ? void 0 : (_options$pluginInject4 = _options$pluginInject3.analytics) === null || _options$pluginInject4 === void 0 ? void 0 : _options$pluginInject4.actions);
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
77
|
const loader = () => {
|
|
@@ -76,10 +80,12 @@ export const lazyTableHeaderView = options => {
|
|
|
76
80
|
default: TableCell
|
|
77
81
|
}) => {
|
|
78
82
|
return (node, view, getPos, decorations, getNodeViewOptions) => {
|
|
83
|
+
var _pluginInjectionApi$a2;
|
|
79
84
|
const {
|
|
80
|
-
eventDispatcher
|
|
85
|
+
eventDispatcher,
|
|
86
|
+
pluginInjectionApi
|
|
81
87
|
} = getNodeViewOptions();
|
|
82
|
-
return new TableCell(node, view, getPos, eventDispatcher);
|
|
88
|
+
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions);
|
|
83
89
|
};
|
|
84
90
|
});
|
|
85
91
|
return result;
|
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
|
|
@@ -265,10 +265,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
265
265
|
eventDispatcher
|
|
266
266
|
}),
|
|
267
267
|
tableCell: lazyTableCellView({
|
|
268
|
-
eventDispatcher
|
|
268
|
+
eventDispatcher,
|
|
269
|
+
pluginInjectionApi
|
|
269
270
|
}),
|
|
270
271
|
tableHeader: lazyTableHeaderView({
|
|
271
|
-
eventDispatcher
|
|
272
|
+
eventDispatcher,
|
|
273
|
+
pluginInjectionApi
|
|
272
274
|
})
|
|
273
275
|
},
|
|
274
276
|
handleDOMEvents: {
|
|
@@ -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
|
+
};
|
|
@@ -9,6 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
12
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
12
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import TableNodeView from './TableNodeViewBase';
|
|
14
15
|
var DEFAULT_COL_SPAN = 1;
|
|
@@ -38,7 +39,7 @@ var cssVariablePattern = /^VAR\(--.*\)$/;
|
|
|
38
39
|
var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
39
40
|
_inherits(TableCell, _TableNodeView);
|
|
40
41
|
var _super = _createSuper(TableCell);
|
|
41
|
-
function TableCell(node, view, getPos, eventDispatcher) {
|
|
42
|
+
function TableCell(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
|
|
42
43
|
var _this;
|
|
43
44
|
_classCallCheck(this, TableCell);
|
|
44
45
|
_this = _super.call(this, node, view, getPos, eventDispatcher);
|
|
@@ -65,9 +66,17 @@ var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
|
65
66
|
_this.delayHandle = delayUntilIdle(function () {
|
|
66
67
|
var pos = getPos();
|
|
67
68
|
if (pos) {
|
|
68
|
-
view.
|
|
69
|
+
var tr = view.state.tr;
|
|
70
|
+
tr.setNodeAttribute(pos, 'background', node.attrs.background.toLowerCase())
|
|
69
71
|
// Ensures dispatch does not contribute to undo history (otherwise user requires multiple undo's to revert table)
|
|
70
|
-
.setMeta('addToHistory', false)
|
|
72
|
+
.setMeta('addToHistory', false);
|
|
73
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
74
|
+
action: TABLE_ACTION.TABLE_CELL_BACKGROUND_FIXED,
|
|
75
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
76
|
+
actionSubjectId: null,
|
|
77
|
+
eventType: EVENT_TYPE.TRACK
|
|
78
|
+
})(tr);
|
|
79
|
+
view.dispatch(tr);
|
|
71
80
|
}
|
|
72
81
|
});
|
|
73
82
|
}
|
|
@@ -41,7 +41,8 @@ export var lazyTableView = function lazyTableView(options) {
|
|
|
41
41
|
export var lazyTableCellView = function lazyTableCellView(options) {
|
|
42
42
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
43
43
|
return function (node, view, getPos) {
|
|
44
|
-
|
|
44
|
+
var _options$pluginInject;
|
|
45
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject = options.pluginInjectionApi) === null || _options$pluginInject === void 0 || (_options$pluginInject = _options$pluginInject.analytics) === null || _options$pluginInject === void 0 ? void 0 : _options$pluginInject.actions);
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
var loader = function loader() {
|
|
@@ -49,9 +50,11 @@ export var lazyTableCellView = function lazyTableCellView(options) {
|
|
|
49
50
|
'./TableCell').then(function (_ref2) {
|
|
50
51
|
var TableCell = _ref2.default;
|
|
51
52
|
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
53
|
+
var _pluginInjectionApi$a;
|
|
52
54
|
var _getNodeViewOptions2 = getNodeViewOptions(),
|
|
53
|
-
eventDispatcher = _getNodeViewOptions2.eventDispatcher
|
|
54
|
-
|
|
55
|
+
eventDispatcher = _getNodeViewOptions2.eventDispatcher,
|
|
56
|
+
pluginInjectionApi = _getNodeViewOptions2.pluginInjectionApi;
|
|
57
|
+
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
|
|
55
58
|
};
|
|
56
59
|
});
|
|
57
60
|
return result;
|
|
@@ -67,7 +70,8 @@ export var lazyTableCellView = function lazyTableCellView(options) {
|
|
|
67
70
|
export var lazyTableHeaderView = function lazyTableHeaderView(options) {
|
|
68
71
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
69
72
|
return function (node, view, getPos) {
|
|
70
|
-
|
|
73
|
+
var _options$pluginInject2;
|
|
74
|
+
return new TableCell(node, view, getPos, options.eventDispatcher, (_options$pluginInject2 = options.pluginInjectionApi) === null || _options$pluginInject2 === void 0 || (_options$pluginInject2 = _options$pluginInject2.analytics) === null || _options$pluginInject2 === void 0 ? void 0 : _options$pluginInject2.actions);
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
77
|
var loader = function loader() {
|
|
@@ -75,9 +79,11 @@ export var lazyTableHeaderView = function lazyTableHeaderView(options) {
|
|
|
75
79
|
'./TableCell').then(function (_ref3) {
|
|
76
80
|
var TableCell = _ref3.default;
|
|
77
81
|
return function (node, view, getPos, decorations, getNodeViewOptions) {
|
|
82
|
+
var _pluginInjectionApi$a2;
|
|
78
83
|
var _getNodeViewOptions3 = getNodeViewOptions(),
|
|
79
|
-
eventDispatcher = _getNodeViewOptions3.eventDispatcher
|
|
80
|
-
|
|
84
|
+
eventDispatcher = _getNodeViewOptions3.eventDispatcher,
|
|
85
|
+
pluginInjectionApi = _getNodeViewOptions3.pluginInjectionApi;
|
|
86
|
+
return new TableCell(node, view, getPos, eventDispatcher, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions);
|
|
81
87
|
};
|
|
82
88
|
});
|
|
83
89
|
return result;
|
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
|
|
@@ -260,10 +260,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
260
260
|
eventDispatcher: eventDispatcher
|
|
261
261
|
}),
|
|
262
262
|
tableCell: lazyTableCellView({
|
|
263
|
-
eventDispatcher: eventDispatcher
|
|
263
|
+
eventDispatcher: eventDispatcher,
|
|
264
|
+
pluginInjectionApi: pluginInjectionApi
|
|
264
265
|
}),
|
|
265
266
|
tableHeader: lazyTableHeaderView({
|
|
266
|
-
eventDispatcher: eventDispatcher
|
|
267
|
+
eventDispatcher: eventDispatcher,
|
|
268
|
+
pluginInjectionApi: pluginInjectionApi
|
|
267
269
|
})
|
|
268
270
|
},
|
|
269
271
|
handleDOMEvents: {
|
|
@@ -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
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
import TableNodeView from './TableNodeViewBase';
|
|
5
6
|
export default class TableCell extends TableNodeView<HTMLElement> implements NodeView {
|
|
6
7
|
private delayHandle;
|
|
7
|
-
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher);
|
|
8
|
+
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, editorAnalyticsAPI: EditorAnalyticsAPI | undefined);
|
|
8
9
|
destroy: () => void;
|
|
9
10
|
update(node: PMNode): boolean;
|
|
10
11
|
private updateNodeView;
|
|
@@ -21,6 +21,7 @@ type TableViewOptions = {
|
|
|
21
21
|
export declare const lazyTableView: (options: TableViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
|
|
22
22
|
type TableCellViewOptions = {
|
|
23
23
|
eventDispatcher: EventDispatcher;
|
|
24
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
25
|
};
|
|
25
26
|
export declare const lazyTableCellView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
26
27
|
export declare const lazyTableHeaderView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
import TableNodeView from './TableNodeViewBase';
|
|
5
6
|
export default class TableCell extends TableNodeView<HTMLElement> implements NodeView {
|
|
6
7
|
private delayHandle;
|
|
7
|
-
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher);
|
|
8
|
+
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined, eventDispatcher: EventDispatcher, editorAnalyticsAPI: EditorAnalyticsAPI | undefined);
|
|
8
9
|
destroy: () => void;
|
|
9
10
|
update(node: PMNode): boolean;
|
|
10
11
|
private updateNodeView;
|
|
@@ -21,6 +21,7 @@ type TableViewOptions = {
|
|
|
21
21
|
export declare const lazyTableView: (options: TableViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
|
|
22
22
|
type TableCellViewOptions = {
|
|
23
23
|
eventDispatcher: EventDispatcher;
|
|
24
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
25
|
};
|
|
25
26
|
export declare const lazyTableCellView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
|
26
27
|
export declare const lazyTableHeaderView: (options: TableCellViewOptions) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor | ((node: PMNode, view: EditorView, getPos: () => number | undefined) => TableCell);
|
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.7",
|
|
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.5.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",
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { CellDomAttrs } from '@atlaskit/adf-schema';
|
|
2
2
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
3
|
+
import {
|
|
4
|
+
ACTION_SUBJECT,
|
|
5
|
+
type EditorAnalyticsAPI,
|
|
6
|
+
EVENT_TYPE,
|
|
7
|
+
TABLE_ACTION,
|
|
8
|
+
} from '@atlaskit/editor-common/analytics';
|
|
3
9
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
10
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
11
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -35,6 +41,7 @@ export default class TableCell extends TableNodeView<HTMLElement> implements Nod
|
|
|
35
41
|
view: EditorView,
|
|
36
42
|
getPos: () => number | undefined,
|
|
37
43
|
eventDispatcher: EventDispatcher,
|
|
44
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined,
|
|
38
45
|
) {
|
|
39
46
|
super(node, view, getPos, eventDispatcher);
|
|
40
47
|
|
|
@@ -55,12 +62,17 @@ export default class TableCell extends TableNodeView<HTMLElement> implements Nod
|
|
|
55
62
|
this.delayHandle = delayUntilIdle(() => {
|
|
56
63
|
const pos = getPos();
|
|
57
64
|
if (pos) {
|
|
58
|
-
view.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
const tr = view.state.tr;
|
|
66
|
+
tr.setNodeAttribute(pos, 'background', node.attrs.background.toLowerCase())
|
|
67
|
+
// Ensures dispatch does not contribute to undo history (otherwise user requires multiple undo's to revert table)
|
|
68
|
+
.setMeta('addToHistory', false);
|
|
69
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
70
|
+
action: TABLE_ACTION.TABLE_CELL_BACKGROUND_FIXED,
|
|
71
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
72
|
+
actionSubjectId: null,
|
|
73
|
+
eventType: EVENT_TYPE.TRACK,
|
|
74
|
+
})(tr);
|
|
75
|
+
view.dispatch(tr);
|
|
64
76
|
}
|
|
65
77
|
});
|
|
66
78
|
}
|
|
@@ -98,11 +98,18 @@ export const lazyTableView = (options: TableViewOptions) => {
|
|
|
98
98
|
|
|
99
99
|
type TableCellViewOptions = {
|
|
100
100
|
eventDispatcher: EventDispatcher;
|
|
101
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
101
102
|
};
|
|
102
103
|
export const lazyTableCellView = (options: TableCellViewOptions) => {
|
|
103
104
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
104
105
|
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
105
|
-
return new TableCell(
|
|
106
|
+
return new TableCell(
|
|
107
|
+
node,
|
|
108
|
+
view,
|
|
109
|
+
getPos,
|
|
110
|
+
options.eventDispatcher,
|
|
111
|
+
options.pluginInjectionApi?.analytics?.actions,
|
|
112
|
+
);
|
|
106
113
|
};
|
|
107
114
|
}
|
|
108
115
|
|
|
@@ -118,9 +125,15 @@ export const lazyTableCellView = (options: TableCellViewOptions) => {
|
|
|
118
125
|
decorations: readonly Decoration[],
|
|
119
126
|
getNodeViewOptions: () => TableCellViewOptions,
|
|
120
127
|
) => {
|
|
121
|
-
const { eventDispatcher } = getNodeViewOptions();
|
|
128
|
+
const { eventDispatcher, pluginInjectionApi } = getNodeViewOptions();
|
|
122
129
|
|
|
123
|
-
return new TableCell(
|
|
130
|
+
return new TableCell(
|
|
131
|
+
node,
|
|
132
|
+
view,
|
|
133
|
+
getPos,
|
|
134
|
+
eventDispatcher,
|
|
135
|
+
pluginInjectionApi?.analytics?.actions,
|
|
136
|
+
);
|
|
124
137
|
};
|
|
125
138
|
});
|
|
126
139
|
|
|
@@ -137,7 +150,13 @@ export const lazyTableCellView = (options: TableCellViewOptions) => {
|
|
|
137
150
|
export const lazyTableHeaderView = (options: TableCellViewOptions) => {
|
|
138
151
|
if (!fg('platform_editor_lazy-node-views')) {
|
|
139
152
|
return (node: PMNode, view: EditorView, getPos: () => number | undefined) => {
|
|
140
|
-
return new TableCell(
|
|
153
|
+
return new TableCell(
|
|
154
|
+
node,
|
|
155
|
+
view,
|
|
156
|
+
getPos,
|
|
157
|
+
options.eventDispatcher,
|
|
158
|
+
options.pluginInjectionApi?.analytics?.actions,
|
|
159
|
+
);
|
|
141
160
|
};
|
|
142
161
|
}
|
|
143
162
|
|
|
@@ -153,9 +172,15 @@ export const lazyTableHeaderView = (options: TableCellViewOptions) => {
|
|
|
153
172
|
decorations: readonly Decoration[],
|
|
154
173
|
getNodeViewOptions: () => TableCellViewOptions,
|
|
155
174
|
) => {
|
|
156
|
-
const { eventDispatcher } = getNodeViewOptions();
|
|
175
|
+
const { eventDispatcher, pluginInjectionApi } = getNodeViewOptions();
|
|
157
176
|
|
|
158
|
-
return new TableCell(
|
|
177
|
+
return new TableCell(
|
|
178
|
+
node,
|
|
179
|
+
view,
|
|
180
|
+
getPos,
|
|
181
|
+
eventDispatcher,
|
|
182
|
+
pluginInjectionApi?.analytics?.actions,
|
|
183
|
+
);
|
|
159
184
|
};
|
|
160
185
|
});
|
|
161
186
|
|
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/pm-plugins/main.ts
CHANGED
|
@@ -364,8 +364,8 @@ export const createPlugin = (
|
|
|
364
364
|
isChromelessEditor,
|
|
365
365
|
}),
|
|
366
366
|
tableRow: lazyTableRowView({ eventDispatcher }),
|
|
367
|
-
tableCell: lazyTableCellView({ eventDispatcher }),
|
|
368
|
-
tableHeader: lazyTableHeaderView({ eventDispatcher }),
|
|
367
|
+
tableCell: lazyTableCellView({ eventDispatcher, pluginInjectionApi }),
|
|
368
|
+
tableHeader: lazyTableHeaderView({ eventDispatcher, pluginInjectionApi }),
|
|
369
369
|
},
|
|
370
370
|
handleDOMEvents: {
|
|
371
371
|
focus: handleFocus,
|
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
|
+
};
|