@atlaskit/editor-synced-block-provider 4.3.0 → 4.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 +18 -0
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +45 -37
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +79 -39
- package/dist/cjs/store-manager/syncBlockStoreManager.js +125 -116
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +6 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +29 -1
- package/dist/es2019/store-manager/syncBlockStoreManager.js +91 -91
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +45 -37
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +79 -39
- package/dist/esm/store-manager/syncBlockStoreManager.js +125 -116
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +3 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +3 -1
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +3 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +3 -1
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +3 -1
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +3 -1
- package/package.json +2 -2
|
@@ -27,12 +27,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
27
27
|
// SourceSyncBlockStoreManager is responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
28
28
|
// Can be used in both editor and renderer contexts.
|
|
29
29
|
var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
30
|
-
function SyncBlockStoreManager(dataProvider) {
|
|
30
|
+
function SyncBlockStoreManager(dataProvider, viewMode) {
|
|
31
31
|
(0, _classCallCheck2.default)(this, SyncBlockStoreManager);
|
|
32
32
|
// In future, if reference manager needs to reach to source manager and read its current in memory cache
|
|
33
33
|
// we can pass the source manager as a parameter to the reference manager constructor
|
|
34
|
-
this.sourceSyncBlockStoreManager = new _sourceSyncBlockStoreManager.SourceSyncBlockStoreManager(dataProvider);
|
|
35
|
-
this.referenceSyncBlockStoreManager = new _referenceSyncBlockStoreManager.ReferenceSyncBlockStoreManager(dataProvider);
|
|
34
|
+
this.sourceSyncBlockStoreManager = new _sourceSyncBlockStoreManager.SourceSyncBlockStoreManager(dataProvider, viewMode);
|
|
35
|
+
this.referenceSyncBlockStoreManager = new _referenceSyncBlockStoreManager.ReferenceSyncBlockStoreManager(dataProvider, viewMode);
|
|
36
36
|
this.dataProvider = dataProvider;
|
|
37
37
|
this.referenceSyncBlockStoreManager.setRealTimeSubscriptionsEnabled(true);
|
|
38
38
|
}
|
|
@@ -41,7 +41,7 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
41
41
|
value: function () {
|
|
42
42
|
var _fetchReferencesSourceInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
43
43
|
var _this = this;
|
|
44
|
-
var _this$fetchReferences, _response$references, _this$
|
|
44
|
+
var _this$fetchReferences, _response$references, _this$fetchReferences5, _response$references2, response, _this$fetchReferences2, _this$fetchReferences3, _this$fetchReferences4, sourceInfoPromises, sourceInfos, sourceSyncBlockData, _this$fireAnalyticsEv;
|
|
45
45
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
46
46
|
while (1) switch (_context2.prev = _context2.next) {
|
|
47
47
|
case 0:
|
|
@@ -69,114 +69,20 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
69
69
|
});
|
|
70
70
|
case 10:
|
|
71
71
|
if (!(!response.references || ((_response$references = response.references) === null || _response$references === void 0 ? void 0 : _response$references.length) === 0)) {
|
|
72
|
-
_context2.next =
|
|
72
|
+
_context2.next = 17;
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
75
|
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_8')) {
|
|
76
|
-
_context2.next =
|
|
76
|
+
_context2.next = 15;
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
// Verify that a reference sync block for this specific source actually
|
|
84
|
-
// exists on the current page by checking if the reference manager has
|
|
85
|
-
// an active subscription for the derived reference resourceId.
|
|
86
|
-
referenceResourceId = this.referenceSyncBlockStoreManager.generateResourceIdForReference(resourceId);
|
|
87
|
-
hasUnregisteredReferenceOnPage = this.referenceSyncBlockStoreManager.getSubscribedResourceIds().includes(referenceResourceId);
|
|
88
|
-
if (!hasUnregisteredReferenceOnPage) {
|
|
89
|
-
_context2.next = 27;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
_context2.next = 18;
|
|
93
|
-
return this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId);
|
|
94
|
-
case 18:
|
|
95
|
-
_sourceSyncBlockData = _context2.sent;
|
|
96
|
-
references = [];
|
|
97
|
-
if (_sourceSyncBlockData) {
|
|
98
|
-
references.push(_objectSpread(_objectSpread({}, _sourceSyncBlockData), {}, {
|
|
99
|
-
onSameDocument: Boolean(_sourceSyncBlockData === null || _sourceSyncBlockData === void 0 ? void 0 : _sourceSyncBlockData.onSameDocument),
|
|
100
|
-
hasAccess: true,
|
|
101
|
-
isSource: true
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
_context2.next = 23;
|
|
105
|
-
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(referenceResourceId);
|
|
106
|
-
case 23:
|
|
107
|
-
unregisteredReferenceData = _context2.sent;
|
|
108
|
-
if (unregisteredReferenceData) {
|
|
109
|
-
references.push(_objectSpread(_objectSpread({}, unregisteredReferenceData), {}, {
|
|
110
|
-
onSameDocument: true,
|
|
111
|
-
hasAccess: true,
|
|
112
|
-
isSource: false
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 || _this$fetchReferences3.success();
|
|
116
|
-
return _context2.abrupt("return", {
|
|
117
|
-
references: references
|
|
118
|
-
});
|
|
119
|
-
case 27:
|
|
120
|
-
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
121
|
-
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 || _this$fetchReferences4.success();
|
|
122
|
-
return _context2.abrupt("return", {
|
|
123
|
-
references: []
|
|
124
|
-
});
|
|
125
|
-
case 29:
|
|
126
|
-
if (isSourceSyncBlock) {
|
|
127
|
-
_context2.next = 44;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
// Though no references registered yet for this reference sync block,
|
|
131
|
-
// still show the source and the current page itself since they are known
|
|
132
|
-
// but not saved yet.
|
|
133
|
-
_references = [];
|
|
134
|
-
_context2.next = 33;
|
|
135
|
-
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
136
|
-
case 33:
|
|
137
|
-
_sourceSyncBlockData2 = _context2.sent;
|
|
138
|
-
if (_sourceSyncBlockData2) {
|
|
139
|
-
_references.push(_objectSpread(_objectSpread({}, _sourceSyncBlockData2), {}, {
|
|
140
|
-
onSameDocument: Boolean(_sourceSyncBlockData2 === null || _sourceSyncBlockData2 === void 0 ? void 0 : _sourceSyncBlockData2.onSameDocument),
|
|
141
|
-
hasAccess: true,
|
|
142
|
-
isSource: true
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
145
|
-
_context2.next = 37;
|
|
146
|
-
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfoByLocalId(blockInstanceId);
|
|
147
|
-
case 37:
|
|
148
|
-
currentPageData = _context2.sent;
|
|
149
|
-
if (currentPageData) {
|
|
150
|
-
_references.push(_objectSpread(_objectSpread({}, currentPageData), {}, {
|
|
151
|
-
onSameDocument: true,
|
|
152
|
-
hasAccess: true,
|
|
153
|
-
isSource: false
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
if (!(_references.length === 0)) {
|
|
157
|
-
_context2.next = 42;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 || _this$fetchReferences5.failure({
|
|
161
|
-
reason: 'No references found for reference synced block'
|
|
162
|
-
});
|
|
163
|
-
return _context2.abrupt("return", {
|
|
164
|
-
error: _types.SyncBlockError.Errored
|
|
165
|
-
});
|
|
166
|
-
case 42:
|
|
167
|
-
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 || _this$fetchReferences6.success();
|
|
168
|
-
return _context2.abrupt("return", {
|
|
169
|
-
references: _references
|
|
170
|
-
});
|
|
171
|
-
case 44:
|
|
172
|
-
_context2.next = 48;
|
|
173
|
-
break;
|
|
174
|
-
case 46:
|
|
79
|
+
return _context2.abrupt("return", this.getUnregisteredReferences(resourceId, blockInstanceId, isSourceSyncBlock));
|
|
80
|
+
case 15:
|
|
175
81
|
// No reference found
|
|
176
82
|
if (isSourceSyncBlock) {
|
|
177
|
-
(_this$
|
|
83
|
+
(_this$fetchReferences3 = this.fetchReferencesExperience) === null || _this$fetchReferences3 === void 0 || _this$fetchReferences3.success();
|
|
178
84
|
} else {
|
|
179
|
-
(_this$
|
|
85
|
+
(_this$fetchReferences4 = this.fetchReferencesExperience) === null || _this$fetchReferences4 === void 0 || _this$fetchReferences4.failure({
|
|
180
86
|
reason: 'No references found for reference synced block'
|
|
181
87
|
});
|
|
182
88
|
}
|
|
@@ -185,8 +91,8 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
185
91
|
} : {
|
|
186
92
|
error: _types.SyncBlockError.Errored
|
|
187
93
|
});
|
|
188
|
-
case
|
|
189
|
-
(_this$
|
|
94
|
+
case 17:
|
|
95
|
+
(_this$fetchReferences5 = this.fetchReferencesExperience) === null || _this$fetchReferences5 === void 0 || _this$fetchReferences5.success();
|
|
190
96
|
sourceInfoPromises = ((_response$references2 = response.references) !== null && _response$references2 !== void 0 ? _response$references2 : []).map( /*#__PURE__*/function () {
|
|
191
97
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reference) {
|
|
192
98
|
var _this$fetchSourceInfo, _this$dataProvider, _this$fetchSourceInfo3;
|
|
@@ -224,13 +130,13 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
224
130
|
return _ref.apply(this, arguments);
|
|
225
131
|
};
|
|
226
132
|
}());
|
|
227
|
-
_context2.next =
|
|
133
|
+
_context2.next = 21;
|
|
228
134
|
return Promise.all(sourceInfoPromises);
|
|
229
|
-
case
|
|
135
|
+
case 21:
|
|
230
136
|
sourceInfos = _context2.sent;
|
|
231
|
-
_context2.next =
|
|
137
|
+
_context2.next = 24;
|
|
232
138
|
return isSourceSyncBlock ? this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId) : this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
233
|
-
case
|
|
139
|
+
case 24:
|
|
234
140
|
sourceSyncBlockData = _context2.sent;
|
|
235
141
|
if (sourceSyncBlockData) {
|
|
236
142
|
sourceInfos.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
@@ -243,8 +149,8 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
243
149
|
return _context2.abrupt("return", {
|
|
244
150
|
references: sourceInfos
|
|
245
151
|
});
|
|
246
|
-
case
|
|
247
|
-
_context2.prev =
|
|
152
|
+
case 29:
|
|
153
|
+
_context2.prev = 29;
|
|
248
154
|
_context2.t0 = _context2["catch"](0);
|
|
249
155
|
(0, _monitoring.logException)(_context2.t0, {
|
|
250
156
|
location: 'editor-synced-block-provider/syncBlockStoreManager'
|
|
@@ -253,11 +159,11 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
253
159
|
return _context2.abrupt("return", {
|
|
254
160
|
error: _types.SyncBlockError.Errored
|
|
255
161
|
});
|
|
256
|
-
case
|
|
162
|
+
case 34:
|
|
257
163
|
case "end":
|
|
258
164
|
return _context2.stop();
|
|
259
165
|
}
|
|
260
|
-
}, _callee2, this, [[0,
|
|
166
|
+
}, _callee2, this, [[0, 29]]);
|
|
261
167
|
}));
|
|
262
168
|
function fetchReferencesSourceInfo(_x, _x2, _x3) {
|
|
263
169
|
return _fetchReferencesSourceInfo.apply(this, arguments);
|
|
@@ -286,16 +192,119 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
286
192
|
}, {
|
|
287
193
|
key: "destroy",
|
|
288
194
|
value: function destroy() {
|
|
289
|
-
var _this$
|
|
195
|
+
var _this$fetchReferences6, _this$fetchSourceInfo4;
|
|
290
196
|
this.referenceSyncBlockStoreManager.destroy();
|
|
291
197
|
this.sourceSyncBlockStoreManager.destroy();
|
|
292
|
-
(_this$
|
|
198
|
+
(_this$fetchReferences6 = this.fetchReferencesExperience) === null || _this$fetchReferences6 === void 0 || _this$fetchReferences6.abort({
|
|
293
199
|
reason: 'editorDestroyed'
|
|
294
200
|
});
|
|
295
201
|
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.abort({
|
|
296
202
|
reason: 'editorDestroyed'
|
|
297
203
|
});
|
|
298
204
|
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "getUnregisteredReferences",
|
|
207
|
+
value: function () {
|
|
208
|
+
var _getUnregisteredReferences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resourceId, blockInstanceId, isSourceSyncBlock) {
|
|
209
|
+
var _this$fetchReferences0;
|
|
210
|
+
var _this$fetchReferences8, referenceResourceId, hasUnregisteredReferenceOnPage, _this$fetchReferences7, _sourceSyncBlockData, _references, sourceSyncBlockReference, referenceSyncBlockReference, references, sourceSyncBlockData, currentPageData, _this$fetchReferences9;
|
|
211
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
212
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
213
|
+
case 0:
|
|
214
|
+
if (!isSourceSyncBlock) {
|
|
215
|
+
_context3.next = 13;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
// Verify that a reference sync block for this specific source actually
|
|
219
|
+
// exists on the current page by checking if the reference manager has
|
|
220
|
+
// an active subscription for the derived reference resourceId.
|
|
221
|
+
referenceResourceId = this.referenceSyncBlockStoreManager.generateResourceIdForReference(resourceId);
|
|
222
|
+
hasUnregisteredReferenceOnPage = this.referenceSyncBlockStoreManager.getSubscribedResourceIds().includes(referenceResourceId);
|
|
223
|
+
if (!hasUnregisteredReferenceOnPage) {
|
|
224
|
+
_context3.next = 11;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
_context3.next = 6;
|
|
228
|
+
return this.sourceSyncBlockStoreManager.getSyncBlockSourceInfo(blockInstanceId);
|
|
229
|
+
case 6:
|
|
230
|
+
_sourceSyncBlockData = _context3.sent;
|
|
231
|
+
_references = [];
|
|
232
|
+
if (_sourceSyncBlockData) {
|
|
233
|
+
sourceSyncBlockReference = _objectSpread(_objectSpread({}, _sourceSyncBlockData), {}, {
|
|
234
|
+
onSameDocument: true,
|
|
235
|
+
hasAccess: true,
|
|
236
|
+
isSource: true
|
|
237
|
+
});
|
|
238
|
+
referenceSyncBlockReference = _objectSpread(_objectSpread({}, _sourceSyncBlockData), {}, {
|
|
239
|
+
onSameDocument: true,
|
|
240
|
+
hasAccess: true,
|
|
241
|
+
isSource: false
|
|
242
|
+
});
|
|
243
|
+
_references.push(sourceSyncBlockReference, referenceSyncBlockReference);
|
|
244
|
+
}
|
|
245
|
+
(_this$fetchReferences7 = this.fetchReferencesExperience) === null || _this$fetchReferences7 === void 0 || _this$fetchReferences7.success();
|
|
246
|
+
return _context3.abrupt("return", {
|
|
247
|
+
references: _references
|
|
248
|
+
});
|
|
249
|
+
case 11:
|
|
250
|
+
// No remote or local reference exists — show info text with link to doco on how to use Synced Blocks
|
|
251
|
+
(_this$fetchReferences8 = this.fetchReferencesExperience) === null || _this$fetchReferences8 === void 0 || _this$fetchReferences8.success();
|
|
252
|
+
return _context3.abrupt("return", {
|
|
253
|
+
references: []
|
|
254
|
+
});
|
|
255
|
+
case 13:
|
|
256
|
+
// Though no references registered yet for this reference sync block,
|
|
257
|
+
// still show the source and the current page itself since they are known
|
|
258
|
+
// but not saved yet.
|
|
259
|
+
references = [];
|
|
260
|
+
_context3.next = 16;
|
|
261
|
+
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfo(resourceId);
|
|
262
|
+
case 16:
|
|
263
|
+
sourceSyncBlockData = _context3.sent;
|
|
264
|
+
if (sourceSyncBlockData) {
|
|
265
|
+
references.push(_objectSpread(_objectSpread({}, sourceSyncBlockData), {}, {
|
|
266
|
+
onSameDocument: Boolean(sourceSyncBlockData === null || sourceSyncBlockData === void 0 ? void 0 : sourceSyncBlockData.onSameDocument),
|
|
267
|
+
hasAccess: true,
|
|
268
|
+
isSource: true
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
_context3.next = 20;
|
|
272
|
+
return this.referenceSyncBlockStoreManager.fetchSyncBlockSourceInfoByLocalId(blockInstanceId);
|
|
273
|
+
case 20:
|
|
274
|
+
currentPageData = _context3.sent;
|
|
275
|
+
if (currentPageData) {
|
|
276
|
+
references.push(_objectSpread(_objectSpread({}, currentPageData), {}, {
|
|
277
|
+
onSameDocument: true,
|
|
278
|
+
hasAccess: true,
|
|
279
|
+
isSource: false
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
if (!(references.length === 0)) {
|
|
283
|
+
_context3.next = 25;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
(_this$fetchReferences9 = this.fetchReferencesExperience) === null || _this$fetchReferences9 === void 0 || _this$fetchReferences9.failure({
|
|
287
|
+
reason: 'No references found for reference synced block'
|
|
288
|
+
});
|
|
289
|
+
return _context3.abrupt("return", {
|
|
290
|
+
error: _types.SyncBlockError.Errored
|
|
291
|
+
});
|
|
292
|
+
case 25:
|
|
293
|
+
(_this$fetchReferences0 = this.fetchReferencesExperience) === null || _this$fetchReferences0 === void 0 || _this$fetchReferences0.success();
|
|
294
|
+
return _context3.abrupt("return", {
|
|
295
|
+
references: references
|
|
296
|
+
});
|
|
297
|
+
case 27:
|
|
298
|
+
case "end":
|
|
299
|
+
return _context3.stop();
|
|
300
|
+
}
|
|
301
|
+
}, _callee3, this);
|
|
302
|
+
}));
|
|
303
|
+
function getUnregisteredReferences(_x5, _x6, _x7) {
|
|
304
|
+
return _getUnregisteredReferences.apply(this, arguments);
|
|
305
|
+
}
|
|
306
|
+
return getUnregisteredReferences;
|
|
307
|
+
}()
|
|
299
308
|
}]);
|
|
300
309
|
}();
|
|
301
310
|
var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { SyncBlockError } from '../common/types';
|
|
5
6
|
import { fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
|
|
6
7
|
import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
|
|
@@ -20,7 +21,7 @@ const CACHE_KEY_PREFIX = 'sync-block-data-';
|
|
|
20
21
|
export class ReferenceSyncBlockStoreManager {
|
|
21
22
|
// Track the setTimeout handle for queued flush so we can cancel it on destroy
|
|
22
23
|
|
|
23
|
-
constructor(dataProvider) {
|
|
24
|
+
constructor(dataProvider, viewMode) {
|
|
24
25
|
var _this$dataProvider;
|
|
25
26
|
// Keeps track of addition and deletion of reference synced blocks on the document
|
|
26
27
|
// This starts as true to always flush the cache when document is saved for the first time
|
|
@@ -33,6 +34,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
33
34
|
// Track if another flush is needed after the current one completes
|
|
34
35
|
_defineProperty(this, "flushNeededAfterCurrent", false);
|
|
35
36
|
this.dataProvider = dataProvider;
|
|
37
|
+
this.viewMode = viewMode;
|
|
36
38
|
this.syncBlockFetchDataRequests = new Map();
|
|
37
39
|
this.syncBlockSourceInfoRequests = new Map();
|
|
38
40
|
this.newlyAddedSyncBlocks = new Set();
|
|
@@ -549,6 +551,9 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
549
551
|
* @returns true if the reference synced blocks are updated successfully, false otherwise
|
|
550
552
|
*/
|
|
551
553
|
async flush() {
|
|
554
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
552
557
|
if (!this.isCacheDirty) {
|
|
553
558
|
// we use the isCacheDirty flag as a quick check.
|
|
554
559
|
return true;
|
|
@@ -13,15 +13,19 @@ import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
|
|
|
13
13
|
// Handles caching, debouncing updates, and publish/subscribe for local changes.
|
|
14
14
|
// Ensures consistency between local and remote state, and can be used in both editor and renderer contexts.
|
|
15
15
|
export class SourceSyncBlockStoreManager {
|
|
16
|
-
constructor(dataProvider) {
|
|
16
|
+
constructor(dataProvider, viewMode) {
|
|
17
17
|
_defineProperty(this, "hasReceivedContentChange", false);
|
|
18
18
|
_defineProperty(this, "setPendingDeletion", (Ids, value) => {
|
|
19
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
19
22
|
const syncBlock = this.syncBlockCache.get(Ids.resourceId);
|
|
20
23
|
if (syncBlock) {
|
|
21
24
|
syncBlock.pendingDeletion = value;
|
|
22
25
|
}
|
|
23
26
|
});
|
|
24
27
|
this.dataProvider = dataProvider;
|
|
28
|
+
this.viewMode = viewMode;
|
|
25
29
|
this.syncBlockCache = new Map();
|
|
26
30
|
this.creationCompletionCallbacks = new Map();
|
|
27
31
|
}
|
|
@@ -51,6 +55,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
51
55
|
*/
|
|
52
56
|
updateSyncBlockData(syncBlockNode) {
|
|
53
57
|
try {
|
|
58
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
54
61
|
if (!this.isSourceBlock(syncBlockNode)) {
|
|
55
62
|
throw new Error('Invalid sync block node type provided for updateSyncBlockData');
|
|
56
63
|
}
|
|
@@ -107,6 +114,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
107
114
|
async flush() {
|
|
108
115
|
try {
|
|
109
116
|
var _this$saveExperience;
|
|
117
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
110
120
|
const bodiedSyncBlockNodes = [];
|
|
111
121
|
const bodiedSyncBlockData = [];
|
|
112
122
|
Array.from(this.syncBlockCache.values()).forEach(syncBlockData => {
|
|
@@ -187,6 +197,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
199
|
hasUnsavedChanges() {
|
|
200
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
190
203
|
return this.hasReceivedContentChange && Array.from(this.syncBlockCache.values()).some(syncBlockData => syncBlockData.isDirty);
|
|
191
204
|
}
|
|
192
205
|
isPendingCreation(resourceId) {
|
|
@@ -198,6 +211,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
198
211
|
* @param success
|
|
199
212
|
*/
|
|
200
213
|
commitPendingCreation(success, resourceId) {
|
|
214
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
201
217
|
const onCompletion = this.creationCompletionCallbacks.get(resourceId);
|
|
202
218
|
if (onCompletion) {
|
|
203
219
|
this.creationCompletionCallbacks.delete(resourceId);
|
|
@@ -255,6 +271,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
255
271
|
* @param attrs attributes Ids of the node
|
|
256
272
|
*/
|
|
257
273
|
createBodiedSyncBlockNode(attrs, onCompletion) {
|
|
274
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
258
277
|
const {
|
|
259
278
|
resourceId,
|
|
260
279
|
localId: blockInstanceId
|
|
@@ -309,6 +328,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
309
328
|
async delete(syncBlockIds, onDelete, onDeleteCompleted, reason) {
|
|
310
329
|
try {
|
|
311
330
|
var _this$deleteExperienc;
|
|
331
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
312
334
|
if (!this.dataProvider) {
|
|
313
335
|
throw new Error('Data provider not set');
|
|
314
336
|
}
|
|
@@ -365,6 +387,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
365
387
|
return !!this.deletionRetryInfo;
|
|
366
388
|
}
|
|
367
389
|
async retryDeletion() {
|
|
390
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
391
|
+
return Promise.resolve();
|
|
392
|
+
}
|
|
368
393
|
if (!this.deletionRetryInfo) {
|
|
369
394
|
return Promise.resolve();
|
|
370
395
|
}
|
|
@@ -392,6 +417,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
392
417
|
* @param destroyCallback - The callback to clear any reference stored for deletion (regardless if deletion is completed or abort)
|
|
393
418
|
*/
|
|
394
419
|
async deleteSyncBlocksWithConfirmation(syncBlockIds, deletionReason, onDelete, onDeleteCompleted, destroyCallback) {
|
|
420
|
+
if (this.viewMode === 'view' && fg('platform_synced_block_patch_8')) {
|
|
421
|
+
return Promise.resolve();
|
|
422
|
+
}
|
|
395
423
|
if (this.confirmationCallback) {
|
|
396
424
|
const confirmed = await this.confirmationCallback(syncBlockIds, deletionReason);
|
|
397
425
|
if (confirmed) {
|