@atlaskit/editor-plugin-synced-block 5.3.36 → 5.4.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,22 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 5.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e9b20ca59c789`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e9b20ca59c789) -
8
+ EDITOR-5666 fix first node bodied synced block selection
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 5.3.37
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 5.3.36
4
21
 
5
22
  ### Patch Changes
@@ -306,9 +306,20 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
306
306
  selectionDecorationSet = currentPluginState.selectionDecorationSet,
307
307
  bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
308
308
  retryCreationPosMap = currentPluginState.retryCreationPosMap;
309
- var newDecorationSet = selectionDecorationSet.map(tr.mapping, tr.doc);
309
+ var newDecorationSet = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
310
+ : selectionDecorationSet : selectionDecorationSet.map(tr.mapping, tr.doc);
310
311
  if (!tr.selection.eq(oldEditorState.selection)) {
311
312
  newDecorationSet = (0, _selectionDecorations.calculateDecorations)(tr.doc, tr.selection, tr.doc.type.schema);
313
+ } else if (tr.docChanged && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
314
+ var existingDecorationsLength = selectionDecorationSet.find().length;
315
+ var newDecorationsLength = newDecorationSet.find().length;
316
+
317
+ // Edge case: When document nodes are replaced, the mapping can lose decorations
318
+ // We rebuild decorations when the document changes but the selection hasn't.
319
+ // We can do this check because we only expect 1 decoration for the selection
320
+ if (existingDecorationsLength !== newDecorationsLength) {
321
+ newDecorationSet = (0, _selectionDecorations.calculateDecorations)(tr.doc, tr.selection, tr.doc.type.schema);
322
+ }
312
323
  }
313
324
  var newPosEntry = meta === null || meta === void 0 ? void 0 : meta.retryCreationPos;
314
325
  var newRetryCreationPosMap = mapRetryCreationPosMap(retryCreationPosMap, newPosEntry, tr.mapping.map.bind(tr.mapping));
@@ -270,9 +270,20 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
270
270
  bodiedSyncBlockDeletionStatus,
271
271
  retryCreationPosMap
272
272
  } = currentPluginState;
273
- let newDecorationSet = selectionDecorationSet.map(tr.mapping, tr.doc);
273
+ let newDecorationSet = fg('platform_synced_block_patch_5') ? tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
274
+ : selectionDecorationSet : selectionDecorationSet.map(tr.mapping, tr.doc);
274
275
  if (!tr.selection.eq(oldEditorState.selection)) {
275
276
  newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
277
+ } else if (tr.docChanged && fg('platform_synced_block_patch_5')) {
278
+ const existingDecorationsLength = selectionDecorationSet.find().length;
279
+ const newDecorationsLength = newDecorationSet.find().length;
280
+
281
+ // Edge case: When document nodes are replaced, the mapping can lose decorations
282
+ // We rebuild decorations when the document changes but the selection hasn't.
283
+ // We can do this check because we only expect 1 decoration for the selection
284
+ if (existingDecorationsLength !== newDecorationsLength) {
285
+ newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
286
+ }
276
287
  }
277
288
  const newPosEntry = meta === null || meta === void 0 ? void 0 : meta.retryCreationPos;
278
289
  const newRetryCreationPosMap = mapRetryCreationPosMap(retryCreationPosMap, newPosEntry, tr.mapping.map.bind(tr.mapping));
@@ -299,9 +299,20 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
299
299
  selectionDecorationSet = currentPluginState.selectionDecorationSet,
300
300
  bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
301
301
  retryCreationPosMap = currentPluginState.retryCreationPosMap;
302
- var newDecorationSet = selectionDecorationSet.map(tr.mapping, tr.doc);
302
+ var newDecorationSet = fg('platform_synced_block_patch_5') ? tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
303
+ : selectionDecorationSet : selectionDecorationSet.map(tr.mapping, tr.doc);
303
304
  if (!tr.selection.eq(oldEditorState.selection)) {
304
305
  newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
306
+ } else if (tr.docChanged && fg('platform_synced_block_patch_5')) {
307
+ var existingDecorationsLength = selectionDecorationSet.find().length;
308
+ var newDecorationsLength = newDecorationSet.find().length;
309
+
310
+ // Edge case: When document nodes are replaced, the mapping can lose decorations
311
+ // We rebuild decorations when the document changes but the selection hasn't.
312
+ // We can do this check because we only expect 1 decoration for the selection
313
+ if (existingDecorationsLength !== newDecorationsLength) {
314
+ newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
315
+ }
305
316
  }
306
317
  var newPosEntry = meta === null || meta === void 0 ? void 0 : meta.retryCreationPos;
307
318
  var newRetryCreationPosMap = mapRetryCreationPosMap(retryCreationPosMap, newPosEntry, tr.mapping.map.bind(tr.mapping));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.3.36",
3
+ "version": "5.4.0",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -51,7 +51,7 @@
51
51
  "@atlaskit/platform-feature-flags": "^1.1.0",
52
52
  "@atlaskit/primitives": "^18.0.0",
53
53
  "@atlaskit/spinner": "19.0.10",
54
- "@atlaskit/tokens": "11.0.1",
54
+ "@atlaskit/tokens": "11.0.2",
55
55
  "@atlaskit/tooltip": "^20.14.0",
56
56
  "@atlaskit/visually-hidden": "^3.0.0",
57
57
  "@babel/runtime": "^7.0.0",
@@ -61,7 +61,7 @@
61
61
  "react-intl-next": "npm:react-intl@^5.18.1"
62
62
  },
63
63
  "peerDependencies": {
64
- "@atlaskit/editor-common": "^111.21.0",
64
+ "@atlaskit/editor-common": "^111.22.0",
65
65
  "react": "^18.2.0"
66
66
  },
67
67
  "devDependencies": {