@atlaskit/editor-synced-block-provider 13.1.7 → 13.2.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 +19 -0
- package/dist/cjs/store-manager/syncBlockStoreManager.js +16 -7
- package/dist/es2019/store-manager/syncBlockStoreManager.js +16 -7
- package/dist/esm/store-manager/syncBlockStoreManager.js +16 -7
- package/dist/types/entry-points/syncBlockStoreManager.d.ts +1 -0
- package/dist/types/store-manager/syncBlockStoreManager.d.ts +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 13.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5dd6cdd8c1d11`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5dd6cdd8c1d11) -
|
|
8
|
+
Allow a surface to opt out of real-time synced block subscriptions.
|
|
9
|
+
|
|
10
|
+
`SyncBlockStoreManager` and `useMemoizedSyncBlockStoreManager` accept a new
|
|
11
|
+
`SyncBlockStoreManagerOptions` argument, and `useMemoizedSyncedBlockNodeComponent` accepts a
|
|
12
|
+
matching `enableRealTimeSubscriptions` prop. Both default to `true`, so existing behaviour is
|
|
13
|
+
unchanged.
|
|
14
|
+
|
|
15
|
+
When set to `false`, real-time updates are turned off at construction, so no
|
|
16
|
+
`blockService_onBlockUpdated` subscription is ever opened for that store's reference blocks. This
|
|
17
|
+
is deliberately independent of `viewMode`: a live doc in read mode is the editor in view mode and
|
|
18
|
+
must stay live. Consumed by the Confluence classic renderer behind the
|
|
19
|
+
`platform_editor_sync_block_renderer_no_realtime` experiment, so a page being read no longer
|
|
20
|
+
changes under the reader.
|
|
21
|
+
|
|
3
22
|
## 13.1.7
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -27,12 +27,16 @@ 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, viewMode, isLivePage) {
|
|
30
|
+
function SyncBlockStoreManager(dataProvider, viewMode, isLivePage, options) {
|
|
31
|
+
var _options$enableRealTi;
|
|
31
32
|
(0, _classCallCheck2.default)(this, SyncBlockStoreManager);
|
|
32
33
|
this.sourceSyncBlockStoreManager = new _sourceSyncBlockStoreManager.SourceSyncBlockStoreManager(dataProvider, viewMode, isLivePage);
|
|
33
34
|
this.referenceSyncBlockStoreManager = new _referenceSyncBlockStoreManager.ReferenceSyncBlockStoreManager(dataProvider, viewMode, this.sourceSyncBlockStoreManager);
|
|
34
35
|
this.dataProvider = dataProvider;
|
|
35
|
-
|
|
36
|
+
// Set in the constructor rather than from an effect on the consumer side:
|
|
37
|
+
// reference nodes subscribe as they mount, so any later toggle would open
|
|
38
|
+
// (and immediately tear down) subscriptions the surface never wanted.
|
|
39
|
+
this.referenceSyncBlockStoreManager.setRealTimeSubscriptionsEnabled((_options$enableRealTi = options === null || options === void 0 ? void 0 : options.enableRealTimeSubscriptions) !== null && _options$enableRealTi !== void 0 ? _options$enableRealTi : true);
|
|
36
40
|
}
|
|
37
41
|
return (0, _createClass2.default)(SyncBlockStoreManager, [{
|
|
38
42
|
key: "isSyncBlock",
|
|
@@ -292,13 +296,18 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
|
|
|
292
296
|
}()
|
|
293
297
|
}]);
|
|
294
298
|
}();
|
|
295
|
-
var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider) {
|
|
296
|
-
return new SyncBlockStoreManager(dataProvider);
|
|
299
|
+
var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider, options) {
|
|
300
|
+
return new SyncBlockStoreManager(dataProvider, undefined, undefined, options);
|
|
297
301
|
};
|
|
298
|
-
var useMemoizedSyncBlockStoreManager = exports.useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStoreManager(dataProvider, fireAnalyticsEvent) {
|
|
302
|
+
var useMemoizedSyncBlockStoreManager = exports.useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStoreManager(dataProvider, fireAnalyticsEvent, options) {
|
|
303
|
+
// Destructured so the memo depends on the value, not on the identity of an
|
|
304
|
+
// options object that callers commonly build inline.
|
|
305
|
+
var enableRealTimeSubscriptions = options === null || options === void 0 ? void 0 : options.enableRealTimeSubscriptions;
|
|
299
306
|
var syncBlockStoreManager = (0, _react.useMemo)(function () {
|
|
300
|
-
return createSyncBlockStoreManager(dataProvider
|
|
301
|
-
|
|
307
|
+
return createSyncBlockStoreManager(dataProvider, {
|
|
308
|
+
enableRealTimeSubscriptions: enableRealTimeSubscriptions
|
|
309
|
+
});
|
|
310
|
+
}, [dataProvider, enableRealTimeSubscriptions]);
|
|
302
311
|
var prevFireAnalyticsEventRef = (0, _react.useRef)(undefined);
|
|
303
312
|
if (fireAnalyticsEvent !== prevFireAnalyticsEventRef.current) {
|
|
304
313
|
prevFireAnalyticsEventRef.current = fireAnalyticsEvent;
|
|
@@ -15,11 +15,15 @@ import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
|
15
15
|
// Can be used in both editor and renderer contexts.
|
|
16
16
|
|
|
17
17
|
export class SyncBlockStoreManager {
|
|
18
|
-
constructor(dataProvider, viewMode, isLivePage) {
|
|
18
|
+
constructor(dataProvider, viewMode, isLivePage, options) {
|
|
19
|
+
var _options$enableRealTi;
|
|
19
20
|
this.sourceSyncBlockStoreManager = new SourceSyncBlockStoreManager(dataProvider, viewMode, isLivePage);
|
|
20
21
|
this.referenceSyncBlockStoreManager = new ReferenceSyncBlockStoreManager(dataProvider, viewMode, this.sourceSyncBlockStoreManager);
|
|
21
22
|
this.dataProvider = dataProvider;
|
|
22
|
-
|
|
23
|
+
// Set in the constructor rather than from an effect on the consumer side:
|
|
24
|
+
// reference nodes subscribe as they mount, so any later toggle would open
|
|
25
|
+
// (and immediately tear down) subscriptions the surface never wanted.
|
|
26
|
+
this.referenceSyncBlockStoreManager.setRealTimeSubscriptionsEnabled((_options$enableRealTi = options === null || options === void 0 ? void 0 : options.enableRealTimeSubscriptions) !== null && _options$enableRealTi !== void 0 ? _options$enableRealTi : true);
|
|
23
27
|
}
|
|
24
28
|
isSyncBlock(node) {
|
|
25
29
|
return this.sourceSyncBlockStoreManager.isSourceBlock(node) || this.referenceSyncBlockStoreManager.isReferenceBlock(node);
|
|
@@ -193,13 +197,18 @@ export class SyncBlockStoreManager {
|
|
|
193
197
|
};
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
|
-
const createSyncBlockStoreManager = dataProvider => {
|
|
197
|
-
return new SyncBlockStoreManager(dataProvider);
|
|
200
|
+
const createSyncBlockStoreManager = (dataProvider, options) => {
|
|
201
|
+
return new SyncBlockStoreManager(dataProvider, undefined, undefined, options);
|
|
198
202
|
};
|
|
199
|
-
export const useMemoizedSyncBlockStoreManager = (dataProvider, fireAnalyticsEvent) => {
|
|
203
|
+
export const useMemoizedSyncBlockStoreManager = (dataProvider, fireAnalyticsEvent, options) => {
|
|
204
|
+
// Destructured so the memo depends on the value, not on the identity of an
|
|
205
|
+
// options object that callers commonly build inline.
|
|
206
|
+
const enableRealTimeSubscriptions = options === null || options === void 0 ? void 0 : options.enableRealTimeSubscriptions;
|
|
200
207
|
const syncBlockStoreManager = useMemo(() => {
|
|
201
|
-
return createSyncBlockStoreManager(dataProvider
|
|
202
|
-
|
|
208
|
+
return createSyncBlockStoreManager(dataProvider, {
|
|
209
|
+
enableRealTimeSubscriptions
|
|
210
|
+
});
|
|
211
|
+
}, [dataProvider, enableRealTimeSubscriptions]);
|
|
203
212
|
const prevFireAnalyticsEventRef = useRef(undefined);
|
|
204
213
|
if (fireAnalyticsEvent !== prevFireAnalyticsEventRef.current) {
|
|
205
214
|
prevFireAnalyticsEventRef.current = fireAnalyticsEvent;
|
|
@@ -22,12 +22,16 @@ import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
|
22
22
|
// Can be used in both editor and renderer contexts.
|
|
23
23
|
|
|
24
24
|
export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
25
|
-
function SyncBlockStoreManager(dataProvider, viewMode, isLivePage) {
|
|
25
|
+
function SyncBlockStoreManager(dataProvider, viewMode, isLivePage, options) {
|
|
26
|
+
var _options$enableRealTi;
|
|
26
27
|
_classCallCheck(this, SyncBlockStoreManager);
|
|
27
28
|
this.sourceSyncBlockStoreManager = new SourceSyncBlockStoreManager(dataProvider, viewMode, isLivePage);
|
|
28
29
|
this.referenceSyncBlockStoreManager = new ReferenceSyncBlockStoreManager(dataProvider, viewMode, this.sourceSyncBlockStoreManager);
|
|
29
30
|
this.dataProvider = dataProvider;
|
|
30
|
-
|
|
31
|
+
// Set in the constructor rather than from an effect on the consumer side:
|
|
32
|
+
// reference nodes subscribe as they mount, so any later toggle would open
|
|
33
|
+
// (and immediately tear down) subscriptions the surface never wanted.
|
|
34
|
+
this.referenceSyncBlockStoreManager.setRealTimeSubscriptionsEnabled((_options$enableRealTi = options === null || options === void 0 ? void 0 : options.enableRealTimeSubscriptions) !== null && _options$enableRealTi !== void 0 ? _options$enableRealTi : true);
|
|
31
35
|
}
|
|
32
36
|
return _createClass(SyncBlockStoreManager, [{
|
|
33
37
|
key: "isSyncBlock",
|
|
@@ -287,13 +291,18 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
287
291
|
}()
|
|
288
292
|
}]);
|
|
289
293
|
}();
|
|
290
|
-
var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider) {
|
|
291
|
-
return new SyncBlockStoreManager(dataProvider);
|
|
294
|
+
var createSyncBlockStoreManager = function createSyncBlockStoreManager(dataProvider, options) {
|
|
295
|
+
return new SyncBlockStoreManager(dataProvider, undefined, undefined, options);
|
|
292
296
|
};
|
|
293
|
-
export var useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStoreManager(dataProvider, fireAnalyticsEvent) {
|
|
297
|
+
export var useMemoizedSyncBlockStoreManager = function useMemoizedSyncBlockStoreManager(dataProvider, fireAnalyticsEvent, options) {
|
|
298
|
+
// Destructured so the memo depends on the value, not on the identity of an
|
|
299
|
+
// options object that callers commonly build inline.
|
|
300
|
+
var enableRealTimeSubscriptions = options === null || options === void 0 ? void 0 : options.enableRealTimeSubscriptions;
|
|
294
301
|
var syncBlockStoreManager = useMemo(function () {
|
|
295
|
-
return createSyncBlockStoreManager(dataProvider
|
|
296
|
-
|
|
302
|
+
return createSyncBlockStoreManager(dataProvider, {
|
|
303
|
+
enableRealTimeSubscriptions: enableRealTimeSubscriptions
|
|
304
|
+
});
|
|
305
|
+
}, [dataProvider, enableRealTimeSubscriptions]);
|
|
297
306
|
var prevFireAnalyticsEventRef = useRef(undefined);
|
|
298
307
|
if (fireAnalyticsEvent !== prevFireAnalyticsEventRef.current) {
|
|
299
308
|
prevFireAnalyticsEventRef.current = fireAnalyticsEvent;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from '../store-manager/syncBlockStoreManager';
|
|
2
|
+
export type { SyncBlockStoreManagerOptions } from '../store-manager/syncBlockStoreManager';
|
|
2
3
|
export type { SourceSyncBlockStoreManager } from '../store-manager/sourceSyncBlockStoreManager';
|
|
@@ -5,6 +5,20 @@ import type { BlockInstanceId, ReferencesSourceInfo, ResourceId } from '../commo
|
|
|
5
5
|
import type { SyncBlockDataProviderInterface } from '../providers/types';
|
|
6
6
|
import { ReferenceSyncBlockStoreManager } from './referenceSyncBlockStoreManager';
|
|
7
7
|
import { SourceSyncBlockStoreManager } from './sourceSyncBlockStoreManager';
|
|
8
|
+
export type SyncBlockStoreManagerOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Whether reference blocks managed by this store should hold a real-time
|
|
11
|
+
* (`blockService_onBlockUpdated`) subscription and refresh in place when the
|
|
12
|
+
* source changes elsewhere. Defaults to `true`.
|
|
13
|
+
*
|
|
14
|
+
* Surfaces that show content "as of load" — most notably the Confluence
|
|
15
|
+
* classic page/blog renderer, where a document being read must not change
|
|
16
|
+
* under the reader — pass `false`. This is deliberately independent of
|
|
17
|
+
* `viewMode`: a live doc in read mode is the editor in view mode and must
|
|
18
|
+
* stay live, so `viewMode` cannot be used to identify those surfaces.
|
|
19
|
+
*/
|
|
20
|
+
enableRealTimeSubscriptions?: boolean;
|
|
21
|
+
};
|
|
8
22
|
export declare class SyncBlockStoreManager {
|
|
9
23
|
private referenceSyncBlockStoreManager;
|
|
10
24
|
private sourceSyncBlockStoreManager;
|
|
@@ -12,7 +26,7 @@ export declare class SyncBlockStoreManager {
|
|
|
12
26
|
private fireAnalyticsEvent?;
|
|
13
27
|
private fetchReferencesExperience;
|
|
14
28
|
private fetchSourceInfoExperience;
|
|
15
|
-
constructor(dataProvider?: SyncBlockDataProviderInterface, viewMode?: ViewMode, isLivePage?: boolean);
|
|
29
|
+
constructor(dataProvider?: SyncBlockDataProviderInterface, viewMode?: ViewMode, isLivePage?: boolean, options?: SyncBlockStoreManagerOptions);
|
|
16
30
|
isSyncBlock(node: PMNode): boolean;
|
|
17
31
|
fetchReferencesSourceInfo(resourceId: ResourceId, blockInstanceId: BlockInstanceId, isSourceSyncBlock: boolean): Promise<ReferencesSourceInfo>;
|
|
18
32
|
setFireAnalyticsEvent(fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void): void;
|
|
@@ -21,4 +35,4 @@ export declare class SyncBlockStoreManager {
|
|
|
21
35
|
destroy(): void;
|
|
22
36
|
private getUnregisteredReferences;
|
|
23
37
|
}
|
|
24
|
-
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void) => SyncBlockStoreManager;
|
|
38
|
+
export declare const useMemoizedSyncBlockStoreManager: (dataProvider?: SyncBlockDataProviderInterface, fireAnalyticsEvent?: (payload: SyncBlockEventPayload) => void, options?: SyncBlockStoreManagerOptions) => SyncBlockStoreManager;
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^19.2.0"
|
|
43
43
|
},
|
|
44
44
|
"name": "@atlaskit/editor-synced-block-provider",
|
|
45
|
-
"version": "13.
|
|
45
|
+
"version": "13.2.0",
|
|
46
46
|
"description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
|
|
47
47
|
"author": "Atlassian Pty Ltd",
|
|
48
48
|
"license": "Apache-2.0",
|