@atlaskit/editor-synced-block-provider 2.11.2 → 2.12.0
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 +15 -0
- package/dist/cjs/clients/block-service/blockService.js +130 -50
- package/dist/cjs/common/types.js +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +135 -59
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +21 -48
- package/dist/es2019/clients/block-service/blockService.js +57 -0
- package/dist/es2019/common/types.js +1 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/providers/block-service/blockServiceAPI.js +54 -1
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +2 -25
- package/dist/esm/clients/block-service/blockService.js +130 -50
- package/dist/esm/common/types.js +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/providers/block-service/blockServiceAPI.js +135 -59
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +18 -45
- package/dist/types/clients/block-service/blockService.d.ts +52 -0
- package/dist/types/common/types.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +2 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -7
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +52 -0
- package/dist/types-ts4.5/common/types.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +2 -1
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -7
- package/package.json +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
6
|
import { useMemo } from 'react';
|
|
6
7
|
import { blockResourceIdFromSourceAndLocalId, getLocalIdFromBlockResourceId } from '../../clients/block-service/ari';
|
|
7
|
-
import { BlockError, createSyncedBlock, deleteSyncedBlock, getSyncedBlockContent, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
8
|
+
import { BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getSyncedBlockContent, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
8
9
|
import { SyncBlockError } from '../../common/types';
|
|
9
10
|
import { stringifyError } from '../../utils/errorHandling';
|
|
10
11
|
var mapBlockError = function mapBlockError(error) {
|
|
@@ -17,6 +18,81 @@ var mapBlockError = function mapBlockError(error) {
|
|
|
17
18
|
return SyncBlockError.Errored;
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
// convert BlockContentResponse to SyncBlockData
|
|
22
|
+
// throws exception if JSON parsing fails
|
|
23
|
+
// what's missing from BlockContentResponse to SyncBlockData:
|
|
24
|
+
// - updatedAt
|
|
25
|
+
// - sourceURL
|
|
26
|
+
// - sourceTitle
|
|
27
|
+
// - isSynced
|
|
28
|
+
var convertToSyncBlockData = function convertToSyncBlockData(data) {
|
|
29
|
+
return {
|
|
30
|
+
blockInstanceId: data.blockInstanceId,
|
|
31
|
+
content: JSON.parse(data.content),
|
|
32
|
+
createdAt: new Date(data.createdAt).toISOString(),
|
|
33
|
+
createdBy: data.createdBy,
|
|
34
|
+
product: data.product,
|
|
35
|
+
resourceId: data.blockAri,
|
|
36
|
+
sourceAri: data.sourceAri
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export var fetchReferences = /*#__PURE__*/function () {
|
|
40
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(documentAri) {
|
|
41
|
+
var response, _ref2, blocks, errors, blocksInstances, errorInstances;
|
|
42
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
_context.prev = 0;
|
|
46
|
+
_context.next = 3;
|
|
47
|
+
return getReferenceSyncedBlocks(documentAri);
|
|
48
|
+
case 3:
|
|
49
|
+
response = _context.sent;
|
|
50
|
+
_context.next = 11;
|
|
51
|
+
break;
|
|
52
|
+
case 6:
|
|
53
|
+
_context.prev = 6;
|
|
54
|
+
_context.t0 = _context["catch"](0);
|
|
55
|
+
if (!(_context.t0 instanceof BlockError)) {
|
|
56
|
+
_context.next = 10;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
return _context.abrupt("return", mapBlockError(_context.t0));
|
|
60
|
+
case 10:
|
|
61
|
+
return _context.abrupt("return", SyncBlockError.Errored);
|
|
62
|
+
case 11:
|
|
63
|
+
_ref2 = response || {}, blocks = _ref2.blocks, errors = _ref2.errors;
|
|
64
|
+
blocksInstances = (blocks || []).map(function (blockContentResponse) {
|
|
65
|
+
try {
|
|
66
|
+
return {
|
|
67
|
+
data: convertToSyncBlockData(blockContentResponse),
|
|
68
|
+
resourceId: blockContentResponse.blockAri
|
|
69
|
+
};
|
|
70
|
+
} catch (_unused) {
|
|
71
|
+
// JSON parsing error, return InvalidContent error
|
|
72
|
+
return {
|
|
73
|
+
error: SyncBlockError.InvalidContent,
|
|
74
|
+
resourceId: blockContentResponse.blockAri
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
errorInstances = (errors || []).map(function (errorBlock) {
|
|
79
|
+
return {
|
|
80
|
+
error: SyncBlockError.Errored,
|
|
81
|
+
resourceId: errorBlock.blockAri
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
return _context.abrupt("return", [].concat(_toConsumableArray(blocksInstances), _toConsumableArray(errorInstances)));
|
|
85
|
+
case 15:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee, null, [[0, 6]]);
|
|
90
|
+
}));
|
|
91
|
+
return function fetchReferences(_x) {
|
|
92
|
+
return _ref.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}();
|
|
95
|
+
|
|
20
96
|
/**
|
|
21
97
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
22
98
|
*/
|
|
@@ -29,32 +105,32 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
29
105
|
value: // resourceId is the ARI of the block. E.G ari:cloud:blocks:site-123:synced-block/uuid-456
|
|
30
106
|
// in the content API provider, this was the concatenation of the source document's ARI and the local ID. E.G ari:cloud:confluence:site-123:page/pageId/uuid-456
|
|
31
107
|
function () {
|
|
32
|
-
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
108
|
+
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resourceId) {
|
|
33
109
|
var localId, blockContentResponse, value, syncedBlockData;
|
|
34
|
-
return _regeneratorRuntime.wrap(function
|
|
35
|
-
while (1) switch (
|
|
110
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
36
112
|
case 0:
|
|
37
113
|
localId = getLocalIdFromBlockResourceId(resourceId);
|
|
38
|
-
|
|
39
|
-
|
|
114
|
+
_context2.prev = 1;
|
|
115
|
+
_context2.next = 4;
|
|
40
116
|
return getSyncedBlockContent({
|
|
41
117
|
blockAri: resourceId
|
|
42
118
|
});
|
|
43
119
|
case 4:
|
|
44
|
-
blockContentResponse =
|
|
120
|
+
blockContentResponse = _context2.sent;
|
|
45
121
|
value = blockContentResponse.content;
|
|
46
122
|
if (value) {
|
|
47
|
-
|
|
123
|
+
_context2.next = 8;
|
|
48
124
|
break;
|
|
49
125
|
}
|
|
50
|
-
return
|
|
126
|
+
return _context2.abrupt("return", {
|
|
51
127
|
error: SyncBlockError.NotFound,
|
|
52
128
|
resourceId: resourceId
|
|
53
129
|
});
|
|
54
130
|
case 8:
|
|
55
131
|
// Parse the synced block content from the response's content
|
|
56
132
|
syncedBlockData = JSON.parse(value);
|
|
57
|
-
return
|
|
133
|
+
return _context2.abrupt("return", {
|
|
58
134
|
data: {
|
|
59
135
|
content: syncedBlockData,
|
|
60
136
|
resourceId: resourceId,
|
|
@@ -65,28 +141,28 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
65
141
|
resourceId: resourceId
|
|
66
142
|
});
|
|
67
143
|
case 12:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!(
|
|
71
|
-
|
|
144
|
+
_context2.prev = 12;
|
|
145
|
+
_context2.t0 = _context2["catch"](1);
|
|
146
|
+
if (!(_context2.t0 instanceof BlockError)) {
|
|
147
|
+
_context2.next = 16;
|
|
72
148
|
break;
|
|
73
149
|
}
|
|
74
|
-
return
|
|
75
|
-
error: mapBlockError(
|
|
150
|
+
return _context2.abrupt("return", {
|
|
151
|
+
error: mapBlockError(_context2.t0),
|
|
76
152
|
resourceId: resourceId
|
|
77
153
|
});
|
|
78
154
|
case 16:
|
|
79
|
-
return
|
|
155
|
+
return _context2.abrupt("return", {
|
|
80
156
|
error: SyncBlockError.Errored,
|
|
81
157
|
resourceId: resourceId
|
|
82
158
|
});
|
|
83
159
|
case 17:
|
|
84
160
|
case "end":
|
|
85
|
-
return
|
|
161
|
+
return _context2.stop();
|
|
86
162
|
}
|
|
87
|
-
},
|
|
163
|
+
}, _callee2, null, [[1, 12]]);
|
|
88
164
|
}));
|
|
89
|
-
function fetchData(
|
|
165
|
+
function fetchData(_x2) {
|
|
90
166
|
return _fetchData.apply(this, arguments);
|
|
91
167
|
}
|
|
92
168
|
return fetchData;
|
|
@@ -107,34 +183,34 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
107
183
|
return _createClass(BlockServiceADFWriteProvider, [{
|
|
108
184
|
key: "writeData",
|
|
109
185
|
value: function () {
|
|
110
|
-
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
186
|
+
var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
111
187
|
var resourceId;
|
|
112
|
-
return _regeneratorRuntime.wrap(function
|
|
113
|
-
while (1) switch (
|
|
188
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
189
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
114
190
|
case 0:
|
|
115
191
|
resourceId = data.resourceId;
|
|
116
|
-
|
|
117
|
-
|
|
192
|
+
_context3.prev = 1;
|
|
193
|
+
_context3.next = 4;
|
|
118
194
|
return updateSyncedBlock({
|
|
119
195
|
blockAri: resourceId,
|
|
120
196
|
content: JSON.stringify(data.content)
|
|
121
197
|
});
|
|
122
198
|
case 4:
|
|
123
|
-
return
|
|
199
|
+
return _context3.abrupt("return", {
|
|
124
200
|
resourceId: resourceId
|
|
125
201
|
});
|
|
126
202
|
case 7:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (!(
|
|
130
|
-
|
|
203
|
+
_context3.prev = 7;
|
|
204
|
+
_context3.t0 = _context3["catch"](1);
|
|
205
|
+
if (!(_context3.t0 instanceof BlockError)) {
|
|
206
|
+
_context3.next = 16;
|
|
131
207
|
break;
|
|
132
208
|
}
|
|
133
|
-
if (!(
|
|
134
|
-
|
|
209
|
+
if (!(_context3.t0.status === 404)) {
|
|
210
|
+
_context3.next = 15;
|
|
135
211
|
break;
|
|
136
212
|
}
|
|
137
|
-
|
|
213
|
+
_context3.next = 13;
|
|
138
214
|
return createSyncedBlock({
|
|
139
215
|
blockAri: resourceId,
|
|
140
216
|
blockInstanceId: data.blockInstanceId,
|
|
@@ -143,25 +219,25 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
143
219
|
content: JSON.stringify(data.content)
|
|
144
220
|
});
|
|
145
221
|
case 13:
|
|
146
|
-
|
|
222
|
+
_context3.next = 16;
|
|
147
223
|
break;
|
|
148
224
|
case 15:
|
|
149
|
-
return
|
|
150
|
-
error: mapBlockError(
|
|
225
|
+
return _context3.abrupt("return", {
|
|
226
|
+
error: mapBlockError(_context3.t0),
|
|
151
227
|
resourceId: resourceId
|
|
152
228
|
});
|
|
153
229
|
case 16:
|
|
154
|
-
return
|
|
155
|
-
error: stringifyError(
|
|
230
|
+
return _context3.abrupt("return", {
|
|
231
|
+
error: stringifyError(_context3.t0),
|
|
156
232
|
resourceId: resourceId
|
|
157
233
|
});
|
|
158
234
|
case 17:
|
|
159
235
|
case "end":
|
|
160
|
-
return
|
|
236
|
+
return _context3.stop();
|
|
161
237
|
}
|
|
162
|
-
},
|
|
238
|
+
}, _callee3, this, [[1, 7]]);
|
|
163
239
|
}));
|
|
164
|
-
function writeData(
|
|
240
|
+
function writeData(_x3) {
|
|
165
241
|
return _writeData.apply(this, arguments);
|
|
166
242
|
}
|
|
167
243
|
return writeData;
|
|
@@ -169,46 +245,46 @@ var BlockServiceADFWriteProvider = /*#__PURE__*/function () {
|
|
|
169
245
|
}, {
|
|
170
246
|
key: "deleteData",
|
|
171
247
|
value: function () {
|
|
172
|
-
var _deleteData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
173
|
-
return _regeneratorRuntime.wrap(function
|
|
174
|
-
while (1) switch (
|
|
248
|
+
var _deleteData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resourceId) {
|
|
249
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
250
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
175
251
|
case 0:
|
|
176
|
-
|
|
177
|
-
|
|
252
|
+
_context4.prev = 0;
|
|
253
|
+
_context4.next = 3;
|
|
178
254
|
return deleteSyncedBlock({
|
|
179
255
|
blockAri: resourceId
|
|
180
256
|
});
|
|
181
257
|
case 3:
|
|
182
|
-
return
|
|
258
|
+
return _context4.abrupt("return", {
|
|
183
259
|
resourceId: resourceId,
|
|
184
260
|
success: true,
|
|
185
261
|
error: undefined
|
|
186
262
|
});
|
|
187
263
|
case 6:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (!(
|
|
191
|
-
|
|
264
|
+
_context4.prev = 6;
|
|
265
|
+
_context4.t0 = _context4["catch"](0);
|
|
266
|
+
if (!(_context4.t0 instanceof BlockError)) {
|
|
267
|
+
_context4.next = 10;
|
|
192
268
|
break;
|
|
193
269
|
}
|
|
194
|
-
return
|
|
270
|
+
return _context4.abrupt("return", {
|
|
195
271
|
resourceId: resourceId,
|
|
196
272
|
success: false,
|
|
197
|
-
error: mapBlockError(
|
|
273
|
+
error: mapBlockError(_context4.t0)
|
|
198
274
|
});
|
|
199
275
|
case 10:
|
|
200
|
-
return
|
|
276
|
+
return _context4.abrupt("return", {
|
|
201
277
|
resourceId: resourceId,
|
|
202
278
|
success: false,
|
|
203
|
-
error: stringifyError(
|
|
279
|
+
error: stringifyError(_context4.t0)
|
|
204
280
|
});
|
|
205
281
|
case 11:
|
|
206
282
|
case "end":
|
|
207
|
-
return
|
|
283
|
+
return _context4.stop();
|
|
208
284
|
}
|
|
209
|
-
},
|
|
285
|
+
}, _callee4, null, [[0, 6]]);
|
|
210
286
|
}));
|
|
211
|
-
function deleteData(
|
|
287
|
+
function deleteData(_x4) {
|
|
212
288
|
return _deleteData.apply(this, arguments);
|
|
213
289
|
}
|
|
214
290
|
return deleteData;
|
|
@@ -6,8 +6,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
7
7
|
import uuid from 'uuid';
|
|
8
8
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
9
|
-
import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
10
|
-
import { rebaseTransaction as _rebaseTransaction } from '../common/rebase-transaction';
|
|
11
9
|
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload } from '../utils/errorHandling';
|
|
12
10
|
import { convertSyncBlockPMNodeToSyncBlockData, createBodiedSyncBlockNode as _createBodiedSyncBlockNode } from '../utils/utils';
|
|
13
11
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
@@ -148,11 +146,6 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
148
146
|
}
|
|
149
147
|
return flush;
|
|
150
148
|
}())
|
|
151
|
-
}, {
|
|
152
|
-
key: "setEditorView",
|
|
153
|
-
value: function setEditorView(editorView) {
|
|
154
|
-
this.editorView = editorView;
|
|
155
|
-
}
|
|
156
149
|
}, {
|
|
157
150
|
key: "registerPendingCreation",
|
|
158
151
|
value: function registerPendingCreation(resourceId) {
|
|
@@ -278,47 +271,40 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
278
271
|
}, {
|
|
279
272
|
key: "deleteSyncBlocksWithConfirmation",
|
|
280
273
|
value: function () {
|
|
281
|
-
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(
|
|
274
|
+
var _deleteSyncBlocksWithConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(syncBlockIds, deleteCallback) {
|
|
282
275
|
var _this5 = this;
|
|
283
|
-
var confirmed,
|
|
276
|
+
var confirmed, results, callback, _this$fireAnalyticsEv4;
|
|
284
277
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
285
278
|
while (1) switch (_context2.prev = _context2.next) {
|
|
286
279
|
case 0:
|
|
287
280
|
if (!this.confirmationCallback) {
|
|
288
|
-
_context2.next =
|
|
281
|
+
_context2.next = 22;
|
|
289
282
|
break;
|
|
290
283
|
}
|
|
291
|
-
|
|
292
|
-
_context2.next = 4;
|
|
284
|
+
_context2.next = 3;
|
|
293
285
|
return this.confirmationCallback(syncBlockIds.length);
|
|
294
|
-
case
|
|
286
|
+
case 3:
|
|
295
287
|
confirmed = _context2.sent;
|
|
296
288
|
if (!confirmed) {
|
|
297
|
-
_context2.next =
|
|
289
|
+
_context2.next = 22;
|
|
298
290
|
break;
|
|
299
291
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// bodiedSyncBlock deletion is expected to be permanent (cannot be undo)
|
|
303
|
-
// For a normal delete (not triggered by undo), remove it from history so that it cannot be undone
|
|
304
|
-
trToDispatch.setMeta('addToHistory', false);
|
|
305
|
-
}
|
|
306
|
-
(_this$editorView = this.editorView) === null || _this$editorView === void 0 || _this$editorView.dispatch(trToDispatch);
|
|
307
|
-
_context2.prev = 9;
|
|
292
|
+
deleteCallback();
|
|
293
|
+
_context2.prev = 6;
|
|
308
294
|
if (this.dataProvider) {
|
|
309
|
-
_context2.next =
|
|
295
|
+
_context2.next = 9;
|
|
310
296
|
break;
|
|
311
297
|
}
|
|
312
298
|
throw new Error('Data provider not set');
|
|
313
|
-
case
|
|
299
|
+
case 9:
|
|
314
300
|
syncBlockIds.forEach(function (Ids) {
|
|
315
301
|
_this5.setPendingDeletion(Ids, true);
|
|
316
302
|
});
|
|
317
|
-
_context2.next =
|
|
303
|
+
_context2.next = 12;
|
|
318
304
|
return this.dataProvider.deleteNodesData(syncBlockIds.map(function (attrs) {
|
|
319
305
|
return attrs.resourceId;
|
|
320
306
|
}));
|
|
321
|
-
case
|
|
307
|
+
case 12:
|
|
322
308
|
results = _context2.sent;
|
|
323
309
|
if (results.every(function (result) {
|
|
324
310
|
return result.success;
|
|
@@ -338,11 +324,11 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
338
324
|
});
|
|
339
325
|
}
|
|
340
326
|
syncBlockIds.forEach(callback);
|
|
341
|
-
_context2.next =
|
|
327
|
+
_context2.next = 22;
|
|
342
328
|
break;
|
|
343
|
-
case
|
|
344
|
-
_context2.prev =
|
|
345
|
-
_context2.t0 = _context2["catch"](
|
|
329
|
+
case 17:
|
|
330
|
+
_context2.prev = 17;
|
|
331
|
+
_context2.t0 = _context2["catch"](6);
|
|
346
332
|
syncBlockIds.forEach(function (Ids) {
|
|
347
333
|
_this5.setPendingDeletion(Ids, false);
|
|
348
334
|
});
|
|
@@ -350,38 +336,25 @@ export var SourceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
350
336
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
351
337
|
});
|
|
352
338
|
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, deleteErrorPayload(_context2.t0.message));
|
|
353
|
-
case
|
|
354
|
-
this.confirmationTransaction = undefined;
|
|
355
|
-
case 26:
|
|
339
|
+
case 22:
|
|
356
340
|
case "end":
|
|
357
341
|
return _context2.stop();
|
|
358
342
|
}
|
|
359
|
-
}, _callee2, this, [[
|
|
343
|
+
}, _callee2, this, [[6, 17]]);
|
|
360
344
|
}));
|
|
361
345
|
function deleteSyncBlocksWithConfirmation(_x, _x2) {
|
|
362
346
|
return _deleteSyncBlocksWithConfirmation.apply(this, arguments);
|
|
363
347
|
}
|
|
364
348
|
return deleteSyncBlocksWithConfirmation;
|
|
365
349
|
}()
|
|
366
|
-
}, {
|
|
367
|
-
key: "rebaseTransaction",
|
|
368
|
-
value: function rebaseTransaction(incomingTr, state) {
|
|
369
|
-
if (!this.confirmationTransaction) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
this.confirmationTransaction = _rebaseTransaction(this.confirmationTransaction, incomingTr, state);
|
|
373
|
-
}
|
|
374
350
|
}, {
|
|
375
351
|
key: "destroy",
|
|
376
352
|
value: function destroy() {
|
|
377
353
|
this.syncBlockCache.clear();
|
|
378
354
|
this.confirmationCallback = undefined;
|
|
379
|
-
this.confirmationTransaction = undefined;
|
|
380
355
|
this.pendingResourceId = undefined;
|
|
381
356
|
this.creationCallback = undefined;
|
|
382
357
|
this.dataProvider = undefined;
|
|
383
|
-
this.editorView = undefined;
|
|
384
|
-
this.fireAnalyticsEvent = undefined;
|
|
385
358
|
}
|
|
386
359
|
}]);
|
|
387
360
|
}();
|
|
@@ -10,6 +10,58 @@ export type BlockContentResponse = {
|
|
|
10
10
|
status: 'active' | 'deleted';
|
|
11
11
|
version: number;
|
|
12
12
|
};
|
|
13
|
+
export type BlockContentErrorResponse = {
|
|
14
|
+
blockAri: string;
|
|
15
|
+
code: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const isBlockContentResponse: (response: BlockContentResponse | BlockContentErrorResponse) => response is BlockContentResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves all synced blocks referenced in a document.
|
|
21
|
+
*
|
|
22
|
+
* Calls the Block Service API endpoint: `/v1/block/document/reference/{documentAri}`
|
|
23
|
+
*
|
|
24
|
+
* @param documentAri - The ARI of the document to fetch synced blocks for
|
|
25
|
+
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const { blocks, errors } = await getReferenceSyncedBlocks(
|
|
30
|
+
* 'ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888'
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Example response:
|
|
35
|
+
* ```json
|
|
36
|
+
* {
|
|
37
|
+
* "blocks": [
|
|
38
|
+
* {
|
|
39
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
40
|
+
* "version": 1,
|
|
41
|
+
* "sourceDocumentAri": "ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888",
|
|
42
|
+
* "blockInstanceId": "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
43
|
+
* "content": "string",
|
|
44
|
+
* "status": "active",
|
|
45
|
+
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
46
|
+
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
47
|
+
* "updatedAt": "2025-10-08T10:30:00.000Z"
|
|
48
|
+
* }
|
|
49
|
+
* ],
|
|
50
|
+
* "errors": [
|
|
51
|
+
* {
|
|
52
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
53
|
+
* "code": "error",
|
|
54
|
+
* "reason": "some error reason"
|
|
55
|
+
* }
|
|
56
|
+
* ]
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
* Check https://block-service.dev.atl-paas.net/ for latest API documentation.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getReferenceSyncedBlocks: (documentAri: string) => Promise<{
|
|
62
|
+
blocks?: Array<BlockContentResponse>;
|
|
63
|
+
errors?: Array<BlockContentErrorResponse>;
|
|
64
|
+
}>;
|
|
13
65
|
export type GetSyncedBlockContentRequest = {
|
|
14
66
|
blockAri: string;
|
|
15
67
|
};
|
|
@@ -15,7 +15,8 @@ export interface SyncBlockNode extends JSONNode {
|
|
|
15
15
|
export declare enum SyncBlockError {
|
|
16
16
|
Errored = "errored",
|
|
17
17
|
NotFound = "not_found",
|
|
18
|
-
Forbidden = "forbidden"
|
|
18
|
+
Forbidden = "forbidden",
|
|
19
|
+
InvalidContent = "invalid_content"
|
|
19
20
|
}
|
|
20
21
|
export interface SyncBlockData {
|
|
21
22
|
blockInstanceId: BlockInstanceId;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlo
|
|
|
15
15
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
16
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
17
17
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, } from './utils/utils';
|
|
18
|
+
export { fetchReferences } from './providers/block-service/blockServiceAPI';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
1
|
+
import { SyncBlockError, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
3
4
|
/**
|
|
4
5
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
6
|
*/
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { type SyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
3
|
import type { ResourceId, SyncBlockAttrs } from '../common/types';
|
|
6
4
|
import type { SyncBlockDataProvider } from '../providers/types';
|
|
7
5
|
export type ConfirmationCallback = (syncBlockCount: number) => Promise<boolean>;
|
|
8
6
|
export type CreationCallback = () => void;
|
|
9
7
|
export declare class SourceSyncBlockStoreManager {
|
|
10
8
|
private dataProvider?;
|
|
11
|
-
private editorView?;
|
|
12
9
|
private fireAnalyticsEvent?;
|
|
13
10
|
private syncBlockCache;
|
|
14
11
|
private confirmationCallback?;
|
|
15
|
-
private confirmationTransaction?;
|
|
16
12
|
private pendingResourceId?;
|
|
17
13
|
private creationCallback?;
|
|
18
14
|
constructor(dataProvider?: SyncBlockDataProvider, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void);
|
|
@@ -28,7 +24,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
28
24
|
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
29
25
|
*/
|
|
30
26
|
flush(): Promise<boolean>;
|
|
31
|
-
setEditorView(editorView: EditorView | undefined): void;
|
|
32
27
|
registerPendingCreation(resourceId: ResourceId): void;
|
|
33
28
|
/**
|
|
34
29
|
* Register callback function (which inserts node, handles focus etc) to be used later when creation to backend succeed
|
|
@@ -56,7 +51,6 @@ export declare class SourceSyncBlockStoreManager {
|
|
|
56
51
|
*/
|
|
57
52
|
createBodiedSyncBlockNode(attrs: SyncBlockAttrs): void;
|
|
58
53
|
private setPendingDeletion;
|
|
59
|
-
deleteSyncBlocksWithConfirmation(
|
|
60
|
-
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
54
|
+
deleteSyncBlocksWithConfirmation(syncBlockIds: SyncBlockAttrs[], deleteCallback: () => void): Promise<void>;
|
|
61
55
|
destroy(): void;
|
|
62
56
|
}
|
|
@@ -10,6 +10,58 @@ export type BlockContentResponse = {
|
|
|
10
10
|
status: 'active' | 'deleted';
|
|
11
11
|
version: number;
|
|
12
12
|
};
|
|
13
|
+
export type BlockContentErrorResponse = {
|
|
14
|
+
blockAri: string;
|
|
15
|
+
code: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const isBlockContentResponse: (response: BlockContentResponse | BlockContentErrorResponse) => response is BlockContentResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves all synced blocks referenced in a document.
|
|
21
|
+
*
|
|
22
|
+
* Calls the Block Service API endpoint: `/v1/block/document/reference/{documentAri}`
|
|
23
|
+
*
|
|
24
|
+
* @param documentAri - The ARI of the document to fetch synced blocks for
|
|
25
|
+
* @returns A promise containing arrays of successfully fetched blocks and any errors encountered
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const { blocks, errors } = await getReferenceSyncedBlocks(
|
|
30
|
+
* 'ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888'
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Example response:
|
|
35
|
+
* ```json
|
|
36
|
+
* {
|
|
37
|
+
* "blocks": [
|
|
38
|
+
* {
|
|
39
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
40
|
+
* "version": 1,
|
|
41
|
+
* "sourceDocumentAri": "ari:cloud:confluence:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:page/88888888",
|
|
42
|
+
* "blockInstanceId": "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
43
|
+
* "content": "string",
|
|
44
|
+
* "status": "active",
|
|
45
|
+
* "createdAt": "2025-10-08T10:30:00.000Z",
|
|
46
|
+
* "createdBy": "557058:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
47
|
+
* "updatedAt": "2025-10-08T10:30:00.000Z"
|
|
48
|
+
* }
|
|
49
|
+
* ],
|
|
50
|
+
* "errors": [
|
|
51
|
+
* {
|
|
52
|
+
* "blockAri": "ari:cloud:blocks:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx:synced-block/xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
53
|
+
* "code": "error",
|
|
54
|
+
* "reason": "some error reason"
|
|
55
|
+
* }
|
|
56
|
+
* ]
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
* Check https://block-service.dev.atl-paas.net/ for latest API documentation.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getReferenceSyncedBlocks: (documentAri: string) => Promise<{
|
|
62
|
+
blocks?: Array<BlockContentResponse>;
|
|
63
|
+
errors?: Array<BlockContentErrorResponse>;
|
|
64
|
+
}>;
|
|
13
65
|
export type GetSyncedBlockContentRequest = {
|
|
14
66
|
blockAri: string;
|
|
15
67
|
};
|
|
@@ -15,7 +15,8 @@ export interface SyncBlockNode extends JSONNode {
|
|
|
15
15
|
export declare enum SyncBlockError {
|
|
16
16
|
Errored = "errored",
|
|
17
17
|
NotFound = "not_found",
|
|
18
|
-
Forbidden = "forbidden"
|
|
18
|
+
Forbidden = "forbidden",
|
|
19
|
+
InvalidContent = "invalid_content"
|
|
19
20
|
}
|
|
20
21
|
export interface SyncBlockData {
|
|
21
22
|
blockInstanceId: BlockInstanceId;
|
|
@@ -15,3 +15,4 @@ export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlo
|
|
|
15
15
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
16
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
17
17
|
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, } from './utils/utils';
|
|
18
|
+
export { fetchReferences } from './providers/block-service/blockServiceAPI';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
1
|
+
import { SyncBlockError, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, WriteSyncBlockResult } from '../types';
|
|
3
|
+
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
3
4
|
/**
|
|
4
5
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
5
6
|
*/
|