@atlaskit/editor-synced-block-provider 2.11.0 → 2.11.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,20 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 2.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1511d9ee0c2e3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1511d9ee0c2e3) -
8
+ [ux] EDITOR-3643 populate source url and title for sync block with block service by returning
9
+ source ari and product from fetchData
10
+
11
+ ## 2.11.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`99387f7d6303b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/99387f7d6303b) -
16
+ [ux] [EDITOR-2767] Implement bodiedSyncBlock creation/deletion undo/redo
17
+
3
18
  ## 2.11.0
4
19
 
5
20
  ### Minor Changes
@@ -65,7 +65,9 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
65
65
  data: {
66
66
  content: syncedBlockData,
67
67
  resourceId: resourceId,
68
- blockInstanceId: localId
68
+ blockInstanceId: localId,
69
+ sourceAri: blockContentResponse.sourceAri,
70
+ product: blockContentResponse.product
69
71
  },
70
72
  resourceId: resourceId
71
73
  });
@@ -144,7 +144,6 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
144
144
  if (this.syncBlockURLRequests.get(resourceId)) {
145
145
  return;
146
146
  }
147
- this.syncBlockURLRequests.set(resourceId, true);
148
147
  var existingSyncBlock = this.getFromCache(resourceId);
149
148
  if (!existingSyncBlock) {
150
149
  throw new Error('No existing sync block to fetch source info for');
@@ -159,8 +158,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
159
158
  product = _ref.product,
160
159
  blockInstanceId = _ref.blockInstanceId;
161
160
  if (!sourceAri || !product || !blockInstanceId) {
162
- throw new Error('SourceAri, product or blockInstanceId missing');
161
+ var _this$fireAnalyticsEv2;
162
+ (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing'));
163
+ return;
163
164
  }
165
+ this.syncBlockURLRequests.set(resourceId, true);
164
166
  this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(function (sourceInfo) {
165
167
  if (!sourceInfo) {
166
168
  return;
@@ -170,17 +172,17 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
170
172
  _this.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
171
173
  }
172
174
  }).catch(function (error) {
173
- var _this$fireAnalyticsEv2;
174
- (_this$fireAnalyticsEv2 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
175
+ var _this$fireAnalyticsEv3;
176
+ (_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
175
177
  }).finally(function () {
176
178
  _this.syncBlockURLRequests.delete(resourceId);
177
179
  });
178
180
  } catch (error) {
179
- var _this$fireAnalyticsEv3;
181
+ var _this$fireAnalyticsEv4;
180
182
  (0, _monitoring.logException)(error, {
181
183
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
182
184
  });
183
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
185
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
184
186
  }
185
187
  }
186
188
 
@@ -389,11 +391,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
389
391
  }
390
392
  return this.subscribeToSyncBlock(resourceId, localId, callback);
391
393
  } catch (error) {
392
- var _this$fireAnalyticsEv4;
394
+ var _this$fireAnalyticsEv5;
393
395
  (0, _monitoring.logException)(error, {
394
396
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
395
397
  });
396
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
398
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
397
399
  return function () {};
398
400
  }
399
401
  }
@@ -417,12 +419,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
417
419
  key: "getProviderFactory",
418
420
  value: function getProviderFactory(resourceId) {
419
421
  if (!this.dataProvider) {
420
- var _this$fireAnalyticsEv5;
422
+ var _this$fireAnalyticsEv6;
421
423
  var error = new Error('Data provider not set');
422
424
  (0, _monitoring.logException)(error, {
423
425
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
424
426
  });
425
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
427
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
426
428
  return undefined;
427
429
  }
428
430
  var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
@@ -441,11 +443,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
441
443
  try {
442
444
  this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
443
445
  } catch (error) {
444
- var _this$fireAnalyticsEv6;
446
+ var _this$fireAnalyticsEv7;
445
447
  (0, _monitoring.logException)(error, {
446
448
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
447
449
  });
448
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
450
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
449
451
  }
450
452
  }
451
453
  return providerFactory;
@@ -464,8 +466,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
464
466
  }
465
467
  var syncBlock = this.getFromCache(resourceId);
466
468
  if (!syncBlock || !((_syncBlock$data2 = syncBlock.data) !== null && _syncBlock$data2 !== void 0 && _syncBlock$data2.sourceAri) || !((_syncBlock$data3 = syncBlock.data) !== null && _syncBlock$data3 !== void 0 && _syncBlock$data3.product)) {
467
- var _this$fireAnalyticsEv7;
468
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchErrorPayload)('Sync block or source ari or product not found'));
469
+ var _this$fireAnalyticsEv8;
470
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchErrorPayload)('Sync block or source ari or product not found'));
469
471
  return;
470
472
  }
471
473
  var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data4 = syncBlock.data) === null || _syncBlock$data4 === void 0 ? void 0 : _syncBlock$data4.sourceAri, (_syncBlock$data5 = syncBlock.data) === null || _syncBlock$data5 === void 0 ? void 0 : _syncBlock$data5.product);
@@ -12,9 +12,10 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
  var _uuid = _interopRequireDefault(require("uuid"));
14
14
  var _monitoring = require("@atlaskit/editor-common/monitoring");
15
+ var _utils = require("@atlaskit/editor-common/utils");
15
16
  var _rebaseTransaction2 = require("../common/rebase-transaction");
16
17
  var _errorHandling = require("../utils/errorHandling");
17
- var _utils = require("../utils/utils");
18
+ var _utils2 = require("../utils/utils");
18
19
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
19
20
  // A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
20
21
  // Designed to manage local in-memory state and synchronize with an external data provider.
@@ -58,7 +59,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
58
59
  if (!localId || !resourceId) {
59
60
  throw new Error('Local ID or resource ID is not set');
60
61
  }
61
- var syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
62
+ var syncBlockData = (0, _utils2.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
62
63
  this.syncBlockCache.set(resourceId, syncBlockData);
63
64
  return true;
64
65
  } catch (error) {
@@ -246,7 +247,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
246
247
  }
247
248
  var resourceId = attrs.resourceId,
248
249
  blockInstanceId = attrs.localId;
249
- this.dataProvider.writeNodesData([(0, _utils.createBodiedSyncBlockNode)(blockInstanceId, resourceId)], [{
250
+ this.dataProvider.writeNodesData([(0, _utils2.createBodiedSyncBlockNode)(blockInstanceId, resourceId)], [{
250
251
  content: [],
251
252
  blockInstanceId: blockInstanceId,
252
253
  resourceId: resourceId
@@ -286,12 +287,12 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
286
287
  value: function () {
287
288
  var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(tr, syncBlockIds) {
288
289
  var _this5 = this;
289
- var confirmed, _this$editorView, results, callback, _this$fireAnalyticsEv4;
290
+ var confirmed, _this$editorView, trToDispatch, results, callback, _this$fireAnalyticsEv4;
290
291
  return _regenerator.default.wrap(function _callee2$(_context2) {
291
292
  while (1) switch (_context2.prev = _context2.next) {
292
293
  case 0:
293
294
  if (!this.confirmationCallback) {
294
- _context2.next = 24;
295
+ _context2.next = 26;
295
296
  break;
296
297
  }
297
298
  this.confirmationTransaction = tr;
@@ -300,25 +301,31 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
300
301
  case 4:
301
302
  confirmed = _context2.sent;
302
303
  if (!confirmed) {
303
- _context2.next = 23;
304
+ _context2.next = 25;
304
305
  break;
305
306
  }
306
- (_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(this.confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true));
307
- _context2.prev = 7;
307
+ trToDispatch = this.confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true);
308
+ if (!trToDispatch.getMeta(_utils.pmHistoryPluginKey)) {
309
+ // bodiedSyncBlock deletion is expected to be permanent (cannot be undo)
310
+ // For a normal delete (not triggered by undo), remove it from history so that it cannot be undone
311
+ trToDispatch.setMeta('addToHistory', false);
312
+ }
313
+ (_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(trToDispatch);
314
+ _context2.prev = 9;
308
315
  if (this.dataProvider) {
309
- _context2.next = 10;
316
+ _context2.next = 12;
310
317
  break;
311
318
  }
312
319
  throw new Error('Data provider not set');
313
- case 10:
320
+ case 12:
314
321
  syncBlockIds.forEach(function (Ids) {
315
322
  _this5.setPendingDeletion(Ids, true);
316
323
  });
317
- _context2.next = 13;
324
+ _context2.next = 15;
318
325
  return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
319
326
  return attrs.resourceId;
320
327
  }));
321
- case 13:
328
+ case 15:
322
329
  results = _context2.sent;
323
330
  if (results.every(function (result) {
324
331
  return result.success;
@@ -338,11 +345,11 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
338
345
  });
339
346
  }
340
347
  syncBlockIds.forEach(callback);
341
- _context2.next = 23;
348
+ _context2.next = 25;
342
349
  break;
343
- case 18:
344
- _context2.prev = 18;
345
- _context2.t0 = _context2["catch"](7);
350
+ case 20:
351
+ _context2.prev = 20;
352
+ _context2.t0 = _context2["catch"](9);
346
353
  syncBlockIds.forEach(function (Ids) {
347
354
  _this5.setPendingDeletion(Ids, false);
348
355
  });
@@ -350,13 +357,13 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
350
357
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
351
358
  });
352
359
  (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.deleteErrorPayload)(_context2.t0.message));
353
- case 23:
360
+ case 25:
354
361
  this.confirmationTransaction = undefined;
355
- case 24:
362
+ case 26:
356
363
  case "end":
357
364
  return _context2.stop();
358
365
  }
359
- }, _callee2, this, [[7, 18]]);
366
+ }, _callee2, this, [[9, 20]]);
360
367
  }));
361
368
  function deleteSyncBlocksWithConfirmation(_x, _x2) {
362
369
  return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
@@ -39,7 +39,9 @@ class BlockServiceADFFetchProvider {
39
39
  data: {
40
40
  content: syncedBlockData,
41
41
  resourceId,
42
- blockInstanceId: localId
42
+ blockInstanceId: localId,
43
+ sourceAri: blockContentResponse.sourceAri,
44
+ product: blockContentResponse.product
43
45
  },
44
46
  resourceId
45
47
  };
@@ -64,7 +64,6 @@ export class ReferenceSyncBlockStoreManager {
64
64
  if (this.syncBlockURLRequests.get(resourceId)) {
65
65
  return;
66
66
  }
67
- this.syncBlockURLRequests.set(resourceId, true);
68
67
  const existingSyncBlock = this.getFromCache(resourceId);
69
68
  if (!existingSyncBlock) {
70
69
  throw new Error('No existing sync block to fetch source info for');
@@ -80,8 +79,11 @@ export class ReferenceSyncBlockStoreManager {
80
79
  blockInstanceId
81
80
  } = existingSyncBlock.data || {};
82
81
  if (!sourceAri || !product || !blockInstanceId) {
83
- throw new Error('SourceAri, product or blockInstanceId missing');
82
+ var _this$fireAnalyticsEv2;
83
+ (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing'));
84
+ return;
84
85
  }
86
+ this.syncBlockURLRequests.set(resourceId, true);
85
87
  this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(sourceInfo => {
86
88
  if (!sourceInfo) {
87
89
  return;
@@ -91,17 +93,17 @@ export class ReferenceSyncBlockStoreManager {
91
93
  this.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
92
94
  }
93
95
  }).catch(error => {
94
- var _this$fireAnalyticsEv2;
95
- (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload(error.message));
96
+ var _this$fireAnalyticsEv3;
97
+ (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload(error.message));
96
98
  }).finally(() => {
97
99
  this.syncBlockURLRequests.delete(resourceId);
98
100
  });
99
101
  } catch (error) {
100
- var _this$fireAnalyticsEv3;
102
+ var _this$fireAnalyticsEv4;
101
103
  logException(error, {
102
104
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
103
105
  });
104
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload(error.message));
106
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload(error.message));
105
107
  }
106
108
  }
107
109
 
@@ -133,13 +135,13 @@ export class ReferenceSyncBlockStoreManager {
133
135
  const resolvedData = [];
134
136
  data.forEach(syncBlockInstance => {
135
137
  if (!syncBlockInstance.resourceId) {
136
- var _this$fireAnalyticsEv4;
137
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
138
+ var _this$fireAnalyticsEv5;
139
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
138
140
  return;
139
141
  }
140
142
  if (syncBlockInstance.error) {
141
- var _this$fireAnalyticsEv5;
142
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, fetchErrorPayload(syncBlockInstance.error));
143
+ var _this$fireAnalyticsEv6;
144
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, fetchErrorPayload(syncBlockInstance.error));
143
145
  this.updateCache(syncBlockInstance);
144
146
  resolvedData.push(syncBlockInstance);
145
147
  return;
@@ -207,11 +209,11 @@ export class ReferenceSyncBlockStoreManager {
207
209
  callback(cachedData);
208
210
  } else {
209
211
  this.fetchSyncBlocksData([createSyncBlockNode(localId, resourceId)]).catch(error => {
210
- var _this$fireAnalyticsEv6;
212
+ var _this$fireAnalyticsEv7;
211
213
  logException(error, {
212
214
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
213
215
  });
214
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, fetchErrorPayload(error.message));
216
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message));
215
217
  });
216
218
  }
217
219
  return () => {
@@ -278,11 +280,11 @@ export class ReferenceSyncBlockStoreManager {
278
280
  }
279
281
  return this.subscribeToSyncBlock(resourceId, localId, callback);
280
282
  } catch (error) {
281
- var _this$fireAnalyticsEv7;
283
+ var _this$fireAnalyticsEv8;
282
284
  logException(error, {
283
285
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
284
286
  });
285
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message));
287
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, fetchErrorPayload(error.message));
286
288
  return () => {};
287
289
  }
288
290
  }
@@ -302,12 +304,12 @@ export class ReferenceSyncBlockStoreManager {
302
304
  }
303
305
  getProviderFactory(resourceId) {
304
306
  if (!this.dataProvider) {
305
- var _this$fireAnalyticsEv8;
307
+ var _this$fireAnalyticsEv9;
306
308
  const error = new Error('Data provider not set');
307
309
  logException(error, {
308
310
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
309
311
  });
310
- (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, fetchErrorPayload(error.message));
312
+ (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, fetchErrorPayload(error.message));
311
313
  return undefined;
312
314
  }
313
315
  const {
@@ -327,11 +329,11 @@ export class ReferenceSyncBlockStoreManager {
327
329
  try {
328
330
  this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
329
331
  } catch (error) {
330
- var _this$fireAnalyticsEv9;
332
+ var _this$fireAnalyticsEv0;
331
333
  logException(error, {
332
334
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
333
335
  });
334
- (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, fetchErrorPayload(error.message));
336
+ (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, fetchErrorPayload(error.message));
335
337
  }
336
338
  }
337
339
  return providerFactory;
@@ -348,8 +350,8 @@ export class ReferenceSyncBlockStoreManager {
348
350
  }
349
351
  const syncBlock = this.getFromCache(resourceId);
350
352
  if (!syncBlock || !((_syncBlock$data2 = syncBlock.data) !== null && _syncBlock$data2 !== void 0 && _syncBlock$data2.sourceAri) || !((_syncBlock$data3 = syncBlock.data) !== null && _syncBlock$data3 !== void 0 && _syncBlock$data3.product)) {
351
- var _this$fireAnalyticsEv0;
352
- (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, fetchErrorPayload('Sync block or source ari or product not found'));
353
+ var _this$fireAnalyticsEv1;
354
+ (_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, fetchErrorPayload('Sync block or source ari or product not found'));
353
355
  return;
354
356
  }
355
357
  const parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data4 = syncBlock.data) === null || _syncBlock$data4 === void 0 ? void 0 : _syncBlock$data4.sourceAri, (_syncBlock$data5 = syncBlock.data) === null || _syncBlock$data5 === void 0 ? void 0 : _syncBlock$data5.product);
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
3
  import uuid from 'uuid';
4
4
  import { logException } from '@atlaskit/editor-common/monitoring';
5
+ import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
5
6
  import { rebaseTransaction } from '../common/rebase-transaction';
6
7
  import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload } from '../utils/errorHandling';
7
8
  import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode } from '../utils/utils';
@@ -217,7 +218,13 @@ export class SourceSyncBlockStoreManager {
217
218
  const confirmed = await this.confirmationCallback(syncBlockIds.length);
218
219
  if (confirmed) {
219
220
  var _this$editorView;
220
- (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.dispatch(this.confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true));
221
+ const trToDispatch = this.confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true);
222
+ if (!trToDispatch.getMeta(pmHistoryPluginKey)) {
223
+ // bodiedSyncBlock deletion is expected to be permanent (cannot be undo)
224
+ // For a normal delete (not triggered by undo), remove it from history so that it cannot be undone
225
+ trToDispatch.setMeta('addToHistory', false);
226
+ }
227
+ (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.dispatch(trToDispatch);
221
228
  try {
222
229
  if (!this.dataProvider) {
223
230
  throw new Error('Data provider not set');
@@ -1,4 +1,4 @@
1
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from "@atlaskit/editor-common/analytics";
1
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
2
2
  export const stringifyError = error => {
3
3
  try {
4
4
  return JSON.stringify(error);
@@ -58,7 +58,9 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
58
58
  data: {
59
59
  content: syncedBlockData,
60
60
  resourceId: resourceId,
61
- blockInstanceId: localId
61
+ blockInstanceId: localId,
62
+ sourceAri: blockContentResponse.sourceAri,
63
+ product: blockContentResponse.product
62
64
  },
63
65
  resourceId: resourceId
64
66
  });
@@ -138,7 +138,6 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
138
138
  if (this.syncBlockURLRequests.get(resourceId)) {
139
139
  return;
140
140
  }
141
- this.syncBlockURLRequests.set(resourceId, true);
142
141
  var existingSyncBlock = this.getFromCache(resourceId);
143
142
  if (!existingSyncBlock) {
144
143
  throw new Error('No existing sync block to fetch source info for');
@@ -153,8 +152,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
153
152
  product = _ref.product,
154
153
  blockInstanceId = _ref.blockInstanceId;
155
154
  if (!sourceAri || !product || !blockInstanceId) {
156
- throw new Error('SourceAri, product or blockInstanceId missing');
155
+ var _this$fireAnalyticsEv2;
156
+ (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing'));
157
+ return;
157
158
  }
159
+ this.syncBlockURLRequests.set(resourceId, true);
158
160
  this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(function (sourceInfo) {
159
161
  if (!sourceInfo) {
160
162
  return;
@@ -164,17 +166,17 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
164
166
  _this.updateSourceTitleSubscriptions(resourceId, sourceInfo.title);
165
167
  }
166
168
  }).catch(function (error) {
167
- var _this$fireAnalyticsEv2;
168
- (_this$fireAnalyticsEv2 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(_this, getSourceInfoErrorPayload(error.message));
169
+ var _this$fireAnalyticsEv3;
170
+ (_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, getSourceInfoErrorPayload(error.message));
169
171
  }).finally(function () {
170
172
  _this.syncBlockURLRequests.delete(resourceId);
171
173
  });
172
174
  } catch (error) {
173
- var _this$fireAnalyticsEv3;
175
+ var _this$fireAnalyticsEv4;
174
176
  logException(error, {
175
177
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
176
178
  });
177
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload(error.message));
179
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload(error.message));
178
180
  }
179
181
  }
180
182
 
@@ -383,11 +385,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
383
385
  }
384
386
  return this.subscribeToSyncBlock(resourceId, localId, callback);
385
387
  } catch (error) {
386
- var _this$fireAnalyticsEv4;
388
+ var _this$fireAnalyticsEv5;
387
389
  logException(error, {
388
390
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
389
391
  });
390
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, fetchErrorPayload(error.message));
392
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, fetchErrorPayload(error.message));
391
393
  return function () {};
392
394
  }
393
395
  }
@@ -411,12 +413,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
411
413
  key: "getProviderFactory",
412
414
  value: function getProviderFactory(resourceId) {
413
415
  if (!this.dataProvider) {
414
- var _this$fireAnalyticsEv5;
416
+ var _this$fireAnalyticsEv6;
415
417
  var error = new Error('Data provider not set');
416
418
  logException(error, {
417
419
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
418
420
  });
419
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(this, fetchErrorPayload(error.message));
421
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, fetchErrorPayload(error.message));
420
422
  return undefined;
421
423
  }
422
424
  var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
@@ -435,11 +437,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
435
437
  try {
436
438
  this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
437
439
  } catch (error) {
438
- var _this$fireAnalyticsEv6;
440
+ var _this$fireAnalyticsEv7;
439
441
  logException(error, {
440
442
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
441
443
  });
442
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, fetchErrorPayload(error.message));
444
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message));
443
445
  }
444
446
  }
445
447
  return providerFactory;
@@ -458,8 +460,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
458
460
  }
459
461
  var syncBlock = this.getFromCache(resourceId);
460
462
  if (!syncBlock || !((_syncBlock$data2 = syncBlock.data) !== null && _syncBlock$data2 !== void 0 && _syncBlock$data2.sourceAri) || !((_syncBlock$data3 = syncBlock.data) !== null && _syncBlock$data3 !== void 0 && _syncBlock$data3.product)) {
461
- var _this$fireAnalyticsEv7;
462
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload('Sync block or source ari or product not found'));
463
+ var _this$fireAnalyticsEv8;
464
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, fetchErrorPayload('Sync block or source ari or product not found'));
463
465
  return;
464
466
  }
465
467
  var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data4 = syncBlock.data) === null || _syncBlock$data4 === void 0 ? void 0 : _syncBlock$data4.sourceAri, (_syncBlock$data5 = syncBlock.data) === null || _syncBlock$data5 === void 0 ? void 0 : _syncBlock$data5.product);
@@ -6,6 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
7
7
  import uuid from 'uuid';
8
8
  import { logException } from '@atlaskit/editor-common/monitoring';
9
+ import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
9
10
  import { rebaseTransaction as _rebaseTransaction } from '../common/rebase-transaction';
10
11
  import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload } from '../utils/errorHandling';
11
12
  import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode as _createBodiedSyncBlockNode } from '../utils/utils';
@@ -279,12 +280,12 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
279
280
  value: function () {
280
281
  var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(tr, syncBlockIds) {
281
282
  var _this5 = this;
282
- var confirmed, _this$editorView, results, callback, _this$fireAnalyticsEv4;
283
+ var confirmed, _this$editorView, trToDispatch, results, callback, _this$fireAnalyticsEv4;
283
284
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
284
285
  while (1) switch (_context2.prev = _context2.next) {
285
286
  case 0:
286
287
  if (!this.confirmationCallback) {
287
- _context2.next = 24;
288
+ _context2.next = 26;
288
289
  break;
289
290
  }
290
291
  this.confirmationTransaction = tr;
@@ -293,25 +294,31 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
293
294
  case 4:
294
295
  confirmed = _context2.sent;
295
296
  if (!confirmed) {
296
- _context2.next = 23;
297
+ _context2.next = 25;
297
298
  break;
298
299
  }
299
- (_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(this.confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true));
300
- _context2.prev = 7;
300
+ trToDispatch = this.confirmationTransaction.setMeta('isConfirmedSyncBlockDeletion', true);
301
+ if (!trToDispatch.getMeta(pmHistoryPluginKey)) {
302
+ // bodiedSyncBlock deletion is expected to be permanent (cannot be undo)
303
+ // For a normal delete (not triggered by undo), remove it from history so that it cannot be undone
304
+ trToDispatch.setMeta('addToHistory', false);
305
+ }
306
+ (_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(trToDispatch);
307
+ _context2.prev = 9;
301
308
  if (this.dataProvider) {
302
- _context2.next = 10;
309
+ _context2.next = 12;
303
310
  break;
304
311
  }
305
312
  throw new Error('Data provider not set');
306
- case 10:
313
+ case 12:
307
314
  syncBlockIds.forEach(function (Ids) {
308
315
  _this5.setPendingDeletion(Ids, true);
309
316
  });
310
- _context2.next = 13;
317
+ _context2.next = 15;
311
318
  return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
312
319
  return attrs.resourceId;
313
320
  }));
314
- case 13:
321
+ case 15:
315
322
  results = _context2.sent;
316
323
  if (results.every(function (result) {
317
324
  return result.success;
@@ -331,11 +338,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
331
338
  });
332
339
  }
333
340
  syncBlockIds.forEach(callback);
334
- _context2.next = 23;
341
+ _context2.next = 25;
335
342
  break;
336
- case 18:
337
- _context2.prev = 18;
338
- _context2.t0 = _context2["catch"](7);
343
+ case 20:
344
+ _context2.prev = 20;
345
+ _context2.t0 = _context2["catch"](9);
339
346
  syncBlockIds.forEach(function (Ids) {
340
347
  _this5.setPendingDeletion(Ids, false);
341
348
  });
@@ -343,13 +350,13 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
343
350
  location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
344
351
  });
345
352
  (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, deleteErrorPayload(_context2.t0.message));
346
- case 23:
353
+ case 25:
347
354
  this.confirmationTransaction = undefined;
348
- case 24:
355
+ case 26:
349
356
  case "end":
350
357
  return _context2.stop();
351
358
  }
352
- }, _callee2, this, [[7, 18]]);
359
+ }, _callee2, this, [[9, 20]]);
353
360
  }));
354
361
  function deleteSyncBlocksWithConfirmation(_x, _x2) {
355
362
  return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
@@ -1,4 +1,4 @@
1
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from "@atlaskit/editor-common/analytics";
1
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
2
2
  export var stringifyError = function stringifyError(error) {
3
3
  try {
4
4
  return JSON.stringify(error);
@@ -1,4 +1,4 @@
1
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from "@atlaskit/editor-common/analytics";
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
2
  export declare const stringifyError: (error: unknown) => string | undefined;
3
3
  export declare const getErrorPayload: <T extends ACTION_SUBJECT_ID>(actionSubjectId: T, error: string) => OperationalAEP<ACTION.ERROR, ACTION_SUBJECT.SYNCED_BLOCK, T, {
4
4
  error: string;
@@ -1,4 +1,4 @@
1
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from "@atlaskit/editor-common/analytics";
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
2
2
  export declare const stringifyError: (error: unknown) => string | undefined;
3
3
  export declare const getErrorPayload: <T extends ACTION_SUBJECT_ID>(actionSubjectId: T, error: string) => OperationalAEP<ACTION.ERROR, ACTION_SUBJECT.SYNCED_BLOCK, T, {
4
4
  error: string;
package/package.json CHANGED
@@ -77,7 +77,7 @@
77
77
  }
78
78
  },
79
79
  "name": "@atlaskit/editor-synced-block-provider",
80
- "version": "2.11.0",
80
+ "version": "2.11.2",
81
81
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
82
82
  "author": "Atlassian Pty Ltd",
83
83
  "license": "Apache-2.0",