@atlaskit/editor-plugin-local-id 4.3.0 → 4.3.2

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,21 @@
1
1
  # @atlaskit/editor-plugin-local-id
2
2
 
3
+ ## 4.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`45270b9a8ed63`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/45270b9a8ed63) -
8
+ CONFCLOUD-83370: Fix broken IME composition
9
+ - Updated dependencies
10
+
11
+ ## 4.3.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`65e23b9169d24`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65e23b9169d24) -
16
+ Do not pre-load local ids with collab
17
+ - Updated dependencies
18
+
3
19
  ## 4.3.0
4
20
 
5
21
  ### Minor Changes
@@ -18,9 +18,18 @@
18
18
  "../src/**/examples.*"
19
19
  ],
20
20
  "references": [
21
+ {
22
+ "path": "../../adf-schema/afm-cc/tsconfig.json"
23
+ },
24
+ {
25
+ "path": "../../editor-prosemirror/afm-cc/tsconfig.json"
26
+ },
21
27
  {
22
28
  "path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
23
29
  },
30
+ {
31
+ "path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
32
+ },
24
33
  {
25
34
  "path": "../../editor-common/afm-cc/tsconfig.json"
26
35
  }
@@ -18,6 +18,12 @@
18
18
  "../src/**/examples.*"
19
19
  ],
20
20
  "references": [
21
+ {
22
+ "path": "../../adf-schema/afm-jira/tsconfig.json"
23
+ },
24
+ {
25
+ "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
26
+ },
21
27
  {
22
28
  "path": "../../../platform/feature-flags/afm-jira/tsconfig.json"
23
29
  },
@@ -18,6 +18,12 @@
18
18
  "../src/**/examples.*"
19
19
  ],
20
20
  "references": [
21
+ {
22
+ "path": "../../adf-schema/afm-products/tsconfig.json"
23
+ },
24
+ {
25
+ "path": "../../editor-prosemirror/afm-products/tsconfig.json"
26
+ },
21
27
  {
22
28
  "path": "../../../platform/feature-flags/afm-products/tsconfig.json"
23
29
  },
@@ -13,6 +13,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
13
  var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
17
  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
18
  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; } }
18
19
  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; }
@@ -45,6 +46,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
45
46
  * to nodes that don't have them. It's designed to run only once per
46
47
  * editor instance to avoid performance issues.
47
48
  */
49
+ // @ts-expect-error - This is an experiment to see if we can improve performance - if successful
50
+ // we will add the plugin as a dependency
51
+ if (api !== null && api !== void 0 && api.collabEdit && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_avoid_initial_localId')) {
52
+ return {
53
+ update: function update() {}
54
+ };
55
+ }
48
56
  requestIdleCallbackWithFallback(function () {
49
57
  var tr = editorView.state.tr;
50
58
  var localIdWasAdded = false;
@@ -90,6 +98,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
90
98
  * This ensures uniqueness of localIds on nodes being created or edited
91
99
  */
92
100
  appendTransaction: function appendTransaction(transactions, _oldState, newState) {
101
+ var _api$composition$shar;
102
+ if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing && (0, _expValEquals.expValEquals)('platform_editor_localid_ime_composition_fix', 'isEnabled', true)) {
103
+ return undefined;
104
+ }
93
105
  var modified = false;
94
106
  var tr = newState.tr;
95
107
  var _newState$schema$node = newState.schema.nodes,
@@ -153,7 +165,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
153
165
  });
154
166
  });
155
167
  if (addedNodes.size > 0 && (0, _platformFeatureFlags.fg)('platform_editor_use_localid_dedupe')) {
156
- newState.doc.descendants(function (node, pos) {
168
+ newState.doc.descendants(function (node) {
157
169
  if (addedNodes.has(node)) {
158
170
  return true;
159
171
  }
@@ -190,7 +202,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
190
202
  _iterator.f();
191
203
  }
192
204
  }
193
-
194
205
  // Apply local ID updates based on the improvements feature flag:
195
206
  // - When enabled: Batch all updates into a single BatchAttrsStep
196
207
  // - When disabled: Individual steps were already applied above during node processing
@@ -5,6 +5,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import { stepHasSlice } from '@atlaskit/editor-common/utils';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  export const localIdPluginKey = new PluginKey('localIdPlugin');
9
10
  const generateUUID = (api, node, pos) => {
10
11
  if (fg('platform_editor_ai_local_id_short')) {
@@ -34,6 +35,13 @@ export const createPlugin = api => {
34
35
  * to nodes that don't have them. It's designed to run only once per
35
36
  * editor instance to avoid performance issues.
36
37
  */
38
+ // @ts-expect-error - This is an experiment to see if we can improve performance - if successful
39
+ // we will add the plugin as a dependency
40
+ if (api !== null && api !== void 0 && api.collabEdit && fg('platform_editor_ai_aifc_avoid_initial_localId')) {
41
+ return {
42
+ update: () => {}
43
+ };
44
+ }
37
45
  requestIdleCallbackWithFallback(() => {
38
46
  const tr = editorView.state.tr;
39
47
  let localIdWasAdded = false;
@@ -80,6 +88,10 @@ export const createPlugin = api => {
80
88
  * This ensures uniqueness of localIds on nodes being created or edited
81
89
  */
82
90
  appendTransaction: (transactions, _oldState, newState) => {
91
+ var _api$composition$shar;
92
+ if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing && expValEquals('platform_editor_localid_ime_composition_fix', 'isEnabled', true)) {
93
+ return undefined;
94
+ }
83
95
  let modified = false;
84
96
  const tr = newState.tr;
85
97
  const {
@@ -144,7 +156,7 @@ export const createPlugin = api => {
144
156
  });
145
157
  });
146
158
  if (addedNodes.size > 0 && fg('platform_editor_use_localid_dedupe')) {
147
- newState.doc.descendants((node, pos) => {
159
+ newState.doc.descendants(node => {
148
160
  if (addedNodes.has(node)) {
149
161
  return true;
150
162
  }
@@ -172,7 +184,6 @@ export const createPlugin = api => {
172
184
  }
173
185
  }
174
186
  }
175
-
176
187
  // Apply local ID updates based on the improvements feature flag:
177
188
  // - When enabled: Batch all updates into a single BatchAttrsStep
178
189
  // - When disabled: Individual steps were already applied above during node processing
@@ -9,6 +9,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
9
  import { stepHasSlice } from '@atlaskit/editor-common/utils';
10
10
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  export var localIdPluginKey = new PluginKey('localIdPlugin');
13
14
  var generateUUID = function generateUUID(api, node, pos) {
14
15
  if (fg('platform_editor_ai_local_id_short')) {
@@ -38,6 +39,13 @@ export var createPlugin = function createPlugin(api) {
38
39
  * to nodes that don't have them. It's designed to run only once per
39
40
  * editor instance to avoid performance issues.
40
41
  */
42
+ // @ts-expect-error - This is an experiment to see if we can improve performance - if successful
43
+ // we will add the plugin as a dependency
44
+ if (api !== null && api !== void 0 && api.collabEdit && fg('platform_editor_ai_aifc_avoid_initial_localId')) {
45
+ return {
46
+ update: function update() {}
47
+ };
48
+ }
41
49
  requestIdleCallbackWithFallback(function () {
42
50
  var tr = editorView.state.tr;
43
51
  var localIdWasAdded = false;
@@ -83,6 +91,10 @@ export var createPlugin = function createPlugin(api) {
83
91
  * This ensures uniqueness of localIds on nodes being created or edited
84
92
  */
85
93
  appendTransaction: function appendTransaction(transactions, _oldState, newState) {
94
+ var _api$composition$shar;
95
+ if (api !== null && api !== void 0 && (_api$composition$shar = api.composition.sharedState.currentState()) !== null && _api$composition$shar !== void 0 && _api$composition$shar.isComposing && expValEquals('platform_editor_localid_ime_composition_fix', 'isEnabled', true)) {
96
+ return undefined;
97
+ }
86
98
  var modified = false;
87
99
  var tr = newState.tr;
88
100
  var _newState$schema$node = newState.schema.nodes,
@@ -146,7 +158,7 @@ export var createPlugin = function createPlugin(api) {
146
158
  });
147
159
  });
148
160
  if (addedNodes.size > 0 && fg('platform_editor_use_localid_dedupe')) {
149
- newState.doc.descendants(function (node, pos) {
161
+ newState.doc.descendants(function (node) {
150
162
  if (addedNodes.has(node)) {
151
163
  return true;
152
164
  }
@@ -183,7 +195,6 @@ export var createPlugin = function createPlugin(api) {
183
195
  _iterator.f();
184
196
  }
185
197
  }
186
-
187
198
  // Apply local ID updates based on the improvements feature flag:
188
199
  // - When enabled: Batch all updates into a single BatchAttrsStep
189
200
  // - When disabled: Individual steps were already applied above during node processing
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
2
3
  import type { Node } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
5
  export type ActionProps = {
@@ -24,4 +25,5 @@ export type LocalIdPlugin = NextEditorPlugin<'localId', {
24
25
  value: Node;
25
26
  }) => boolean;
26
27
  };
28
+ dependencies: [CompositionPlugin];
27
29
  }>;
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
2
3
  import type { Node } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
5
  export type ActionProps = {
@@ -24,4 +25,7 @@ export type LocalIdPlugin = NextEditorPlugin<'localId', {
24
25
  value: Node;
25
26
  }) => boolean;
26
27
  };
28
+ dependencies: [
29
+ CompositionPlugin
30
+ ];
27
31
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-local-id",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "LocalId plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,14 +28,15 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^51.5.1",
32
- "@atlaskit/editor-prosemirror": "7.0.0",
31
+ "@atlaskit/adf-schema": "^51.5.0",
32
+ "@atlaskit/editor-prosemirror": "^7.2.0",
33
33
  "@atlaskit/platform-feature-flags": "^1.1.0",
34
+ "@atlaskit/tmp-editor-statsig": "^16.3.0",
34
35
  "@babel/runtime": "^7.0.0",
35
36
  "raf-schd": "^4.0.3"
36
37
  },
37
38
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^110.41.0",
39
+ "@atlaskit/editor-common": "^110.49.0",
39
40
  "react": "^18.2.0"
40
41
  },
41
42
  "devDependencies": {
@@ -84,6 +85,9 @@
84
85
  "platform_editor_ai_local_id_short": {
85
86
  "type": "boolean"
86
87
  },
88
+ "platform_editor_ai_aifc_avoid_initial_localId": {
89
+ "type": "boolean"
90
+ },
87
91
  "platform_editor_localid_improvements": {
88
92
  "type": "boolean"
89
93
  }