@atlaskit/editor-synced-block-provider 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/hooks/useFetchSyncBlockTitle.js +24 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/providers/syncBlockProvider.js +12 -15
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +58 -8
- package/dist/cjs/store-manager/syncBlockStoreManager.js +5 -0
- package/dist/cjs/utils/resolveSyncBlockInstance.js +4 -3
- package/dist/es2019/hooks/useFetchSyncBlockTitle.js +13 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/providers/syncBlockProvider.js +10 -8
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +56 -7
- package/dist/es2019/store-manager/syncBlockStoreManager.js +3 -0
- package/dist/es2019/utils/resolveSyncBlockInstance.js +4 -3
- package/dist/esm/hooks/useFetchSyncBlockTitle.js +17 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/providers/syncBlockProvider.js +12 -15
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +58 -8
- package/dist/esm/store-manager/syncBlockStoreManager.js +5 -0
- package/dist/esm/utils/resolveSyncBlockInstance.js +4 -3
- package/dist/types/common/types.d.ts +1 -0
- package/dist/types/hooks/useFetchSyncBlockTitle.d.ts +3 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types/providers/types.d.ts +6 -1
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +5 -2
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +2 -1
- package/dist/types-ts4.5/common/types.d.ts +1 -0
- package/dist/types-ts4.5/hooks/useFetchSyncBlockTitle.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +2 -2
- package/dist/types-ts4.5/providers/types.d.ts +6 -1
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +5 -2
- package/dist/types-ts4.5/store-manager/syncBlockStoreManager.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 2.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7e3353721fa66`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7e3353721fa66) -
|
|
8
|
+
[ux] EDITOR-1822 update sync blocks ui to new design
|
|
9
|
+
|
|
10
|
+
## 2.5.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`ff3e1422d5b70`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ff3e1422d5b70) -
|
|
15
|
+
[ux] EDITOR-2437 implement request access to sync block component
|
|
16
|
+
|
|
3
17
|
## 2.5.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useFetchSyncBlockTitle = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var useFetchSyncBlockTitle = exports.useFetchSyncBlockTitle = function useFetchSyncBlockTitle(manager, syncBlockNode) {
|
|
11
|
+
var _useState = (0, _react.useState)(undefined),
|
|
12
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
13
|
+
sourceTitle = _useState2[0],
|
|
14
|
+
setSourceTitle = _useState2[1];
|
|
15
|
+
(0, _react.useEffect)(function () {
|
|
16
|
+
var unsubscribe = manager.subscribeToSyncBlockSourceTitle(syncBlockNode, function (title) {
|
|
17
|
+
setSourceTitle(title);
|
|
18
|
+
});
|
|
19
|
+
return function () {
|
|
20
|
+
unsubscribe();
|
|
21
|
+
};
|
|
22
|
+
}, [manager, syncBlockNode]);
|
|
23
|
+
return sourceTitle;
|
|
24
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -45,6 +45,12 @@ Object.defineProperty(exports, "getDefaultSyncBlockSchema", {
|
|
|
45
45
|
return _schema.getDefaultSyncBlockSchema;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "getPageIdAndTypeFromAri", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _ari.getPageIdAndTypeFromAri;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
48
54
|
Object.defineProperty(exports, "rebaseTransaction", {
|
|
49
55
|
enumerable: true,
|
|
50
56
|
get: function get() {
|
|
@@ -63,6 +69,12 @@ Object.defineProperty(exports, "useFetchSyncBlockData", {
|
|
|
63
69
|
return _useFetchSyncBlockData.useFetchSyncBlockData;
|
|
64
70
|
}
|
|
65
71
|
});
|
|
72
|
+
Object.defineProperty(exports, "useFetchSyncBlockTitle", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _useFetchSyncBlockTitle.useFetchSyncBlockTitle;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
66
78
|
Object.defineProperty(exports, "useHandleContentChanges", {
|
|
67
79
|
enumerable: true,
|
|
68
80
|
get: function get() {
|
|
@@ -84,6 +96,7 @@ Object.defineProperty(exports, "useMemoizedSyncedBlockProvider", {
|
|
|
84
96
|
var _syncBlockProvider = require("./providers/syncBlockProvider");
|
|
85
97
|
var _syncBlockStoreManager = require("./store-manager/syncBlockStoreManager");
|
|
86
98
|
var _useFetchSyncBlockData = require("./hooks/useFetchSyncBlockData");
|
|
99
|
+
var _useFetchSyncBlockTitle = require("./hooks/useFetchSyncBlockTitle");
|
|
87
100
|
var _useHandleContentChanges = require("./hooks/useHandleContentChanges");
|
|
88
101
|
var _types = require("./common/types");
|
|
89
102
|
var _schema = require("./common/schema");
|
|
@@ -133,8 +133,8 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
133
133
|
return this.sourceId;
|
|
134
134
|
}
|
|
135
135
|
}, {
|
|
136
|
-
key: "
|
|
137
|
-
value: function
|
|
136
|
+
key: "retrieveSyncBlockSourceUrlAndTitle",
|
|
137
|
+
value: function retrieveSyncBlockSourceUrlAndTitle(node) {
|
|
138
138
|
var resourceId = node.attrs.resourceId;
|
|
139
139
|
var pageARI;
|
|
140
140
|
var sourceLocalId;
|
|
@@ -150,7 +150,7 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
|
|
|
150
150
|
// EDITOR-1921: log analytic here, safe to continue
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
return pageARI ?
|
|
153
|
+
return pageARI ? fetchURLandTitlefromARI(pageARI, sourceLocalId) : Promise.resolve(undefined);
|
|
154
154
|
}
|
|
155
155
|
}]);
|
|
156
156
|
}(_types2.SyncBlockDataProvider);
|
|
@@ -159,9 +159,9 @@ var useMemoizedSyncedBlockProvider = exports.useMemoizedSyncedBlockProvider = fu
|
|
|
159
159
|
return new SyncBlockProvider(fetchProvider, writeProvider, sourceId);
|
|
160
160
|
}, [fetchProvider, writeProvider, sourceId]);
|
|
161
161
|
};
|
|
162
|
-
var
|
|
162
|
+
var fetchURLandTitlefromARI = /*#__PURE__*/function () {
|
|
163
163
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(ari, sourceLocalId) {
|
|
164
|
-
var response, _payload$data, payload, url;
|
|
164
|
+
var response, _payload$data, _payload$data2, payload, url, title;
|
|
165
165
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
166
166
|
while (1) switch (_context2.prev = _context2.next) {
|
|
167
167
|
case 0:
|
|
@@ -187,17 +187,14 @@ var fetchURLfromARI = /*#__PURE__*/function () {
|
|
|
187
187
|
case 6:
|
|
188
188
|
payload = _context2.sent;
|
|
189
189
|
url = payload === null || payload === void 0 || (_payload$data = payload.data) === null || _payload$data === void 0 ? void 0 : _payload$data.url;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
case 10:
|
|
196
|
-
_context2.next = 13;
|
|
197
|
-
break;
|
|
190
|
+
title = payload === null || payload === void 0 || (_payload$data2 = payload.data) === null || _payload$data2 === void 0 ? void 0 : _payload$data2.name;
|
|
191
|
+
return _context2.abrupt("return", {
|
|
192
|
+
url: typeof url === 'string' ? sourceLocalId ? url + "?block=".concat(sourceLocalId) : url : undefined,
|
|
193
|
+
title: typeof title === 'string' ? title : undefined
|
|
194
|
+
});
|
|
198
195
|
case 12:
|
|
199
196
|
//eslint-disable-next-line no-console
|
|
200
|
-
console.error('Failed to fetch URL from ARI', response.statusText);
|
|
197
|
+
console.error('Failed to fetch URL and title from ARI', response.statusText);
|
|
201
198
|
case 13:
|
|
202
199
|
return _context2.abrupt("return", undefined);
|
|
203
200
|
case 14:
|
|
@@ -206,7 +203,7 @@ var fetchURLfromARI = /*#__PURE__*/function () {
|
|
|
206
203
|
}
|
|
207
204
|
}, _callee2);
|
|
208
205
|
}));
|
|
209
|
-
return function
|
|
206
|
+
return function fetchURLandTitlefromARI(_x2, _x3) {
|
|
210
207
|
return _ref.apply(this, arguments);
|
|
211
208
|
};
|
|
212
209
|
}();
|
|
@@ -24,6 +24,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
24
24
|
(0, _defineProperty2.default)(this, "isRefreshingSubscriptions", false);
|
|
25
25
|
this.syncBlockCache = new Map();
|
|
26
26
|
this.subscriptions = new Map();
|
|
27
|
+
this.titleSubscriptions = new Map();
|
|
27
28
|
this.dataProvider = dataProvider;
|
|
28
29
|
this.syncBlockURLRequests = new Map();
|
|
29
30
|
}
|
|
@@ -112,8 +113,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
112
113
|
return refreshSubscriptions;
|
|
113
114
|
}())
|
|
114
115
|
}, {
|
|
115
|
-
key: "
|
|
116
|
-
value: function
|
|
116
|
+
key: "fetchSyncBlockSourceURLAndTitle",
|
|
117
|
+
value: function fetchSyncBlockSourceURLAndTitle(resourceId) {
|
|
117
118
|
var _this = this;
|
|
118
119
|
if (!resourceId || !this.dataProvider) {
|
|
119
120
|
return;
|
|
@@ -123,13 +124,17 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
123
124
|
// we could optimise this further by checking if the sync block is on the same page as the source
|
|
124
125
|
if (!this.syncBlockURLRequests.get(resourceId)) {
|
|
125
126
|
this.syncBlockURLRequests.set(resourceId, true);
|
|
126
|
-
this.dataProvider.
|
|
127
|
+
this.dataProvider.retrieveSyncBlockSourceUrlAndTitle((0, _createSyncBlock.createSyncBlockNode)('', resourceId)).then(function (sourceInfo) {
|
|
127
128
|
var existingSyncBlock = _this.getFromCache(resourceId);
|
|
128
129
|
if (existingSyncBlock && existingSyncBlock.data) {
|
|
129
130
|
existingSyncBlock.data = _objectSpread(_objectSpread({}, existingSyncBlock.data), {}, {
|
|
130
|
-
sourceURL:
|
|
131
|
+
sourceURL: sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url,
|
|
132
|
+
sourceTitle: sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.title
|
|
131
133
|
});
|
|
132
134
|
_this.updateCache(existingSyncBlock);
|
|
135
|
+
if (sourceInfo !== null && sourceInfo !== void 0 && sourceInfo.title) {
|
|
136
|
+
_this.updateSourceTitleSubscriptions(existingSyncBlock.resourceId, sourceInfo.title);
|
|
137
|
+
}
|
|
133
138
|
}
|
|
134
139
|
}).finally(function () {
|
|
135
140
|
_this.syncBlockURLRequests.set(resourceId, false);
|
|
@@ -163,7 +168,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
163
168
|
case 7:
|
|
164
169
|
resolvedData = [];
|
|
165
170
|
data.forEach(function (syncBlockInstance) {
|
|
166
|
-
var _resolvedSyncBlockIns;
|
|
171
|
+
var _resolvedSyncBlockIns, _resolvedSyncBlockIns2;
|
|
167
172
|
if (!syncBlockInstance.resourceId) {
|
|
168
173
|
return;
|
|
169
174
|
}
|
|
@@ -172,9 +177,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
172
177
|
_this2.updateCache(resolvedSyncBlockInstance);
|
|
173
178
|
resolvedData.push(resolvedSyncBlockInstance);
|
|
174
179
|
|
|
175
|
-
// fetch source URL if not already present
|
|
176
|
-
if (!((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns !== void 0 && _resolvedSyncBlockIns.sourceURL) && resolvedSyncBlockInstance.resourceId) {
|
|
177
|
-
_this2.
|
|
180
|
+
// fetch source URL and title if not already present
|
|
181
|
+
if ((!((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns !== void 0 && _resolvedSyncBlockIns.sourceURL) || !((_resolvedSyncBlockIns2 = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns2 !== void 0 && _resolvedSyncBlockIns2.sourceTitle)) && resolvedSyncBlockInstance.resourceId) {
|
|
182
|
+
_this2.fetchSyncBlockSourceURLAndTitle(resolvedSyncBlockInstance.resourceId);
|
|
178
183
|
}
|
|
179
184
|
});
|
|
180
185
|
return _context3.abrupt("return", resolvedData);
|
|
@@ -203,6 +208,16 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
203
208
|
}
|
|
204
209
|
}
|
|
205
210
|
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "updateSourceTitleSubscriptions",
|
|
213
|
+
value: function updateSourceTitleSubscriptions(resourceId, title) {
|
|
214
|
+
var callbacks = this.titleSubscriptions.get(resourceId);
|
|
215
|
+
if (callbacks) {
|
|
216
|
+
Object.values(callbacks).forEach(function (callback) {
|
|
217
|
+
callback(title);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
206
221
|
}, {
|
|
207
222
|
key: "getFromCache",
|
|
208
223
|
value: function getFromCache(resourceId) {
|
|
@@ -252,6 +267,41 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
252
267
|
}
|
|
253
268
|
};
|
|
254
269
|
}
|
|
270
|
+
}, {
|
|
271
|
+
key: "subscribeToSourceTitle",
|
|
272
|
+
value: function subscribeToSourceTitle(node, callback) {
|
|
273
|
+
var _cachedData$data,
|
|
274
|
+
_this4 = this;
|
|
275
|
+
// check node is a sync block, as we only support sync block subscriptions
|
|
276
|
+
if (node.type.name !== 'syncBlock') {
|
|
277
|
+
return function () {};
|
|
278
|
+
}
|
|
279
|
+
var _node$attrs2 = node.attrs,
|
|
280
|
+
resourceId = _node$attrs2.resourceId,
|
|
281
|
+
localId = _node$attrs2.localId;
|
|
282
|
+
if (!localId || !resourceId) {
|
|
283
|
+
return function () {};
|
|
284
|
+
}
|
|
285
|
+
var cachedData = this.getFromCache(resourceId);
|
|
286
|
+
if (cachedData !== null && cachedData !== void 0 && (_cachedData$data = cachedData.data) !== null && _cachedData$data !== void 0 && _cachedData$data.sourceTitle) {
|
|
287
|
+
callback(cachedData.data.sourceTitle);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// add to subscriptions map
|
|
291
|
+
var resourceSubscriptions = this.titleSubscriptions.get(resourceId) || {};
|
|
292
|
+
this.titleSubscriptions.set(resourceId, _objectSpread(_objectSpread({}, resourceSubscriptions), {}, (0, _defineProperty2.default)({}, localId, callback)));
|
|
293
|
+
return function () {
|
|
294
|
+
var resourceSubscriptions = _this4.titleSubscriptions.get(resourceId);
|
|
295
|
+
if (resourceSubscriptions) {
|
|
296
|
+
delete resourceSubscriptions[localId];
|
|
297
|
+
if (Object.keys(resourceSubscriptions).length === 0) {
|
|
298
|
+
_this4.titleSubscriptions.delete(resourceId);
|
|
299
|
+
} else {
|
|
300
|
+
_this4.titleSubscriptions.set(resourceId, resourceSubscriptions);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
255
305
|
|
|
256
306
|
/**
|
|
257
307
|
* Get the URL for a sync block.
|
|
@@ -111,6 +111,11 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
111
111
|
value: function subscribeToSyncBlockData(node, callback) {
|
|
112
112
|
return this.referenceSyncBlockStoreManager.subscribe(node, callback);
|
|
113
113
|
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "subscribeToSyncBlockSourceTitle",
|
|
116
|
+
value: function subscribeToSyncBlockSourceTitle(node, callback) {
|
|
117
|
+
return this.referenceSyncBlockStoreManager.subscribeToSourceTitle(node, callback);
|
|
118
|
+
}
|
|
114
119
|
}, {
|
|
115
120
|
key: "refreshSubscriptions",
|
|
116
121
|
value: function refreshSubscriptions() {
|
|
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
19
19
|
* @returns A merged SyncBlockInstance object.
|
|
20
20
|
*/
|
|
21
21
|
var resolveSyncBlockInstance = exports.resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResult, newResult) {
|
|
22
|
-
var _newResult$data, _oldResult$data;
|
|
22
|
+
var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2;
|
|
23
23
|
// if the old result has no data, we simple return the new result
|
|
24
24
|
if (!oldResult.data) {
|
|
25
25
|
return newResult;
|
|
@@ -29,10 +29,11 @@ var resolveSyncBlockInstance = exports.resolveSyncBlockInstance = function resol
|
|
|
29
29
|
return oldResult;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// otherwise, we merge the two results, preserving the sourceURL from the old result if it exists
|
|
32
|
+
// otherwise, we merge the two results, preserving the sourceURL and sourceTitle from the old result if it exists
|
|
33
33
|
return _objectSpread(_objectSpread({}, newResult), {}, {
|
|
34
34
|
data: _objectSpread(_objectSpread({}, newResult.data), {}, {
|
|
35
|
-
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined
|
|
35
|
+
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
|
|
36
|
+
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined
|
|
36
37
|
})
|
|
37
38
|
});
|
|
38
39
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export const useFetchSyncBlockTitle = (manager, syncBlockNode) => {
|
|
3
|
+
const [sourceTitle, setSourceTitle] = useState(undefined);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const unsubscribe = manager.subscribeToSyncBlockSourceTitle(syncBlockNode, title => {
|
|
6
|
+
setSourceTitle(title);
|
|
7
|
+
});
|
|
8
|
+
return () => {
|
|
9
|
+
unsubscribe();
|
|
10
|
+
};
|
|
11
|
+
}, [manager, syncBlockNode]);
|
|
12
|
+
return sourceTitle;
|
|
13
|
+
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
|
|
4
4
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
5
5
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
6
|
+
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
7
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
8
|
export { SyncBlockError } from './common/types';
|
|
8
9
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
9
10
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders } from './providers/confluence/confluenceContentAPI';
|
|
10
|
-
export { getConfluencePageAri } from './utils/ari';
|
|
11
|
+
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
11
12
|
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
12
13
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
13
14
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -72,7 +72,7 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
72
72
|
getSourceId() {
|
|
73
73
|
return this.sourceId;
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
retrieveSyncBlockSourceUrlAndTitle(node) {
|
|
76
76
|
const {
|
|
77
77
|
resourceId
|
|
78
78
|
} = node.attrs;
|
|
@@ -90,7 +90,7 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
90
90
|
// EDITOR-1921: log analytic here, safe to continue
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
return pageARI ?
|
|
93
|
+
return pageARI ? fetchURLandTitlefromARI(pageARI, sourceLocalId) : Promise.resolve(undefined);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
export const useMemoizedSyncedBlockProvider = (fetchProvider, writeProvider, sourceId) => {
|
|
@@ -98,7 +98,7 @@ export const useMemoizedSyncedBlockProvider = (fetchProvider, writeProvider, sou
|
|
|
98
98
|
return new SyncBlockProvider(fetchProvider, writeProvider, sourceId);
|
|
99
99
|
}, [fetchProvider, writeProvider, sourceId]);
|
|
100
100
|
};
|
|
101
|
-
const
|
|
101
|
+
const fetchURLandTitlefromARI = async (ari, sourceLocalId) => {
|
|
102
102
|
const response = await fetch('/gateway/api/object-resolver/resolve/ari', {
|
|
103
103
|
method: 'POST',
|
|
104
104
|
headers: {
|
|
@@ -110,15 +110,17 @@ const fetchURLfromARI = async (ari, sourceLocalId) => {
|
|
|
110
110
|
})
|
|
111
111
|
});
|
|
112
112
|
if (response.ok) {
|
|
113
|
-
var _payload$data;
|
|
113
|
+
var _payload$data, _payload$data2;
|
|
114
114
|
const payload = await response.json();
|
|
115
115
|
const url = payload === null || payload === void 0 ? void 0 : (_payload$data = payload.data) === null || _payload$data === void 0 ? void 0 : _payload$data.url;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
const title = payload === null || payload === void 0 ? void 0 : (_payload$data2 = payload.data) === null || _payload$data2 === void 0 ? void 0 : _payload$data2.name;
|
|
117
|
+
return {
|
|
118
|
+
url: typeof url === 'string' ? sourceLocalId ? url + `?block=${sourceLocalId}` : url : undefined,
|
|
119
|
+
title: typeof title === 'string' ? title : undefined
|
|
120
|
+
};
|
|
119
121
|
} else {
|
|
120
122
|
//eslint-disable-next-line no-console
|
|
121
|
-
console.error('Failed to fetch URL from ARI', response.statusText);
|
|
123
|
+
console.error('Failed to fetch URL and title from ARI', response.statusText);
|
|
122
124
|
}
|
|
123
125
|
return undefined;
|
|
124
126
|
};
|
|
@@ -6,6 +6,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
6
6
|
_defineProperty(this, "isRefreshingSubscriptions", false);
|
|
7
7
|
this.syncBlockCache = new Map();
|
|
8
8
|
this.subscriptions = new Map();
|
|
9
|
+
this.titleSubscriptions = new Map();
|
|
9
10
|
this.dataProvider = dataProvider;
|
|
10
11
|
this.syncBlockURLRequests = new Map();
|
|
11
12
|
}
|
|
@@ -35,7 +36,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
35
36
|
this.isRefreshingSubscriptions = false;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
fetchSyncBlockSourceURLAndTitle(resourceId) {
|
|
39
40
|
if (!resourceId || !this.dataProvider) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
@@ -44,14 +45,18 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
44
45
|
// we could optimise this further by checking if the sync block is on the same page as the source
|
|
45
46
|
if (!this.syncBlockURLRequests.get(resourceId)) {
|
|
46
47
|
this.syncBlockURLRequests.set(resourceId, true);
|
|
47
|
-
this.dataProvider.
|
|
48
|
+
this.dataProvider.retrieveSyncBlockSourceUrlAndTitle(createSyncBlockNode('', resourceId)).then(sourceInfo => {
|
|
48
49
|
const existingSyncBlock = this.getFromCache(resourceId);
|
|
49
50
|
if (existingSyncBlock && existingSyncBlock.data) {
|
|
50
51
|
existingSyncBlock.data = {
|
|
51
52
|
...existingSyncBlock.data,
|
|
52
|
-
sourceURL
|
|
53
|
+
sourceURL: sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url,
|
|
54
|
+
sourceTitle: sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.title
|
|
53
55
|
};
|
|
54
56
|
this.updateCache(existingSyncBlock);
|
|
57
|
+
if (sourceInfo !== null && sourceInfo !== void 0 && sourceInfo.title) {
|
|
58
|
+
this.updateSourceTitleSubscriptions(existingSyncBlock.resourceId, sourceInfo.title);
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
61
|
}).finally(() => {
|
|
57
62
|
this.syncBlockURLRequests.set(resourceId, false);
|
|
@@ -68,7 +73,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
68
73
|
}
|
|
69
74
|
const resolvedData = [];
|
|
70
75
|
data.forEach(syncBlockInstance => {
|
|
71
|
-
var _resolvedSyncBlockIns;
|
|
76
|
+
var _resolvedSyncBlockIns, _resolvedSyncBlockIns2;
|
|
72
77
|
if (!syncBlockInstance.resourceId) {
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
@@ -77,9 +82,9 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
77
82
|
this.updateCache(resolvedSyncBlockInstance);
|
|
78
83
|
resolvedData.push(resolvedSyncBlockInstance);
|
|
79
84
|
|
|
80
|
-
// fetch source URL if not already present
|
|
81
|
-
if (!((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns !== void 0 && _resolvedSyncBlockIns.sourceURL) && resolvedSyncBlockInstance.resourceId) {
|
|
82
|
-
this.
|
|
85
|
+
// fetch source URL and title if not already present
|
|
86
|
+
if ((!((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns !== void 0 && _resolvedSyncBlockIns.sourceURL) || !((_resolvedSyncBlockIns2 = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns2 !== void 0 && _resolvedSyncBlockIns2.sourceTitle)) && resolvedSyncBlockInstance.resourceId) {
|
|
87
|
+
this.fetchSyncBlockSourceURLAndTitle(resolvedSyncBlockInstance.resourceId);
|
|
83
88
|
}
|
|
84
89
|
});
|
|
85
90
|
return resolvedData;
|
|
@@ -98,6 +103,14 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
}
|
|
106
|
+
updateSourceTitleSubscriptions(resourceId, title) {
|
|
107
|
+
const callbacks = this.titleSubscriptions.get(resourceId);
|
|
108
|
+
if (callbacks) {
|
|
109
|
+
Object.values(callbacks).forEach(callback => {
|
|
110
|
+
callback(title);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
101
114
|
getFromCache(resourceId) {
|
|
102
115
|
return this.syncBlockCache.get(resourceId);
|
|
103
116
|
}
|
|
@@ -144,6 +157,42 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
144
157
|
}
|
|
145
158
|
};
|
|
146
159
|
}
|
|
160
|
+
subscribeToSourceTitle(node, callback) {
|
|
161
|
+
var _cachedData$data;
|
|
162
|
+
// check node is a sync block, as we only support sync block subscriptions
|
|
163
|
+
if (node.type.name !== 'syncBlock') {
|
|
164
|
+
return () => {};
|
|
165
|
+
}
|
|
166
|
+
const {
|
|
167
|
+
resourceId,
|
|
168
|
+
localId
|
|
169
|
+
} = node.attrs;
|
|
170
|
+
if (!localId || !resourceId) {
|
|
171
|
+
return () => {};
|
|
172
|
+
}
|
|
173
|
+
const cachedData = this.getFromCache(resourceId);
|
|
174
|
+
if (cachedData !== null && cachedData !== void 0 && (_cachedData$data = cachedData.data) !== null && _cachedData$data !== void 0 && _cachedData$data.sourceTitle) {
|
|
175
|
+
callback(cachedData.data.sourceTitle);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// add to subscriptions map
|
|
179
|
+
const resourceSubscriptions = this.titleSubscriptions.get(resourceId) || {};
|
|
180
|
+
this.titleSubscriptions.set(resourceId, {
|
|
181
|
+
...resourceSubscriptions,
|
|
182
|
+
[localId]: callback
|
|
183
|
+
});
|
|
184
|
+
return () => {
|
|
185
|
+
const resourceSubscriptions = this.titleSubscriptions.get(resourceId);
|
|
186
|
+
if (resourceSubscriptions) {
|
|
187
|
+
delete resourceSubscriptions[localId];
|
|
188
|
+
if (Object.keys(resourceSubscriptions).length === 0) {
|
|
189
|
+
this.titleSubscriptions.delete(resourceId);
|
|
190
|
+
} else {
|
|
191
|
+
this.titleSubscriptions.set(resourceId, resourceSubscriptions);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
147
196
|
|
|
148
197
|
/**
|
|
149
198
|
* Get the URL for a sync block.
|
|
@@ -82,6 +82,9 @@ export class SyncBlockStoreManager {
|
|
|
82
82
|
subscribeToSyncBlockData(node, callback) {
|
|
83
83
|
return this.referenceSyncBlockStoreManager.subscribe(node, callback);
|
|
84
84
|
}
|
|
85
|
+
subscribeToSyncBlockSourceTitle(node, callback) {
|
|
86
|
+
return this.referenceSyncBlockStoreManager.subscribeToSourceTitle(node, callback);
|
|
87
|
+
}
|
|
85
88
|
refreshSubscriptions() {
|
|
86
89
|
this.referenceSyncBlockStoreManager.refreshSubscriptions();
|
|
87
90
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @returns A merged SyncBlockInstance object.
|
|
10
10
|
*/
|
|
11
11
|
export const resolveSyncBlockInstance = (oldResult, newResult) => {
|
|
12
|
-
var _newResult$data, _oldResult$data;
|
|
12
|
+
var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2;
|
|
13
13
|
// if the old result has no data, we simple return the new result
|
|
14
14
|
if (!oldResult.data) {
|
|
15
15
|
return newResult;
|
|
@@ -19,12 +19,13 @@ export const resolveSyncBlockInstance = (oldResult, newResult) => {
|
|
|
19
19
|
return oldResult;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// otherwise, we merge the two results, preserving the sourceURL from the old result if it exists
|
|
22
|
+
// otherwise, we merge the two results, preserving the sourceURL and sourceTitle from the old result if it exists
|
|
23
23
|
return {
|
|
24
24
|
...newResult,
|
|
25
25
|
data: {
|
|
26
26
|
...newResult.data,
|
|
27
|
-
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined
|
|
27
|
+
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
|
|
28
|
+
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export var useFetchSyncBlockTitle = function useFetchSyncBlockTitle(manager, syncBlockNode) {
|
|
4
|
+
var _useState = useState(undefined),
|
|
5
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6
|
+
sourceTitle = _useState2[0],
|
|
7
|
+
setSourceTitle = _useState2[1];
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
var unsubscribe = manager.subscribeToSyncBlockSourceTitle(syncBlockNode, function (title) {
|
|
10
|
+
setSourceTitle(title);
|
|
11
|
+
});
|
|
12
|
+
return function () {
|
|
13
|
+
unsubscribe();
|
|
14
|
+
};
|
|
15
|
+
}, [manager, syncBlockNode]);
|
|
16
|
+
return sourceTitle;
|
|
17
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
|
|
4
4
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
5
5
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
6
|
+
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
7
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
8
|
export { SyncBlockError } from './common/types';
|
|
8
9
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
9
10
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders } from './providers/confluence/confluenceContentAPI';
|
|
10
|
-
export { getConfluencePageAri } from './utils/ari';
|
|
11
|
+
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
11
12
|
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
12
13
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
13
14
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -126,8 +126,8 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
126
126
|
return this.sourceId;
|
|
127
127
|
}
|
|
128
128
|
}, {
|
|
129
|
-
key: "
|
|
130
|
-
value: function
|
|
129
|
+
key: "retrieveSyncBlockSourceUrlAndTitle",
|
|
130
|
+
value: function retrieveSyncBlockSourceUrlAndTitle(node) {
|
|
131
131
|
var resourceId = node.attrs.resourceId;
|
|
132
132
|
var pageARI;
|
|
133
133
|
var sourceLocalId;
|
|
@@ -143,7 +143,7 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
143
143
|
// EDITOR-1921: log analytic here, safe to continue
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
return pageARI ?
|
|
146
|
+
return pageARI ? fetchURLandTitlefromARI(pageARI, sourceLocalId) : Promise.resolve(undefined);
|
|
147
147
|
}
|
|
148
148
|
}]);
|
|
149
149
|
}(SyncBlockDataProvider);
|
|
@@ -152,9 +152,9 @@ export var useMemoizedSyncedBlockProvider = function useMemoizedSyncedBlockProvi
|
|
|
152
152
|
return new SyncBlockProvider(fetchProvider, writeProvider, sourceId);
|
|
153
153
|
}, [fetchProvider, writeProvider, sourceId]);
|
|
154
154
|
};
|
|
155
|
-
var
|
|
155
|
+
var fetchURLandTitlefromARI = /*#__PURE__*/function () {
|
|
156
156
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ari, sourceLocalId) {
|
|
157
|
-
var response, _payload$data, payload, url;
|
|
157
|
+
var response, _payload$data, _payload$data2, payload, url, title;
|
|
158
158
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
159
159
|
while (1) switch (_context2.prev = _context2.next) {
|
|
160
160
|
case 0:
|
|
@@ -180,17 +180,14 @@ var fetchURLfromARI = /*#__PURE__*/function () {
|
|
|
180
180
|
case 6:
|
|
181
181
|
payload = _context2.sent;
|
|
182
182
|
url = payload === null || payload === void 0 || (_payload$data = payload.data) === null || _payload$data === void 0 ? void 0 : _payload$data.url;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
case 10:
|
|
189
|
-
_context2.next = 13;
|
|
190
|
-
break;
|
|
183
|
+
title = payload === null || payload === void 0 || (_payload$data2 = payload.data) === null || _payload$data2 === void 0 ? void 0 : _payload$data2.name;
|
|
184
|
+
return _context2.abrupt("return", {
|
|
185
|
+
url: typeof url === 'string' ? sourceLocalId ? url + "?block=".concat(sourceLocalId) : url : undefined,
|
|
186
|
+
title: typeof title === 'string' ? title : undefined
|
|
187
|
+
});
|
|
191
188
|
case 12:
|
|
192
189
|
//eslint-disable-next-line no-console
|
|
193
|
-
console.error('Failed to fetch URL from ARI', response.statusText);
|
|
190
|
+
console.error('Failed to fetch URL and title from ARI', response.statusText);
|
|
194
191
|
case 13:
|
|
195
192
|
return _context2.abrupt("return", undefined);
|
|
196
193
|
case 14:
|
|
@@ -199,7 +196,7 @@ var fetchURLfromARI = /*#__PURE__*/function () {
|
|
|
199
196
|
}
|
|
200
197
|
}, _callee2);
|
|
201
198
|
}));
|
|
202
|
-
return function
|
|
199
|
+
return function fetchURLandTitlefromARI(_x2, _x3) {
|
|
203
200
|
return _ref.apply(this, arguments);
|
|
204
201
|
};
|
|
205
202
|
}();
|
|
@@ -17,6 +17,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
17
17
|
_defineProperty(this, "isRefreshingSubscriptions", false);
|
|
18
18
|
this.syncBlockCache = new Map();
|
|
19
19
|
this.subscriptions = new Map();
|
|
20
|
+
this.titleSubscriptions = new Map();
|
|
20
21
|
this.dataProvider = dataProvider;
|
|
21
22
|
this.syncBlockURLRequests = new Map();
|
|
22
23
|
}
|
|
@@ -105,8 +106,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
105
106
|
return refreshSubscriptions;
|
|
106
107
|
}())
|
|
107
108
|
}, {
|
|
108
|
-
key: "
|
|
109
|
-
value: function
|
|
109
|
+
key: "fetchSyncBlockSourceURLAndTitle",
|
|
110
|
+
value: function fetchSyncBlockSourceURLAndTitle(resourceId) {
|
|
110
111
|
var _this = this;
|
|
111
112
|
if (!resourceId || !this.dataProvider) {
|
|
112
113
|
return;
|
|
@@ -116,13 +117,17 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
116
117
|
// we could optimise this further by checking if the sync block is on the same page as the source
|
|
117
118
|
if (!this.syncBlockURLRequests.get(resourceId)) {
|
|
118
119
|
this.syncBlockURLRequests.set(resourceId, true);
|
|
119
|
-
this.dataProvider.
|
|
120
|
+
this.dataProvider.retrieveSyncBlockSourceUrlAndTitle(createSyncBlockNode('', resourceId)).then(function (sourceInfo) {
|
|
120
121
|
var existingSyncBlock = _this.getFromCache(resourceId);
|
|
121
122
|
if (existingSyncBlock && existingSyncBlock.data) {
|
|
122
123
|
existingSyncBlock.data = _objectSpread(_objectSpread({}, existingSyncBlock.data), {}, {
|
|
123
|
-
sourceURL:
|
|
124
|
+
sourceURL: sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.url,
|
|
125
|
+
sourceTitle: sourceInfo === null || sourceInfo === void 0 ? void 0 : sourceInfo.title
|
|
124
126
|
});
|
|
125
127
|
_this.updateCache(existingSyncBlock);
|
|
128
|
+
if (sourceInfo !== null && sourceInfo !== void 0 && sourceInfo.title) {
|
|
129
|
+
_this.updateSourceTitleSubscriptions(existingSyncBlock.resourceId, sourceInfo.title);
|
|
130
|
+
}
|
|
126
131
|
}
|
|
127
132
|
}).finally(function () {
|
|
128
133
|
_this.syncBlockURLRequests.set(resourceId, false);
|
|
@@ -156,7 +161,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
156
161
|
case 7:
|
|
157
162
|
resolvedData = [];
|
|
158
163
|
data.forEach(function (syncBlockInstance) {
|
|
159
|
-
var _resolvedSyncBlockIns;
|
|
164
|
+
var _resolvedSyncBlockIns, _resolvedSyncBlockIns2;
|
|
160
165
|
if (!syncBlockInstance.resourceId) {
|
|
161
166
|
return;
|
|
162
167
|
}
|
|
@@ -165,9 +170,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
165
170
|
_this2.updateCache(resolvedSyncBlockInstance);
|
|
166
171
|
resolvedData.push(resolvedSyncBlockInstance);
|
|
167
172
|
|
|
168
|
-
// fetch source URL if not already present
|
|
169
|
-
if (!((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns !== void 0 && _resolvedSyncBlockIns.sourceURL) && resolvedSyncBlockInstance.resourceId) {
|
|
170
|
-
_this2.
|
|
173
|
+
// fetch source URL and title if not already present
|
|
174
|
+
if ((!((_resolvedSyncBlockIns = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns !== void 0 && _resolvedSyncBlockIns.sourceURL) || !((_resolvedSyncBlockIns2 = resolvedSyncBlockInstance.data) !== null && _resolvedSyncBlockIns2 !== void 0 && _resolvedSyncBlockIns2.sourceTitle)) && resolvedSyncBlockInstance.resourceId) {
|
|
175
|
+
_this2.fetchSyncBlockSourceURLAndTitle(resolvedSyncBlockInstance.resourceId);
|
|
171
176
|
}
|
|
172
177
|
});
|
|
173
178
|
return _context3.abrupt("return", resolvedData);
|
|
@@ -196,6 +201,16 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
203
|
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "updateSourceTitleSubscriptions",
|
|
206
|
+
value: function updateSourceTitleSubscriptions(resourceId, title) {
|
|
207
|
+
var callbacks = this.titleSubscriptions.get(resourceId);
|
|
208
|
+
if (callbacks) {
|
|
209
|
+
Object.values(callbacks).forEach(function (callback) {
|
|
210
|
+
callback(title);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
199
214
|
}, {
|
|
200
215
|
key: "getFromCache",
|
|
201
216
|
value: function getFromCache(resourceId) {
|
|
@@ -245,6 +260,41 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
245
260
|
}
|
|
246
261
|
};
|
|
247
262
|
}
|
|
263
|
+
}, {
|
|
264
|
+
key: "subscribeToSourceTitle",
|
|
265
|
+
value: function subscribeToSourceTitle(node, callback) {
|
|
266
|
+
var _cachedData$data,
|
|
267
|
+
_this4 = this;
|
|
268
|
+
// check node is a sync block, as we only support sync block subscriptions
|
|
269
|
+
if (node.type.name !== 'syncBlock') {
|
|
270
|
+
return function () {};
|
|
271
|
+
}
|
|
272
|
+
var _node$attrs2 = node.attrs,
|
|
273
|
+
resourceId = _node$attrs2.resourceId,
|
|
274
|
+
localId = _node$attrs2.localId;
|
|
275
|
+
if (!localId || !resourceId) {
|
|
276
|
+
return function () {};
|
|
277
|
+
}
|
|
278
|
+
var cachedData = this.getFromCache(resourceId);
|
|
279
|
+
if (cachedData !== null && cachedData !== void 0 && (_cachedData$data = cachedData.data) !== null && _cachedData$data !== void 0 && _cachedData$data.sourceTitle) {
|
|
280
|
+
callback(cachedData.data.sourceTitle);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// add to subscriptions map
|
|
284
|
+
var resourceSubscriptions = this.titleSubscriptions.get(resourceId) || {};
|
|
285
|
+
this.titleSubscriptions.set(resourceId, _objectSpread(_objectSpread({}, resourceSubscriptions), {}, _defineProperty({}, localId, callback)));
|
|
286
|
+
return function () {
|
|
287
|
+
var resourceSubscriptions = _this4.titleSubscriptions.get(resourceId);
|
|
288
|
+
if (resourceSubscriptions) {
|
|
289
|
+
delete resourceSubscriptions[localId];
|
|
290
|
+
if (Object.keys(resourceSubscriptions).length === 0) {
|
|
291
|
+
_this4.titleSubscriptions.delete(resourceId);
|
|
292
|
+
} else {
|
|
293
|
+
_this4.titleSubscriptions.set(resourceId, resourceSubscriptions);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
248
298
|
|
|
249
299
|
/**
|
|
250
300
|
* Get the URL for a sync block.
|
|
@@ -105,6 +105,11 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
105
105
|
value: function subscribeToSyncBlockData(node, callback) {
|
|
106
106
|
return this.referenceSyncBlockStoreManager.subscribe(node, callback);
|
|
107
107
|
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "subscribeToSyncBlockSourceTitle",
|
|
110
|
+
value: function subscribeToSyncBlockSourceTitle(node, callback) {
|
|
111
|
+
return this.referenceSyncBlockStoreManager.subscribeToSourceTitle(node, callback);
|
|
112
|
+
}
|
|
108
113
|
}, {
|
|
109
114
|
key: "refreshSubscriptions",
|
|
110
115
|
value: function refreshSubscriptions() {
|
|
@@ -12,7 +12,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
12
12
|
* @returns A merged SyncBlockInstance object.
|
|
13
13
|
*/
|
|
14
14
|
export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResult, newResult) {
|
|
15
|
-
var _newResult$data, _oldResult$data;
|
|
15
|
+
var _newResult$data, _oldResult$data, _newResult$data2, _oldResult$data2;
|
|
16
16
|
// if the old result has no data, we simple return the new result
|
|
17
17
|
if (!oldResult.data) {
|
|
18
18
|
return newResult;
|
|
@@ -22,10 +22,11 @@ export var resolveSyncBlockInstance = function resolveSyncBlockInstance(oldResul
|
|
|
22
22
|
return oldResult;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// otherwise, we merge the two results, preserving the sourceURL from the old result if it exists
|
|
25
|
+
// otherwise, we merge the two results, preserving the sourceURL and sourceTitle from the old result if it exists
|
|
26
26
|
return _objectSpread(_objectSpread({}, newResult), {}, {
|
|
27
27
|
data: _objectSpread(_objectSpread({}, newResult.data), {}, {
|
|
28
|
-
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined
|
|
28
|
+
sourceURL: ((_newResult$data = newResult.data) === null || _newResult$data === void 0 ? void 0 : _newResult$data.sourceURL) || ((_oldResult$data = oldResult.data) === null || _oldResult$data === void 0 ? void 0 : _oldResult$data.sourceURL) || undefined,
|
|
29
|
+
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined
|
|
29
30
|
})
|
|
30
31
|
});
|
|
31
32
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
3
|
+
export declare const useFetchSyncBlockTitle: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => string | undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
2
2
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
3
3
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
4
|
+
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
4
5
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
5
6
|
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
6
7
|
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockInstance, } from './providers/types';
|
|
7
8
|
export { SyncBlockError } from './common/types';
|
|
8
9
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
9
10
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
10
|
-
export { getConfluencePageAri } from './utils/ari';
|
|
11
|
+
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
11
12
|
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
12
13
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
13
14
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
2
|
import { type SyncBlockData, type SyncBlockNode } from '../common/types';
|
|
3
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance } from '../providers/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -20,6 +20,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
20
20
|
writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
21
21
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
22
22
|
getSourceId(): string;
|
|
23
|
-
|
|
23
|
+
retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
24
24
|
}
|
|
25
25
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -15,6 +15,10 @@ export type DeleteSyncBlockResult = {
|
|
|
15
15
|
resourceId: string;
|
|
16
16
|
success: boolean;
|
|
17
17
|
};
|
|
18
|
+
export type SyncBlockSourceInfo = {
|
|
19
|
+
title?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
};
|
|
18
22
|
export interface ADFFetchProvider {
|
|
19
23
|
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
20
24
|
}
|
|
@@ -26,6 +30,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
26
30
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
27
31
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
28
32
|
abstract getSourceId(): ResourceId;
|
|
29
|
-
abstract
|
|
33
|
+
abstract retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
30
34
|
}
|
|
31
35
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
36
|
+
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
3
|
-
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
3
|
+
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
|
|
4
4
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
5
|
private dataProvider?;
|
|
6
6
|
private syncBlockCache;
|
|
7
7
|
private subscriptions;
|
|
8
|
+
private titleSubscriptions;
|
|
8
9
|
private syncBlockURLRequests;
|
|
9
10
|
private isRefreshingSubscriptions;
|
|
10
11
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
@@ -13,12 +14,14 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
13
14
|
* @returns {Promise<void>}
|
|
14
15
|
*/
|
|
15
16
|
refreshSubscriptions(): Promise<void>;
|
|
16
|
-
private
|
|
17
|
+
private fetchSyncBlockSourceURLAndTitle;
|
|
17
18
|
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
18
19
|
private updateCache;
|
|
20
|
+
private updateSourceTitleSubscriptions;
|
|
19
21
|
private getFromCache;
|
|
20
22
|
private deleteFromCache;
|
|
21
23
|
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
24
|
+
subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
22
25
|
/**
|
|
23
26
|
* Get the URL for a sync block.
|
|
24
27
|
* @param resourceId - The resource ID of the sync block
|
|
@@ -2,7 +2,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
-
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance } from '../providers/types';
|
|
5
|
+
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
|
|
6
6
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
7
|
export declare class SyncBlockStoreManager {
|
|
8
8
|
private referenceSyncBlockStoreManager;
|
|
@@ -37,6 +37,7 @@ export declare class SyncBlockStoreManager {
|
|
|
37
37
|
requireConfirmationBeforeDelete(): boolean;
|
|
38
38
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
39
|
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
40
|
+
subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
40
41
|
refreshSubscriptions(): void;
|
|
41
42
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
42
43
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { SyncBlockStoreManager } from '../store-manager/syncBlockStoreManager';
|
|
3
|
+
export declare const useFetchSyncBlockTitle: (manager: SyncBlockStoreManager, syncBlockNode: PMNode) => string | undefined;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
2
2
|
export { SyncBlockStoreManager } from './store-manager/syncBlockStoreManager';
|
|
3
3
|
export { useFetchSyncBlockData } from './hooks/useFetchSyncBlockData';
|
|
4
|
+
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
4
5
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
5
6
|
export type { SyncBlockData, SyncBlockNode } from './common/types';
|
|
6
7
|
export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockInstance, } from './providers/types';
|
|
7
8
|
export { SyncBlockError } from './common/types';
|
|
8
9
|
export { getDefaultSyncBlockSchema } from './common/schema';
|
|
9
10
|
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
10
|
-
export { getConfluencePageAri } from './utils/ari';
|
|
11
|
+
export { getConfluencePageAri, getPageIdAndTypeFromAri } from './utils/ari';
|
|
11
12
|
export { convertSyncBlockPMNodeToSyncBlockData } from './utils/utils';
|
|
12
13
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
13
14
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
2
2
|
import { type SyncBlockData, type SyncBlockNode } from '../common/types';
|
|
3
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance } from '../providers/types';
|
|
3
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockSourceInfo } from '../providers/types';
|
|
4
4
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
5
5
|
name: string;
|
|
6
6
|
private fetchProvider;
|
|
@@ -20,6 +20,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
20
20
|
writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<string | undefined>>;
|
|
21
21
|
deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
22
22
|
getSourceId(): string;
|
|
23
|
-
|
|
23
|
+
retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
24
24
|
}
|
|
25
25
|
export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
|
|
@@ -15,6 +15,10 @@ export type DeleteSyncBlockResult = {
|
|
|
15
15
|
resourceId: string;
|
|
16
16
|
success: boolean;
|
|
17
17
|
};
|
|
18
|
+
export type SyncBlockSourceInfo = {
|
|
19
|
+
title?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
};
|
|
18
22
|
export interface ADFFetchProvider {
|
|
19
23
|
fetchData: (resourceId: ResourceId) => Promise<SyncBlockInstance>;
|
|
20
24
|
}
|
|
@@ -26,6 +30,7 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
26
30
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<ResourceId | undefined>>;
|
|
27
31
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
28
32
|
abstract getSourceId(): ResourceId;
|
|
29
|
-
abstract
|
|
33
|
+
abstract retrieveSyncBlockSourceUrlAndTitle(node: SyncBlockNode): Promise<SyncBlockSourceInfo | undefined>;
|
|
30
34
|
}
|
|
31
35
|
export type SubscriptionCallback = (data: SyncBlockInstance) => void;
|
|
36
|
+
export type TitleSubscriptionCallback = (title: string) => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { ResourceId, SyncBlockNode } from '../common/types';
|
|
3
|
-
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider } from '../providers/types';
|
|
3
|
+
import type { SyncBlockInstance, SubscriptionCallback, SyncBlockDataProvider, TitleSubscriptionCallback } from '../providers/types';
|
|
4
4
|
export declare class ReferenceSyncBlockStoreManager {
|
|
5
5
|
private dataProvider?;
|
|
6
6
|
private syncBlockCache;
|
|
7
7
|
private subscriptions;
|
|
8
|
+
private titleSubscriptions;
|
|
8
9
|
private syncBlockURLRequests;
|
|
9
10
|
private isRefreshingSubscriptions;
|
|
10
11
|
constructor(dataProvider?: SyncBlockDataProvider);
|
|
@@ -13,12 +14,14 @@ export declare class ReferenceSyncBlockStoreManager {
|
|
|
13
14
|
* @returns {Promise<void>}
|
|
14
15
|
*/
|
|
15
16
|
refreshSubscriptions(): Promise<void>;
|
|
16
|
-
private
|
|
17
|
+
private fetchSyncBlockSourceURLAndTitle;
|
|
17
18
|
fetchSyncBlocksData(syncBlockNodes: SyncBlockNode[]): Promise<SyncBlockInstance[]>;
|
|
18
19
|
private updateCache;
|
|
20
|
+
private updateSourceTitleSubscriptions;
|
|
19
21
|
private getFromCache;
|
|
20
22
|
private deleteFromCache;
|
|
21
23
|
subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
24
|
+
subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
22
25
|
/**
|
|
23
26
|
* Get the URL for a sync block.
|
|
24
27
|
* @param resourceId - The resource ID of the sync block
|
|
@@ -2,7 +2,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
|
2
2
|
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { ResourceId, SyncBlockAttrs, SyncBlockNode } from '../common/types';
|
|
5
|
-
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance } from '../providers/types';
|
|
5
|
+
import type { SubscriptionCallback, SyncBlockDataProvider, SyncBlockInstance, TitleSubscriptionCallback } from '../providers/types';
|
|
6
6
|
import { type ConfirmationCallback } from './sourceSyncBlockStoreManager';
|
|
7
7
|
export declare class SyncBlockStoreManager {
|
|
8
8
|
private referenceSyncBlockStoreManager;
|
|
@@ -37,6 +37,7 @@ export declare class SyncBlockStoreManager {
|
|
|
37
37
|
requireConfirmationBeforeDelete(): boolean;
|
|
38
38
|
createSyncBlockNode(): SyncBlockNode;
|
|
39
39
|
subscribeToSyncBlockData(node: PMNode, callback: SubscriptionCallback): () => void;
|
|
40
|
+
subscribeToSyncBlockSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
|
|
40
41
|
refreshSubscriptions(): void;
|
|
41
42
|
deleteSyncBlocksWithConfirmation(tr: Transaction, syncBlockIds: SyncBlockAttrs[]): Promise<void>;
|
|
42
43
|
rebaseTransaction(incomingTr: Transaction, state: EditorState): void;
|
package/package.json
CHANGED