@atlaskit/editor-plugin-local-id 8.1.1 → 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 +24 -0
- package/dist/cjs/pm-plugins/main.js +103 -23
- package/dist/es2019/pm-plugins/main.js +61 -12
- package/dist/esm/pm-plugins/main.js +103 -23
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
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
|
+
|
|
19
|
+
## 8.1.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`79c9ce8cbf593`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/79c9ce8cbf593) -
|
|
24
|
+
FFCLEANUP-84819 - Clean up platform_editor_localid_ime_composition_fix
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 8.1.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ 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");
|
|
@@ -93,7 +94,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
93
94
|
*/
|
|
94
95
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
95
96
|
var _api$composition$shar;
|
|
96
|
-
if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing
|
|
97
|
+
if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing) {
|
|
97
98
|
return undefined;
|
|
98
99
|
}
|
|
99
100
|
var modified = false;
|
|
@@ -106,6 +107,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
106
107
|
// https://bitbucket.org/atlassian/adf-schema/src/fb2236147a0c2bc9c8efbdb75fd8f8c411df44ba/packages/adf-schema/src/next-schema/nodes/mediaGroup.ts#lines-12
|
|
107
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];
|
|
108
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();
|
|
109
115
|
var addedNodePos = new Map();
|
|
110
116
|
var localIds = new Set();
|
|
111
117
|
var nodesToUpdate = new Map(); // position -> localId
|
|
@@ -142,7 +148,16 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
142
148
|
if ((0, _platformFeatureFlags.fg)('platform_editor_use_localid_dedupe')) {
|
|
143
149
|
// Always add to addedNodes for duplicate prevention
|
|
144
150
|
addedNodes.add(node);
|
|
145
|
-
|
|
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
|
+
}
|
|
146
161
|
} else {
|
|
147
162
|
if (!(node !== null && node !== void 0 && node.attrs.localId)) {
|
|
148
163
|
if ((0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
|
|
@@ -174,32 +189,97 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
174
189
|
hasInitializedExistingUUIDs = true;
|
|
175
190
|
// Also ensure the added have no duplicates
|
|
176
191
|
var seenIds = new Set();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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();
|
|
191
245
|
}
|
|
192
|
-
|
|
246
|
+
} else if (existingId) {
|
|
247
|
+
seenIds.add(existingId);
|
|
193
248
|
}
|
|
194
249
|
}
|
|
195
|
-
|
|
196
|
-
|
|
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
|
+
}
|
|
197
277
|
}
|
|
278
|
+
} catch (err) {
|
|
279
|
+
_iterator4.e(err);
|
|
280
|
+
} finally {
|
|
281
|
+
_iterator4.f();
|
|
198
282
|
}
|
|
199
|
-
} catch (err) {
|
|
200
|
-
_iterator.e(err);
|
|
201
|
-
} finally {
|
|
202
|
-
_iterator.f();
|
|
203
283
|
}
|
|
204
284
|
}
|
|
205
285
|
// Apply local ID updates based on the improvements feature flag:
|
|
@@ -83,7 +83,7 @@ export const createPlugin = api => {
|
|
|
83
83
|
*/
|
|
84
84
|
appendTransaction: (transactions, _oldState, newState) => {
|
|
85
85
|
var _api$composition$shar;
|
|
86
|
-
if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing
|
|
86
|
+
if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing) {
|
|
87
87
|
return undefined;
|
|
88
88
|
}
|
|
89
89
|
let modified = false;
|
|
@@ -97,6 +97,11 @@ export const createPlugin = api => {
|
|
|
97
97
|
// https://bitbucket.org/atlassian/adf-schema/src/fb2236147a0c2bc9c8efbdb75fd8f8c411df44ba/packages/adf-schema/src/next-schema/nodes/mediaGroup.ts#lines-12
|
|
98
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];
|
|
99
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();
|
|
100
105
|
const addedNodePos = new Map();
|
|
101
106
|
const localIds = new Set();
|
|
102
107
|
const nodesToUpdate = new Map(); // position -> localId
|
|
@@ -133,7 +138,16 @@ export const createPlugin = api => {
|
|
|
133
138
|
if (fg('platform_editor_use_localid_dedupe')) {
|
|
134
139
|
// Always add to addedNodes for duplicate prevention
|
|
135
140
|
addedNodes.add(node);
|
|
136
|
-
|
|
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
|
+
}
|
|
137
151
|
} else {
|
|
138
152
|
if (!(node !== null && node !== void 0 && node.attrs.localId)) {
|
|
139
153
|
if (fg('platform_editor_localid_improvements')) {
|
|
@@ -165,22 +179,57 @@ export const createPlugin = api => {
|
|
|
165
179
|
hasInitializedExistingUUIDs = true;
|
|
166
180
|
// Also ensure the added have no duplicates
|
|
167
181
|
const seenIds = new Set();
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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) {
|
|
173
195
|
const newId = generateUUID();
|
|
174
196
|
nodesToUpdate.set(pos, newId);
|
|
175
197
|
seenIds.add(newId);
|
|
176
|
-
|
|
177
|
-
addLocalIdToNode(pos, tr);
|
|
198
|
+
modified = true;
|
|
178
199
|
}
|
|
179
|
-
|
|
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);
|
|
180
213
|
}
|
|
181
214
|
}
|
|
182
|
-
|
|
183
|
-
|
|
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
|
+
}
|
|
184
233
|
}
|
|
185
234
|
}
|
|
186
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; }
|
|
@@ -86,7 +87,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
86
87
|
*/
|
|
87
88
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
88
89
|
var _api$composition$shar;
|
|
89
|
-
if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing
|
|
90
|
+
if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing) {
|
|
90
91
|
return undefined;
|
|
91
92
|
}
|
|
92
93
|
var modified = false;
|
|
@@ -99,6 +100,11 @@ export var createPlugin = function createPlugin(api) {
|
|
|
99
100
|
// https://bitbucket.org/atlassian/adf-schema/src/fb2236147a0c2bc9c8efbdb75fd8f8c411df44ba/packages/adf-schema/src/next-schema/nodes/mediaGroup.ts#lines-12
|
|
100
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];
|
|
101
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();
|
|
102
108
|
var addedNodePos = new Map();
|
|
103
109
|
var localIds = new Set();
|
|
104
110
|
var nodesToUpdate = new Map(); // position -> localId
|
|
@@ -135,7 +141,16 @@ export var createPlugin = function createPlugin(api) {
|
|
|
135
141
|
if (fg('platform_editor_use_localid_dedupe')) {
|
|
136
142
|
// Always add to addedNodes for duplicate prevention
|
|
137
143
|
addedNodes.add(node);
|
|
138
|
-
|
|
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
|
+
}
|
|
139
154
|
} else {
|
|
140
155
|
if (!(node !== null && node !== void 0 && node.attrs.localId)) {
|
|
141
156
|
if (fg('platform_editor_localid_improvements')) {
|
|
@@ -167,32 +182,97 @@ export var createPlugin = function createPlugin(api) {
|
|
|
167
182
|
hasInitializedExistingUUIDs = true;
|
|
168
183
|
// Also ensure the added have no duplicates
|
|
169
184
|
var seenIds = new Set();
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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();
|
|
184
238
|
}
|
|
185
|
-
|
|
239
|
+
} else if (existingId) {
|
|
240
|
+
seenIds.add(existingId);
|
|
186
241
|
}
|
|
187
242
|
}
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
}
|
|
190
270
|
}
|
|
271
|
+
} catch (err) {
|
|
272
|
+
_iterator4.e(err);
|
|
273
|
+
} finally {
|
|
274
|
+
_iterator4.f();
|
|
191
275
|
}
|
|
192
|
-
} catch (err) {
|
|
193
|
-
_iterator.e(err);
|
|
194
|
-
} finally {
|
|
195
|
-
_iterator.f();
|
|
196
276
|
}
|
|
197
277
|
}
|
|
198
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",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^52.
|
|
31
|
+
"@atlaskit/adf-schema": "^52.13.0",
|
|
32
32
|
"@atlaskit/editor-plugin-collab-edit": "^11.2.0",
|
|
33
33
|
"@atlaskit/editor-plugin-composition": "^9.1.0",
|
|
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": "^
|
|
37
|
+
"@atlaskit/tmp-editor-statsig": "^82.2.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
39
|
"raf-schd": "^4.0.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@atlaskit/editor-common": "^114.
|
|
42
|
+
"@atlaskit/editor-common": "^114.40.0",
|
|
43
43
|
"react": "^18.2.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|