@atlaskit/editor-plugin-table 17.3.5 → 17.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/nodeviews/table.js +39 -7
- package/dist/es2019/nodeviews/table.js +41 -7
- package/dist/esm/nodeviews/table.js +39 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 17.3.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`d3b00bd311c9d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d3b00bd311c9d) -
|
|
8
|
+
Improves an edge case where users may face unexpected cursor jumps collaboratively
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 17.3.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -17,9 +17,11 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
17
17
|
var _nodeWidth = require("@atlaskit/editor-common/node-width");
|
|
18
18
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
19
19
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
20
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
20
21
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
21
22
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
22
23
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
25
|
var _createPluginConfig = require("../pm-plugins/create-plugin-config");
|
|
24
26
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
25
27
|
var _tableWidth = require("../pm-plugins/table-width");
|
|
@@ -146,8 +148,16 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
146
148
|
|
|
147
149
|
// Store the current selection state if there is a visible selection
|
|
148
150
|
// This lets us restore it after DOM changes
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_fix_cursor_flickering', 'isEnabled', true)) {
|
|
152
|
+
var selection = this.view.state.selection;
|
|
153
|
+
var tablePos = this.getPos();
|
|
154
|
+
if (selection.empty && tablePos && _state.TextSelection.near(this.view.state.doc.resolve(tablePos)).from === selection.from) {
|
|
155
|
+
selectionBookmark = this.view.state.selection.getBookmark();
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
if (this.view.state.selection.visible) {
|
|
159
|
+
selectionBookmark = this.view.state.selection.getBookmark();
|
|
160
|
+
}
|
|
151
161
|
}
|
|
152
162
|
if (this.dom) {
|
|
153
163
|
this.dom.setAttribute('data-ssr-placeholder', "table-nodeview-".concat(this.node.attrs.localId));
|
|
@@ -172,11 +182,33 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
172
182
|
// - The bookmarked selection is different from the current selection.
|
|
173
183
|
if (selectionBookmark && mutationsIgnored) {
|
|
174
184
|
var resolvedSelection = selectionBookmark.resolve(_this2.view.state.tr.doc);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
185
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_fix_cursor_flickering', 'isEnabled', true)) {
|
|
186
|
+
var _TextSelection$findFr;
|
|
187
|
+
/**
|
|
188
|
+
* This handles a very specific case only -> insertion by the user of a new
|
|
189
|
+
* table
|
|
190
|
+
* Since it's behind a RAF it's possible the user has clicked elsewhere or
|
|
191
|
+
* it affects collaborative users (which selection changes shouldn't ever)
|
|
192
|
+
*
|
|
193
|
+
* This ensures that the selectionBookmark *before* is inside the first
|
|
194
|
+
* position in the table and that after it is the text position directly
|
|
195
|
+
* before the table
|
|
196
|
+
* Ideally we want to remove this RAF entirely but that would require removing
|
|
197
|
+
* the DOM manipulation and is a more complex effort
|
|
198
|
+
*/
|
|
199
|
+
if (!resolvedSelection.eq(_this2.view.state.selection) && resolvedSelection.empty && // Ensure that the *next* valid text position matches the first position
|
|
200
|
+
// in the table
|
|
201
|
+
(_TextSelection$findFr = _state.TextSelection.findFrom(_this2.view.state.doc.resolve(_this2.view.state.selection.from + 1), 1, true)) !== null && _TextSelection$findFr !== void 0 && _TextSelection$findFr.eq(resolvedSelection)) {
|
|
202
|
+
var tr = _this2.view.state.tr.setSelection(resolvedSelection);
|
|
203
|
+
tr.setMeta('source', 'TableNodeView:_handleTableRef:selection-resync');
|
|
204
|
+
_this2.view.dispatch(tr);
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
if (!resolvedSelection.eq(_this2.view.state.selection)) {
|
|
208
|
+
var _tr = _this2.view.state.tr.setSelection(resolvedSelection);
|
|
209
|
+
_tr.setMeta('source', 'TableNodeView:_handleTableRef:selection-resync');
|
|
210
|
+
_this2.view.dispatch(_tr);
|
|
211
|
+
}
|
|
180
212
|
}
|
|
181
213
|
}
|
|
182
214
|
});
|
|
@@ -3,9 +3,11 @@ import React from 'react';
|
|
|
3
3
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
4
4
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
5
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
7
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
11
|
import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
|
|
10
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
11
13
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -118,8 +120,18 @@ export default class TableView extends ReactNodeView {
|
|
|
118
120
|
|
|
119
121
|
// Store the current selection state if there is a visible selection
|
|
120
122
|
// This lets us restore it after DOM changes
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
+
if (expValEquals('platform_editor_fix_cursor_flickering', 'isEnabled', true)) {
|
|
124
|
+
const {
|
|
125
|
+
selection
|
|
126
|
+
} = this.view.state;
|
|
127
|
+
const tablePos = this.getPos();
|
|
128
|
+
if (selection.empty && tablePos && TextSelection.near(this.view.state.doc.resolve(tablePos)).from === selection.from) {
|
|
129
|
+
selectionBookmark = this.view.state.selection.getBookmark();
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
if (this.view.state.selection.visible) {
|
|
133
|
+
selectionBookmark = this.view.state.selection.getBookmark();
|
|
134
|
+
}
|
|
123
135
|
}
|
|
124
136
|
if (this.dom) {
|
|
125
137
|
this.dom.setAttribute('data-ssr-placeholder', `table-nodeview-${this.node.attrs.localId}`);
|
|
@@ -144,11 +156,33 @@ export default class TableView extends ReactNodeView {
|
|
|
144
156
|
// - The bookmarked selection is different from the current selection.
|
|
145
157
|
if (selectionBookmark && mutationsIgnored) {
|
|
146
158
|
const resolvedSelection = selectionBookmark.resolve(this.view.state.tr.doc);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
if (expValEquals('platform_editor_fix_cursor_flickering', 'isEnabled', true)) {
|
|
160
|
+
var _TextSelection$findFr;
|
|
161
|
+
/**
|
|
162
|
+
* This handles a very specific case only -> insertion by the user of a new
|
|
163
|
+
* table
|
|
164
|
+
* Since it's behind a RAF it's possible the user has clicked elsewhere or
|
|
165
|
+
* it affects collaborative users (which selection changes shouldn't ever)
|
|
166
|
+
*
|
|
167
|
+
* This ensures that the selectionBookmark *before* is inside the first
|
|
168
|
+
* position in the table and that after it is the text position directly
|
|
169
|
+
* before the table
|
|
170
|
+
* Ideally we want to remove this RAF entirely but that would require removing
|
|
171
|
+
* the DOM manipulation and is a more complex effort
|
|
172
|
+
*/
|
|
173
|
+
if (!resolvedSelection.eq(this.view.state.selection) && resolvedSelection.empty && // Ensure that the *next* valid text position matches the first position
|
|
174
|
+
// in the table
|
|
175
|
+
(_TextSelection$findFr = TextSelection.findFrom(this.view.state.doc.resolve(this.view.state.selection.from + 1), 1, true)) !== null && _TextSelection$findFr !== void 0 && _TextSelection$findFr.eq(resolvedSelection)) {
|
|
176
|
+
const tr = this.view.state.tr.setSelection(resolvedSelection);
|
|
177
|
+
tr.setMeta('source', 'TableNodeView:_handleTableRef:selection-resync');
|
|
178
|
+
this.view.dispatch(tr);
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
if (!resolvedSelection.eq(this.view.state.selection)) {
|
|
182
|
+
const tr = this.view.state.tr.setSelection(resolvedSelection);
|
|
183
|
+
tr.setMeta('source', 'TableNodeView:_handleTableRef:selection-resync');
|
|
184
|
+
this.view.dispatch(tr);
|
|
185
|
+
}
|
|
152
186
|
}
|
|
153
187
|
}
|
|
154
188
|
});
|
|
@@ -13,9 +13,11 @@ import React from 'react';
|
|
|
13
13
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
14
14
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
15
15
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
16
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
16
17
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
17
18
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
18
19
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
19
21
|
import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
|
|
20
22
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
21
23
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
@@ -139,8 +141,16 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
139
141
|
|
|
140
142
|
// Store the current selection state if there is a visible selection
|
|
141
143
|
// This lets us restore it after DOM changes
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
+
if (expValEquals('platform_editor_fix_cursor_flickering', 'isEnabled', true)) {
|
|
145
|
+
var selection = this.view.state.selection;
|
|
146
|
+
var tablePos = this.getPos();
|
|
147
|
+
if (selection.empty && tablePos && TextSelection.near(this.view.state.doc.resolve(tablePos)).from === selection.from) {
|
|
148
|
+
selectionBookmark = this.view.state.selection.getBookmark();
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
if (this.view.state.selection.visible) {
|
|
152
|
+
selectionBookmark = this.view.state.selection.getBookmark();
|
|
153
|
+
}
|
|
144
154
|
}
|
|
145
155
|
if (this.dom) {
|
|
146
156
|
this.dom.setAttribute('data-ssr-placeholder', "table-nodeview-".concat(this.node.attrs.localId));
|
|
@@ -165,11 +175,33 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
165
175
|
// - The bookmarked selection is different from the current selection.
|
|
166
176
|
if (selectionBookmark && mutationsIgnored) {
|
|
167
177
|
var resolvedSelection = selectionBookmark.resolve(_this2.view.state.tr.doc);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
if (expValEquals('platform_editor_fix_cursor_flickering', 'isEnabled', true)) {
|
|
179
|
+
var _TextSelection$findFr;
|
|
180
|
+
/**
|
|
181
|
+
* This handles a very specific case only -> insertion by the user of a new
|
|
182
|
+
* table
|
|
183
|
+
* Since it's behind a RAF it's possible the user has clicked elsewhere or
|
|
184
|
+
* it affects collaborative users (which selection changes shouldn't ever)
|
|
185
|
+
*
|
|
186
|
+
* This ensures that the selectionBookmark *before* is inside the first
|
|
187
|
+
* position in the table and that after it is the text position directly
|
|
188
|
+
* before the table
|
|
189
|
+
* Ideally we want to remove this RAF entirely but that would require removing
|
|
190
|
+
* the DOM manipulation and is a more complex effort
|
|
191
|
+
*/
|
|
192
|
+
if (!resolvedSelection.eq(_this2.view.state.selection) && resolvedSelection.empty && // Ensure that the *next* valid text position matches the first position
|
|
193
|
+
// in the table
|
|
194
|
+
(_TextSelection$findFr = TextSelection.findFrom(_this2.view.state.doc.resolve(_this2.view.state.selection.from + 1), 1, true)) !== null && _TextSelection$findFr !== void 0 && _TextSelection$findFr.eq(resolvedSelection)) {
|
|
195
|
+
var tr = _this2.view.state.tr.setSelection(resolvedSelection);
|
|
196
|
+
tr.setMeta('source', 'TableNodeView:_handleTableRef:selection-resync');
|
|
197
|
+
_this2.view.dispatch(tr);
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
if (!resolvedSelection.eq(_this2.view.state.selection)) {
|
|
201
|
+
var _tr = _this2.view.state.tr.setSelection(resolvedSelection);
|
|
202
|
+
_tr.setMeta('source', 'TableNodeView:_handleTableRef:selection-resync');
|
|
203
|
+
_this2.view.dispatch(_tr);
|
|
204
|
+
}
|
|
173
205
|
}
|
|
174
206
|
}
|
|
175
207
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "17.3.
|
|
3
|
+
"version": "17.3.6",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
58
58
|
"@atlaskit/primitives": "^18.0.0",
|
|
59
59
|
"@atlaskit/theme": "^21.0.0",
|
|
60
|
-
"@atlaskit/tmp-editor-statsig": "^20.
|
|
60
|
+
"@atlaskit/tmp-editor-statsig": "^20.1.0",
|
|
61
61
|
"@atlaskit/toggle": "^15.2.0",
|
|
62
62
|
"@atlaskit/tokens": "^11.0.0",
|
|
63
63
|
"@atlaskit/tooltip": "^20.14.0",
|