@atlaskit/editor-plugin-table 7.28.8 → 7.28.9
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 +8 -0
- package/dist/cjs/nodeviews/TableComponent.js +4 -9
- package/dist/cjs/plugin.js +1 -1
- package/dist/cjs/pm-plugins/view-mode-sort/index.js +9 -8
- package/dist/cjs/ui/icons/SortingIconWrapper.js +18 -0
- package/dist/es2019/nodeviews/TableComponent.js +4 -10
- package/dist/es2019/plugin.js +1 -1
- package/dist/es2019/pm-plugins/view-mode-sort/index.js +9 -8
- package/dist/es2019/ui/icons/SortingIconWrapper.js +12 -0
- package/dist/esm/nodeviews/TableComponent.js +4 -9
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/pm-plugins/view-mode-sort/index.js +9 -8
- package/dist/esm/ui/icons/SortingIconWrapper.js +11 -0
- package/dist/types/pm-plugins/view-mode-sort/index.d.ts +1 -1
- package/dist/types/ui/icons/SortingIconWrapper.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/view-mode-sort/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/SortingIconWrapper.d.ts +10 -0
- package/package.json +1 -1
- package/src/nodeviews/TableComponent.tsx +1 -5
- package/src/plugin.tsx +1 -1
- package/src/pm-plugins/view-mode-sort/index.ts +6 -8
- package/src/ui/icons/SortingIconWrapper.tsx +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.28.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#150125](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/150125)
|
|
8
|
+
[`c9d8f549c024a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c9d8f549c024a) -
|
|
9
|
+
[ux] ED-24539 Fix live view toggle and column sorting in live view pages
|
|
10
|
+
|
|
3
11
|
## 7.28.8
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -358,7 +358,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
358
358
|
(0, _createClass2.default)(TableComponent, [{
|
|
359
359
|
key: "componentDidMount",
|
|
360
360
|
value: function componentDidMount() {
|
|
361
|
-
var _this$
|
|
361
|
+
var _this$table, _this$table2, _this$table3;
|
|
362
362
|
var _this$props7 = this.props,
|
|
363
363
|
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
364
364
|
eventDispatcher = _this$props7.eventDispatcher,
|
|
@@ -367,12 +367,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
367
367
|
getNode = _this$props7.getNode,
|
|
368
368
|
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags,
|
|
369
369
|
isTableScalingEnabled = _this$props7.isTableScalingEnabled;
|
|
370
|
-
|
|
371
|
-
mode = _ref.mode;
|
|
372
|
-
if (mode === 'view') {
|
|
373
|
-
var _this$table;
|
|
374
|
-
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
375
|
-
}
|
|
370
|
+
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
376
371
|
this === null || this === void 0 || (_this$table2 = this.table) === null || _this$table2 === void 0 || _this$table2.addEventListener('mouseout', this.handleMouseOut);
|
|
377
372
|
this === null || this === void 0 || (_this$table3 = this.table) === null || _this$table3 === void 0 || _this$table3.addEventListener('mouseover', this.handleMouseOver);
|
|
378
373
|
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
@@ -647,8 +642,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
647
642
|
var isNoOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(currentTable, previousTable);
|
|
648
643
|
var isNoOfRowsChanged = (0, _utils5.tablesHaveDifferentNoOfRows)(currentTable, previousTable);
|
|
649
644
|
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
650
|
-
var _this$props$
|
|
651
|
-
(_this$props$
|
|
645
|
+
var _this$props$pluginInj;
|
|
646
|
+
(_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify((0, _utils5.getAssistiveMessage)(previousTable, currentTable, this.props.intl), {
|
|
652
647
|
priority: 'important'
|
|
653
648
|
});
|
|
654
649
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -275,7 +275,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
275
275
|
}, {
|
|
276
276
|
name: 'tableViewModeSort',
|
|
277
277
|
plugin: function plugin() {
|
|
278
|
-
return api !== null && api !== void 0 && api.editorViewMode ? (0, _viewModeSort.createPlugin)(api
|
|
278
|
+
return api !== null && api !== void 0 && api.editorViewMode ? (0, _viewModeSort.createPlugin)(api) : undefined;
|
|
279
279
|
}
|
|
280
280
|
}, {
|
|
281
281
|
name: 'tableLocalId',
|
|
@@ -12,10 +12,10 @@ var _react = require("react");
|
|
|
12
12
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
13
|
var _reactIntlNext = require("react-intl-next");
|
|
14
14
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
|
-
var _table3 = require("@atlaskit/editor-common/table");
|
|
16
15
|
var _types = require("@atlaskit/editor-common/types");
|
|
17
16
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
18
17
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
18
|
+
var _SortingIconWrapper = require("../../ui/icons/SortingIconWrapper");
|
|
19
19
|
var _pluginFactory = require("../plugin-factory");
|
|
20
20
|
var _consts = require("./consts");
|
|
21
21
|
var _pluginKey = require("./plugin-key");
|
|
@@ -29,7 +29,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
29
29
|
* Instead of making changes to the ProseMirror document, the plugin sorts the table rows in the DOM. This allows the sorting to be
|
|
30
30
|
* visible to the user without affecting the document's content.
|
|
31
31
|
*/
|
|
32
|
-
var createPlugin = exports.createPlugin = function createPlugin(
|
|
32
|
+
var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
33
33
|
return new _safePlugin.SafePlugin({
|
|
34
34
|
state: {
|
|
35
35
|
init: function init() {
|
|
@@ -40,9 +40,10 @@ var createPlugin = exports.createPlugin = function createPlugin(editorViewModeAP
|
|
|
40
40
|
};
|
|
41
41
|
},
|
|
42
42
|
apply: function apply(tr, pluginState, oldState) {
|
|
43
|
+
var _api$editorViewMode;
|
|
43
44
|
// TODO - move this mode check to plugin creation if possible. Right now it's here because the initial state
|
|
44
45
|
// does not appear correct when the plugin is created.
|
|
45
|
-
var _ref = (
|
|
46
|
+
var _ref = ((_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) || {},
|
|
46
47
|
mode = _ref.mode;
|
|
47
48
|
if (mode !== 'view') {
|
|
48
49
|
return pluginState;
|
|
@@ -101,7 +102,6 @@ var createPlugin = exports.createPlugin = function createPlugin(editorViewModeAP
|
|
|
101
102
|
var map = _tableMap.TableMap.get(tableNode);
|
|
102
103
|
var hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
103
104
|
map.mapByRow[0].forEach(function (cell, index) {
|
|
104
|
-
// return pluginState;
|
|
105
105
|
decs.push(_view.Decoration.widget(cell + pos + 2, function () {
|
|
106
106
|
var _sort$tableId;
|
|
107
107
|
var element = document.createElement('div');
|
|
@@ -121,11 +121,12 @@ var createPlugin = exports.createPlugin = function createPlugin(editorViewModeAP
|
|
|
121
121
|
getIntl = _getPluginState.getIntl;
|
|
122
122
|
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
123
123
|
value: getIntl()
|
|
124
|
-
}, /*#__PURE__*/(0, _react.createElement)(
|
|
124
|
+
}, /*#__PURE__*/(0, _react.createElement)(_SortingIconWrapper.SortingIconWrapper, {
|
|
125
125
|
isSortingAllowed: !hasMergedCells,
|
|
126
126
|
sortOrdered: sortOrdered,
|
|
127
127
|
onClick: function onClick() {},
|
|
128
|
-
onKeyDown: function onKeyDown() {}
|
|
128
|
+
onKeyDown: function onKeyDown() {},
|
|
129
|
+
api: api
|
|
129
130
|
})), element);
|
|
130
131
|
return element;
|
|
131
132
|
}));
|
|
@@ -152,9 +153,9 @@ var createPlugin = exports.createPlugin = function createPlugin(editorViewModeAP
|
|
|
152
153
|
},
|
|
153
154
|
key: _pluginKey.tableViewModeSortPluginKey,
|
|
154
155
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
155
|
-
var _key$getState;
|
|
156
|
+
var _api$editorViewMode2, _key$getState;
|
|
156
157
|
// return newState.tr;
|
|
157
|
-
var _ref8 = (
|
|
158
|
+
var _ref8 = (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState()) || {},
|
|
158
159
|
mode = _ref8.mode;
|
|
159
160
|
if (mode !== 'view') {
|
|
160
161
|
return newState.tr;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SortingIconWrapper = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _table = require("@atlaskit/editor-common/table");
|
|
11
|
+
var SortingIconWrapper = exports.SortingIconWrapper = function SortingIconWrapper(props) {
|
|
12
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.api, ['editorViewMode']),
|
|
13
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
14
|
+
if ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit') {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(_table.SortingIcon, props);
|
|
18
|
+
};
|
|
@@ -339,7 +339,7 @@ class TableComponent extends React.Component {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
componentDidMount() {
|
|
342
|
-
var _this$
|
|
342
|
+
var _this$table, _this$table2, _this$table3;
|
|
343
343
|
const {
|
|
344
344
|
allowColumnResizing,
|
|
345
345
|
eventDispatcher,
|
|
@@ -349,13 +349,7 @@ class TableComponent extends React.Component {
|
|
|
349
349
|
getEditorFeatureFlags,
|
|
350
350
|
isTableScalingEnabled
|
|
351
351
|
} = this.props;
|
|
352
|
-
|
|
353
|
-
mode
|
|
354
|
-
} = ((_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 ? void 0 : (_this$props$pluginInj2 = _this$props$pluginInj.editorViewMode) === null || _this$props$pluginInj2 === void 0 ? void 0 : _this$props$pluginInj2.sharedState.currentState()) || {};
|
|
355
|
-
if (mode === 'view') {
|
|
356
|
-
var _this$table;
|
|
357
|
-
this === null || this === void 0 ? void 0 : (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
358
|
-
}
|
|
352
|
+
this === null || this === void 0 ? void 0 : (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
359
353
|
this === null || this === void 0 ? void 0 : (_this$table2 = this.table) === null || _this$table2 === void 0 ? void 0 : _this$table2.addEventListener('mouseout', this.handleMouseOut);
|
|
360
354
|
this === null || this === void 0 ? void 0 : (_this$table3 = this.table) === null || _this$table3 === void 0 ? void 0 : _this$table3.addEventListener('mouseover', this.handleMouseOver);
|
|
361
355
|
const {
|
|
@@ -625,8 +619,8 @@ class TableComponent extends React.Component {
|
|
|
625
619
|
const isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
|
|
626
620
|
const isNoOfRowsChanged = tablesHaveDifferentNoOfRows(currentTable, previousTable);
|
|
627
621
|
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
628
|
-
var _this$props$
|
|
629
|
-
(_this$props$
|
|
622
|
+
var _this$props$pluginInj, _this$props$pluginInj2;
|
|
623
|
+
(_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 ? void 0 : (_this$props$pluginInj2 = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj2 === void 0 ? void 0 : _this$props$pluginInj2.actions.ariaNotify(getAssistiveMessage(previousTable, currentTable, this.props.intl), {
|
|
630
624
|
priority: 'important'
|
|
631
625
|
});
|
|
632
626
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -263,7 +263,7 @@ const tablesPlugin = ({
|
|
|
263
263
|
}, {
|
|
264
264
|
name: 'tableViewModeSort',
|
|
265
265
|
plugin: () => {
|
|
266
|
-
return api !== null && api !== void 0 && api.editorViewMode ? createViewModeSortPlugin(api
|
|
266
|
+
return api !== null && api !== void 0 && api.editorViewMode ? createViewModeSortPlugin(api) : undefined;
|
|
267
267
|
}
|
|
268
268
|
}, {
|
|
269
269
|
name: 'tableLocalId',
|
|
@@ -8,15 +8,15 @@ import { createElement } from 'react';
|
|
|
8
8
|
import ReactDOM from 'react-dom';
|
|
9
9
|
import { RawIntlProvider } from 'react-intl-next';
|
|
10
10
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
11
|
-
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
12
11
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
13
12
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
14
13
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
14
|
+
import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
|
|
15
15
|
import { getPluginState } from '../plugin-factory';
|
|
16
16
|
import { IS_DISABLED_CLASS_NAME, SORT_INDEX_DATA_ATTRIBUTE, SORTING_ICON_CLASS_NAME } from './consts';
|
|
17
17
|
import { tableViewModeSortPluginKey as key } from './plugin-key';
|
|
18
18
|
import { getTableElements, toggleSort } from './utils';
|
|
19
|
-
export const createPlugin =
|
|
19
|
+
export const createPlugin = api => {
|
|
20
20
|
return new SafePlugin({
|
|
21
21
|
state: {
|
|
22
22
|
init: () => ({
|
|
@@ -25,11 +25,12 @@ export const createPlugin = editorViewModeAPI => {
|
|
|
25
25
|
allTables: []
|
|
26
26
|
}),
|
|
27
27
|
apply(tr, pluginState, oldState) {
|
|
28
|
+
var _api$editorViewMode;
|
|
28
29
|
// TODO - move this mode check to plugin creation if possible. Right now it's here because the initial state
|
|
29
30
|
// does not appear correct when the plugin is created.
|
|
30
31
|
const {
|
|
31
32
|
mode
|
|
32
|
-
} = (
|
|
33
|
+
} = ((_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) || {};
|
|
33
34
|
if (mode !== 'view') {
|
|
34
35
|
return pluginState;
|
|
35
36
|
}
|
|
@@ -77,7 +78,6 @@ export const createPlugin = editorViewModeAPI => {
|
|
|
77
78
|
const map = TableMap.get(tableNode);
|
|
78
79
|
const hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
79
80
|
map.mapByRow[0].forEach((cell, index) => {
|
|
80
|
-
// return pluginState;
|
|
81
81
|
decs.push(Decoration.widget(cell + pos + 2, () => {
|
|
82
82
|
var _sort$tableId;
|
|
83
83
|
const element = document.createElement('div');
|
|
@@ -98,11 +98,12 @@ export const createPlugin = editorViewModeAPI => {
|
|
|
98
98
|
} = getPluginState(oldState);
|
|
99
99
|
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
100
100
|
value: getIntl()
|
|
101
|
-
}, /*#__PURE__*/createElement(
|
|
101
|
+
}, /*#__PURE__*/createElement(SortingIconWrapper, {
|
|
102
102
|
isSortingAllowed: !hasMergedCells,
|
|
103
103
|
sortOrdered,
|
|
104
104
|
onClick: () => {},
|
|
105
|
-
onKeyDown: () => {}
|
|
105
|
+
onKeyDown: () => {},
|
|
106
|
+
api
|
|
106
107
|
})), element);
|
|
107
108
|
return element;
|
|
108
109
|
}));
|
|
@@ -129,11 +130,11 @@ export const createPlugin = editorViewModeAPI => {
|
|
|
129
130
|
},
|
|
130
131
|
key,
|
|
131
132
|
appendTransaction: (trs, oldState, newState) => {
|
|
132
|
-
var _key$getState;
|
|
133
|
+
var _api$editorViewMode2, _key$getState;
|
|
133
134
|
// return newState.tr;
|
|
134
135
|
const {
|
|
135
136
|
mode
|
|
136
|
-
} = (
|
|
137
|
+
} = (api === null || api === void 0 ? void 0 : (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState()) || {};
|
|
137
138
|
if (mode !== 'view') {
|
|
138
139
|
return newState.tr;
|
|
139
140
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
4
|
+
export const SortingIconWrapper = props => {
|
|
5
|
+
const {
|
|
6
|
+
editorViewModeState
|
|
7
|
+
} = useSharedPluginState(props.api, ['editorViewMode']);
|
|
8
|
+
if ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit') {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return /*#__PURE__*/React.createElement(SortingIcon, props);
|
|
12
|
+
};
|
|
@@ -351,7 +351,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
351
351
|
_createClass(TableComponent, [{
|
|
352
352
|
key: "componentDidMount",
|
|
353
353
|
value: function componentDidMount() {
|
|
354
|
-
var _this$
|
|
354
|
+
var _this$table, _this$table2, _this$table3;
|
|
355
355
|
var _this$props7 = this.props,
|
|
356
356
|
allowColumnResizing = _this$props7.allowColumnResizing,
|
|
357
357
|
eventDispatcher = _this$props7.eventDispatcher,
|
|
@@ -360,12 +360,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
360
360
|
getNode = _this$props7.getNode,
|
|
361
361
|
getEditorFeatureFlags = _this$props7.getEditorFeatureFlags,
|
|
362
362
|
isTableScalingEnabled = _this$props7.isTableScalingEnabled;
|
|
363
|
-
|
|
364
|
-
mode = _ref.mode;
|
|
365
|
-
if (mode === 'view') {
|
|
366
|
-
var _this$table;
|
|
367
|
-
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
368
|
-
}
|
|
363
|
+
this === null || this === void 0 || (_this$table = this.table) === null || _this$table === void 0 || _this$table.addEventListener('mouseenter', this.handleMouseEnter);
|
|
369
364
|
this === null || this === void 0 || (_this$table2 = this.table) === null || _this$table2 === void 0 || _this$table2.addEventListener('mouseout', this.handleMouseOut);
|
|
370
365
|
this === null || this === void 0 || (_this$table3 = this.table) === null || _this$table3 === void 0 || _this$table3.addEventListener('mouseover', this.handleMouseOver);
|
|
371
366
|
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
@@ -640,8 +635,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
640
635
|
var isNoOfColumnsChanged = tablesHaveDifferentNoOfColumns(currentTable, previousTable);
|
|
641
636
|
var isNoOfRowsChanged = tablesHaveDifferentNoOfRows(currentTable, previousTable);
|
|
642
637
|
if (isNoOfColumnsChanged || isNoOfRowsChanged) {
|
|
643
|
-
var _this$props$
|
|
644
|
-
(_this$props$
|
|
638
|
+
var _this$props$pluginInj;
|
|
639
|
+
(_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify(getAssistiveMessage(previousTable, currentTable, this.props.intl), {
|
|
645
640
|
priority: 'important'
|
|
646
641
|
});
|
|
647
642
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -268,7 +268,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
268
268
|
}, {
|
|
269
269
|
name: 'tableViewModeSort',
|
|
270
270
|
plugin: function plugin() {
|
|
271
|
-
return api !== null && api !== void 0 && api.editorViewMode ? createViewModeSortPlugin(api
|
|
271
|
+
return api !== null && api !== void 0 && api.editorViewMode ? createViewModeSortPlugin(api) : undefined;
|
|
272
272
|
}
|
|
273
273
|
}, {
|
|
274
274
|
name: 'tableLocalId',
|
|
@@ -16,15 +16,15 @@ import { createElement } from 'react';
|
|
|
16
16
|
import ReactDOM from 'react-dom';
|
|
17
17
|
import { RawIntlProvider } from 'react-intl-next';
|
|
18
18
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
19
|
-
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
20
19
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
21
20
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
22
21
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
22
|
+
import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
|
|
23
23
|
import { getPluginState } from '../plugin-factory';
|
|
24
24
|
import { IS_DISABLED_CLASS_NAME, SORT_INDEX_DATA_ATTRIBUTE, SORTING_ICON_CLASS_NAME } from './consts';
|
|
25
25
|
import { tableViewModeSortPluginKey as key } from './plugin-key';
|
|
26
26
|
import { getTableElements, toggleSort } from './utils';
|
|
27
|
-
export var createPlugin = function createPlugin(
|
|
27
|
+
export var createPlugin = function createPlugin(api) {
|
|
28
28
|
return new SafePlugin({
|
|
29
29
|
state: {
|
|
30
30
|
init: function init() {
|
|
@@ -35,9 +35,10 @@ export var createPlugin = function createPlugin(editorViewModeAPI) {
|
|
|
35
35
|
};
|
|
36
36
|
},
|
|
37
37
|
apply: function apply(tr, pluginState, oldState) {
|
|
38
|
+
var _api$editorViewMode;
|
|
38
39
|
// TODO - move this mode check to plugin creation if possible. Right now it's here because the initial state
|
|
39
40
|
// does not appear correct when the plugin is created.
|
|
40
|
-
var _ref = (
|
|
41
|
+
var _ref = ((_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) || {},
|
|
41
42
|
mode = _ref.mode;
|
|
42
43
|
if (mode !== 'view') {
|
|
43
44
|
return pluginState;
|
|
@@ -96,7 +97,6 @@ export var createPlugin = function createPlugin(editorViewModeAPI) {
|
|
|
96
97
|
var map = TableMap.get(tableNode);
|
|
97
98
|
var hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
98
99
|
map.mapByRow[0].forEach(function (cell, index) {
|
|
99
|
-
// return pluginState;
|
|
100
100
|
decs.push(Decoration.widget(cell + pos + 2, function () {
|
|
101
101
|
var _sort$tableId;
|
|
102
102
|
var element = document.createElement('div');
|
|
@@ -116,11 +116,12 @@ export var createPlugin = function createPlugin(editorViewModeAPI) {
|
|
|
116
116
|
getIntl = _getPluginState.getIntl;
|
|
117
117
|
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
118
118
|
value: getIntl()
|
|
119
|
-
}, /*#__PURE__*/createElement(
|
|
119
|
+
}, /*#__PURE__*/createElement(SortingIconWrapper, {
|
|
120
120
|
isSortingAllowed: !hasMergedCells,
|
|
121
121
|
sortOrdered: sortOrdered,
|
|
122
122
|
onClick: function onClick() {},
|
|
123
|
-
onKeyDown: function onKeyDown() {}
|
|
123
|
+
onKeyDown: function onKeyDown() {},
|
|
124
|
+
api: api
|
|
124
125
|
})), element);
|
|
125
126
|
return element;
|
|
126
127
|
}));
|
|
@@ -147,9 +148,9 @@ export var createPlugin = function createPlugin(editorViewModeAPI) {
|
|
|
147
148
|
},
|
|
148
149
|
key: key,
|
|
149
150
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
150
|
-
var _key$getState;
|
|
151
|
+
var _api$editorViewMode2, _key$getState;
|
|
151
152
|
// return newState.tr;
|
|
152
|
-
var _ref8 = (
|
|
153
|
+
var _ref8 = (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.sharedState.currentState()) || {},
|
|
153
154
|
mode = _ref8.mode;
|
|
154
155
|
if (mode !== 'view') {
|
|
155
156
|
return newState.tr;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
4
|
+
export var SortingIconWrapper = function SortingIconWrapper(props) {
|
|
5
|
+
var _useSharedPluginState = useSharedPluginState(props.api, ['editorViewMode']),
|
|
6
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
7
|
+
if ((editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'edit') {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return /*#__PURE__*/React.createElement(SortingIcon, props);
|
|
11
|
+
};
|
|
@@ -7,4 +7,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
7
7
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
8
8
|
import type tablePlugin from '../../plugin';
|
|
9
9
|
import type { ViewModeSortPluginState } from './types';
|
|
10
|
-
export declare const createPlugin: (
|
|
10
|
+
export declare const createPlugin: (api: ExtractInjectionAPI<typeof tablePlugin>) => SafePlugin<ViewModeSortPluginState>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { TablePlugin } from '../../plugin';
|
|
5
|
+
type SortingIconProps = React.ComponentProps<typeof SortingIcon>;
|
|
6
|
+
type SortingIconWrapperProps = SortingIconProps & {
|
|
7
|
+
api: ExtractInjectionAPI<TablePlugin>;
|
|
8
|
+
};
|
|
9
|
+
export declare const SortingIconWrapper: (props: SortingIconWrapperProps) => JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -7,4 +7,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
7
7
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
8
8
|
import type tablePlugin from '../../plugin';
|
|
9
9
|
import type { ViewModeSortPluginState } from './types';
|
|
10
|
-
export declare const createPlugin: (
|
|
10
|
+
export declare const createPlugin: (api: ExtractInjectionAPI<typeof tablePlugin>) => SafePlugin<ViewModeSortPluginState>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { TablePlugin } from '../../plugin';
|
|
5
|
+
type SortingIconProps = React.ComponentProps<typeof SortingIcon>;
|
|
6
|
+
type SortingIconWrapperProps = SortingIconProps & {
|
|
7
|
+
api: ExtractInjectionAPI<TablePlugin>;
|
|
8
|
+
};
|
|
9
|
+
export declare const SortingIconWrapper: (props: SortingIconWrapperProps) => JSX.Element | null;
|
|
10
|
+
export {};
|
package/package.json
CHANGED
|
@@ -228,11 +228,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
228
228
|
isTableScalingEnabled,
|
|
229
229
|
} = this.props;
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
this.props.pluginInjectionApi?.editorViewMode?.sharedState.currentState() || {};
|
|
233
|
-
if (mode === 'view') {
|
|
234
|
-
this?.table?.addEventListener('mouseenter', this.handleMouseEnter);
|
|
235
|
-
}
|
|
231
|
+
this?.table?.addEventListener('mouseenter', this.handleMouseEnter);
|
|
236
232
|
|
|
237
233
|
this?.table?.addEventListener('mouseout', this.handleMouseOut);
|
|
238
234
|
|
package/src/plugin.tsx
CHANGED
|
@@ -436,7 +436,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
436
436
|
{
|
|
437
437
|
name: 'tableViewModeSort',
|
|
438
438
|
plugin: () => {
|
|
439
|
-
return api?.editorViewMode ? createViewModeSortPlugin(api
|
|
439
|
+
return api?.editorViewMode ? createViewModeSortPlugin(api) : undefined;
|
|
440
440
|
},
|
|
441
441
|
},
|
|
442
442
|
{
|
|
@@ -10,13 +10,13 @@ import ReactDOM from 'react-dom';
|
|
|
10
10
|
import { RawIntlProvider } from 'react-intl-next';
|
|
11
11
|
|
|
12
12
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
13
|
-
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
14
13
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
15
14
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
16
15
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
17
16
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
18
17
|
|
|
19
18
|
import type tablePlugin from '../../plugin';
|
|
19
|
+
import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
|
|
20
20
|
import { getPluginState } from '../plugin-factory';
|
|
21
21
|
|
|
22
22
|
import {
|
|
@@ -28,9 +28,7 @@ import { tableViewModeSortPluginKey as key } from './plugin-key';
|
|
|
28
28
|
import type { ViewModeSortPluginState } from './types';
|
|
29
29
|
import { getTableElements, toggleSort } from './utils';
|
|
30
30
|
|
|
31
|
-
export const createPlugin = (
|
|
32
|
-
editorViewModeAPI: ExtractInjectionAPI<typeof tablePlugin>['editorViewMode'],
|
|
33
|
-
) => {
|
|
31
|
+
export const createPlugin = (api: ExtractInjectionAPI<typeof tablePlugin>) => {
|
|
34
32
|
return new SafePlugin({
|
|
35
33
|
state: {
|
|
36
34
|
init: () => ({
|
|
@@ -41,7 +39,7 @@ export const createPlugin = (
|
|
|
41
39
|
apply(tr, pluginState: ViewModeSortPluginState, oldState) {
|
|
42
40
|
// TODO - move this mode check to plugin creation if possible. Right now it's here because the initial state
|
|
43
41
|
// does not appear correct when the plugin is created.
|
|
44
|
-
const { mode } =
|
|
42
|
+
const { mode } = api.editorViewMode?.sharedState.currentState() || {};
|
|
45
43
|
if (mode !== 'view') {
|
|
46
44
|
return pluginState;
|
|
47
45
|
}
|
|
@@ -86,7 +84,6 @@ export const createPlugin = (
|
|
|
86
84
|
const map = TableMap.get(tableNode);
|
|
87
85
|
const hasMergedCells = new Set(map.map).size !== map.map.length;
|
|
88
86
|
map.mapByRow[0].forEach((cell, index) => {
|
|
89
|
-
// return pluginState;
|
|
90
87
|
decs.push(
|
|
91
88
|
Decoration.widget(cell + pos + 2, () => {
|
|
92
89
|
const element = document.createElement('div');
|
|
@@ -109,11 +106,12 @@ export const createPlugin = (
|
|
|
109
106
|
createElement(
|
|
110
107
|
RawIntlProvider,
|
|
111
108
|
{ value: getIntl() },
|
|
112
|
-
createElement(
|
|
109
|
+
createElement(SortingIconWrapper, {
|
|
113
110
|
isSortingAllowed: !hasMergedCells,
|
|
114
111
|
sortOrdered,
|
|
115
112
|
onClick: () => {},
|
|
116
113
|
onKeyDown: () => {},
|
|
114
|
+
api,
|
|
117
115
|
}),
|
|
118
116
|
),
|
|
119
117
|
element,
|
|
@@ -146,7 +144,7 @@ export const createPlugin = (
|
|
|
146
144
|
key,
|
|
147
145
|
appendTransaction: (trs, oldState, newState) => {
|
|
148
146
|
// return newState.tr;
|
|
149
|
-
const { mode } =
|
|
147
|
+
const { mode } = api?.editorViewMode?.sharedState.currentState() || {};
|
|
150
148
|
if (mode !== 'view') {
|
|
151
149
|
return newState.tr;
|
|
152
150
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { SortingIcon } from '@atlaskit/editor-common/table';
|
|
5
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
|
+
|
|
7
|
+
import type { TablePlugin } from '../../plugin';
|
|
8
|
+
|
|
9
|
+
type SortingIconProps = React.ComponentProps<typeof SortingIcon>;
|
|
10
|
+
type SortingIconWrapperProps = SortingIconProps & {
|
|
11
|
+
api: ExtractInjectionAPI<TablePlugin>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const SortingIconWrapper = (props: SortingIconWrapperProps) => {
|
|
15
|
+
const { editorViewModeState } = useSharedPluginState(props.api, ['editorViewMode']);
|
|
16
|
+
if (editorViewModeState?.mode === 'edit') {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return <SortingIcon {...props} />;
|
|
20
|
+
};
|