@atlaskit/editor-synced-block-provider 6.3.0 → 6.3.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 +14 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +7 -10
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +19 -159
- package/dist/es2019/providers/block-service/blockServiceAPI.js +4 -8
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +2 -95
- package/dist/esm/providers/block-service/blockServiceAPI.js +7 -10
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +19 -159
- package/dist/types/clients/jira/requestJiraIssueAccess.d.ts +1 -1
- package/dist/types/providers/types.d.ts +1 -2
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +0 -15
- package/dist/types-ts4.5/clients/jira/requestJiraIssueAccess.d.ts +1 -1
- package/dist/types-ts4.5/providers/types.d.ts +1 -2
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +0 -15
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 6.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 6.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`717df2cfeca9e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/717df2cfeca9e) -
|
|
14
|
+
[ux] Pass accountId to SyncedBlockRenderer from Jira.
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 6.3.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -54,7 +54,7 @@ var mapErrorResponseCode = function mapErrorResponseCode(errorCode) {
|
|
|
54
54
|
case 'NOT_FOUND':
|
|
55
55
|
return _types.SyncBlockError.NotFound;
|
|
56
56
|
case 'EntityNotFound':
|
|
57
|
-
return (0, _platformFeatureFlags.fg)('
|
|
57
|
+
return (0, _platformFeatureFlags.fg)('platform_synced_block_patch_9') ? _types.SyncBlockError.EntityNotFound : _types.SyncBlockError.Errored;
|
|
58
58
|
case 'INVALID_REQUEST':
|
|
59
59
|
return _types.SyncBlockError.InvalidRequest;
|
|
60
60
|
case 'CONFLICT':
|
|
@@ -1271,7 +1271,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1271
1271
|
value: function () {
|
|
1272
1272
|
var _writeDataBatch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(data) {
|
|
1273
1273
|
var _this3 = this;
|
|
1274
|
-
var stepVersion, blockAriToResourceIdMap, blocks, response, results,
|
|
1274
|
+
var stepVersion, blockAriToResourceIdMap, blocks, response, results, successResourceIds, _iterator6, _step6, block, errorResourceIds, _iterator7, _step7, _loop2;
|
|
1275
1275
|
return _regenerator.default.wrap(function _callee10$(_context12) {
|
|
1276
1276
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1277
1277
|
case 0:
|
|
@@ -1321,20 +1321,17 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1321
1321
|
response = _context12.sent;
|
|
1322
1322
|
results = []; // Process successful updates
|
|
1323
1323
|
if (response.success) {
|
|
1324
|
-
|
|
1325
|
-
return
|
|
1324
|
+
successResourceIds = new Set(response.success.map(function (block) {
|
|
1325
|
+
return blockAriToResourceIdMap.get(block.blockAri);
|
|
1326
1326
|
}));
|
|
1327
1327
|
_iterator6 = _createForOfIteratorHelper(data);
|
|
1328
1328
|
try {
|
|
1329
1329
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1330
1330
|
block = _step6.value;
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
results.push(_objectSpread({
|
|
1331
|
+
if (successResourceIds.has(block.resourceId)) {
|
|
1332
|
+
results.push({
|
|
1334
1333
|
resourceId: block.resourceId
|
|
1335
|
-
}
|
|
1336
|
-
status: successBlock.status
|
|
1337
|
-
}));
|
|
1334
|
+
});
|
|
1338
1335
|
}
|
|
1339
1336
|
}
|
|
1340
1337
|
} catch (err) {
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.SourceSyncBlockStoreManager = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -19,9 +18,6 @@ var _types = require("../common/types");
|
|
|
19
18
|
var _errorHandling = require("../utils/errorHandling");
|
|
20
19
|
var _experienceTracking = require("../utils/experienceTracking");
|
|
21
20
|
var _utils = require("../utils/utils");
|
|
22
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
23
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
25
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
23
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
@@ -112,8 +108,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
112
108
|
isDirty: isDirty,
|
|
113
109
|
// if the change is from remote, it's not dirty
|
|
114
110
|
contentFragment: syncBlockNode.content
|
|
115
|
-
}, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_10') && {
|
|
116
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
117
111
|
}));
|
|
118
112
|
} else {
|
|
119
113
|
var _syncBlockData = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(syncBlockNode);
|
|
@@ -122,8 +116,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
122
116
|
}
|
|
123
117
|
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, _syncBlockData), {}, {
|
|
124
118
|
isDirty: true
|
|
125
|
-
}, (0, _platformFeatureFlags.fg)('platform_synced_block_patch_10') && {
|
|
126
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
127
119
|
}));
|
|
128
120
|
}
|
|
129
121
|
return true;
|
|
@@ -222,13 +214,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
222
214
|
writeResults.forEach(function (result) {
|
|
223
215
|
if (result.resourceId && !result.error) {
|
|
224
216
|
var _this2$fireAnalyticsE;
|
|
225
|
-
// Update cache with the status returned from the backend
|
|
226
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
227
|
-
var cachedData = _this2.syncBlockCache.get(result.resourceId);
|
|
228
|
-
if (cachedData && result.status) {
|
|
229
|
-
cachedData.status = result.status;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
217
|
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.updateSuccessPayload)(result.resourceId, false));
|
|
233
218
|
}
|
|
234
219
|
});
|
|
@@ -382,14 +367,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
382
367
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
|
|
383
368
|
// add the node to the cache
|
|
384
369
|
this.updateSyncBlockData(node, false);
|
|
385
|
-
|
|
386
|
-
// Mark the block as unpublished in the cache so it can be cleaned up on cancel
|
|
387
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
388
|
-
var cached = this.syncBlockCache.get(resourceId);
|
|
389
|
-
if (cached) {
|
|
390
|
-
cached.status = 'unpublished';
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
370
|
}
|
|
394
371
|
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
395
372
|
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
|
|
@@ -573,123 +550,6 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
573
550
|
}
|
|
574
551
|
|
|
575
552
|
/**
|
|
576
|
-
* Fetches the current status of all source sync blocks in the cache from the backend
|
|
577
|
-
* and updates the cache entries with the fetched status.
|
|
578
|
-
* This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
|
|
579
|
-
*/
|
|
580
|
-
}, {
|
|
581
|
-
key: "fetchAndCacheStatuses",
|
|
582
|
-
value: (function () {
|
|
583
|
-
var _fetchAndCacheStatuses = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
584
|
-
var _this6 = this;
|
|
585
|
-
var sourceToReferenceMap, syncBlockNodes, results, _iterator, _step, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
|
|
586
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
587
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
588
|
-
case 0:
|
|
589
|
-
if (!(!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_10') || !this.dataProvider || this.syncBlockCache.size === 0)) {
|
|
590
|
-
_context4.next = 2;
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
return _context4.abrupt("return");
|
|
594
|
-
case 2:
|
|
595
|
-
// Source blocks have plain UUID resourceIds, but fetchNodesData internally uses
|
|
596
|
-
// generateBlockAriFromReference which expects reference-format resourceIds
|
|
597
|
-
// (e.g. "confluence-page/pageId/uuid"). We convert source resourceIds to reference
|
|
598
|
-
// format before fetching, and maintain a mapping back to original resourceIds
|
|
599
|
-
// so we can update the correct cache entries.
|
|
600
|
-
sourceToReferenceMap = new Map();
|
|
601
|
-
syncBlockNodes = Array.from(this.syncBlockCache.entries()).map(function (_ref) {
|
|
602
|
-
var _this6$dataProvider$g, _this6$dataProvider;
|
|
603
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
604
|
-
resourceId = _ref2[0],
|
|
605
|
-
data = _ref2[1];
|
|
606
|
-
var referenceResourceId = (_this6$dataProvider$g = (_this6$dataProvider = _this6.dataProvider) === null || _this6$dataProvider === void 0 ? void 0 : _this6$dataProvider.generateResourceIdForReference(resourceId)) !== null && _this6$dataProvider$g !== void 0 ? _this6$dataProvider$g : resourceId;
|
|
607
|
-
sourceToReferenceMap.set(referenceResourceId, resourceId);
|
|
608
|
-
return {
|
|
609
|
-
type: 'bodiedSyncBlock',
|
|
610
|
-
attrs: {
|
|
611
|
-
localId: data.blockInstanceId,
|
|
612
|
-
resourceId: referenceResourceId
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
});
|
|
616
|
-
_context4.prev = 4;
|
|
617
|
-
_context4.next = 7;
|
|
618
|
-
return this.dataProvider.fetchNodesData(syncBlockNodes);
|
|
619
|
-
case 7:
|
|
620
|
-
results = _context4.sent;
|
|
621
|
-
_iterator = _createForOfIteratorHelper(results);
|
|
622
|
-
try {
|
|
623
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
624
|
-
result = _step.value;
|
|
625
|
-
// Map the reference resourceId back to the source resourceId
|
|
626
|
-
sourceResourceId = (_sourceToReferenceMap = sourceToReferenceMap.get(result.resourceId)) !== null && _sourceToReferenceMap !== void 0 ? _sourceToReferenceMap : result.resourceId;
|
|
627
|
-
cached = this.syncBlockCache.get(sourceResourceId);
|
|
628
|
-
if (cached && (_result$data = result.data) !== null && _result$data !== void 0 && _result$data.status) {
|
|
629
|
-
cached.status = result.data.status;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
} catch (err) {
|
|
633
|
-
_iterator.e(err);
|
|
634
|
-
} finally {
|
|
635
|
-
_iterator.f();
|
|
636
|
-
}
|
|
637
|
-
_context4.next = 14;
|
|
638
|
-
break;
|
|
639
|
-
case 12:
|
|
640
|
-
_context4.prev = 12;
|
|
641
|
-
_context4.t0 = _context4["catch"](4);
|
|
642
|
-
case 14:
|
|
643
|
-
case "end":
|
|
644
|
-
return _context4.stop();
|
|
645
|
-
}
|
|
646
|
-
}, _callee4, this, [[4, 12]]);
|
|
647
|
-
}));
|
|
648
|
-
function fetchAndCacheStatuses() {
|
|
649
|
-
return _fetchAndCacheStatuses.apply(this, arguments);
|
|
650
|
-
}
|
|
651
|
-
return fetchAndCacheStatuses;
|
|
652
|
-
}()
|
|
653
|
-
/**
|
|
654
|
-
* Deletes all source sync blocks that have 'unpublished' status.
|
|
655
|
-
* Used to clean up orphaned blocks when a user cancels editing without saving.
|
|
656
|
-
* Blocks that were already saved (status 'active') are not affected.
|
|
657
|
-
*
|
|
658
|
-
* @returns true if all deletions succeeded, false otherwise
|
|
659
|
-
*/
|
|
660
|
-
)
|
|
661
|
-
}, {
|
|
662
|
-
key: "discardUnpublishedBlocks",
|
|
663
|
-
value: function discardUnpublishedBlocks() {
|
|
664
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
665
|
-
return Promise.resolve(true);
|
|
666
|
-
}
|
|
667
|
-
var unpublishedBlockIds = Array.from(this.syncBlockCache.entries()).filter(function (_ref3) {
|
|
668
|
-
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
669
|
-
_ = _ref4[0],
|
|
670
|
-
data = _ref4[1];
|
|
671
|
-
return data.status === 'unpublished' && !data.pendingDeletion;
|
|
672
|
-
}).map(function (_ref5) {
|
|
673
|
-
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
|
674
|
-
resourceId = _ref6[0],
|
|
675
|
-
data = _ref6[1];
|
|
676
|
-
return {
|
|
677
|
-
resourceId: resourceId,
|
|
678
|
-
localId: data.blockInstanceId
|
|
679
|
-
};
|
|
680
|
-
});
|
|
681
|
-
if (unpublishedBlockIds.length === 0) {
|
|
682
|
-
return Promise.resolve(true);
|
|
683
|
-
}
|
|
684
|
-
return this.delete(unpublishedBlockIds, function () {},
|
|
685
|
-
// onDelete: no-op, document is being discarded
|
|
686
|
-
function () {},
|
|
687
|
-
// onDeleteCompleted: no-op
|
|
688
|
-
'source-block-unpublished');
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Deletes sync blocks with confirmation from the backend
|
|
693
553
|
*
|
|
694
554
|
* @param syncBlockIds - The sync block ids to delete
|
|
695
555
|
* @param onDelete - The callback to delete sync block node from document
|
|
@@ -699,33 +559,33 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
699
559
|
}, {
|
|
700
560
|
key: "deleteSyncBlocksWithConfirmation",
|
|
701
561
|
value: (function () {
|
|
702
|
-
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
562
|
+
var _deleteSyncBlocksWithConfirmation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
703
563
|
var confirmed, isDeleteSuccessful;
|
|
704
|
-
return _regenerator.default.wrap(function
|
|
705
|
-
while (1) switch (
|
|
564
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
565
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
706
566
|
case 0:
|
|
707
567
|
if (!(this.viewMode === 'view' && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_8'))) {
|
|
708
|
-
|
|
568
|
+
_context4.next = 2;
|
|
709
569
|
break;
|
|
710
570
|
}
|
|
711
|
-
return
|
|
571
|
+
return _context4.abrupt("return", Promise.resolve());
|
|
712
572
|
case 2:
|
|
713
573
|
if (!this.confirmationCallback) {
|
|
714
|
-
|
|
574
|
+
_context4.next = 14;
|
|
715
575
|
break;
|
|
716
576
|
}
|
|
717
|
-
|
|
577
|
+
_context4.next = 5;
|
|
718
578
|
return this.confirmationCallback(syncBlockIds, deletionReason);
|
|
719
579
|
case 5:
|
|
720
|
-
confirmed =
|
|
580
|
+
confirmed = _context4.sent;
|
|
721
581
|
if (!confirmed) {
|
|
722
|
-
|
|
582
|
+
_context4.next = 13;
|
|
723
583
|
break;
|
|
724
584
|
}
|
|
725
|
-
|
|
585
|
+
_context4.next = 9;
|
|
726
586
|
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
727
587
|
case 9:
|
|
728
|
-
isDeleteSuccessful =
|
|
588
|
+
isDeleteSuccessful = _context4.sent;
|
|
729
589
|
if (!isDeleteSuccessful) {
|
|
730
590
|
// If deletion failed, save deletion info for potential retry
|
|
731
591
|
this.deletionRetryInfo = {
|
|
@@ -738,15 +598,15 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
738
598
|
} else {
|
|
739
599
|
destroyCallback();
|
|
740
600
|
}
|
|
741
|
-
|
|
601
|
+
_context4.next = 14;
|
|
742
602
|
break;
|
|
743
603
|
case 13:
|
|
744
604
|
destroyCallback();
|
|
745
605
|
case 14:
|
|
746
606
|
case "end":
|
|
747
|
-
return
|
|
607
|
+
return _context4.stop();
|
|
748
608
|
}
|
|
749
|
-
},
|
|
609
|
+
}, _callee4, this);
|
|
750
610
|
}));
|
|
751
611
|
function deleteSyncBlocksWithConfirmation(_x5, _x6, _x7, _x8, _x9) {
|
|
752
612
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
@@ -756,7 +616,7 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
756
616
|
}, {
|
|
757
617
|
key: "getSyncBlockSourceInfo",
|
|
758
618
|
value: function getSyncBlockSourceInfo(localId) {
|
|
759
|
-
var
|
|
619
|
+
var _this6 = this;
|
|
760
620
|
try {
|
|
761
621
|
var _this$fetchSourceInfo;
|
|
762
622
|
if (!this.dataProvider) {
|
|
@@ -765,13 +625,13 @@ var SourceSyncBlockStoreManager = exports.SourceSyncBlockStoreManager = /*#__PUR
|
|
|
765
625
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
766
626
|
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined).then(function (sourceInfo) {
|
|
767
627
|
if (!sourceInfo) {
|
|
768
|
-
var
|
|
769
|
-
(
|
|
628
|
+
var _this6$fetchSourceInf;
|
|
629
|
+
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
770
630
|
reason: 'No source info returned'
|
|
771
631
|
});
|
|
772
632
|
} else {
|
|
773
|
-
var
|
|
774
|
-
(
|
|
633
|
+
var _this6$fetchSourceInf2;
|
|
634
|
+
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
775
635
|
}
|
|
776
636
|
return sourceInfo;
|
|
777
637
|
});
|
|
@@ -37,7 +37,7 @@ const mapErrorResponseCode = errorCode => {
|
|
|
37
37
|
case 'NOT_FOUND':
|
|
38
38
|
return SyncBlockError.NotFound;
|
|
39
39
|
case 'EntityNotFound':
|
|
40
|
-
return fg('
|
|
40
|
+
return fg('platform_synced_block_patch_9') ? SyncBlockError.EntityNotFound : SyncBlockError.Errored;
|
|
41
41
|
case 'INVALID_REQUEST':
|
|
42
42
|
return SyncBlockError.InvalidRequest;
|
|
43
43
|
case 'CONFLICT':
|
|
@@ -861,15 +861,11 @@ class BlockServiceADFWriteProvider {
|
|
|
861
861
|
|
|
862
862
|
// Process successful updates
|
|
863
863
|
if (response.success) {
|
|
864
|
-
const
|
|
864
|
+
const successResourceIds = new Set(response.success.map(block => blockAriToResourceIdMap.get(block.blockAri)));
|
|
865
865
|
for (const block of data) {
|
|
866
|
-
|
|
867
|
-
if (successBlock) {
|
|
866
|
+
if (successResourceIds.has(block.resourceId)) {
|
|
868
867
|
results.push({
|
|
869
|
-
resourceId: block.resourceId
|
|
870
|
-
...(fg('platform_synced_block_patch_10') && {
|
|
871
|
-
status: successBlock.status
|
|
872
|
-
})
|
|
868
|
+
resourceId: block.resourceId
|
|
873
869
|
});
|
|
874
870
|
}
|
|
875
871
|
}
|
|
@@ -86,10 +86,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
86
86
|
...syncBlockData,
|
|
87
87
|
isDirty: isDirty,
|
|
88
88
|
// if the change is from remote, it's not dirty
|
|
89
|
-
contentFragment: syncBlockNode.content
|
|
90
|
-
...(fg('platform_synced_block_patch_10') && {
|
|
91
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
92
|
-
})
|
|
89
|
+
contentFragment: syncBlockNode.content
|
|
93
90
|
});
|
|
94
91
|
} else {
|
|
95
92
|
const syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
@@ -98,10 +95,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
98
95
|
}
|
|
99
96
|
this.syncBlockCache.set(resourceId, {
|
|
100
97
|
...syncBlockData,
|
|
101
|
-
isDirty: true
|
|
102
|
-
...(fg('platform_synced_block_patch_10') && {
|
|
103
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
104
|
-
})
|
|
98
|
+
isDirty: true
|
|
105
99
|
});
|
|
106
100
|
}
|
|
107
101
|
return true;
|
|
@@ -178,13 +172,6 @@ export class SourceSyncBlockStoreManager {
|
|
|
178
172
|
writeResults.forEach(result => {
|
|
179
173
|
if (result.resourceId && !result.error) {
|
|
180
174
|
var _this$fireAnalyticsEv2;
|
|
181
|
-
// Update cache with the status returned from the backend
|
|
182
|
-
if (fg('platform_synced_block_patch_10')) {
|
|
183
|
-
const cachedData = this.syncBlockCache.get(result.resourceId);
|
|
184
|
-
if (cachedData && result.status) {
|
|
185
|
-
cachedData.status = result.status;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
175
|
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, updateSuccessPayload(result.resourceId, false));
|
|
189
176
|
}
|
|
190
177
|
});
|
|
@@ -309,14 +296,6 @@ export class SourceSyncBlockStoreManager {
|
|
|
309
296
|
if (fg('platform_synced_block_update_refactor')) {
|
|
310
297
|
// add the node to the cache
|
|
311
298
|
this.updateSyncBlockData(node, false);
|
|
312
|
-
|
|
313
|
-
// Mark the block as unpublished in the cache so it can be cleaned up on cancel
|
|
314
|
-
if (fg('platform_synced_block_patch_10')) {
|
|
315
|
-
const cached = this.syncBlockCache.get(resourceId);
|
|
316
|
-
if (cached) {
|
|
317
|
-
cached.status = 'unpublished';
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
299
|
}
|
|
321
300
|
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
322
301
|
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 ? void 0 : _this$createExperienc.start({});
|
|
@@ -445,78 +424,6 @@ export class SourceSyncBlockStoreManager {
|
|
|
445
424
|
}
|
|
446
425
|
|
|
447
426
|
/**
|
|
448
|
-
* Fetches the current status of all source sync blocks in the cache from the backend
|
|
449
|
-
* and updates the cache entries with the fetched status.
|
|
450
|
-
* This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
|
|
451
|
-
*/
|
|
452
|
-
async fetchAndCacheStatuses() {
|
|
453
|
-
if (!fg('platform_synced_block_patch_10') || !this.dataProvider || this.syncBlockCache.size === 0) {
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// Source blocks have plain UUID resourceIds, but fetchNodesData internally uses
|
|
458
|
-
// generateBlockAriFromReference which expects reference-format resourceIds
|
|
459
|
-
// (e.g. "confluence-page/pageId/uuid"). We convert source resourceIds to reference
|
|
460
|
-
// format before fetching, and maintain a mapping back to original resourceIds
|
|
461
|
-
// so we can update the correct cache entries.
|
|
462
|
-
const sourceToReferenceMap = new Map();
|
|
463
|
-
const syncBlockNodes = Array.from(this.syncBlockCache.entries()).map(([resourceId, data]) => {
|
|
464
|
-
var _this$dataProvider$ge, _this$dataProvider;
|
|
465
|
-
const referenceResourceId = (_this$dataProvider$ge = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.generateResourceIdForReference(resourceId)) !== null && _this$dataProvider$ge !== void 0 ? _this$dataProvider$ge : resourceId;
|
|
466
|
-
sourceToReferenceMap.set(referenceResourceId, resourceId);
|
|
467
|
-
return {
|
|
468
|
-
type: 'bodiedSyncBlock',
|
|
469
|
-
attrs: {
|
|
470
|
-
localId: data.blockInstanceId,
|
|
471
|
-
resourceId: referenceResourceId
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
});
|
|
475
|
-
try {
|
|
476
|
-
const results = await this.dataProvider.fetchNodesData(syncBlockNodes);
|
|
477
|
-
for (const result of results) {
|
|
478
|
-
var _sourceToReferenceMap, _result$data;
|
|
479
|
-
// Map the reference resourceId back to the source resourceId
|
|
480
|
-
const sourceResourceId = (_sourceToReferenceMap = sourceToReferenceMap.get(result.resourceId)) !== null && _sourceToReferenceMap !== void 0 ? _sourceToReferenceMap : result.resourceId;
|
|
481
|
-
const cached = this.syncBlockCache.get(sourceResourceId);
|
|
482
|
-
if (cached && (_result$data = result.data) !== null && _result$data !== void 0 && _result$data.status) {
|
|
483
|
-
cached.status = result.data.status;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
} catch {
|
|
487
|
-
// If the fetch fails, statuses remain undefined.
|
|
488
|
-
// This is acceptable — on cancel, blocks without a known status
|
|
489
|
-
// will not be deleted (safe default).
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Deletes all source sync blocks that have 'unpublished' status.
|
|
495
|
-
* Used to clean up orphaned blocks when a user cancels editing without saving.
|
|
496
|
-
* Blocks that were already saved (status 'active') are not affected.
|
|
497
|
-
*
|
|
498
|
-
* @returns true if all deletions succeeded, false otherwise
|
|
499
|
-
*/
|
|
500
|
-
discardUnpublishedBlocks() {
|
|
501
|
-
if (!fg('platform_synced_block_patch_10')) {
|
|
502
|
-
return Promise.resolve(true);
|
|
503
|
-
}
|
|
504
|
-
const unpublishedBlockIds = Array.from(this.syncBlockCache.entries()).filter(([_, data]) => data.status === 'unpublished' && !data.pendingDeletion).map(([resourceId, data]) => ({
|
|
505
|
-
resourceId,
|
|
506
|
-
localId: data.blockInstanceId
|
|
507
|
-
}));
|
|
508
|
-
if (unpublishedBlockIds.length === 0) {
|
|
509
|
-
return Promise.resolve(true);
|
|
510
|
-
}
|
|
511
|
-
return this.delete(unpublishedBlockIds, () => {},
|
|
512
|
-
// onDelete: no-op, document is being discarded
|
|
513
|
-
() => {},
|
|
514
|
-
// onDeleteCompleted: no-op
|
|
515
|
-
'source-block-unpublished');
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Deletes sync blocks with confirmation from the backend
|
|
520
427
|
*
|
|
521
428
|
* @param syncBlockIds - The sync block ids to delete
|
|
522
429
|
* @param onDelete - The callback to delete sync block node from document
|
|
@@ -48,7 +48,7 @@ var mapErrorResponseCode = function mapErrorResponseCode(errorCode) {
|
|
|
48
48
|
case 'NOT_FOUND':
|
|
49
49
|
return SyncBlockError.NotFound;
|
|
50
50
|
case 'EntityNotFound':
|
|
51
|
-
return fg('
|
|
51
|
+
return fg('platform_synced_block_patch_9') ? SyncBlockError.EntityNotFound : SyncBlockError.Errored;
|
|
52
52
|
case 'INVALID_REQUEST':
|
|
53
53
|
return SyncBlockError.InvalidRequest;
|
|
54
54
|
case 'CONFLICT':
|
|
@@ -1266,7 +1266,7 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1266
1266
|
value: function () {
|
|
1267
1267
|
var _writeDataBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(data) {
|
|
1268
1268
|
var _this3 = this;
|
|
1269
|
-
var stepVersion, blockAriToResourceIdMap, blocks, response, results,
|
|
1269
|
+
var stepVersion, blockAriToResourceIdMap, blocks, response, results, successResourceIds, _iterator6, _step6, block, errorResourceIds, _iterator7, _step7, _loop2;
|
|
1270
1270
|
return _regeneratorRuntime.wrap(function _callee10$(_context12) {
|
|
1271
1271
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1272
1272
|
case 0:
|
|
@@ -1316,20 +1316,17 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
1316
1316
|
response = _context12.sent;
|
|
1317
1317
|
results = []; // Process successful updates
|
|
1318
1318
|
if (response.success) {
|
|
1319
|
-
|
|
1320
|
-
return
|
|
1319
|
+
successResourceIds = new Set(response.success.map(function (block) {
|
|
1320
|
+
return blockAriToResourceIdMap.get(block.blockAri);
|
|
1321
1321
|
}));
|
|
1322
1322
|
_iterator6 = _createForOfIteratorHelper(data);
|
|
1323
1323
|
try {
|
|
1324
1324
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1325
1325
|
block = _step6.value;
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
results.push(_objectSpread({
|
|
1326
|
+
if (successResourceIds.has(block.resourceId)) {
|
|
1327
|
+
results.push({
|
|
1329
1328
|
resourceId: block.resourceId
|
|
1330
|
-
}
|
|
1331
|
-
status: successBlock.status
|
|
1332
|
-
}));
|
|
1329
|
+
});
|
|
1333
1330
|
}
|
|
1334
1331
|
}
|
|
1335
1332
|
} catch (err) {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
7
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -105,8 +101,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
105
101
|
isDirty: isDirty,
|
|
106
102
|
// if the change is from remote, it's not dirty
|
|
107
103
|
contentFragment: syncBlockNode.content
|
|
108
|
-
}, fg('platform_synced_block_patch_10') && {
|
|
109
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
110
104
|
}));
|
|
111
105
|
} else {
|
|
112
106
|
var _syncBlockData = convertSyncBlockPMNodeToSyncBlockData(syncBlockNode);
|
|
@@ -115,8 +109,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
115
109
|
}
|
|
116
110
|
this.syncBlockCache.set(resourceId, _objectSpread(_objectSpread({}, _syncBlockData), {}, {
|
|
117
111
|
isDirty: true
|
|
118
|
-
}, fg('platform_synced_block_patch_10') && {
|
|
119
|
-
status: cachedBlock === null || cachedBlock === void 0 ? void 0 : cachedBlock.status
|
|
120
112
|
}));
|
|
121
113
|
}
|
|
122
114
|
return true;
|
|
@@ -215,13 +207,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
215
207
|
writeResults.forEach(function (result) {
|
|
216
208
|
if (result.resourceId && !result.error) {
|
|
217
209
|
var _this2$fireAnalyticsE;
|
|
218
|
-
// Update cache with the status returned from the backend
|
|
219
|
-
if (fg('platform_synced_block_patch_10')) {
|
|
220
|
-
var cachedData = _this2.syncBlockCache.get(result.resourceId);
|
|
221
|
-
if (cachedData && result.status) {
|
|
222
|
-
cachedData.status = result.status;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
210
|
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, updateSuccessPayload(result.resourceId, false));
|
|
226
211
|
}
|
|
227
212
|
});
|
|
@@ -375,14 +360,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
375
360
|
if (fg('platform_synced_block_update_refactor')) {
|
|
376
361
|
// add the node to the cache
|
|
377
362
|
this.updateSyncBlockData(node, false);
|
|
378
|
-
|
|
379
|
-
// Mark the block as unpublished in the cache so it can be cleaned up on cancel
|
|
380
|
-
if (fg('platform_synced_block_patch_10')) {
|
|
381
|
-
var cached = this.syncBlockCache.get(resourceId);
|
|
382
|
-
if (cached) {
|
|
383
|
-
cached.status = 'unpublished';
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
363
|
}
|
|
387
364
|
this.creationCompletionCallbacks.set(resourceId, onCompletion);
|
|
388
365
|
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 || _this$createExperienc.start({});
|
|
@@ -566,123 +543,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
566
543
|
}
|
|
567
544
|
|
|
568
545
|
/**
|
|
569
|
-
* Fetches the current status of all source sync blocks in the cache from the backend
|
|
570
|
-
* and updates the cache entries with the fetched status.
|
|
571
|
-
* This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
|
|
572
|
-
*/
|
|
573
|
-
}, {
|
|
574
|
-
key: "fetchAndCacheStatuses",
|
|
575
|
-
value: (function () {
|
|
576
|
-
var _fetchAndCacheStatuses = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
577
|
-
var _this6 = this;
|
|
578
|
-
var sourceToReferenceMap, syncBlockNodes, results, _iterator, _step, _sourceToReferenceMap, _result$data, result, sourceResourceId, cached;
|
|
579
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
580
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
581
|
-
case 0:
|
|
582
|
-
if (!(!fg('platform_synced_block_patch_10') || !this.dataProvider || this.syncBlockCache.size === 0)) {
|
|
583
|
-
_context4.next = 2;
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
return _context4.abrupt("return");
|
|
587
|
-
case 2:
|
|
588
|
-
// Source blocks have plain UUID resourceIds, but fetchNodesData internally uses
|
|
589
|
-
// generateBlockAriFromReference which expects reference-format resourceIds
|
|
590
|
-
// (e.g. "confluence-page/pageId/uuid"). We convert source resourceIds to reference
|
|
591
|
-
// format before fetching, and maintain a mapping back to original resourceIds
|
|
592
|
-
// so we can update the correct cache entries.
|
|
593
|
-
sourceToReferenceMap = new Map();
|
|
594
|
-
syncBlockNodes = Array.from(this.syncBlockCache.entries()).map(function (_ref) {
|
|
595
|
-
var _this6$dataProvider$g, _this6$dataProvider;
|
|
596
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
597
|
-
resourceId = _ref2[0],
|
|
598
|
-
data = _ref2[1];
|
|
599
|
-
var referenceResourceId = (_this6$dataProvider$g = (_this6$dataProvider = _this6.dataProvider) === null || _this6$dataProvider === void 0 ? void 0 : _this6$dataProvider.generateResourceIdForReference(resourceId)) !== null && _this6$dataProvider$g !== void 0 ? _this6$dataProvider$g : resourceId;
|
|
600
|
-
sourceToReferenceMap.set(referenceResourceId, resourceId);
|
|
601
|
-
return {
|
|
602
|
-
type: 'bodiedSyncBlock',
|
|
603
|
-
attrs: {
|
|
604
|
-
localId: data.blockInstanceId,
|
|
605
|
-
resourceId: referenceResourceId
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
});
|
|
609
|
-
_context4.prev = 4;
|
|
610
|
-
_context4.next = 7;
|
|
611
|
-
return this.dataProvider.fetchNodesData(syncBlockNodes);
|
|
612
|
-
case 7:
|
|
613
|
-
results = _context4.sent;
|
|
614
|
-
_iterator = _createForOfIteratorHelper(results);
|
|
615
|
-
try {
|
|
616
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
617
|
-
result = _step.value;
|
|
618
|
-
// Map the reference resourceId back to the source resourceId
|
|
619
|
-
sourceResourceId = (_sourceToReferenceMap = sourceToReferenceMap.get(result.resourceId)) !== null && _sourceToReferenceMap !== void 0 ? _sourceToReferenceMap : result.resourceId;
|
|
620
|
-
cached = this.syncBlockCache.get(sourceResourceId);
|
|
621
|
-
if (cached && (_result$data = result.data) !== null && _result$data !== void 0 && _result$data.status) {
|
|
622
|
-
cached.status = result.data.status;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
} catch (err) {
|
|
626
|
-
_iterator.e(err);
|
|
627
|
-
} finally {
|
|
628
|
-
_iterator.f();
|
|
629
|
-
}
|
|
630
|
-
_context4.next = 14;
|
|
631
|
-
break;
|
|
632
|
-
case 12:
|
|
633
|
-
_context4.prev = 12;
|
|
634
|
-
_context4.t0 = _context4["catch"](4);
|
|
635
|
-
case 14:
|
|
636
|
-
case "end":
|
|
637
|
-
return _context4.stop();
|
|
638
|
-
}
|
|
639
|
-
}, _callee4, this, [[4, 12]]);
|
|
640
|
-
}));
|
|
641
|
-
function fetchAndCacheStatuses() {
|
|
642
|
-
return _fetchAndCacheStatuses.apply(this, arguments);
|
|
643
|
-
}
|
|
644
|
-
return fetchAndCacheStatuses;
|
|
645
|
-
}()
|
|
646
|
-
/**
|
|
647
|
-
* Deletes all source sync blocks that have 'unpublished' status.
|
|
648
|
-
* Used to clean up orphaned blocks when a user cancels editing without saving.
|
|
649
|
-
* Blocks that were already saved (status 'active') are not affected.
|
|
650
|
-
*
|
|
651
|
-
* @returns true if all deletions succeeded, false otherwise
|
|
652
|
-
*/
|
|
653
|
-
)
|
|
654
|
-
}, {
|
|
655
|
-
key: "discardUnpublishedBlocks",
|
|
656
|
-
value: function discardUnpublishedBlocks() {
|
|
657
|
-
if (!fg('platform_synced_block_patch_10')) {
|
|
658
|
-
return Promise.resolve(true);
|
|
659
|
-
}
|
|
660
|
-
var unpublishedBlockIds = Array.from(this.syncBlockCache.entries()).filter(function (_ref3) {
|
|
661
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
662
|
-
_ = _ref4[0],
|
|
663
|
-
data = _ref4[1];
|
|
664
|
-
return data.status === 'unpublished' && !data.pendingDeletion;
|
|
665
|
-
}).map(function (_ref5) {
|
|
666
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
667
|
-
resourceId = _ref6[0],
|
|
668
|
-
data = _ref6[1];
|
|
669
|
-
return {
|
|
670
|
-
resourceId: resourceId,
|
|
671
|
-
localId: data.blockInstanceId
|
|
672
|
-
};
|
|
673
|
-
});
|
|
674
|
-
if (unpublishedBlockIds.length === 0) {
|
|
675
|
-
return Promise.resolve(true);
|
|
676
|
-
}
|
|
677
|
-
return this.delete(unpublishedBlockIds, function () {},
|
|
678
|
-
// onDelete: no-op, document is being discarded
|
|
679
|
-
function () {},
|
|
680
|
-
// onDeleteCompleted: no-op
|
|
681
|
-
'source-block-unpublished');
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Deletes sync blocks with confirmation from the backend
|
|
686
546
|
*
|
|
687
547
|
* @param syncBlockIds - The sync block ids to delete
|
|
688
548
|
* @param onDelete - The callback to delete sync block node from document
|
|
@@ -692,33 +552,33 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
692
552
|
}, {
|
|
693
553
|
key: "deleteSyncBlocksWithConfirmation",
|
|
694
554
|
value: (function () {
|
|
695
|
-
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
555
|
+
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
696
556
|
var confirmed, isDeleteSuccessful;
|
|
697
|
-
return _regeneratorRuntime.wrap(function
|
|
698
|
-
while (1) switch (
|
|
557
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
558
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
699
559
|
case 0:
|
|
700
560
|
if (!(this.viewMode === 'view' && fg('platform_synced_block_patch_8'))) {
|
|
701
|
-
|
|
561
|
+
_context4.next = 2;
|
|
702
562
|
break;
|
|
703
563
|
}
|
|
704
|
-
return
|
|
564
|
+
return _context4.abrupt("return", Promise.resolve());
|
|
705
565
|
case 2:
|
|
706
566
|
if (!this.confirmationCallback) {
|
|
707
|
-
|
|
567
|
+
_context4.next = 14;
|
|
708
568
|
break;
|
|
709
569
|
}
|
|
710
|
-
|
|
570
|
+
_context4.next = 5;
|
|
711
571
|
return this.confirmationCallback(syncBlockIds, deletionReason);
|
|
712
572
|
case 5:
|
|
713
|
-
confirmed =
|
|
573
|
+
confirmed = _context4.sent;
|
|
714
574
|
if (!confirmed) {
|
|
715
|
-
|
|
575
|
+
_context4.next = 13;
|
|
716
576
|
break;
|
|
717
577
|
}
|
|
718
|
-
|
|
578
|
+
_context4.next = 9;
|
|
719
579
|
return this.delete(syncBlockIds, onDelete, onDeleteCompleted, deletionReason);
|
|
720
580
|
case 9:
|
|
721
|
-
isDeleteSuccessful =
|
|
581
|
+
isDeleteSuccessful = _context4.sent;
|
|
722
582
|
if (!isDeleteSuccessful) {
|
|
723
583
|
// If deletion failed, save deletion info for potential retry
|
|
724
584
|
this.deletionRetryInfo = {
|
|
@@ -731,15 +591,15 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
731
591
|
} else {
|
|
732
592
|
destroyCallback();
|
|
733
593
|
}
|
|
734
|
-
|
|
594
|
+
_context4.next = 14;
|
|
735
595
|
break;
|
|
736
596
|
case 13:
|
|
737
597
|
destroyCallback();
|
|
738
598
|
case 14:
|
|
739
599
|
case "end":
|
|
740
|
-
return
|
|
600
|
+
return _context4.stop();
|
|
741
601
|
}
|
|
742
|
-
},
|
|
602
|
+
}, _callee4, this);
|
|
743
603
|
}));
|
|
744
604
|
function deleteSyncBlocksWithConfirmation(_x5, _x6, _x7, _x8, _x9) {
|
|
745
605
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
@@ -749,7 +609,7 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
749
609
|
}, {
|
|
750
610
|
key: "getSyncBlockSourceInfo",
|
|
751
611
|
value: function getSyncBlockSourceInfo(localId) {
|
|
752
|
-
var
|
|
612
|
+
var _this6 = this;
|
|
753
613
|
try {
|
|
754
614
|
var _this$fetchSourceInfo;
|
|
755
615
|
if (!this.dataProvider) {
|
|
@@ -758,13 +618,13 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
758
618
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
759
619
|
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined).then(function (sourceInfo) {
|
|
760
620
|
if (!sourceInfo) {
|
|
761
|
-
var
|
|
762
|
-
(
|
|
621
|
+
var _this6$fetchSourceInf;
|
|
622
|
+
(_this6$fetchSourceInf = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf === void 0 || _this6$fetchSourceInf.failure({
|
|
763
623
|
reason: 'No source info returned'
|
|
764
624
|
});
|
|
765
625
|
} else {
|
|
766
|
-
var
|
|
767
|
-
(
|
|
626
|
+
var _this6$fetchSourceInf2;
|
|
627
|
+
(_this6$fetchSourceInf2 = _this6.fetchSourceInfoExperience) === null || _this6$fetchSourceInf2 === void 0 || _this6$fetchSourceInf2.success();
|
|
768
628
|
}
|
|
769
629
|
return sourceInfo;
|
|
770
630
|
});
|
|
@@ -3,7 +3,7 @@ import type { EmojiProvider } from '@atlaskit/emoji';
|
|
|
3
3
|
import type { MentionProvider } from '@atlaskit/mention/types';
|
|
4
4
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
5
5
|
import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
|
|
6
|
-
import type { SyncBlockData,
|
|
6
|
+
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, DeletionReason } from '../common/types';
|
|
7
7
|
type SyncBlockErrorInfo = {
|
|
8
8
|
reason?: string;
|
|
9
9
|
sourceAri?: string;
|
|
@@ -48,7 +48,6 @@ export type SyncBlockParentInfo = {
|
|
|
48
48
|
export type WriteSyncBlockResult = {
|
|
49
49
|
error?: string;
|
|
50
50
|
resourceId?: ResourceId;
|
|
51
|
-
status?: SyncBlockStatus;
|
|
52
51
|
};
|
|
53
52
|
export type SourceInfoFetchData = {
|
|
54
53
|
pageARI: string;
|
|
@@ -68,21 +68,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
68
68
|
retryDeletion(): Promise<void>;
|
|
69
69
|
clearPendingDeletion(): void;
|
|
70
70
|
/**
|
|
71
|
-
* Fetches the current status of all source sync blocks in the cache from the backend
|
|
72
|
-
* and updates the cache entries with the fetched status.
|
|
73
|
-
* This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
|
|
74
|
-
*/
|
|
75
|
-
fetchAndCacheStatuses(): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Deletes all source sync blocks that have 'unpublished' status.
|
|
78
|
-
* Used to clean up orphaned blocks when a user cancels editing without saving.
|
|
79
|
-
* Blocks that were already saved (status 'active') are not affected.
|
|
80
|
-
*
|
|
81
|
-
* @returns true if all deletions succeeded, false otherwise
|
|
82
|
-
*/
|
|
83
|
-
discardUnpublishedBlocks(): Promise<boolean>;
|
|
84
|
-
/**
|
|
85
|
-
* Deletes sync blocks with confirmation from the backend
|
|
86
71
|
*
|
|
87
72
|
* @param syncBlockIds - The sync block ids to delete
|
|
88
73
|
* @param onDelete - The callback to delete sync block node from document
|
|
@@ -3,7 +3,7 @@ import type { EmojiProvider } from '@atlaskit/emoji';
|
|
|
3
3
|
import type { MentionProvider } from '@atlaskit/mention/types';
|
|
4
4
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
5
5
|
import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
|
|
6
|
-
import type { SyncBlockData,
|
|
6
|
+
import type { SyncBlockData, ResourceId, SyncBlockError, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, ReferenceSyncBlockData, DeletionReason } from '../common/types';
|
|
7
7
|
type SyncBlockErrorInfo = {
|
|
8
8
|
reason?: string;
|
|
9
9
|
sourceAri?: string;
|
|
@@ -48,7 +48,6 @@ export type SyncBlockParentInfo = {
|
|
|
48
48
|
export type WriteSyncBlockResult = {
|
|
49
49
|
error?: string;
|
|
50
50
|
resourceId?: ResourceId;
|
|
51
|
-
status?: SyncBlockStatus;
|
|
52
51
|
};
|
|
53
52
|
export type SourceInfoFetchData = {
|
|
54
53
|
pageARI: string;
|
|
@@ -68,21 +68,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
68
68
|
retryDeletion(): Promise<void>;
|
|
69
69
|
clearPendingDeletion(): void;
|
|
70
70
|
/**
|
|
71
|
-
* Fetches the current status of all source sync blocks in the cache from the backend
|
|
72
|
-
* and updates the cache entries with the fetched status.
|
|
73
|
-
* This is called on editor init so we know which blocks are 'unpublished' vs 'active'.
|
|
74
|
-
*/
|
|
75
|
-
fetchAndCacheStatuses(): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Deletes all source sync blocks that have 'unpublished' status.
|
|
78
|
-
* Used to clean up orphaned blocks when a user cancels editing without saving.
|
|
79
|
-
* Blocks that were already saved (status 'active') are not affected.
|
|
80
|
-
*
|
|
81
|
-
* @returns true if all deletions succeeded, false otherwise
|
|
82
|
-
*/
|
|
83
|
-
discardUnpublishedBlocks(): Promise<boolean>;
|
|
84
|
-
/**
|
|
85
|
-
* Deletes sync blocks with confirmation from the backend
|
|
86
71
|
*
|
|
87
72
|
* @param syncBlockIds - The sync block ids to delete
|
|
88
73
|
* @param onDelete - The callback to delete sync block node from document
|
package/package.json
CHANGED
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
],
|
|
25
25
|
"atlaskit:src": "src/index.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/adf-utils": "^19.
|
|
27
|
+
"@atlaskit/adf-utils": "^19.28.0",
|
|
28
28
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
29
29
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
30
30
|
"@atlaskit/node-data-provider": "^11.0.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
32
|
+
"@atlaskit/tmp-editor-statsig": "^74.0.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@compiled/react": "^0.20.0",
|
|
35
35
|
"graphql-ws": "^5.14.2",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"uuid": "^3.1.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^114.
|
|
41
|
+
"@atlaskit/editor-common": "^114.15.0",
|
|
42
42
|
"react": "^18.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
84
|
-
"version": "6.3.
|
|
84
|
+
"version": "6.3.2",
|
|
85
85
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
86
86
|
"author": "Atlassian Pty Ltd",
|
|
87
87
|
"license": "Apache-2.0",
|
|
@@ -98,9 +98,6 @@
|
|
|
98
98
|
"platform_synced_block_patch_9": {
|
|
99
99
|
"type": "boolean"
|
|
100
100
|
},
|
|
101
|
-
"platform_synced_block_patch_10": {
|
|
102
|
-
"type": "boolean"
|
|
103
|
-
},
|
|
104
101
|
"platform_synced_block_add_info_web_socket_error": {
|
|
105
102
|
"type": "boolean"
|
|
106
103
|
}
|