@atlaskit/editor-plugin-synced-block 5.3.37 → 5.4.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,24 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 5.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3b290b31e9ad1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b290b31e9ad1) -
8
+ Update menu button text for sync blocks
9
+ - Updated dependencies
10
+
11
+ ## 5.4.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`e9b20ca59c789`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e9b20ca59c789) -
16
+ EDITOR-5666 fix first node bodied synced block selection
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 5.3.37
4
23
 
5
24
  ### 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));
@@ -53,6 +53,11 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
53
53
  // Adds size="small" to icons for better visual consistency in block menu.
54
54
  // To clean up: remove conditional, keep only size="small" version.
55
55
  var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
56
+
57
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
58
+ // Changes wording from "Create synced block" to "Sync block" for conciseness.
59
+ // To clean up: remove conditional, keep only the syncBlock message.
60
+ var message = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? _messages.blockMenuMessages.syncBlock : _messages.blockMenuMessages.createSyncedBlock;
56
61
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
57
62
  elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.SyncBlocksIcon, {
58
63
  label: "",
@@ -64,7 +69,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
64
69
  elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
65
70
  appearance: "new"
66
71
  }, formatMessage(_messages.blockMenuMessages.newLozenge))
67
- }, formatMessage(_messages.blockMenuMessages.createSyncedBlock));
72
+ }, formatMessage(message));
68
73
  };
69
74
  var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
70
75
  var api = _ref2.api;
@@ -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));
@@ -45,6 +45,11 @@ const CreateSyncedBlockDropdownItem = ({
45
45
  // Adds size="small" to icons for better visual consistency in block menu.
46
46
  // To clean up: remove conditional, keep only size="small" version.
47
47
  const iconSize = fg('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
48
+
49
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
50
+ // Changes wording from "Create synced block" to "Sync block" for conciseness.
51
+ // To clean up: remove conditional, keep only the syncBlock message.
52
+ const message = fg('platform_editor_block_menu_v2_patch_3') ? blockMenuMessages.syncBlock : blockMenuMessages.createSyncedBlock;
48
53
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
49
54
  elemBefore: /*#__PURE__*/React.createElement(SyncBlocksIcon, {
50
55
  label: "",
@@ -56,7 +61,7 @@ const CreateSyncedBlockDropdownItem = ({
56
61
  elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
57
62
  appearance: "new"
58
63
  }, formatMessage(blockMenuMessages.newLozenge))
59
- }, formatMessage(blockMenuMessages.createSyncedBlock));
64
+ }, formatMessage(message));
60
65
  };
61
66
  const CopySyncedBlockDropdownItem = ({
62
67
  api
@@ -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));
@@ -44,6 +44,11 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
44
44
  // Adds size="small" to icons for better visual consistency in block menu.
45
45
  // To clean up: remove conditional, keep only size="small" version.
46
46
  var iconSize = fg('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
47
+
48
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
49
+ // Changes wording from "Create synced block" to "Sync block" for conciseness.
50
+ // To clean up: remove conditional, keep only the syncBlock message.
51
+ var message = fg('platform_editor_block_menu_v2_patch_3') ? blockMenuMessages.syncBlock : blockMenuMessages.createSyncedBlock;
47
52
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
48
53
  elemBefore: /*#__PURE__*/React.createElement(SyncBlocksIcon, {
49
54
  label: "",
@@ -55,7 +60,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
55
60
  elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
56
61
  appearance: "new"
57
62
  }, formatMessage(blockMenuMessages.newLozenge))
58
- }, formatMessage(blockMenuMessages.createSyncedBlock));
63
+ }, formatMessage(message));
59
64
  };
60
65
  var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
61
66
  var api = _ref2.api;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.3.37",
3
+ "version": "5.4.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.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.23.0",
65
65
  "react": "^18.2.0"
66
66
  },
67
67
  "devDependencies": {