@atlaskit/editor-plugin-local-id 8.1.2 → 8.2.0
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 +16 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/pm-plugins/main.js +103 -22
- package/dist/es2019/pm-plugins/main.js +61 -11
- package/dist/esm/pm-plugins/main.js +103 -22
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-local-id
|
|
2
2
|
|
|
3
|
+
## 8.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b284d7fc05568`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b284d7fc05568) -
|
|
8
|
+
Fix tableCell/tableHeader nodes in middle rows of newly-inserted tables missing localId. The
|
|
9
|
+
localId plugin's appendTransaction was keyed by PMNode identity, which incorrectly overwrote
|
|
10
|
+
positions when the same node reference legitimately occupied multiple document positions (as
|
|
11
|
+
createTable from prosemirror-utils does by reusing cell node objects across non-header rows). The
|
|
12
|
+
plugin now tracks all positions per node identity and assigns a unique localId per position. Gated
|
|
13
|
+
behind the `platform_editor_ai_tablecell_localids` experiment.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 8.1.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.localIdPluginKey = exports.createPlugin = exports.batchAddLocalIdToNodes = exports.addLocalIdToNode = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
|
9
10
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
11
|
var _collab = require("@atlaskit/editor-common/collab");
|
|
11
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
17
|
var _generateShortUUID = require("./generateShortUUID");
|
|
16
18
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
17
19
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -105,6 +107,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
105
107
|
// https://bitbucket.org/atlassian/adf-schema/src/fb2236147a0c2bc9c8efbdb75fd8f8c411df44ba/packages/adf-schema/src/next-schema/nodes/mediaGroup.ts#lines-12
|
|
106
108
|
var ignoredNodeTypes = [text === null || text === void 0 ? void 0 : text.name, hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.name, mediaGroup === null || mediaGroup === void 0 ? void 0 : mediaGroup.name];
|
|
107
109
|
var addedNodes = new Set();
|
|
110
|
+
// A single PMNode reference can appear at multiple positions in the doc (e.g.
|
|
111
|
+
// `createTable` from `prosemirror-utils` reuses cell node objects across
|
|
112
|
+
// non-header rows), so the new code path tracks every position per node identity.
|
|
113
|
+
// The legacy path retains the single-position-per-node map for compatibility.
|
|
114
|
+
var positionsByNode = new Map();
|
|
108
115
|
var addedNodePos = new Map();
|
|
109
116
|
var localIds = new Set();
|
|
110
117
|
var nodesToUpdate = new Map(); // position -> localId
|
|
@@ -141,7 +148,16 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
141
148
|
if ((0, _platformFeatureFlags.fg)('platform_editor_use_localid_dedupe')) {
|
|
142
149
|
// Always add to addedNodes for duplicate prevention
|
|
143
150
|
addedNodes.add(node);
|
|
144
|
-
|
|
151
|
+
if (
|
|
152
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
153
|
+
(0, _platformFeatureFlags.fg)('platform_editor_localid_improvements') && (0, _expValEquals.expValEquals)('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
|
|
154
|
+
var _positionsByNode$get;
|
|
155
|
+
var positions = (_positionsByNode$get = positionsByNode.get(node)) !== null && _positionsByNode$get !== void 0 ? _positionsByNode$get : new Set();
|
|
156
|
+
positions.add(pos);
|
|
157
|
+
positionsByNode.set(node, positions);
|
|
158
|
+
} else {
|
|
159
|
+
addedNodePos.set(node, pos);
|
|
160
|
+
}
|
|
145
161
|
} else {
|
|
146
162
|
if (!(node !== null && node !== void 0 && node.attrs.localId)) {
|
|
147
163
|
if ((0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
|
|
@@ -173,32 +189,97 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
173
189
|
hasInitializedExistingUUIDs = true;
|
|
174
190
|
// Also ensure the added have no duplicates
|
|
175
191
|
var seenIds = new Set();
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
192
|
+
if (
|
|
193
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
194
|
+
(0, _platformFeatureFlags.fg)('platform_editor_localid_improvements') && (0, _expValEquals.expValEquals)('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
|
|
195
|
+
var _iterator = _createForOfIteratorHelper(addedNodes),
|
|
196
|
+
_step;
|
|
197
|
+
try {
|
|
198
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
199
|
+
var node = _step.value;
|
|
200
|
+
var positions = positionsByNode.get(node);
|
|
201
|
+
if (!positions || positions.size === 0) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
var existingId = node.attrs.localId;
|
|
205
|
+
var needsNewIds = !existingId || localIds.has(existingId) || seenIds.has(existingId);
|
|
206
|
+
if (needsNewIds) {
|
|
207
|
+
// No usable localId: assign a fresh unique one to every position.
|
|
208
|
+
var _iterator2 = _createForOfIteratorHelper(positions),
|
|
209
|
+
_step2;
|
|
210
|
+
try {
|
|
211
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
212
|
+
var pos = _step2.value;
|
|
213
|
+
var newId = generateUUID();
|
|
214
|
+
nodesToUpdate.set(pos, newId);
|
|
215
|
+
seenIds.add(newId);
|
|
216
|
+
modified = true;
|
|
217
|
+
}
|
|
218
|
+
} catch (err) {
|
|
219
|
+
_iterator2.e(err);
|
|
220
|
+
} finally {
|
|
221
|
+
_iterator2.f();
|
|
222
|
+
}
|
|
223
|
+
} else if (positions.size > 1) {
|
|
224
|
+
// Shared node reference: keep the existing id at the first position,
|
|
225
|
+
// assign fresh ones to the rest so they don't share the same localId.
|
|
226
|
+
seenIds.add(existingId);
|
|
227
|
+
var _Array$from = Array.from(positions),
|
|
228
|
+
_Array$from2 = (0, _toArray2.default)(_Array$from),
|
|
229
|
+
_first = _Array$from2[0],
|
|
230
|
+
rest = _Array$from2.slice(1);
|
|
231
|
+
var _iterator3 = _createForOfIteratorHelper(rest),
|
|
232
|
+
_step3;
|
|
233
|
+
try {
|
|
234
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
235
|
+
var _pos = _step3.value;
|
|
236
|
+
var _newId = generateUUID();
|
|
237
|
+
nodesToUpdate.set(_pos, _newId);
|
|
238
|
+
seenIds.add(_newId);
|
|
239
|
+
modified = true;
|
|
240
|
+
}
|
|
241
|
+
} catch (err) {
|
|
242
|
+
_iterator3.e(err);
|
|
243
|
+
} finally {
|
|
244
|
+
_iterator3.f();
|
|
190
245
|
}
|
|
191
|
-
|
|
246
|
+
} else if (existingId) {
|
|
247
|
+
seenIds.add(existingId);
|
|
192
248
|
}
|
|
193
249
|
}
|
|
194
|
-
|
|
195
|
-
|
|
250
|
+
} catch (err) {
|
|
251
|
+
_iterator.e(err);
|
|
252
|
+
} finally {
|
|
253
|
+
_iterator.f();
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
var _iterator4 = _createForOfIteratorHelper(addedNodes),
|
|
257
|
+
_step4;
|
|
258
|
+
try {
|
|
259
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
260
|
+
var _node = _step4.value;
|
|
261
|
+
if (!_node.attrs.localId || localIds.has(_node.attrs.localId) || seenIds.has(_node.attrs.localId)) {
|
|
262
|
+
var _pos2 = addedNodePos.get(_node);
|
|
263
|
+
if (_pos2 !== undefined) {
|
|
264
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
|
|
265
|
+
var _newId2 = generateUUID();
|
|
266
|
+
nodesToUpdate.set(_pos2, _newId2);
|
|
267
|
+
seenIds.add(_newId2);
|
|
268
|
+
} else {
|
|
269
|
+
addLocalIdToNode(_pos2, tr);
|
|
270
|
+
}
|
|
271
|
+
modified = true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (_node.attrs.localId) {
|
|
275
|
+
seenIds.add(_node.attrs.localId);
|
|
276
|
+
}
|
|
196
277
|
}
|
|
278
|
+
} catch (err) {
|
|
279
|
+
_iterator4.e(err);
|
|
280
|
+
} finally {
|
|
281
|
+
_iterator4.f();
|
|
197
282
|
}
|
|
198
|
-
} catch (err) {
|
|
199
|
-
_iterator.e(err);
|
|
200
|
-
} finally {
|
|
201
|
-
_iterator.f();
|
|
202
283
|
}
|
|
203
284
|
}
|
|
204
285
|
// Apply local ID updates based on the improvements feature flag:
|
|
@@ -4,6 +4,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
4
4
|
import { stepHasSlice } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { generateShortUUID, generatedShortUUIDs } from './generateShortUUID';
|
|
8
9
|
export const localIdPluginKey = new PluginKey('localIdPlugin');
|
|
9
10
|
const generateUUID = () => {
|
|
@@ -96,6 +97,11 @@ export const createPlugin = api => {
|
|
|
96
97
|
// https://bitbucket.org/atlassian/adf-schema/src/fb2236147a0c2bc9c8efbdb75fd8f8c411df44ba/packages/adf-schema/src/next-schema/nodes/mediaGroup.ts#lines-12
|
|
97
98
|
const ignoredNodeTypes = [text === null || text === void 0 ? void 0 : text.name, hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.name, mediaGroup === null || mediaGroup === void 0 ? void 0 : mediaGroup.name];
|
|
98
99
|
const addedNodes = new Set();
|
|
100
|
+
// A single PMNode reference can appear at multiple positions in the doc (e.g.
|
|
101
|
+
// `createTable` from `prosemirror-utils` reuses cell node objects across
|
|
102
|
+
// non-header rows), so the new code path tracks every position per node identity.
|
|
103
|
+
// The legacy path retains the single-position-per-node map for compatibility.
|
|
104
|
+
const positionsByNode = new Map();
|
|
99
105
|
const addedNodePos = new Map();
|
|
100
106
|
const localIds = new Set();
|
|
101
107
|
const nodesToUpdate = new Map(); // position -> localId
|
|
@@ -132,7 +138,16 @@ export const createPlugin = api => {
|
|
|
132
138
|
if (fg('platform_editor_use_localid_dedupe')) {
|
|
133
139
|
// Always add to addedNodes for duplicate prevention
|
|
134
140
|
addedNodes.add(node);
|
|
135
|
-
|
|
141
|
+
if (
|
|
142
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
143
|
+
fg('platform_editor_localid_improvements') && expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
|
|
144
|
+
var _positionsByNode$get;
|
|
145
|
+
const positions = (_positionsByNode$get = positionsByNode.get(node)) !== null && _positionsByNode$get !== void 0 ? _positionsByNode$get : new Set();
|
|
146
|
+
positions.add(pos);
|
|
147
|
+
positionsByNode.set(node, positions);
|
|
148
|
+
} else {
|
|
149
|
+
addedNodePos.set(node, pos);
|
|
150
|
+
}
|
|
136
151
|
} else {
|
|
137
152
|
if (!(node !== null && node !== void 0 && node.attrs.localId)) {
|
|
138
153
|
if (fg('platform_editor_localid_improvements')) {
|
|
@@ -164,22 +179,57 @@ export const createPlugin = api => {
|
|
|
164
179
|
hasInitializedExistingUUIDs = true;
|
|
165
180
|
// Also ensure the added have no duplicates
|
|
166
181
|
const seenIds = new Set();
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
182
|
+
if (
|
|
183
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
184
|
+
fg('platform_editor_localid_improvements') && expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
|
|
185
|
+
for (const node of addedNodes) {
|
|
186
|
+
const positions = positionsByNode.get(node);
|
|
187
|
+
if (!positions || positions.size === 0) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const existingId = node.attrs.localId;
|
|
191
|
+
const needsNewIds = !existingId || localIds.has(existingId) || seenIds.has(existingId);
|
|
192
|
+
if (needsNewIds) {
|
|
193
|
+
// No usable localId: assign a fresh unique one to every position.
|
|
194
|
+
for (const pos of positions) {
|
|
172
195
|
const newId = generateUUID();
|
|
173
196
|
nodesToUpdate.set(pos, newId);
|
|
174
197
|
seenIds.add(newId);
|
|
175
|
-
|
|
176
|
-
addLocalIdToNode(pos, tr);
|
|
198
|
+
modified = true;
|
|
177
199
|
}
|
|
178
|
-
|
|
200
|
+
} else if (positions.size > 1) {
|
|
201
|
+
// Shared node reference: keep the existing id at the first position,
|
|
202
|
+
// assign fresh ones to the rest so they don't share the same localId.
|
|
203
|
+
seenIds.add(existingId);
|
|
204
|
+
const [_first, ...rest] = Array.from(positions);
|
|
205
|
+
for (const pos of rest) {
|
|
206
|
+
const newId = generateUUID();
|
|
207
|
+
nodesToUpdate.set(pos, newId);
|
|
208
|
+
seenIds.add(newId);
|
|
209
|
+
modified = true;
|
|
210
|
+
}
|
|
211
|
+
} else if (existingId) {
|
|
212
|
+
seenIds.add(existingId);
|
|
179
213
|
}
|
|
180
214
|
}
|
|
181
|
-
|
|
182
|
-
|
|
215
|
+
} else {
|
|
216
|
+
for (const node of addedNodes) {
|
|
217
|
+
if (!node.attrs.localId || localIds.has(node.attrs.localId) || seenIds.has(node.attrs.localId)) {
|
|
218
|
+
const pos = addedNodePos.get(node);
|
|
219
|
+
if (pos !== undefined) {
|
|
220
|
+
if (fg('platform_editor_localid_improvements')) {
|
|
221
|
+
const newId = generateUUID();
|
|
222
|
+
nodesToUpdate.set(pos, newId);
|
|
223
|
+
seenIds.add(newId);
|
|
224
|
+
} else {
|
|
225
|
+
addLocalIdToNode(pos, tr);
|
|
226
|
+
}
|
|
227
|
+
modified = true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (node.attrs.localId) {
|
|
231
|
+
seenIds.add(node.attrs.localId);
|
|
232
|
+
}
|
|
183
233
|
}
|
|
184
234
|
}
|
|
185
235
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _toArray from "@babel/runtime/helpers/toArray";
|
|
2
3
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
4
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
5
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -8,6 +9,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
8
9
|
import { stepHasSlice } from '@atlaskit/editor-common/utils';
|
|
9
10
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
13
|
import { generateShortUUID, generatedShortUUIDs } from './generateShortUUID';
|
|
12
14
|
export var localIdPluginKey = new PluginKey('localIdPlugin');
|
|
13
15
|
var generateUUID = function generateUUID() {
|
|
@@ -98,6 +100,11 @@ export var createPlugin = function createPlugin(api) {
|
|
|
98
100
|
// https://bitbucket.org/atlassian/adf-schema/src/fb2236147a0c2bc9c8efbdb75fd8f8c411df44ba/packages/adf-schema/src/next-schema/nodes/mediaGroup.ts#lines-12
|
|
99
101
|
var ignoredNodeTypes = [text === null || text === void 0 ? void 0 : text.name, hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.name, mediaGroup === null || mediaGroup === void 0 ? void 0 : mediaGroup.name];
|
|
100
102
|
var addedNodes = new Set();
|
|
103
|
+
// A single PMNode reference can appear at multiple positions in the doc (e.g.
|
|
104
|
+
// `createTable` from `prosemirror-utils` reuses cell node objects across
|
|
105
|
+
// non-header rows), so the new code path tracks every position per node identity.
|
|
106
|
+
// The legacy path retains the single-position-per-node map for compatibility.
|
|
107
|
+
var positionsByNode = new Map();
|
|
101
108
|
var addedNodePos = new Map();
|
|
102
109
|
var localIds = new Set();
|
|
103
110
|
var nodesToUpdate = new Map(); // position -> localId
|
|
@@ -134,7 +141,16 @@ export var createPlugin = function createPlugin(api) {
|
|
|
134
141
|
if (fg('platform_editor_use_localid_dedupe')) {
|
|
135
142
|
// Always add to addedNodes for duplicate prevention
|
|
136
143
|
addedNodes.add(node);
|
|
137
|
-
|
|
144
|
+
if (
|
|
145
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
146
|
+
fg('platform_editor_localid_improvements') && expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
|
|
147
|
+
var _positionsByNode$get;
|
|
148
|
+
var positions = (_positionsByNode$get = positionsByNode.get(node)) !== null && _positionsByNode$get !== void 0 ? _positionsByNode$get : new Set();
|
|
149
|
+
positions.add(pos);
|
|
150
|
+
positionsByNode.set(node, positions);
|
|
151
|
+
} else {
|
|
152
|
+
addedNodePos.set(node, pos);
|
|
153
|
+
}
|
|
138
154
|
} else {
|
|
139
155
|
if (!(node !== null && node !== void 0 && node.attrs.localId)) {
|
|
140
156
|
if (fg('platform_editor_localid_improvements')) {
|
|
@@ -166,32 +182,97 @@ export var createPlugin = function createPlugin(api) {
|
|
|
166
182
|
hasInitializedExistingUUIDs = true;
|
|
167
183
|
// Also ensure the added have no duplicates
|
|
168
184
|
var seenIds = new Set();
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
if (
|
|
186
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
187
|
+
fg('platform_editor_localid_improvements') && expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
|
|
188
|
+
var _iterator = _createForOfIteratorHelper(addedNodes),
|
|
189
|
+
_step;
|
|
190
|
+
try {
|
|
191
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
192
|
+
var node = _step.value;
|
|
193
|
+
var positions = positionsByNode.get(node);
|
|
194
|
+
if (!positions || positions.size === 0) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
var existingId = node.attrs.localId;
|
|
198
|
+
var needsNewIds = !existingId || localIds.has(existingId) || seenIds.has(existingId);
|
|
199
|
+
if (needsNewIds) {
|
|
200
|
+
// No usable localId: assign a fresh unique one to every position.
|
|
201
|
+
var _iterator2 = _createForOfIteratorHelper(positions),
|
|
202
|
+
_step2;
|
|
203
|
+
try {
|
|
204
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
205
|
+
var pos = _step2.value;
|
|
206
|
+
var newId = generateUUID();
|
|
207
|
+
nodesToUpdate.set(pos, newId);
|
|
208
|
+
seenIds.add(newId);
|
|
209
|
+
modified = true;
|
|
210
|
+
}
|
|
211
|
+
} catch (err) {
|
|
212
|
+
_iterator2.e(err);
|
|
213
|
+
} finally {
|
|
214
|
+
_iterator2.f();
|
|
215
|
+
}
|
|
216
|
+
} else if (positions.size > 1) {
|
|
217
|
+
// Shared node reference: keep the existing id at the first position,
|
|
218
|
+
// assign fresh ones to the rest so they don't share the same localId.
|
|
219
|
+
seenIds.add(existingId);
|
|
220
|
+
var _Array$from = Array.from(positions),
|
|
221
|
+
_Array$from2 = _toArray(_Array$from),
|
|
222
|
+
_first = _Array$from2[0],
|
|
223
|
+
rest = _Array$from2.slice(1);
|
|
224
|
+
var _iterator3 = _createForOfIteratorHelper(rest),
|
|
225
|
+
_step3;
|
|
226
|
+
try {
|
|
227
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
228
|
+
var _pos = _step3.value;
|
|
229
|
+
var _newId = generateUUID();
|
|
230
|
+
nodesToUpdate.set(_pos, _newId);
|
|
231
|
+
seenIds.add(_newId);
|
|
232
|
+
modified = true;
|
|
233
|
+
}
|
|
234
|
+
} catch (err) {
|
|
235
|
+
_iterator3.e(err);
|
|
236
|
+
} finally {
|
|
237
|
+
_iterator3.f();
|
|
183
238
|
}
|
|
184
|
-
|
|
239
|
+
} else if (existingId) {
|
|
240
|
+
seenIds.add(existingId);
|
|
185
241
|
}
|
|
186
242
|
}
|
|
187
|
-
|
|
188
|
-
|
|
243
|
+
} catch (err) {
|
|
244
|
+
_iterator.e(err);
|
|
245
|
+
} finally {
|
|
246
|
+
_iterator.f();
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
var _iterator4 = _createForOfIteratorHelper(addedNodes),
|
|
250
|
+
_step4;
|
|
251
|
+
try {
|
|
252
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
253
|
+
var _node = _step4.value;
|
|
254
|
+
if (!_node.attrs.localId || localIds.has(_node.attrs.localId) || seenIds.has(_node.attrs.localId)) {
|
|
255
|
+
var _pos2 = addedNodePos.get(_node);
|
|
256
|
+
if (_pos2 !== undefined) {
|
|
257
|
+
if (fg('platform_editor_localid_improvements')) {
|
|
258
|
+
var _newId2 = generateUUID();
|
|
259
|
+
nodesToUpdate.set(_pos2, _newId2);
|
|
260
|
+
seenIds.add(_newId2);
|
|
261
|
+
} else {
|
|
262
|
+
addLocalIdToNode(_pos2, tr);
|
|
263
|
+
}
|
|
264
|
+
modified = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (_node.attrs.localId) {
|
|
268
|
+
seenIds.add(_node.attrs.localId);
|
|
269
|
+
}
|
|
189
270
|
}
|
|
271
|
+
} catch (err) {
|
|
272
|
+
_iterator4.e(err);
|
|
273
|
+
} finally {
|
|
274
|
+
_iterator4.f();
|
|
190
275
|
}
|
|
191
|
-
} catch (err) {
|
|
192
|
-
_iterator.e(err);
|
|
193
|
-
} finally {
|
|
194
|
-
_iterator.f();
|
|
195
276
|
}
|
|
196
277
|
}
|
|
197
278
|
// Apply local ID updates based on the improvements feature flag:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-local-id",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "LocalId plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,11 +34,12 @@
|
|
|
34
34
|
"@atlaskit/editor-plugin-limited-mode": "^7.2.0",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
37
|
+
"@atlaskit/tmp-editor-statsig": "^82.2.0",
|
|
37
38
|
"@babel/runtime": "^7.0.0",
|
|
38
39
|
"raf-schd": "^4.0.3"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^114.
|
|
42
|
+
"@atlaskit/editor-common": "^114.40.0",
|
|
42
43
|
"react": "^18.2.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|