@atlaskit/editor-plugin-local-id 8.2.0 → 8.3.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-local-id
2
2
 
3
+ ## 8.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1c5e23accfe24`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1c5e23accfe24) -
8
+ Cleanup feature gate platform_editor_localid_improvements. Updates are now always batched into a
9
+ single BatchAttrsStep. Removes the unused addLocalIdToNode export.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 8.2.0
4
16
 
5
17
  ### Minor Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.localIdPluginKey = exports.createPlugin = exports.batchAddLocalIdToNodes = exports.addLocalIdToNode = void 0;
7
+ exports.localIdPluginKey = exports.createPlugin = exports.batchAddLocalIdToNodes = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
10
10
  var _steps = require("@atlaskit/adf-schema/steps");
@@ -50,7 +50,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
50
50
  }
51
51
  requestIdleCallbackWithFallback(function () {
52
52
  var tr = editorView.state.tr;
53
- var localIdWasAdded = false;
54
53
  var nodesToUpdate = new Map(); // position -> localId
55
54
 
56
55
  var _editorView$state$sch = editorView.state.schema.nodes,
@@ -63,23 +62,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
63
62
  editorView.state.doc.descendants(function (node, pos) {
64
63
  var _node$type$spec$attrs;
65
64
  if (!ignoredNodeTypes.includes(node.type.name) && !node.attrs.localId && !!((_node$type$spec$attrs = node.type.spec.attrs) !== null && _node$type$spec$attrs !== void 0 && _node$type$spec$attrs.localId)) {
66
- if ((0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
67
- nodesToUpdate.set(pos, generateUUID());
68
- } else {
69
- localIdWasAdded = true;
70
- addLocalIdToNode(pos, tr);
71
- }
65
+ nodesToUpdate.set(pos, generateUUID());
72
66
  }
73
67
  return true; // Continue traversing
74
68
  });
75
- if ((0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
76
- if (nodesToUpdate.size > 0) {
77
- batchAddLocalIdToNodes(nodesToUpdate, tr);
78
- (0, _collab.tintDirtyTransaction)(tr);
79
- editorView.dispatch(tr);
80
- }
81
- } else if (localIdWasAdded) {
82
- tr.setMeta('addToHistory', false);
69
+ if (nodesToUpdate.size > 0) {
70
+ batchAddLocalIdToNodes(nodesToUpdate, tr);
83
71
  (0, _collab.tintDirtyTransaction)(tr);
84
72
  editorView.dispatch(tr);
85
73
  }
@@ -148,9 +136,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
148
136
  if ((0, _platformFeatureFlags.fg)('platform_editor_use_localid_dedupe')) {
149
137
  // Always add to addedNodes for duplicate prevention
150
138
  addedNodes.add(node);
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)) {
139
+ if ((0, _expValEquals.expValEquals)('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
154
140
  var _positionsByNode$get;
155
141
  var positions = (_positionsByNode$get = positionsByNode.get(node)) !== null && _positionsByNode$get !== void 0 ? _positionsByNode$get : new Set();
156
142
  positions.add(pos);
@@ -160,12 +146,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
160
146
  }
161
147
  } else {
162
148
  if (!(node !== null && node !== void 0 && node.attrs.localId)) {
163
- if ((0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
164
- nodesToUpdate.set(pos, generateUUID());
165
- } else {
166
- // Legacy behavior - individual steps
167
- addLocalIdToNode(pos, tr);
168
- }
149
+ nodesToUpdate.set(pos, generateUUID());
169
150
  }
170
151
  }
171
152
  return true;
@@ -189,9 +170,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
189
170
  hasInitializedExistingUUIDs = true;
190
171
  // Also ensure the added have no duplicates
191
172
  var seenIds = new Set();
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)) {
173
+ if ((0, _expValEquals.expValEquals)('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
195
174
  var _iterator = _createForOfIteratorHelper(addedNodes),
196
175
  _step;
197
176
  try {
@@ -261,13 +240,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
261
240
  if (!_node.attrs.localId || localIds.has(_node.attrs.localId) || seenIds.has(_node.attrs.localId)) {
262
241
  var _pos2 = addedNodePos.get(_node);
263
242
  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
- }
243
+ var _newId2 = generateUUID();
244
+ nodesToUpdate.set(_pos2, _newId2);
245
+ seenIds.add(_newId2);
271
246
  modified = true;
272
247
  }
273
248
  }
@@ -285,26 +260,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
285
260
  // Apply local ID updates based on the improvements feature flag:
286
261
  // - When enabled: Batch all updates into a single BatchAttrsStep
287
262
  // - When disabled: Individual steps were already applied above during node processing
288
- if (modified && nodesToUpdate.size > 0 && (0, _platformFeatureFlags.fg)('platform_editor_localid_improvements')) {
263
+ if (modified && nodesToUpdate.size > 0) {
289
264
  batchAddLocalIdToNodes(nodesToUpdate, tr);
290
265
  }
291
266
  return modified ? tr : undefined;
292
267
  }
293
268
  });
294
269
  };
295
- /**
296
- * Adds a local ID to a ProseMirror node
297
- *
298
- * This utility function updates a node's attributes to include a unique local ID.
299
- *
300
- * @param pos - The position of the node in the document
301
- * @param tr - The transaction to apply the change to
302
- */
303
- var addLocalIdToNode = exports.addLocalIdToNode = function addLocalIdToNode(pos, tr) {
304
- tr.setNodeAttribute(pos, 'localId', generateUUID());
305
- tr.setMeta('addToHistory', false);
306
- };
307
-
308
270
  /**
309
271
  * Batch adds local IDs to nodes using a BatchAttrsStep
310
272
  * @param nodesToUpdate Map of position -> localId for nodes that need updates
@@ -38,7 +38,6 @@ export const createPlugin = api => {
38
38
  }
39
39
  requestIdleCallbackWithFallback(() => {
40
40
  const tr = editorView.state.tr;
41
- let localIdWasAdded = false;
42
41
  const nodesToUpdate = new Map(); // position -> localId
43
42
 
44
43
  const {
@@ -52,23 +51,12 @@ export const createPlugin = api => {
52
51
  editorView.state.doc.descendants((node, pos) => {
53
52
  var _node$type$spec$attrs;
54
53
  if (!ignoredNodeTypes.includes(node.type.name) && !node.attrs.localId && !!((_node$type$spec$attrs = node.type.spec.attrs) !== null && _node$type$spec$attrs !== void 0 && _node$type$spec$attrs.localId)) {
55
- if (fg('platform_editor_localid_improvements')) {
56
- nodesToUpdate.set(pos, generateUUID());
57
- } else {
58
- localIdWasAdded = true;
59
- addLocalIdToNode(pos, tr);
60
- }
54
+ nodesToUpdate.set(pos, generateUUID());
61
55
  }
62
56
  return true; // Continue traversing
63
57
  });
64
- if (fg('platform_editor_localid_improvements')) {
65
- if (nodesToUpdate.size > 0) {
66
- batchAddLocalIdToNodes(nodesToUpdate, tr);
67
- tintDirtyTransaction(tr);
68
- editorView.dispatch(tr);
69
- }
70
- } else if (localIdWasAdded) {
71
- tr.setMeta('addToHistory', false);
58
+ if (nodesToUpdate.size > 0) {
59
+ batchAddLocalIdToNodes(nodesToUpdate, tr);
72
60
  tintDirtyTransaction(tr);
73
61
  editorView.dispatch(tr);
74
62
  }
@@ -138,9 +126,7 @@ export const createPlugin = api => {
138
126
  if (fg('platform_editor_use_localid_dedupe')) {
139
127
  // Always add to addedNodes for duplicate prevention
140
128
  addedNodes.add(node);
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)) {
129
+ if (expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
144
130
  var _positionsByNode$get;
145
131
  const positions = (_positionsByNode$get = positionsByNode.get(node)) !== null && _positionsByNode$get !== void 0 ? _positionsByNode$get : new Set();
146
132
  positions.add(pos);
@@ -150,12 +136,7 @@ export const createPlugin = api => {
150
136
  }
151
137
  } else {
152
138
  if (!(node !== null && node !== void 0 && node.attrs.localId)) {
153
- if (fg('platform_editor_localid_improvements')) {
154
- nodesToUpdate.set(pos, generateUUID());
155
- } else {
156
- // Legacy behavior - individual steps
157
- addLocalIdToNode(pos, tr);
158
- }
139
+ nodesToUpdate.set(pos, generateUUID());
159
140
  }
160
141
  }
161
142
  return true;
@@ -179,9 +160,7 @@ export const createPlugin = api => {
179
160
  hasInitializedExistingUUIDs = true;
180
161
  // Also ensure the added have no duplicates
181
162
  const seenIds = new Set();
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)) {
163
+ if (expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
185
164
  for (const node of addedNodes) {
186
165
  const positions = positionsByNode.get(node);
187
166
  if (!positions || positions.size === 0) {
@@ -217,13 +196,9 @@ export const createPlugin = api => {
217
196
  if (!node.attrs.localId || localIds.has(node.attrs.localId) || seenIds.has(node.attrs.localId)) {
218
197
  const pos = addedNodePos.get(node);
219
198
  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
- }
199
+ const newId = generateUUID();
200
+ nodesToUpdate.set(pos, newId);
201
+ seenIds.add(newId);
227
202
  modified = true;
228
203
  }
229
204
  }
@@ -236,26 +211,13 @@ export const createPlugin = api => {
236
211
  // Apply local ID updates based on the improvements feature flag:
237
212
  // - When enabled: Batch all updates into a single BatchAttrsStep
238
213
  // - When disabled: Individual steps were already applied above during node processing
239
- if (modified && nodesToUpdate.size > 0 && fg('platform_editor_localid_improvements')) {
214
+ if (modified && nodesToUpdate.size > 0) {
240
215
  batchAddLocalIdToNodes(nodesToUpdate, tr);
241
216
  }
242
217
  return modified ? tr : undefined;
243
218
  }
244
219
  });
245
220
  };
246
- /**
247
- * Adds a local ID to a ProseMirror node
248
- *
249
- * This utility function updates a node's attributes to include a unique local ID.
250
- *
251
- * @param pos - The position of the node in the document
252
- * @param tr - The transaction to apply the change to
253
- */
254
- export const addLocalIdToNode = (pos, tr) => {
255
- tr.setNodeAttribute(pos, 'localId', generateUUID());
256
- tr.setMeta('addToHistory', false);
257
- };
258
-
259
221
  /**
260
222
  * Batch adds local IDs to nodes using a BatchAttrsStep
261
223
  * @param nodesToUpdate Map of position -> localId for nodes that need updates
@@ -43,7 +43,6 @@ export var createPlugin = function createPlugin(api) {
43
43
  }
44
44
  requestIdleCallbackWithFallback(function () {
45
45
  var tr = editorView.state.tr;
46
- var localIdWasAdded = false;
47
46
  var nodesToUpdate = new Map(); // position -> localId
48
47
 
49
48
  var _editorView$state$sch = editorView.state.schema.nodes,
@@ -56,23 +55,12 @@ export var createPlugin = function createPlugin(api) {
56
55
  editorView.state.doc.descendants(function (node, pos) {
57
56
  var _node$type$spec$attrs;
58
57
  if (!ignoredNodeTypes.includes(node.type.name) && !node.attrs.localId && !!((_node$type$spec$attrs = node.type.spec.attrs) !== null && _node$type$spec$attrs !== void 0 && _node$type$spec$attrs.localId)) {
59
- if (fg('platform_editor_localid_improvements')) {
60
- nodesToUpdate.set(pos, generateUUID());
61
- } else {
62
- localIdWasAdded = true;
63
- addLocalIdToNode(pos, tr);
64
- }
58
+ nodesToUpdate.set(pos, generateUUID());
65
59
  }
66
60
  return true; // Continue traversing
67
61
  });
68
- if (fg('platform_editor_localid_improvements')) {
69
- if (nodesToUpdate.size > 0) {
70
- batchAddLocalIdToNodes(nodesToUpdate, tr);
71
- tintDirtyTransaction(tr);
72
- editorView.dispatch(tr);
73
- }
74
- } else if (localIdWasAdded) {
75
- tr.setMeta('addToHistory', false);
62
+ if (nodesToUpdate.size > 0) {
63
+ batchAddLocalIdToNodes(nodesToUpdate, tr);
76
64
  tintDirtyTransaction(tr);
77
65
  editorView.dispatch(tr);
78
66
  }
@@ -141,9 +129,7 @@ export var createPlugin = function createPlugin(api) {
141
129
  if (fg('platform_editor_use_localid_dedupe')) {
142
130
  // Always add to addedNodes for duplicate prevention
143
131
  addedNodes.add(node);
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)) {
132
+ if (expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
147
133
  var _positionsByNode$get;
148
134
  var positions = (_positionsByNode$get = positionsByNode.get(node)) !== null && _positionsByNode$get !== void 0 ? _positionsByNode$get : new Set();
149
135
  positions.add(pos);
@@ -153,12 +139,7 @@ export var createPlugin = function createPlugin(api) {
153
139
  }
154
140
  } else {
155
141
  if (!(node !== null && node !== void 0 && node.attrs.localId)) {
156
- if (fg('platform_editor_localid_improvements')) {
157
- nodesToUpdate.set(pos, generateUUID());
158
- } else {
159
- // Legacy behavior - individual steps
160
- addLocalIdToNode(pos, tr);
161
- }
142
+ nodesToUpdate.set(pos, generateUUID());
162
143
  }
163
144
  }
164
145
  return true;
@@ -182,9 +163,7 @@ export var createPlugin = function createPlugin(api) {
182
163
  hasInitializedExistingUUIDs = true;
183
164
  // Also ensure the added have no duplicates
184
165
  var seenIds = new Set();
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)) {
166
+ if (expValEquals('platform_editor_ai_tablecell_localids', 'isEnabled', true)) {
188
167
  var _iterator = _createForOfIteratorHelper(addedNodes),
189
168
  _step;
190
169
  try {
@@ -254,13 +233,9 @@ export var createPlugin = function createPlugin(api) {
254
233
  if (!_node.attrs.localId || localIds.has(_node.attrs.localId) || seenIds.has(_node.attrs.localId)) {
255
234
  var _pos2 = addedNodePos.get(_node);
256
235
  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
- }
236
+ var _newId2 = generateUUID();
237
+ nodesToUpdate.set(_pos2, _newId2);
238
+ seenIds.add(_newId2);
264
239
  modified = true;
265
240
  }
266
241
  }
@@ -278,26 +253,13 @@ export var createPlugin = function createPlugin(api) {
278
253
  // Apply local ID updates based on the improvements feature flag:
279
254
  // - When enabled: Batch all updates into a single BatchAttrsStep
280
255
  // - When disabled: Individual steps were already applied above during node processing
281
- if (modified && nodesToUpdate.size > 0 && fg('platform_editor_localid_improvements')) {
256
+ if (modified && nodesToUpdate.size > 0) {
282
257
  batchAddLocalIdToNodes(nodesToUpdate, tr);
283
258
  }
284
259
  return modified ? tr : undefined;
285
260
  }
286
261
  });
287
262
  };
288
- /**
289
- * Adds a local ID to a ProseMirror node
290
- *
291
- * This utility function updates a node's attributes to include a unique local ID.
292
- *
293
- * @param pos - The position of the node in the document
294
- * @param tr - The transaction to apply the change to
295
- */
296
- export var addLocalIdToNode = function addLocalIdToNode(pos, tr) {
297
- tr.setNodeAttribute(pos, 'localId', generateUUID());
298
- tr.setMeta('addToHistory', false);
299
- };
300
-
301
263
  /**
302
264
  * Batch adds local IDs to nodes using a BatchAttrsStep
303
265
  * @param nodesToUpdate Map of position -> localId for nodes that need updates
@@ -4,15 +4,6 @@ import { PluginKey, type Transaction } from '@atlaskit/editor-prosemirror/state'
4
4
  import type { LocalIdPlugin } from '../localIdPluginType';
5
5
  export declare const localIdPluginKey: PluginKey;
6
6
  export declare const createPlugin: (api: ExtractInjectionAPI<LocalIdPlugin> | undefined) => SafePlugin;
7
- /**
8
- * Adds a local ID to a ProseMirror node
9
- *
10
- * This utility function updates a node's attributes to include a unique local ID.
11
- *
12
- * @param pos - The position of the node in the document
13
- * @param tr - The transaction to apply the change to
14
- */
15
- export declare const addLocalIdToNode: (pos: number, tr: Transaction) => void;
16
7
  /**
17
8
  * Batch adds local IDs to nodes using a BatchAttrsStep
18
9
  * @param nodesToUpdate Map of position -> localId for nodes that need updates
@@ -4,15 +4,6 @@ import { PluginKey, type Transaction } from '@atlaskit/editor-prosemirror/state'
4
4
  import type { LocalIdPlugin } from '../localIdPluginType';
5
5
  export declare const localIdPluginKey: PluginKey;
6
6
  export declare const createPlugin: (api: ExtractInjectionAPI<LocalIdPlugin> | undefined) => SafePlugin;
7
- /**
8
- * Adds a local ID to a ProseMirror node
9
- *
10
- * This utility function updates a node's attributes to include a unique local ID.
11
- *
12
- * @param pos - The position of the node in the document
13
- * @param tr - The transaction to apply the change to
14
- */
15
- export declare const addLocalIdToNode: (pos: number, tr: Transaction) => void;
16
7
  /**
17
8
  * Batch adds local IDs to nodes using a BatchAttrsStep
18
9
  * @param nodesToUpdate Map of position -> localId for nodes that need updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-local-id",
3
- "version": "8.2.0",
3
+ "version": "8.3.0",
4
4
  "description": "LocalId plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,15 +34,16 @@
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
+ "@atlaskit/tmp-editor-statsig": "^82.3.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.40.0",
42
+ "@atlaskit/editor-common": "^114.41.0",
43
43
  "react": "^18.2.0"
44
44
  },
45
45
  "devDependencies": {
46
+ "react": "^18.2.0",
46
47
  "typescript": "5.9.2"
47
48
  },
48
49
  "techstack": {
@@ -85,9 +86,6 @@
85
86
  "platform_editor_use_localid_dedupe": {
86
87
  "type": "boolean"
87
88
  },
88
- "platform_editor_localid_improvements": {
89
- "type": "boolean"
90
- },
91
89
  "platform_editor_ai_aifc_localid_error_reporting": {
92
90
  "type": "boolean"
93
91
  }