@atlaskit/editor-plugin-local-id 10.0.5 → 10.1.1

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,29 @@
1
1
  # @atlaskit/editor-plugin-local-id
2
2
 
3
+ ## 10.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 10.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`c3f49a97737db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c3f49a97737db) -
14
+ Generate localIds for nodes inserted when a template replaces the whole document (e.g. applying a
15
+ template to a blank page), gated behind the experiment `platform_editor_ai_template_localids`.
16
+
17
+ Such replacements are delivered by NCS as a remote `OverrideDocumentStep`, which has no `slice`
18
+ and so was skipped by the localId plugin's slice-based scan. When the experiment is enabled,
19
+ remote transactions containing an `OverrideDocumentStep` are now processed so the freshly inserted
20
+ template nodes receive localIds. Ordinary remote collaborator edits remain skipped, and nodes that
21
+ already have a localId are never overwritten.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+
3
27
  ## 10.0.5
4
28
 
5
29
  ### Patch Changes
@@ -109,12 +109,30 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
109
109
  if (!transaction.docChanged) {
110
110
  return;
111
111
  }
112
- if (transaction.getMeta('uiEvent') === 'cut' ||
113
- // We skip remote transactions as we don't want to affect transactions created
114
- // by other users
115
- Boolean(transaction.getMeta('isRemote'))) {
116
- return;
112
+ if ((0, _expValEquals.expValEquals)('platform_editor_ai_template_localids', 'isEnabled', true)) {
113
+ if (transaction.getMeta('uiEvent') === 'cut' ||
114
+ // We skip remote transactions as we don't want to affect transactions
115
+ // created by other collaborators.
116
+ //
117
+ // Exception (platform_editor_ai_template_localids): applying a template to a
118
+ // blank page arrives as a remote OverrideDocumentStep (a full-document
119
+ // replacement with no localIds). We still want those template nodes to get
120
+ // localIds, so we let such transactions through. Ordinary remote edits are
121
+ // still skipped, and existing localIds are never overwritten.
122
+ Boolean(transaction.getMeta('isRemote')) && !transaction.steps.some(function (step) {
123
+ return step instanceof _steps.OverrideDocumentStep;
124
+ })) {
125
+ return;
126
+ }
127
+ } else {
128
+ if (transaction.getMeta('uiEvent') === 'cut' ||
129
+ // We skip remote transactions as we don't want to affect transactions created
130
+ // by other users
131
+ Boolean(transaction.getMeta('isRemote'))) {
132
+ return;
133
+ }
117
134
  }
135
+
118
136
  // Ignore local ID updates for certain transactions
119
137
  // this is purposely not a public API as we should not use
120
138
  // this except in some circumstances (ie. streaming)
@@ -122,7 +140,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
122
140
  return;
123
141
  }
124
142
  transaction.steps.forEach(function (step) {
125
- if (!(0, _utils.stepHasSlice)(step)) {
143
+ // Steps with a slice are scanned for nodes that need localIds.
144
+ // OverrideDocumentStep (template replacement) has no `slice`, so when the
145
+ // experiment is on we also scan it so the inserted template nodes get
146
+ // localIds.
147
+ var isTemplateOverrideStep = step instanceof _steps.OverrideDocumentStep && (0, _expValEquals.expValEquals)('platform_editor_ai_template_localids', 'isEnabled', true);
148
+ if (!(0, _utils.stepHasSlice)(step) && !isTemplateOverrideStep) {
126
149
  return;
127
150
  }
128
151
  step.getMap().forEach(function (oldStart, oldEnd, newStart, newEnd) {
@@ -1,4 +1,4 @@
1
- import { BatchAttrsStep } from '@atlaskit/adf-schema/steps';
1
+ import { BatchAttrsStep, OverrideDocumentStep } from '@atlaskit/adf-schema/steps';
2
2
  import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { stepHasSlice } from '@atlaskit/editor-common/utils';
@@ -99,12 +99,28 @@ export const createPlugin = api => {
99
99
  if (!transaction.docChanged) {
100
100
  return;
101
101
  }
102
- if (transaction.getMeta('uiEvent') === 'cut' ||
103
- // We skip remote transactions as we don't want to affect transactions created
104
- // by other users
105
- Boolean(transaction.getMeta('isRemote'))) {
106
- return;
102
+ if (expValEquals('platform_editor_ai_template_localids', 'isEnabled', true)) {
103
+ if (transaction.getMeta('uiEvent') === 'cut' ||
104
+ // We skip remote transactions as we don't want to affect transactions
105
+ // created by other collaborators.
106
+ //
107
+ // Exception (platform_editor_ai_template_localids): applying a template to a
108
+ // blank page arrives as a remote OverrideDocumentStep (a full-document
109
+ // replacement with no localIds). We still want those template nodes to get
110
+ // localIds, so we let such transactions through. Ordinary remote edits are
111
+ // still skipped, and existing localIds are never overwritten.
112
+ Boolean(transaction.getMeta('isRemote')) && !transaction.steps.some(step => step instanceof OverrideDocumentStep)) {
113
+ return;
114
+ }
115
+ } else {
116
+ if (transaction.getMeta('uiEvent') === 'cut' ||
117
+ // We skip remote transactions as we don't want to affect transactions created
118
+ // by other users
119
+ Boolean(transaction.getMeta('isRemote'))) {
120
+ return;
121
+ }
107
122
  }
123
+
108
124
  // Ignore local ID updates for certain transactions
109
125
  // this is purposely not a public API as we should not use
110
126
  // this except in some circumstances (ie. streaming)
@@ -112,7 +128,12 @@ export const createPlugin = api => {
112
128
  return;
113
129
  }
114
130
  transaction.steps.forEach(step => {
115
- if (!stepHasSlice(step)) {
131
+ // Steps with a slice are scanned for nodes that need localIds.
132
+ // OverrideDocumentStep (template replacement) has no `slice`, so when the
133
+ // experiment is on we also scan it so the inserted template nodes get
134
+ // localIds.
135
+ const isTemplateOverrideStep = step instanceof OverrideDocumentStep && expValEquals('platform_editor_ai_template_localids', 'isEnabled', true);
136
+ if (!stepHasSlice(step) && !isTemplateOverrideStep) {
116
137
  return;
117
138
  }
118
139
  step.getMap().forEach((oldStart, oldEnd, newStart, newEnd) => {
@@ -3,7 +3,7 @@ import _toArray from "@babel/runtime/helpers/toArray";
3
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; } } }; }
4
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; } }
5
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; }
6
- import { BatchAttrsStep } from '@atlaskit/adf-schema/steps';
6
+ import { BatchAttrsStep, OverrideDocumentStep } from '@atlaskit/adf-schema/steps';
7
7
  import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
8
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
9
  import { stepHasSlice } from '@atlaskit/editor-common/utils';
@@ -102,12 +102,30 @@ export var createPlugin = function createPlugin(api) {
102
102
  if (!transaction.docChanged) {
103
103
  return;
104
104
  }
105
- if (transaction.getMeta('uiEvent') === 'cut' ||
106
- // We skip remote transactions as we don't want to affect transactions created
107
- // by other users
108
- Boolean(transaction.getMeta('isRemote'))) {
109
- return;
105
+ if (expValEquals('platform_editor_ai_template_localids', 'isEnabled', true)) {
106
+ if (transaction.getMeta('uiEvent') === 'cut' ||
107
+ // We skip remote transactions as we don't want to affect transactions
108
+ // created by other collaborators.
109
+ //
110
+ // Exception (platform_editor_ai_template_localids): applying a template to a
111
+ // blank page arrives as a remote OverrideDocumentStep (a full-document
112
+ // replacement with no localIds). We still want those template nodes to get
113
+ // localIds, so we let such transactions through. Ordinary remote edits are
114
+ // still skipped, and existing localIds are never overwritten.
115
+ Boolean(transaction.getMeta('isRemote')) && !transaction.steps.some(function (step) {
116
+ return step instanceof OverrideDocumentStep;
117
+ })) {
118
+ return;
119
+ }
120
+ } else {
121
+ if (transaction.getMeta('uiEvent') === 'cut' ||
122
+ // We skip remote transactions as we don't want to affect transactions created
123
+ // by other users
124
+ Boolean(transaction.getMeta('isRemote'))) {
125
+ return;
126
+ }
110
127
  }
128
+
111
129
  // Ignore local ID updates for certain transactions
112
130
  // this is purposely not a public API as we should not use
113
131
  // this except in some circumstances (ie. streaming)
@@ -115,7 +133,12 @@ export var createPlugin = function createPlugin(api) {
115
133
  return;
116
134
  }
117
135
  transaction.steps.forEach(function (step) {
118
- if (!stepHasSlice(step)) {
136
+ // Steps with a slice are scanned for nodes that need localIds.
137
+ // OverrideDocumentStep (template replacement) has no `slice`, so when the
138
+ // experiment is on we also scan it so the inserted template nodes get
139
+ // localIds.
140
+ var isTemplateOverrideStep = step instanceof OverrideDocumentStep && expValEquals('platform_editor_ai_template_localids', 'isEnabled', true);
141
+ if (!stepHasSlice(step) && !isTemplateOverrideStep) {
119
142
  return;
120
143
  }
121
144
  step.getMap().forEach(function (oldStart, oldEnd, newStart, newEnd) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-local-id",
3
- "version": "10.0.5",
3
+ "version": "10.1.1",
4
4
  "description": "LocalId plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,17 +26,17 @@
26
26
  "@atlaskit/editor-plugin-limited-mode": "^9.0.0",
27
27
  "@atlaskit/editor-prosemirror": "^8.0.0",
28
28
  "@atlaskit/platform-feature-flags": "^2.0.0",
29
- "@atlaskit/tmp-editor-statsig": "^108.3.0",
29
+ "@atlaskit/tmp-editor-statsig": "^110.0.0",
30
30
  "@babel/runtime": "^7.0.0",
31
31
  "raf-schd": "^4.0.3"
32
32
  },
33
33
  "peerDependencies": {
34
- "@atlaskit/editor-common": "^116.4.0",
34
+ "@atlaskit/editor-common": "^116.11.0",
35
35
  "react": "^18.2.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "react": "^18.2.0",
39
- "typescript": "5.9.2"
39
+ "typescript": "5.9.3"
40
40
  },
41
41
  "techstack": {
42
42
  "@atlassian/frontend": {