@atlaskit/editor-synced-block-provider 2.11.1 → 2.11.3
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 +16 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +3 -1
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +16 -14
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +21 -48
- package/dist/es2019/providers/block-service/blockServiceAPI.js +3 -1
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +22 -20
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +2 -25
- package/dist/es2019/utils/errorHandling.js +1 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +3 -1
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +16 -14
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +18 -45
- package/dist/esm/utils/errorHandling.js +1 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -7
- package/dist/types/utils/errorHandling.d.ts +1 -1
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -7
- package/dist/types-ts4.5/utils/errorHandling.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 2.11.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`48a3dd84c602b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48a3dd84c602b) -
|
|
8
|
+
[EDITOR-3394] Decouple editorView from source manager
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 2.11.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`1511d9ee0c2e3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1511d9ee0c2e3) -
|
|
16
|
+
[ux] EDITOR-3643 populate source url and title for sync block with block service by returning
|
|
17
|
+
source ari and product from fetchData
|
|
18
|
+
|
|
3
19
|
## 2.11.1
|
|
4
20
|
|
|
5
21
|
### Patch 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
|
-
|
|
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$
|
|
174
|
-
(_this$
|
|
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$
|
|
181
|
+
var _this$fireAnalyticsEv4;
|
|
180
182
|
(0, _monitoring.logException)(error, {
|
|
181
183
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
182
184
|
});
|
|
183
|
-
(_this$
|
|
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$
|
|
394
|
+
var _this$fireAnalyticsEv5;
|
|
393
395
|
(0, _monitoring.logException)(error, {
|
|
394
396
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
395
397
|
});
|
|
396
|
-
(_this$
|
|
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$
|
|
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$
|
|
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$
|
|
446
|
+
var _this$fireAnalyticsEv7;
|
|
445
447
|
(0, _monitoring.logException)(error, {
|
|
446
448
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
447
449
|
});
|
|
448
|
-
(_this$
|
|
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$
|
|
468
|
-
(_this$
|
|
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,10 +12,8 @@ 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");
|
|
16
|
-
var _rebaseTransaction2 = require("../common/rebase-transaction");
|
|
17
15
|
var _errorHandling = require("../utils/errorHandling");
|
|
18
|
-
var
|
|
16
|
+
var _utils = require("../utils/utils");
|
|
19
17
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
20
18
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
21
19
|
// Designed to manage local in-memory state and synchronize with an external data provider.
|
|
@@ -59,7 +57,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
59
57
|
if (!localId || !resourceId) {
|
|
60
58
|
throw new Error('Local ID or resource ID is not set');
|
|
61
59
|
}
|
|
62
|
-
var syncBlockData = (0,
|
|
60
|
+
var syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
63
61
|
this.syncBlockCache.set(resourceId, syncBlockData);
|
|
64
62
|
return true;
|
|
65
63
|
} catch (error) {
|
|
@@ -155,11 +153,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
155
153
|
}
|
|
156
154
|
return flush;
|
|
157
155
|
}())
|
|
158
|
-
}, {
|
|
159
|
-
key: "setEditorView",
|
|
160
|
-
value: function setEditorView(editorView) {
|
|
161
|
-
this.editorView = editorView;
|
|
162
|
-
}
|
|
163
156
|
}, {
|
|
164
157
|
key: "registerPendingCreation",
|
|
165
158
|
value: function registerPendingCreation(resourceId) {
|
|
@@ -247,7 +240,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
247
240
|
}
|
|
248
241
|
var resourceId = attrs.resourceId,
|
|
249
242
|
blockInstanceId = attrs.localId;
|
|
250
|
-
this.dataProvider.writeNodesData([(0,
|
|
243
|
+
this.dataProvider.writeNodesData([(0, _utils.createBodiedSyncBlockNode)(blockInstanceId, resourceId)], [{
|
|
251
244
|
content: [],
|
|
252
245
|
blockInstanceId: blockInstanceId,
|
|
253
246
|
resourceId: resourceId
|
|
@@ -285,47 +278,40 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
285
278
|
}, {
|
|
286
279
|
key: "deleteSyncBlocksWithConfirmation",
|
|
287
280
|
value: function () {
|
|
288
|
-
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(
|
|
281
|
+
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockIds, deleteCallback) {
|
|
289
282
|
var _this5 = this;
|
|
290
|
-
var confirmed,
|
|
283
|
+
var confirmed, results, callback, _this$fireAnalyticsEv4;
|
|
291
284
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
292
285
|
while (1) switch (_context2.prev = _context2.next) {
|
|
293
286
|
case 0:
|
|
294
287
|
if (!this.confirmationCallback) {
|
|
295
|
-
_context2.next =
|
|
288
|
+
_context2.next = 22;
|
|
296
289
|
break;
|
|
297
290
|
}
|
|
298
|
-
|
|
299
|
-
_context2.next = 4;
|
|
291
|
+
_context2.next = 3;
|
|
300
292
|
return this.confirmationCallback(syncBlockIds.length);
|
|
301
|
-
case
|
|
293
|
+
case 3:
|
|
302
294
|
confirmed = _context2.sent;
|
|
303
295
|
if (!confirmed) {
|
|
304
|
-
_context2.next =
|
|
296
|
+
_context2.next = 22;
|
|
305
297
|
break;
|
|
306
298
|
}
|
|
307
|
-
|
|
308
|
-
|
|
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;
|
|
299
|
+
deleteCallback();
|
|
300
|
+
_context2.prev = 6;
|
|
315
301
|
if (this.dataProvider) {
|
|
316
|
-
_context2.next =
|
|
302
|
+
_context2.next = 9;
|
|
317
303
|
break;
|
|
318
304
|
}
|
|
319
305
|
throw new Error('Data provider not set');
|
|
320
|
-
case
|
|
306
|
+
case 9:
|
|
321
307
|
syncBlockIds.forEach(function (Ids) {
|
|
322
308
|
_this5.setPendingDeletion(Ids, true);
|
|
323
309
|
});
|
|
324
|
-
_context2.next =
|
|
310
|
+
_context2.next = 12;
|
|
325
311
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
326
312
|
return attrs.resourceId;
|
|
327
313
|
}));
|
|
328
|
-
case
|
|
314
|
+
case 12:
|
|
329
315
|
results = _context2.sent;
|
|
330
316
|
if (results.every(function (result) {
|
|
331
317
|
return result.success;
|
|
@@ -345,11 +331,11 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
345
331
|
});
|
|
346
332
|
}
|
|
347
333
|
syncBlockIds.forEach(callback);
|
|
348
|
-
_context2.next =
|
|
334
|
+
_context2.next = 22;
|
|
349
335
|
break;
|
|
350
|
-
case
|
|
351
|
-
_context2.prev =
|
|
352
|
-
_context2.t0 = _context2["catch"](
|
|
336
|
+
case 17:
|
|
337
|
+
_context2.prev = 17;
|
|
338
|
+
_context2.t0 = _context2["catch"](6);
|
|
353
339
|
syncBlockIds.forEach(function (Ids) {
|
|
354
340
|
_this5.setPendingDeletion(Ids, false);
|
|
355
341
|
});
|
|
@@ -357,38 +343,25 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
357
343
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
358
344
|
});
|
|
359
345
|
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.deleteErrorPayload)(_context2.t0.message));
|
|
360
|
-
case
|
|
361
|
-
this.confirmationTransaction = undefined;
|
|
362
|
-
case 26:
|
|
346
|
+
case 22:
|
|
363
347
|
case "end":
|
|
364
348
|
return _context2.stop();
|
|
365
349
|
}
|
|
366
|
-
}, _callee2, this, [[
|
|
350
|
+
}, _callee2, this, [[6, 17]]);
|
|
367
351
|
}));
|
|
368
352
|
function deleteSyncBlocksWithConfirmation(_x, _x2) {
|
|
369
353
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
370
354
|
}
|
|
371
355
|
return deleteSyncBlocksWithConfirmation;
|
|
372
356
|
}()
|
|
373
|
-
}, {
|
|
374
|
-
key: "rebaseTransaction",
|
|
375
|
-
value: function rebaseTransaction(incomingTr, state) {
|
|
376
|
-
if (!this.confirmationTransaction) {
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
this.confirmationTransaction = (0, _rebaseTransaction2.rebaseTransaction)(this.confirmationTransaction, incomingTr, state);
|
|
380
|
-
}
|
|
381
357
|
}, {
|
|
382
358
|
key: "destroy",
|
|
383
359
|
value: function destroy() {
|
|
384
360
|
this.syncBlockCache.clear();
|
|
385
361
|
this.confirmationCallback = undefined;
|
|
386
|
-
this.confirmationTransaction = undefined;
|
|
387
362
|
this.pendingResourceId = undefined;
|
|
388
363
|
this.creationCallback = undefined;
|
|
389
364
|
this.dataProvider = undefined;
|
|
390
|
-
this.editorView = undefined;
|
|
391
|
-
this.fireAnalyticsEvent = undefined;
|
|
392
365
|
}
|
|
393
366
|
}]);
|
|
394
367
|
}();
|
|
@@ -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
|
-
|
|
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$
|
|
95
|
-
(_this$
|
|
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$
|
|
102
|
+
var _this$fireAnalyticsEv4;
|
|
101
103
|
logException(error, {
|
|
102
104
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
103
105
|
});
|
|
104
|
-
(_this$
|
|
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$
|
|
137
|
-
(_this$
|
|
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$
|
|
142
|
-
(_this$
|
|
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$
|
|
212
|
+
var _this$fireAnalyticsEv7;
|
|
211
213
|
logException(error, {
|
|
212
214
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
213
215
|
});
|
|
214
|
-
(_this$
|
|
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$
|
|
283
|
+
var _this$fireAnalyticsEv8;
|
|
282
284
|
logException(error, {
|
|
283
285
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
284
286
|
});
|
|
285
|
-
(_this$
|
|
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$
|
|
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$
|
|
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$
|
|
332
|
+
var _this$fireAnalyticsEv0;
|
|
331
333
|
logException(error, {
|
|
332
334
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
333
335
|
});
|
|
334
|
-
(_this$
|
|
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$
|
|
352
|
-
(_this$
|
|
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,8 +2,6 @@ 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';
|
|
6
|
-
import { rebaseTransaction } from '../common/rebase-transaction';
|
|
7
5
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload } from '../utils/errorHandling';
|
|
8
6
|
import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode } from '../utils/utils';
|
|
9
7
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
@@ -103,9 +101,6 @@ export class SourceSyncBlockStoreManager {
|
|
|
103
101
|
return false;
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
|
-
setEditorView(editorView) {
|
|
107
|
-
this.editorView = editorView;
|
|
108
|
-
}
|
|
109
104
|
registerPendingCreation(resourceId) {
|
|
110
105
|
this.pendingResourceId = resourceId;
|
|
111
106
|
}
|
|
@@ -212,19 +207,11 @@ export class SourceSyncBlockStoreManager {
|
|
|
212
207
|
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createErrorPayload(error.message));
|
|
213
208
|
}
|
|
214
209
|
}
|
|
215
|
-
async deleteSyncBlocksWithConfirmation(
|
|
210
|
+
async deleteSyncBlocksWithConfirmation(syncBlockIds, deleteCallback) {
|
|
216
211
|
if (this.confirmationCallback) {
|
|
217
|
-
this.confirmationTransaction = tr;
|
|
218
212
|
const confirmed = await this.confirmationCallback(syncBlockIds.length);
|
|
219
213
|
if (confirmed) {
|
|
220
|
-
|
|
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);
|
|
214
|
+
deleteCallback();
|
|
228
215
|
try {
|
|
229
216
|
if (!this.dataProvider) {
|
|
230
217
|
throw new Error('Data provider not set');
|
|
@@ -257,23 +244,13 @@ export class SourceSyncBlockStoreManager {
|
|
|
257
244
|
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, deleteErrorPayload(error.message));
|
|
258
245
|
}
|
|
259
246
|
}
|
|
260
|
-
this.confirmationTransaction = undefined;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
rebaseTransaction(incomingTr, state) {
|
|
264
|
-
if (!this.confirmationTransaction) {
|
|
265
|
-
return;
|
|
266
247
|
}
|
|
267
|
-
this.confirmationTransaction = rebaseTransaction(this.confirmationTransaction, incomingTr, state);
|
|
268
248
|
}
|
|
269
249
|
destroy() {
|
|
270
250
|
this.syncBlockCache.clear();
|
|
271
251
|
this.confirmationCallback = undefined;
|
|
272
|
-
this.confirmationTransaction = undefined;
|
|
273
252
|
this.pendingResourceId = undefined;
|
|
274
253
|
this.creationCallback = undefined;
|
|
275
254
|
this.dataProvider = undefined;
|
|
276
|
-
this.editorView = undefined;
|
|
277
|
-
this.fireAnalyticsEvent = undefined;
|
|
278
255
|
}
|
|
279
256
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from
|
|
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
|
-
|
|
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$
|
|
168
|
-
(_this$
|
|
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$
|
|
175
|
+
var _this$fireAnalyticsEv4;
|
|
174
176
|
logException(error, {
|
|
175
177
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
176
178
|
});
|
|
177
|
-
(_this$
|
|
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$
|
|
388
|
+
var _this$fireAnalyticsEv5;
|
|
387
389
|
logException(error, {
|
|
388
390
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
389
391
|
});
|
|
390
|
-
(_this$
|
|
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$
|
|
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$
|
|
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$
|
|
440
|
+
var _this$fireAnalyticsEv7;
|
|
439
441
|
logException(error, {
|
|
440
442
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
441
443
|
});
|
|
442
|
-
(_this$
|
|
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$
|
|
462
|
-
(_this$
|
|
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,8 +6,6 @@ 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';
|
|
10
|
-
import { rebaseTransaction as _rebaseTransaction } from '../common/rebase-transaction';
|
|
11
9
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload } from '../utils/errorHandling';
|
|
12
10
|
import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode as _createBodiedSyncBlockNode } from '../utils/utils';
|
|
13
11
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
@@ -148,11 +146,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
148
146
|
}
|
|
149
147
|
return flush;
|
|
150
148
|
}())
|
|
151
|
-
}, {
|
|
152
|
-
key: "setEditorView",
|
|
153
|
-
value: function setEditorView(editorView) {
|
|
154
|
-
this.editorView = editorView;
|
|
155
|
-
}
|
|
156
149
|
}, {
|
|
157
150
|
key: "registerPendingCreation",
|
|
158
151
|
value: function registerPendingCreation(resourceId) {
|
|
@@ -278,47 +271,40 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
278
271
|
}, {
|
|
279
272
|
key: "deleteSyncBlocksWithConfirmation",
|
|
280
273
|
value: function () {
|
|
281
|
-
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(
|
|
274
|
+
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(syncBlockIds, deleteCallback) {
|
|
282
275
|
var _this5 = this;
|
|
283
|
-
var confirmed,
|
|
276
|
+
var confirmed, results, callback, _this$fireAnalyticsEv4;
|
|
284
277
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
285
278
|
while (1) switch (_context2.prev = _context2.next) {
|
|
286
279
|
case 0:
|
|
287
280
|
if (!this.confirmationCallback) {
|
|
288
|
-
_context2.next =
|
|
281
|
+
_context2.next = 22;
|
|
289
282
|
break;
|
|
290
283
|
}
|
|
291
|
-
|
|
292
|
-
_context2.next = 4;
|
|
284
|
+
_context2.next = 3;
|
|
293
285
|
return this.confirmationCallback(syncBlockIds.length);
|
|
294
|
-
case
|
|
286
|
+
case 3:
|
|
295
287
|
confirmed = _context2.sent;
|
|
296
288
|
if (!confirmed) {
|
|
297
|
-
_context2.next =
|
|
289
|
+
_context2.next = 22;
|
|
298
290
|
break;
|
|
299
291
|
}
|
|
300
|
-
|
|
301
|
-
|
|
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;
|
|
292
|
+
deleteCallback();
|
|
293
|
+
_context2.prev = 6;
|
|
308
294
|
if (this.dataProvider) {
|
|
309
|
-
_context2.next =
|
|
295
|
+
_context2.next = 9;
|
|
310
296
|
break;
|
|
311
297
|
}
|
|
312
298
|
throw new Error('Data provider not set');
|
|
313
|
-
case
|
|
299
|
+
case 9:
|
|
314
300
|
syncBlockIds.forEach(function (Ids) {
|
|
315
301
|
_this5.setPendingDeletion(Ids, true);
|
|
316
302
|
});
|
|
317
|
-
_context2.next =
|
|
303
|
+
_context2.next = 12;
|
|
318
304
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
319
305
|
return attrs.resourceId;
|
|
320
306
|
}));
|
|
321
|
-
case
|
|
307
|
+
case 12:
|
|
322
308
|
results = _context2.sent;
|
|
323
309
|
if (results.every(function (result) {
|
|
324
310
|
return result.success;
|
|
@@ -338,11 +324,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
338
324
|
});
|
|
339
325
|
}
|
|
340
326
|
syncBlockIds.forEach(callback);
|
|
341
|
-
_context2.next =
|
|
327
|
+
_context2.next = 22;
|
|
342
328
|
break;
|
|
343
|
-
case
|
|
344
|
-
_context2.prev =
|
|
345
|
-
_context2.t0 = _context2["catch"](
|
|
329
|
+
case 17:
|
|
330
|
+
_context2.prev = 17;
|
|
331
|
+
_context2.t0 = _context2["catch"](6);
|
|
346
332
|
syncBlockIds.forEach(function (Ids) {
|
|
347
333
|
_this5.setPendingDeletion(Ids, false);
|
|
348
334
|
});
|
|
@@ -350,38 +336,25 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
350
336
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
351
337
|
});
|
|
352
338
|
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, deleteErrorPayload(_context2.t0.message));
|
|
353
|
-
case
|
|
354
|
-
this.confirmationTransaction = undefined;
|
|
355
|
-
case 26:
|
|
339
|
+
case 22:
|
|
356
340
|
case "end":
|
|
357
341
|
return _context2.stop();
|
|
358
342
|
}
|
|
359
|
-
}, _callee2, this, [[
|
|
343
|
+
}, _callee2, this, [[6, 17]]);
|
|
360
344
|
}));
|
|
361
345
|
function deleteSyncBlocksWithConfirmation(_x, _x2) {
|
|
362
346
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
363
347
|
}
|
|
364
348
|
return deleteSyncBlocksWithConfirmation;
|
|
365
349
|
}()
|
|
366
|
-
}, {
|
|
367
|
-
key: "rebaseTransaction",
|
|
368
|
-
value: function rebaseTransaction(incomingTr, state) {
|
|
369
|
-
if (!this.confirmationTransaction) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
this.confirmationTransaction = _rebaseTransaction(this.confirmationTransaction, incomingTr, state);
|
|
373
|
-
}
|
|
374
350
|
}, {
|
|
375
351
|
key: "destroy",
|
|
376
352
|
value: function destroy() {
|
|
377
353
|
this.syncBlockCache.clear();
|
|
378
354
|
this.confirmationCallback = undefined;
|
|
379
|
-
this.confirmationTransaction = undefined;
|
|
380
355
|
this.pendingResourceId = undefined;
|
|
381
356
|
this.creationCallback = undefined;
|
|
382
357
|
this.dataProvider = undefined;
|
|
383
|
-
this.editorView = undefined;
|
|
384
|
-
this.fireAnalyticsEvent = undefined;
|
|
385
358
|
}
|
|
386
359
|
}]);
|
|
387
360
|
}();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from
|
|
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,18 +1,14 @@
|
|
|
1
1
|
import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
3
|
import type { ResourceId, SyncBlockAttrs } from '../common/types';
|
|
6
4
|
import type { SyncBlockDataProvider } from '../providers/types';
|
|
7
5
|
export type ConfirmationCallback = (syncBlockCount: number) => Promise<boolean>;
|
|
8
6
|
export type CreationCallback = () => void;
|
|
9
7
|
export declare class SourceSyncBlockStoreManager {
|
|
10
8
|
private dataProvider?;
|
|
11
|
-
private editorView?;
|
|
12
9
|
private fireAnalyticsEvent?;
|
|
13
10
|
private syncBlockCache;
|
|
14
11
|
private confirmationCallback?;
|
|
15
|
-
private confirmationTransaction?;
|
|
16
12
|
private pendingResourceId?;
|
|
17
13
|
private creationCallback?;
|
|
18
14
|
constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
|
|
@@ -28,7 +24,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
28
24
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
29
25
|
*/
|
|
30
26
|
flush(): Promise<boolean>;
|
|
31
|
-
setEditorView(editorView: EditorView | undefined): void;
|
|
32
27
|
registerPendingCreation(resourceId: ResourceId): void;
|
|
33
28
|
/**
|
|
34
29
|
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
@@ -56,7 +51,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
56
51
|
*/
|
|
57
52
|
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
58
53
|
private setPendingDeletion;
|
|
59
|
-
deleteSyncBlocksWithConfirmation(
|
|
60
|
-
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
54
|
+
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deleteCallback: () => void): Promise<void>;
|
|
61
55
|
destroy(): void;
|
|
62
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from
|
|
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,18 +1,14 @@
|
|
|
1
1
|
import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
3
|
import type { ResourceId, SyncBlockAttrs } from '../common/types';
|
|
6
4
|
import type { SyncBlockDataProvider } from '../providers/types';
|
|
7
5
|
export type ConfirmationCallback = (syncBlockCount: number) => Promise<boolean>;
|
|
8
6
|
export type CreationCallback = () => void;
|
|
9
7
|
export declare class SourceSyncBlockStoreManager {
|
|
10
8
|
private dataProvider?;
|
|
11
|
-
private editorView?;
|
|
12
9
|
private fireAnalyticsEvent?;
|
|
13
10
|
private syncBlockCache;
|
|
14
11
|
private confirmationCallback?;
|
|
15
|
-
private confirmationTransaction?;
|
|
16
12
|
private pendingResourceId?;
|
|
17
13
|
private creationCallback?;
|
|
18
14
|
constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
|
|
@@ -28,7 +24,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
28
24
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
29
25
|
*/
|
|
30
26
|
flush(): Promise<boolean>;
|
|
31
|
-
setEditorView(editorView: EditorView | undefined): void;
|
|
32
27
|
registerPendingCreation(resourceId: ResourceId): void;
|
|
33
28
|
/**
|
|
34
29
|
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
@@ -56,7 +51,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
56
51
|
*/
|
|
57
52
|
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
58
53
|
private setPendingDeletion;
|
|
59
|
-
deleteSyncBlocksWithConfirmation(
|
|
60
|
-
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
54
|
+
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deleteCallback: () => void): Promise<void>;
|
|
61
55
|
destroy(): void;
|
|
62
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, type RendererSyncBlockEventPayload, type OperationalAEP, type SyncBlockEventPayload } from
|
|
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