@atlaskit/editor-synced-block-provider 12.2.0 → 12.2.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,15 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 12.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c5bc5493c5486`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c5bc5493c5486) -
8
+ Fix migrateSyncBlockIds mutating the caller's input ADF document. traverse() falls back to
9
+ mutating a node in place whenever its visitor returns undefined, so the transform now always
10
+ returns a copy instead.
11
+ - Updated dependencies
12
+
3
13
  ## 12.2.0
4
14
 
5
15
  ### Minor Changes
@@ -72,14 +72,19 @@ var migrateAttrs = function migrateAttrs(attrs, resolvers, unresolvedContentIds)
72
72
  var migrateSyncBlockIds = exports.migrateSyncBlockIds = function migrateSyncBlockIds(adf, resolvers) {
73
73
  var unresolvedContentIds = new Set();
74
74
  var isTransformed = false;
75
+
76
+ // Always returns a copy, even when nothing changes: traverse() falls back to mutating
77
+ // the original node in place (its `content` array gets reassigned) whenever a visitor
78
+ // returns undefined, so returning undefined here would leak that mutation onto the
79
+ // caller's input document.
75
80
  var migrateNode = function migrateNode(node) {
76
81
  var syncBlockAttrs = node.attrs && parseSyncBlockAttrs(node.attrs);
77
82
  if (!syncBlockAttrs) {
78
- return undefined;
83
+ return _objectSpread({}, node);
79
84
  }
80
85
  var nextAttrs = migrateAttrs(syncBlockAttrs, resolvers, unresolvedContentIds);
81
86
  if (!nextAttrs) {
82
- return undefined;
87
+ return _objectSpread({}, node);
83
88
  }
84
89
  isTransformed = true;
85
90
  return _objectSpread(_objectSpread({}, node), {}, {
@@ -67,14 +67,23 @@ const migrateAttrs = (attrs, resolvers, unresolvedContentIds) => {
67
67
  export const migrateSyncBlockIds = (adf, resolvers) => {
68
68
  const unresolvedContentIds = new Set();
69
69
  let isTransformed = false;
70
+
71
+ // Always returns a copy, even when nothing changes: traverse() falls back to mutating
72
+ // the original node in place (its `content` array gets reassigned) whenever a visitor
73
+ // returns undefined, so returning undefined here would leak that mutation onto the
74
+ // caller's input document.
70
75
  const migrateNode = node => {
71
76
  const syncBlockAttrs = node.attrs && parseSyncBlockAttrs(node.attrs);
72
77
  if (!syncBlockAttrs) {
73
- return undefined;
78
+ return {
79
+ ...node
80
+ };
74
81
  }
75
82
  const nextAttrs = migrateAttrs(syncBlockAttrs, resolvers, unresolvedContentIds);
76
83
  if (!nextAttrs) {
77
- return undefined;
84
+ return {
85
+ ...node
86
+ };
78
87
  }
79
88
  isTransformed = true;
80
89
  return {
@@ -66,14 +66,19 @@ var migrateAttrs = function migrateAttrs(attrs, resolvers, unresolvedContentIds)
66
66
  export var migrateSyncBlockIds = function migrateSyncBlockIds(adf, resolvers) {
67
67
  var unresolvedContentIds = new Set();
68
68
  var isTransformed = false;
69
+
70
+ // Always returns a copy, even when nothing changes: traverse() falls back to mutating
71
+ // the original node in place (its `content` array gets reassigned) whenever a visitor
72
+ // returns undefined, so returning undefined here would leak that mutation onto the
73
+ // caller's input document.
69
74
  var migrateNode = function migrateNode(node) {
70
75
  var syncBlockAttrs = node.attrs && parseSyncBlockAttrs(node.attrs);
71
76
  if (!syncBlockAttrs) {
72
- return undefined;
77
+ return _objectSpread({}, node);
73
78
  }
74
79
  var nextAttrs = migrateAttrs(syncBlockAttrs, resolvers, unresolvedContentIds);
75
80
  if (!nextAttrs) {
76
- return undefined;
81
+ return _objectSpread({}, node);
77
82
  }
78
83
  isTransformed = true;
79
84
  return _objectSpread(_objectSpread({}, node), {}, {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "atlaskit:src": "src/index.ts",
18
18
  "dependencies": {
19
- "@atlaskit/adf-utils": "^20.8.0",
19
+ "@atlaskit/adf-utils": "^20.9.0",
20
20
  "@atlaskit/browser-apis": "^1.2.0",
21
21
  "@atlaskit/editor-json-transformer": "^9.8.0",
22
22
  "@atlaskit/editor-prosemirror": "^8.0.0",
@@ -33,7 +33,7 @@
33
33
  "uuid": "^3.1.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@atlaskit/editor-common": "^120.12.0",
36
+ "@atlaskit/editor-common": "^120.13.0",
37
37
  "react": "^18.2.0 || ^19.2.0"
38
38
  },
39
39
  "devDependencies": {
@@ -42,7 +42,7 @@
42
42
  "react-dom": "^19.2.0"
43
43
  },
44
44
  "name": "@atlaskit/editor-synced-block-provider",
45
- "version": "12.2.0",
45
+ "version": "12.2.1",
46
46
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
47
47
  "author": "Atlassian Pty Ltd",
48
48
  "license": "Apache-2.0",