@atlaskit/editor-synced-block-provider 20.0.0 → 20.0.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 +20 -0
- package/dist/cjs/clients/block-service/ari.js +4 -0
- package/dist/cjs/clients/block-service/blockService.js +2 -1
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +9 -2
- package/dist/cjs/store-manager/syncBlockStoreManager.js +91 -24
- package/dist/es2019/clients/block-service/ari.js +4 -0
- package/dist/es2019/clients/block-service/blockService.js +2 -1
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +9 -3
- package/dist/es2019/store-manager/syncBlockStoreManager.js +40 -0
- package/dist/esm/clients/block-service/ari.js +4 -0
- package/dist/esm/clients/block-service/blockService.js +2 -1
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +9 -2
- package/dist/esm/store-manager/syncBlockStoreManager.js +91 -24
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +1 -0
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +5 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 20.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c239b60db852a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c239b60db852a) -
|
|
8
|
+
Flush removed references that disappear before the first save under
|
|
9
|
+
platform_editor_blocks_patch_11
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 20.0.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`a5e4fa298e7ad`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a5e4fa298e7ad) -
|
|
17
|
+
[EDITOR-8408] Synced locations that the viewer cannot access now show as 'Restricted content' with
|
|
18
|
+
a lock icon, link to the restricted page, and never expose the current page's title. They still
|
|
19
|
+
count in the synced locations total and the delete warning. Behind the
|
|
20
|
+
platform_editor_blocks_patch_11 experiment.
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 20.0.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getProductFromSourceAri = exports.getLocationScope = exports.getLocalIdFromBlockResourceId = exports.generateBlockAriFromReference = exports.generateBlockAri = void 0;
|
|
7
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
7
8
|
var _ari = require("../jira/ari");
|
|
8
9
|
/* eslint-disable require-unicode-regexp */
|
|
9
10
|
|
|
@@ -80,6 +81,9 @@ var getLocationScope = exports.getLocationScope = function getLocationScope(_ref
|
|
|
80
81
|
return location.fieldId === hostLocation.fieldId ? 'same-document' : 'same-parent-document';
|
|
81
82
|
};
|
|
82
83
|
var getProductFromSourceAri = exports.getProductFromSourceAri = function getProductFromSourceAri(ari) {
|
|
84
|
+
if (!ari && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11')) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
83
87
|
var jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(JIRA_SOURCE_ARI_REGEX);
|
|
84
88
|
if (jiraMatch !== -1) {
|
|
85
89
|
return 'jira-work-item';
|
|
@@ -13,6 +13,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
13
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
14
|
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
16
17
|
var _retry = require("../../utils/retry");
|
|
17
18
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
18
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -199,7 +200,7 @@ var buildBatchRetrieveBlocksQuery = function buildBatchRetrieveBlocksQuery(block
|
|
|
199
200
|
return "query ".concat(BATCH_RETRIEVE_BLOCKS_OPERATION_NAME, " {\n\tblockService_batchRetrieveBlocks(input: { ").concat(inputArgs, " }) {\n\t\tsuccess {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdeletionReason\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terror {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
200
201
|
};
|
|
201
202
|
var buildGetBlockReferencesQuery = function buildGetBlockReferencesQuery(blockAri) {
|
|
202
|
-
return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
203
|
+
return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode").concat((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11') ? '\n\t\t\tdocumentAri' : '', "\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
203
204
|
};
|
|
204
205
|
var buildBatchUpdateBlocksMutation = function buildBatchUpdateBlocksMutation(blocks) {
|
|
205
206
|
var blocksArray = blocks.map(function (block) {
|
|
@@ -57,6 +57,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
57
57
|
(0, _defineProperty2.default)(this, "isCacheDirty", true);
|
|
58
58
|
// Keep track of the last flushed subscriptions to optimize cache flushing on document save
|
|
59
59
|
(0, _defineProperty2.default)(this, "lastFlushedSyncedBlocks", {});
|
|
60
|
+
(0, _defineProperty2.default)(this, "subscribedSinceLastFlush", false);
|
|
60
61
|
// Track if a flush operation is currently in progress
|
|
61
62
|
(0, _defineProperty2.default)(this, "isFlushInProgress", false);
|
|
62
63
|
// Track if another flush is needed after the current one completes
|
|
@@ -978,6 +979,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
978
979
|
value: function subscribeToSyncBlock(resourceId, localId, callback) {
|
|
979
980
|
var _this$sourceManager2,
|
|
980
981
|
_this9 = this;
|
|
982
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11')) {
|
|
983
|
+
this.subscribedSinceLastFlush = true;
|
|
984
|
+
}
|
|
981
985
|
var isSamePageSyncEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('editor-synced-block-same-page-sync');
|
|
982
986
|
var sameDocumentParts = isSamePageSyncEnabled ? this.getSameDocumentReferenceParts(resourceId) : undefined;
|
|
983
987
|
var localReference = isSamePageSyncEnabled ? this.getLocalReference(resourceId) : undefined;
|
|
@@ -1094,7 +1098,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1094
1098
|
value: (function () {
|
|
1095
1099
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
1096
1100
|
var _this0 = this;
|
|
1097
|
-
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
|
|
1101
|
+
var subscribedSinceLastFlushToFlush, success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
|
|
1098
1102
|
return _regenerator.default.wrap(function (_context4) {
|
|
1099
1103
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1100
1104
|
case 0:
|
|
@@ -1122,6 +1126,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1122
1126
|
case 3:
|
|
1123
1127
|
this.isFlushInProgress = true;
|
|
1124
1128
|
case 4:
|
|
1129
|
+
subscribedSinceLastFlushToFlush = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11') && this.subscribedSinceLastFlush;
|
|
1130
|
+
this.subscribedSinceLastFlush = false;
|
|
1125
1131
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
1126
1132
|
// To be saved as the last flushed structure if the flush is successful
|
|
1127
1133
|
syncedBlocksToFlush = {};
|
|
@@ -1177,7 +1183,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1177
1183
|
_iterator.f();
|
|
1178
1184
|
return _context4.finish(12);
|
|
1179
1185
|
case 13:
|
|
1180
|
-
if (!(0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1186
|
+
if (!(!subscribedSinceLastFlushToFlush && (0, _isEqual.default)(syncedBlocksToFlush, this.lastFlushedSyncedBlocks))) {
|
|
1181
1187
|
_context4.next = 14;
|
|
1182
1188
|
break;
|
|
1183
1189
|
}
|
|
@@ -1223,6 +1229,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
1223
1229
|
if (!success) {
|
|
1224
1230
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1225
1231
|
this.isCacheDirty = true;
|
|
1232
|
+
this.subscribedSinceLastFlush || (this.subscribedSinceLastFlush = subscribedSinceLastFlushToFlush);
|
|
1226
1233
|
} else {
|
|
1227
1234
|
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1228
1235
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
@@ -12,6 +12,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
12
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
var _react = require("react");
|
|
14
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
15
16
|
var _ari = require("../clients/block-service/ari");
|
|
16
17
|
var _types = require("../common/types");
|
|
17
18
|
var _errorHandling = require("../utils/errorHandling");
|
|
@@ -89,20 +90,26 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
89
90
|
return _regenerator.default.wrap(function (_context) {
|
|
90
91
|
while (1) switch (_context.prev = _context.next) {
|
|
91
92
|
case 0:
|
|
93
|
+
if (!(!reference.hasAccess && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_blocks_patch_11'))) {
|
|
94
|
+
_context.next = 1;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
return _context.abrupt("return", _this.fetchRestrictedReferenceInfo(reference.documentAri));
|
|
98
|
+
case 1:
|
|
92
99
|
(_this$fetchSourceInfo = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
93
|
-
_context.next =
|
|
100
|
+
_context.next = 2;
|
|
94
101
|
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, (0, _ari.getProductFromSourceAri)(reference.documentAri), reference.hasAccess);
|
|
95
|
-
case
|
|
102
|
+
case 2:
|
|
96
103
|
sourceInfo = _context.sent;
|
|
97
104
|
if (sourceInfo) {
|
|
98
|
-
_context.next =
|
|
105
|
+
_context.next = 3;
|
|
99
106
|
break;
|
|
100
107
|
}
|
|
101
108
|
(_this$fetchSourceInfo2 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.failure({
|
|
102
109
|
reason: "no source info returned for ari: ".concat(reference.documentAri)
|
|
103
110
|
});
|
|
104
111
|
return _context.abrupt("return", undefined);
|
|
105
|
-
case
|
|
112
|
+
case 3:
|
|
106
113
|
(_this$fetchSourceInfo3 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.success();
|
|
107
114
|
return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
108
115
|
onSameDocument: reference.onSameDocument
|
|
@@ -112,7 +119,7 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
112
119
|
hasAccess: reference.hasAccess,
|
|
113
120
|
productType: sourceInfo.productType
|
|
114
121
|
}));
|
|
115
|
-
case
|
|
122
|
+
case 4:
|
|
116
123
|
case "end":
|
|
117
124
|
return _context.stop();
|
|
118
125
|
}
|
|
@@ -194,17 +201,77 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
194
201
|
reason: 'editorDestroyed'
|
|
195
202
|
});
|
|
196
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Keeps only the link of a location the user cannot read, so its title never reaches the UI.
|
|
207
|
+
* The location still counts when the link cannot be resolved or there is no document to link to.
|
|
208
|
+
*/
|
|
209
|
+
}, {
|
|
210
|
+
key: "fetchRestrictedReferenceInfo",
|
|
211
|
+
value: (function () {
|
|
212
|
+
var _fetchRestrictedReferenceInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(documentAri) {
|
|
213
|
+
var _this$fetchSourceInfo5;
|
|
214
|
+
var productType, url, _this$dataProvider2, _this$fetchSourceInfo6, sourceInfo, _this$fetchSourceInfo7, _t2;
|
|
215
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
216
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
217
|
+
case 0:
|
|
218
|
+
if (documentAri) {
|
|
219
|
+
_context3.next = 1;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
return _context3.abrupt("return", {
|
|
223
|
+
sourceAri: '',
|
|
224
|
+
hasAccess: false,
|
|
225
|
+
onSameDocument: false
|
|
226
|
+
});
|
|
227
|
+
case 1:
|
|
228
|
+
productType = (0, _ari.getProductFromSourceAri)(documentAri);
|
|
229
|
+
(_this$fetchSourceInfo5 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 || _this$fetchSourceInfo5.start();
|
|
230
|
+
_context3.prev = 2;
|
|
231
|
+
_context3.next = 3;
|
|
232
|
+
return (_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.fetchSyncBlockSourceInfo(undefined, documentAri, productType, false);
|
|
233
|
+
case 3:
|
|
234
|
+
sourceInfo = _context3.sent;
|
|
235
|
+
url = sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url;
|
|
236
|
+
(_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 || _this$fetchSourceInfo6.success();
|
|
237
|
+
_context3.next = 5;
|
|
238
|
+
break;
|
|
239
|
+
case 4:
|
|
240
|
+
_context3.prev = 4;
|
|
241
|
+
_t2 = _context3["catch"](2);
|
|
242
|
+
(_this$fetchSourceInfo7 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo7 === void 0 || _this$fetchSourceInfo7.failure({
|
|
243
|
+
reason: _t2.message
|
|
244
|
+
});
|
|
245
|
+
case 5:
|
|
246
|
+
return _context3.abrupt("return", {
|
|
247
|
+
sourceAri: documentAri,
|
|
248
|
+
productType: productType,
|
|
249
|
+
url: url,
|
|
250
|
+
hasAccess: false,
|
|
251
|
+
onSameDocument: false
|
|
252
|
+
});
|
|
253
|
+
case 6:
|
|
254
|
+
case "end":
|
|
255
|
+
return _context3.stop();
|
|
256
|
+
}
|
|
257
|
+
}, _callee3, this, [[2, 4]]);
|
|
258
|
+
}));
|
|
259
|
+
function fetchRestrictedReferenceInfo(_x5) {
|
|
260
|
+
return _fetchRestrictedReferenceInfo.apply(this, arguments);
|
|
261
|
+
}
|
|
262
|
+
return fetchRestrictedReferenceInfo;
|
|
263
|
+
}())
|
|
197
264
|
}, {
|
|
198
265
|
key: "getUnregisteredReferences",
|
|
199
266
|
value: function () {
|
|
200
|
-
var _getUnregisteredReferences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
267
|
+
var _getUnregisteredReferences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
201
268
|
var _this$fetchReferences8;
|
|
202
269
|
var _this$fetchReferences6, referenceResourceId, hasUnregisteredReferenceOnPage, _this$fetchReferences5, _sourceSyncBlockData, _references, sourceSyncBlockReference, referenceSyncBlockReference, references, sourceSyncBlockData, currentPageData, _this$fetchReferences7;
|
|
203
|
-
return _regenerator.default.wrap(function (
|
|
204
|
-
while (1) switch (
|
|
270
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
271
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
205
272
|
case 0:
|
|
206
273
|
if (!isSourceSyncBlock) {
|
|
207
|
-
|
|
274
|
+
_context4.next = 3;
|
|
208
275
|
break;
|
|
209
276
|
}
|
|
210
277
|
// Verify that a reference sync block for this specific source actually
|
|
@@ -213,13 +280,13 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
213
280
|
referenceResourceId = this.referenceSyncBlockStoreManager.generateResourceIdForReference(resourceId);
|
|
214
281
|
hasUnregisteredReferenceOnPage = this.referenceSyncBlockStoreManager.getSubscribedResourceIds().includes(referenceResourceId);
|
|
215
282
|
if (!hasUnregisteredReferenceOnPage) {
|
|
216
|
-
|
|
283
|
+
_context4.next = 2;
|
|
217
284
|
break;
|
|
218
285
|
}
|
|
219
|
-
|
|
286
|
+
_context4.next = 1;
|
|
220
287
|
return this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId);
|
|
221
288
|
case 1:
|
|
222
|
-
_sourceSyncBlockData =
|
|
289
|
+
_sourceSyncBlockData = _context4.sent;
|
|
223
290
|
_references = [];
|
|
224
291
|
if (_sourceSyncBlockData) {
|
|
225
292
|
sourceSyncBlockReference = _objectSpread(_objectSpread({}, _sourceSyncBlockData), {}, {
|
|
@@ -235,13 +302,13 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
235
302
|
_references.push(sourceSyncBlockReference, referenceSyncBlockReference);
|
|
236
303
|
}
|
|
237
304
|
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 || _this$fetchReferences5.success();
|
|
238
|
-
return
|
|
305
|
+
return _context4.abrupt("return", {
|
|
239
306
|
references: _references
|
|
240
307
|
});
|
|
241
308
|
case 2:
|
|
242
309
|
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
243
310
|
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 || _this$fetchReferences6.success();
|
|
244
|
-
return
|
|
311
|
+
return _context4.abrupt("return", {
|
|
245
312
|
references: []
|
|
246
313
|
});
|
|
247
314
|
case 3:
|
|
@@ -249,10 +316,10 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
249
316
|
// still show the source and the current page itself since they are known
|
|
250
317
|
// but not saved yet.
|
|
251
318
|
references = [];
|
|
252
|
-
|
|
319
|
+
_context4.next = 4;
|
|
253
320
|
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
254
321
|
case 4:
|
|
255
|
-
sourceSyncBlockData =
|
|
322
|
+
sourceSyncBlockData = _context4.sent;
|
|
256
323
|
if (sourceSyncBlockData) {
|
|
257
324
|
references.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
258
325
|
onSameDocument: Boolean(sourceSyncBlockData === null || sourceSyncBlockData === void 0 ? void 0 : sourceSyncBlockData.onSameDocument),
|
|
@@ -260,10 +327,10 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
260
327
|
isSource: true
|
|
261
328
|
}));
|
|
262
329
|
}
|
|
263
|
-
|
|
330
|
+
_context4.next = 5;
|
|
264
331
|
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfoByLocalId(blockInstanceId);
|
|
265
332
|
case 5:
|
|
266
|
-
currentPageData =
|
|
333
|
+
currentPageData = _context4.sent;
|
|
267
334
|
if (currentPageData) {
|
|
268
335
|
references.push(_objectSpread(_objectSpread({}, currentPageData), {}, {
|
|
269
336
|
onSameDocument: true,
|
|
@@ -272,27 +339,27 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
272
339
|
}));
|
|
273
340
|
}
|
|
274
341
|
if (!(references.length === 0)) {
|
|
275
|
-
|
|
342
|
+
_context4.next = 6;
|
|
276
343
|
break;
|
|
277
344
|
}
|
|
278
345
|
(_this$fetchReferences7 = this.fetchReferencesExperience) === null || _this$fetchReferences7 === void 0 || _this$fetchReferences7.failure({
|
|
279
346
|
reason: 'No references found for reference synced block'
|
|
280
347
|
});
|
|
281
|
-
return
|
|
348
|
+
return _context4.abrupt("return", {
|
|
282
349
|
error: _types.SyncBlockError.Errored
|
|
283
350
|
});
|
|
284
351
|
case 6:
|
|
285
352
|
(_this$fetchReferences8 = this.fetchReferencesExperience) === null || _this$fetchReferences8 === void 0 || _this$fetchReferences8.success();
|
|
286
|
-
return
|
|
353
|
+
return _context4.abrupt("return", {
|
|
287
354
|
references: references
|
|
288
355
|
});
|
|
289
356
|
case 7:
|
|
290
357
|
case "end":
|
|
291
|
-
return
|
|
358
|
+
return _context4.stop();
|
|
292
359
|
}
|
|
293
|
-
},
|
|
360
|
+
}, _callee4, this);
|
|
294
361
|
}));
|
|
295
|
-
function getUnregisteredReferences(
|
|
362
|
+
function getUnregisteredReferences(_x6, _x7, _x8) {
|
|
296
363
|
return _getUnregisteredReferences.apply(this, arguments);
|
|
297
364
|
}
|
|
298
365
|
return getUnregisteredReferences;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
|
|
3
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
3
4
|
import { parseJiraFieldLocation } from '../jira/ari';
|
|
4
5
|
const GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/;
|
|
5
6
|
const JIRA_SOURCE_ARI_REGEX = /ari:cloud:jira:.*/;
|
|
@@ -77,6 +78,9 @@ export const getLocationScope = ({
|
|
|
77
78
|
return location.fieldId === hostLocation.fieldId ? 'same-document' : 'same-parent-document';
|
|
78
79
|
};
|
|
79
80
|
export const getProductFromSourceAri = ari => {
|
|
81
|
+
if (!ari && isExperimentEnabled('platform_editor_blocks_patch_11')) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
80
84
|
const jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(JIRA_SOURCE_ARI_REGEX);
|
|
81
85
|
if (jiraMatch !== -1) {
|
|
82
86
|
return 'jira-work-item';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
1
2
|
import { fetchWithRetry } from '../../utils/retry';
|
|
2
3
|
export const isBlockContentResponse = response => {
|
|
3
4
|
const content = response.content;
|
|
@@ -251,7 +252,7 @@ const buildGetBlockReferencesQuery = blockAri => {
|
|
|
251
252
|
}
|
|
252
253
|
errors {
|
|
253
254
|
blockAri
|
|
254
|
-
code
|
|
255
|
+
code${isExperimentEnabled('platform_editor_blocks_patch_11') ? '\n\t\t\tdocumentAri' : ''}
|
|
255
256
|
reason
|
|
256
257
|
}
|
|
257
258
|
}
|
|
@@ -37,6 +37,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
37
37
|
_defineProperty(this, "isCacheDirty", true);
|
|
38
38
|
// Keep track of the last flushed subscriptions to optimize cache flushing on document save
|
|
39
39
|
_defineProperty(this, "lastFlushedSyncedBlocks", {});
|
|
40
|
+
_defineProperty(this, "subscribedSinceLastFlush", false);
|
|
40
41
|
// Track if a flush operation is currently in progress
|
|
41
42
|
_defineProperty(this, "isFlushInProgress", false);
|
|
42
43
|
// Track if another flush is needed after the current one completes
|
|
@@ -819,6 +820,9 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
819
820
|
}
|
|
820
821
|
subscribeToSyncBlock(resourceId, localId, callback) {
|
|
821
822
|
var _this$sourceManager2;
|
|
823
|
+
if (isExperimentEnabled('platform_editor_blocks_patch_11')) {
|
|
824
|
+
this.subscribedSinceLastFlush = true;
|
|
825
|
+
}
|
|
822
826
|
const isSamePageSyncEnabled = isExperimentEnabled('editor-synced-block-same-page-sync');
|
|
823
827
|
const sameDocumentParts = isSamePageSyncEnabled ? this.getSameDocumentReferenceParts(resourceId) : undefined;
|
|
824
828
|
let localReference = isSamePageSyncEnabled ? this.getLocalReference(resourceId) : undefined;
|
|
@@ -938,6 +942,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
938
942
|
} else {
|
|
939
943
|
this.isFlushInProgress = true;
|
|
940
944
|
}
|
|
945
|
+
const subscribedSinceLastFlushToFlush = isExperimentEnabled('platform_editor_blocks_patch_11') && this.subscribedSinceLastFlush;
|
|
946
|
+
this.subscribedSinceLastFlush = false;
|
|
941
947
|
let success = true;
|
|
942
948
|
// a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
943
949
|
// To be saved as the last flushed structure if the flush is successful
|
|
@@ -963,9 +969,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
963
969
|
|
|
964
970
|
// Then, compare with the last flushed structure to detect changes
|
|
965
971
|
// We check against the last flushed structure to prevent unnecessary flushes
|
|
966
|
-
//
|
|
967
|
-
|
|
968
|
-
if (isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
972
|
+
// A reference can subscribe and disappear before the first flush, leaving both structures empty.
|
|
973
|
+
if (!subscribedSinceLastFlushToFlush && isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
969
974
|
this.isCacheDirty = false; // Reset since we're considering this a successful no-op flush
|
|
970
975
|
return true;
|
|
971
976
|
}
|
|
@@ -1002,6 +1007,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1002
1007
|
if (!success) {
|
|
1003
1008
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1004
1009
|
this.isCacheDirty = true;
|
|
1010
|
+
this.subscribedSinceLastFlush ||= subscribedSinceLastFlushToFlush;
|
|
1005
1011
|
} else {
|
|
1006
1012
|
var _this$saveExperience4;
|
|
1007
1013
|
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
3
4
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
4
5
|
import { SyncBlockError } from '../common/types';
|
|
5
6
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
@@ -51,6 +52,9 @@ export class SyncBlockStoreManager {
|
|
|
51
52
|
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 ? void 0 : _this$fetchReferences3.success();
|
|
52
53
|
const sourceInfoPromises = ((_response$references2 = response.references) !== null && _response$references2 !== void 0 ? _response$references2 : []).map(async reference => {
|
|
53
54
|
var _this$fetchSourceInfo, _this$dataProvider, _this$fetchSourceInfo3;
|
|
55
|
+
if (!reference.hasAccess && isExperimentEnabled('platform_editor_blocks_patch_11')) {
|
|
56
|
+
return this.fetchRestrictedReferenceInfo(reference.documentAri);
|
|
57
|
+
}
|
|
54
58
|
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start();
|
|
55
59
|
const sourceInfo = await ((_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), reference.hasAccess));
|
|
56
60
|
if (!sourceInfo) {
|
|
@@ -120,6 +124,42 @@ export class SyncBlockStoreManager {
|
|
|
120
124
|
reason: 'editorDestroyed'
|
|
121
125
|
});
|
|
122
126
|
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Keeps only the link of a location the user cannot read, so its title never reaches the UI.
|
|
130
|
+
* The location still counts when the link cannot be resolved or there is no document to link to.
|
|
131
|
+
*/
|
|
132
|
+
async fetchRestrictedReferenceInfo(documentAri) {
|
|
133
|
+
var _this$fetchSourceInfo5;
|
|
134
|
+
if (!documentAri) {
|
|
135
|
+
return {
|
|
136
|
+
sourceAri: '',
|
|
137
|
+
hasAccess: false,
|
|
138
|
+
onSameDocument: false
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const productType = getProductFromSourceAri(documentAri);
|
|
142
|
+
let url;
|
|
143
|
+
(_this$fetchSourceInfo5 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 ? void 0 : _this$fetchSourceInfo5.start();
|
|
144
|
+
try {
|
|
145
|
+
var _this$dataProvider2, _this$fetchSourceInfo6;
|
|
146
|
+
const sourceInfo = await ((_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.fetchSyncBlockSourceInfo(undefined, documentAri, productType, false));
|
|
147
|
+
url = sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url;
|
|
148
|
+
(_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 ? void 0 : _this$fetchSourceInfo6.success();
|
|
149
|
+
} catch (error) {
|
|
150
|
+
var _this$fetchSourceInfo7;
|
|
151
|
+
(_this$fetchSourceInfo7 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo7 === void 0 ? void 0 : _this$fetchSourceInfo7.failure({
|
|
152
|
+
reason: error.message
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
sourceAri: documentAri,
|
|
157
|
+
productType,
|
|
158
|
+
url,
|
|
159
|
+
hasAccess: false,
|
|
160
|
+
onSameDocument: false
|
|
161
|
+
};
|
|
162
|
+
}
|
|
123
163
|
async getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
124
164
|
var _this$fetchReferences8;
|
|
125
165
|
// No reference found
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
|
|
3
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
3
4
|
import { parseJiraFieldLocation } from '../jira/ari';
|
|
4
5
|
var GET_LOCAL_ID_FROM_BLOCK_RESOURCE_ID_REGEX = /ari:cloud:blocks:[^:]+:synced-block\/([a-zA-Z0-9-]+)/;
|
|
5
6
|
var JIRA_SOURCE_ARI_REGEX = /ari:cloud:jira:.*/;
|
|
@@ -74,6 +75,9 @@ export var getLocationScope = function getLocationScope(_ref3) {
|
|
|
74
75
|
return location.fieldId === hostLocation.fieldId ? 'same-document' : 'same-parent-document';
|
|
75
76
|
};
|
|
76
77
|
export var getProductFromSourceAri = function getProductFromSourceAri(ari) {
|
|
78
|
+
if (!ari && isExperimentEnabled('platform_editor_blocks_patch_11')) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
77
81
|
var jiraMatch = ari === null || ari === void 0 ? void 0 : ari.search(JIRA_SOURCE_ARI_REGEX);
|
|
78
82
|
if (jiraMatch !== -1) {
|
|
79
83
|
return 'jira-work-item';
|
|
@@ -8,6 +8,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
8
8
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
9
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
11
12
|
import { fetchWithRetry } from '../../utils/retry';
|
|
12
13
|
export var isBlockContentResponse = function isBlockContentResponse(response) {
|
|
13
14
|
var content = response.content;
|
|
@@ -192,7 +193,7 @@ var buildBatchRetrieveBlocksQuery = function buildBatchRetrieveBlocksQuery(block
|
|
|
192
193
|
return "query ".concat(BATCH_RETRIEVE_BLOCKS_OPERATION_NAME, " {\n\tblockService_batchRetrieveBlocks(input: { ").concat(inputArgs, " }) {\n\t\tsuccess {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcontent\n\t\t\tcontentUpdatedAt\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdeletionReason\n\t\t\tproduct\n\t\t\tsourceAri\n\t\t\tstatus\n\t\t\tversion\n\t\t}\n\t\terror {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
193
194
|
};
|
|
194
195
|
var buildGetBlockReferencesQuery = function buildGetBlockReferencesQuery(blockAri) {
|
|
195
|
-
return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
196
|
+
return "query ".concat(GET_BLOCK_REFERENCES_OPERATION_NAME, " {\n\tblockService_getReferences(blockAri: ").concat(JSON.stringify(blockAri), ") {\n\t\treferences {\n\t\t\tblockAri\n\t\t\tblockInstanceId\n\t\t\tcreatedAt\n\t\t\tcreatedBy\n\t\t\tdocumentAri\n\t\t}\n\t\terrors {\n\t\t\tblockAri\n\t\t\tcode").concat(isExperimentEnabled('platform_editor_blocks_patch_11') ? '\n\t\t\tdocumentAri' : '', "\n\t\t\treason\n\t\t}\n\t}\n}");
|
|
196
197
|
};
|
|
197
198
|
var buildBatchUpdateBlocksMutation = function buildBatchUpdateBlocksMutation(blocks) {
|
|
198
199
|
var blocksArray = blocks.map(function (block) {
|
|
@@ -50,6 +50,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
50
50
|
_defineProperty(this, "isCacheDirty", true);
|
|
51
51
|
// Keep track of the last flushed subscriptions to optimize cache flushing on document save
|
|
52
52
|
_defineProperty(this, "lastFlushedSyncedBlocks", {});
|
|
53
|
+
_defineProperty(this, "subscribedSinceLastFlush", false);
|
|
53
54
|
// Track if a flush operation is currently in progress
|
|
54
55
|
_defineProperty(this, "isFlushInProgress", false);
|
|
55
56
|
// Track if another flush is needed after the current one completes
|
|
@@ -971,6 +972,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
971
972
|
value: function subscribeToSyncBlock(resourceId, localId, callback) {
|
|
972
973
|
var _this$sourceManager2,
|
|
973
974
|
_this9 = this;
|
|
975
|
+
if (isExperimentEnabled('platform_editor_blocks_patch_11')) {
|
|
976
|
+
this.subscribedSinceLastFlush = true;
|
|
977
|
+
}
|
|
974
978
|
var isSamePageSyncEnabled = isExperimentEnabled('editor-synced-block-same-page-sync');
|
|
975
979
|
var sameDocumentParts = isSamePageSyncEnabled ? this.getSameDocumentReferenceParts(resourceId) : undefined;
|
|
976
980
|
var localReference = isSamePageSyncEnabled ? this.getLocalReference(resourceId) : undefined;
|
|
@@ -1087,7 +1091,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1087
1091
|
value: (function () {
|
|
1088
1092
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
1089
1093
|
var _this0 = this;
|
|
1090
|
-
var success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
|
|
1094
|
+
var subscribedSinceLastFlushToFlush, success, syncedBlocksToFlush, _this$saveExperience, blocks, _iterator, _step, _loop, updateResult, _this$saveExperience2, _this$fireAnalyticsEv8, _this$saveExperience3, _this$fireAnalyticsEv9, _this$saveExperience4, _t2, _t3;
|
|
1091
1095
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
1092
1096
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1093
1097
|
case 0:
|
|
@@ -1115,6 +1119,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1115
1119
|
case 3:
|
|
1116
1120
|
this.isFlushInProgress = true;
|
|
1117
1121
|
case 4:
|
|
1122
|
+
subscribedSinceLastFlushToFlush = isExperimentEnabled('platform_editor_blocks_patch_11') && this.subscribedSinceLastFlush;
|
|
1123
|
+
this.subscribedSinceLastFlush = false;
|
|
1118
1124
|
success = true; // a copy of the subscriptions STRUCTURE (without the callbacks)
|
|
1119
1125
|
// To be saved as the last flushed structure if the flush is successful
|
|
1120
1126
|
syncedBlocksToFlush = {};
|
|
@@ -1170,7 +1176,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1170
1176
|
_iterator.f();
|
|
1171
1177
|
return _context4.finish(12);
|
|
1172
1178
|
case 13:
|
|
1173
|
-
if (!isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks)) {
|
|
1179
|
+
if (!(!subscribedSinceLastFlushToFlush && isEqual(syncedBlocksToFlush, this.lastFlushedSyncedBlocks))) {
|
|
1174
1180
|
_context4.next = 14;
|
|
1175
1181
|
break;
|
|
1176
1182
|
}
|
|
@@ -1216,6 +1222,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
1216
1222
|
if (!success) {
|
|
1217
1223
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
1218
1224
|
this.isCacheDirty = true;
|
|
1225
|
+
this.subscribedSinceLastFlush || (this.subscribedSinceLastFlush = subscribedSinceLastFlushToFlush);
|
|
1219
1226
|
} else {
|
|
1220
1227
|
this.lastFlushedSyncedBlocks = syncedBlocksToFlush;
|
|
1221
1228
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
@@ -7,6 +7,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
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; }
|
|
8
8
|
import { useEffect, useMemo, useRef } from 'react';
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
10
11
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
11
12
|
import { SyncBlockError } from '../common/types';
|
|
12
13
|
import { fetchReferencesErrorPayload } from '../utils/errorHandling';
|
|
@@ -84,20 +85,26 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
84
85
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
85
86
|
while (1) switch (_context.prev = _context.next) {
|
|
86
87
|
case 0:
|
|
88
|
+
if (!(!reference.hasAccess && isExperimentEnabled('platform_editor_blocks_patch_11'))) {
|
|
89
|
+
_context.next = 1;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
return _context.abrupt("return", _this.fetchRestrictedReferenceInfo(reference.documentAri));
|
|
93
|
+
case 1:
|
|
87
94
|
(_this$fetchSourceInfo = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start();
|
|
88
|
-
_context.next =
|
|
95
|
+
_context.next = 2;
|
|
89
96
|
return (_this$dataProvider = _this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.fetchSyncBlockSourceInfo(reference.blockInstanceId || '', reference.documentAri, getProductFromSourceAri(reference.documentAri), reference.hasAccess);
|
|
90
|
-
case
|
|
97
|
+
case 2:
|
|
91
98
|
sourceInfo = _context.sent;
|
|
92
99
|
if (sourceInfo) {
|
|
93
|
-
_context.next =
|
|
100
|
+
_context.next = 3;
|
|
94
101
|
break;
|
|
95
102
|
}
|
|
96
103
|
(_this$fetchSourceInfo2 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.failure({
|
|
97
104
|
reason: "no source info returned for ari: ".concat(reference.documentAri)
|
|
98
105
|
});
|
|
99
106
|
return _context.abrupt("return", undefined);
|
|
100
|
-
case
|
|
107
|
+
case 3:
|
|
101
108
|
(_this$fetchSourceInfo3 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.success();
|
|
102
109
|
return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, sourceInfo), {}, {
|
|
103
110
|
onSameDocument: reference.onSameDocument
|
|
@@ -107,7 +114,7 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
107
114
|
hasAccess: reference.hasAccess,
|
|
108
115
|
productType: sourceInfo.productType
|
|
109
116
|
}));
|
|
110
|
-
case
|
|
117
|
+
case 4:
|
|
111
118
|
case "end":
|
|
112
119
|
return _context.stop();
|
|
113
120
|
}
|
|
@@ -189,17 +196,77 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
189
196
|
reason: 'editorDestroyed'
|
|
190
197
|
});
|
|
191
198
|
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Keeps only the link of a location the user cannot read, so its title never reaches the UI.
|
|
202
|
+
* The location still counts when the link cannot be resolved or there is no document to link to.
|
|
203
|
+
*/
|
|
204
|
+
}, {
|
|
205
|
+
key: "fetchRestrictedReferenceInfo",
|
|
206
|
+
value: (function () {
|
|
207
|
+
var _fetchRestrictedReferenceInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(documentAri) {
|
|
208
|
+
var _this$fetchSourceInfo5;
|
|
209
|
+
var productType, url, _this$dataProvider2, _this$fetchSourceInfo6, sourceInfo, _this$fetchSourceInfo7, _t2;
|
|
210
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
211
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
if (documentAri) {
|
|
214
|
+
_context3.next = 1;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
return _context3.abrupt("return", {
|
|
218
|
+
sourceAri: '',
|
|
219
|
+
hasAccess: false,
|
|
220
|
+
onSameDocument: false
|
|
221
|
+
});
|
|
222
|
+
case 1:
|
|
223
|
+
productType = getProductFromSourceAri(documentAri);
|
|
224
|
+
(_this$fetchSourceInfo5 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 || _this$fetchSourceInfo5.start();
|
|
225
|
+
_context3.prev = 2;
|
|
226
|
+
_context3.next = 3;
|
|
227
|
+
return (_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.fetchSyncBlockSourceInfo(undefined, documentAri, productType, false);
|
|
228
|
+
case 3:
|
|
229
|
+
sourceInfo = _context3.sent;
|
|
230
|
+
url = sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url;
|
|
231
|
+
(_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 || _this$fetchSourceInfo6.success();
|
|
232
|
+
_context3.next = 5;
|
|
233
|
+
break;
|
|
234
|
+
case 4:
|
|
235
|
+
_context3.prev = 4;
|
|
236
|
+
_t2 = _context3["catch"](2);
|
|
237
|
+
(_this$fetchSourceInfo7 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo7 === void 0 || _this$fetchSourceInfo7.failure({
|
|
238
|
+
reason: _t2.message
|
|
239
|
+
});
|
|
240
|
+
case 5:
|
|
241
|
+
return _context3.abrupt("return", {
|
|
242
|
+
sourceAri: documentAri,
|
|
243
|
+
productType: productType,
|
|
244
|
+
url: url,
|
|
245
|
+
hasAccess: false,
|
|
246
|
+
onSameDocument: false
|
|
247
|
+
});
|
|
248
|
+
case 6:
|
|
249
|
+
case "end":
|
|
250
|
+
return _context3.stop();
|
|
251
|
+
}
|
|
252
|
+
}, _callee3, this, [[2, 4]]);
|
|
253
|
+
}));
|
|
254
|
+
function fetchRestrictedReferenceInfo(_x5) {
|
|
255
|
+
return _fetchRestrictedReferenceInfo.apply(this, arguments);
|
|
256
|
+
}
|
|
257
|
+
return fetchRestrictedReferenceInfo;
|
|
258
|
+
}())
|
|
192
259
|
}, {
|
|
193
260
|
key: "getUnregisteredReferences",
|
|
194
261
|
value: function () {
|
|
195
|
-
var _getUnregisteredReferences = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
262
|
+
var _getUnregisteredReferences = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
196
263
|
var _this$fetchReferences8;
|
|
197
264
|
var _this$fetchReferences6, referenceResourceId, hasUnregisteredReferenceOnPage, _this$fetchReferences5, _sourceSyncBlockData, _references, sourceSyncBlockReference, referenceSyncBlockReference, references, sourceSyncBlockData, currentPageData, _this$fetchReferences7;
|
|
198
|
-
return _regeneratorRuntime.wrap(function (
|
|
199
|
-
while (1) switch (
|
|
265
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
266
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
200
267
|
case 0:
|
|
201
268
|
if (!isSourceSyncBlock) {
|
|
202
|
-
|
|
269
|
+
_context4.next = 3;
|
|
203
270
|
break;
|
|
204
271
|
}
|
|
205
272
|
// Verify that a reference sync block for this specific source actually
|
|
@@ -208,13 +275,13 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
208
275
|
referenceResourceId = this.referenceSyncBlockStoreManager.generateResourceIdForReference(resourceId);
|
|
209
276
|
hasUnregisteredReferenceOnPage = this.referenceSyncBlockStoreManager.getSubscribedResourceIds().includes(referenceResourceId);
|
|
210
277
|
if (!hasUnregisteredReferenceOnPage) {
|
|
211
|
-
|
|
278
|
+
_context4.next = 2;
|
|
212
279
|
break;
|
|
213
280
|
}
|
|
214
|
-
|
|
281
|
+
_context4.next = 1;
|
|
215
282
|
return this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId);
|
|
216
283
|
case 1:
|
|
217
|
-
_sourceSyncBlockData =
|
|
284
|
+
_sourceSyncBlockData = _context4.sent;
|
|
218
285
|
_references = [];
|
|
219
286
|
if (_sourceSyncBlockData) {
|
|
220
287
|
sourceSyncBlockReference = _objectSpread(_objectSpread({}, _sourceSyncBlockData), {}, {
|
|
@@ -230,13 +297,13 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
230
297
|
_references.push(sourceSyncBlockReference, referenceSyncBlockReference);
|
|
231
298
|
}
|
|
232
299
|
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 || _this$fetchReferences5.success();
|
|
233
|
-
return
|
|
300
|
+
return _context4.abrupt("return", {
|
|
234
301
|
references: _references
|
|
235
302
|
});
|
|
236
303
|
case 2:
|
|
237
304
|
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
238
305
|
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 || _this$fetchReferences6.success();
|
|
239
|
-
return
|
|
306
|
+
return _context4.abrupt("return", {
|
|
240
307
|
references: []
|
|
241
308
|
});
|
|
242
309
|
case 3:
|
|
@@ -244,10 +311,10 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
244
311
|
// still show the source and the current page itself since they are known
|
|
245
312
|
// but not saved yet.
|
|
246
313
|
references = [];
|
|
247
|
-
|
|
314
|
+
_context4.next = 4;
|
|
248
315
|
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
249
316
|
case 4:
|
|
250
|
-
sourceSyncBlockData =
|
|
317
|
+
sourceSyncBlockData = _context4.sent;
|
|
251
318
|
if (sourceSyncBlockData) {
|
|
252
319
|
references.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
253
320
|
onSameDocument: Boolean(sourceSyncBlockData === null || sourceSyncBlockData === void 0 ? void 0 : sourceSyncBlockData.onSameDocument),
|
|
@@ -255,10 +322,10 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
255
322
|
isSource: true
|
|
256
323
|
}));
|
|
257
324
|
}
|
|
258
|
-
|
|
325
|
+
_context4.next = 5;
|
|
259
326
|
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfoByLocalId(blockInstanceId);
|
|
260
327
|
case 5:
|
|
261
|
-
currentPageData =
|
|
328
|
+
currentPageData = _context4.sent;
|
|
262
329
|
if (currentPageData) {
|
|
263
330
|
references.push(_objectSpread(_objectSpread({}, currentPageData), {}, {
|
|
264
331
|
onSameDocument: true,
|
|
@@ -267,27 +334,27 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
267
334
|
}));
|
|
268
335
|
}
|
|
269
336
|
if (!(references.length === 0)) {
|
|
270
|
-
|
|
337
|
+
_context4.next = 6;
|
|
271
338
|
break;
|
|
272
339
|
}
|
|
273
340
|
(_this$fetchReferences7 = this.fetchReferencesExperience) === null || _this$fetchReferences7 === void 0 || _this$fetchReferences7.failure({
|
|
274
341
|
reason: 'No references found for reference synced block'
|
|
275
342
|
});
|
|
276
|
-
return
|
|
343
|
+
return _context4.abrupt("return", {
|
|
277
344
|
error: SyncBlockError.Errored
|
|
278
345
|
});
|
|
279
346
|
case 6:
|
|
280
347
|
(_this$fetchReferences8 = this.fetchReferencesExperience) === null || _this$fetchReferences8 === void 0 || _this$fetchReferences8.success();
|
|
281
|
-
return
|
|
348
|
+
return _context4.abrupt("return", {
|
|
282
349
|
references: references
|
|
283
350
|
});
|
|
284
351
|
case 7:
|
|
285
352
|
case "end":
|
|
286
|
-
return
|
|
353
|
+
return _context4.stop();
|
|
287
354
|
}
|
|
288
|
-
},
|
|
355
|
+
}, _callee4, this);
|
|
289
356
|
}));
|
|
290
|
-
function getUnregisteredReferences(
|
|
357
|
+
function getUnregisteredReferences(_x6, _x7, _x8) {
|
|
291
358
|
return _getUnregisteredReferences.apply(this, arguments);
|
|
292
359
|
}
|
|
293
360
|
return getUnregisteredReferences;
|
|
@@ -16,6 +16,7 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
16
16
|
private syncBlockSourceInfoRequests;
|
|
17
17
|
private newlyAddedSyncBlocks;
|
|
18
18
|
private lastFlushedSyncedBlocks;
|
|
19
|
+
private subscribedSinceLastFlush;
|
|
19
20
|
private onUnpublishedSyncBlockDetected?;
|
|
20
21
|
private isFlushInProgress;
|
|
21
22
|
private flushNeededAfterCurrent;
|
|
@@ -33,6 +33,11 @@ export declare class SyncBlockStoreManager {
|
|
|
33
33
|
get referenceManager(): ReferenceSyncBlockStoreManager;
|
|
34
34
|
get sourceManager(): SourceSyncBlockStoreManager;
|
|
35
35
|
destroy(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Keeps only the link of a location the user cannot read, so its title never reaches the UI.
|
|
38
|
+
* The location still counts when the link cannot be resolved or there is no document to link to.
|
|
39
|
+
*/
|
|
40
|
+
private fetchRestrictedReferenceInfo;
|
|
36
41
|
private getUnregisteredReferences;
|
|
37
42
|
}
|
|
38
43
|
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void, options?: SyncBlockStoreManagerOptions) => SyncBlockStoreManager;
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@atlaskit/node-data-provider": "^25.0.0",
|
|
24
24
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
25
25
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
26
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
26
|
+
"@atlaskit/tmp-editor-statsig": "^222.0.0",
|
|
27
27
|
"@babel/runtime": "^7.0.0",
|
|
28
28
|
"@compiled/react": "^1.0.2",
|
|
29
29
|
"bind-event-listener": "^3.0.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"uuid": "^11.1.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^128.
|
|
36
|
+
"@atlaskit/editor-common": "^128.3.0",
|
|
37
37
|
"react": "^18.2.0 || ^19.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^19.2.0"
|
|
43
43
|
},
|
|
44
44
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
45
|
-
"version": "20.0.
|
|
45
|
+
"version": "20.0.2",
|
|
46
46
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
47
47
|
"author": "Atlassian Pty Ltd",
|
|
48
48
|
"license": "Apache-2.0",
|