@atlaskit/editor-plugin-synced-block 6.0.13 → 6.0.14
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 +8 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +1 -2
- package/dist/cjs/pm-plugins/main.js +39 -136
- package/dist/cjs/pm-plugins/utils/utils.js +1 -6
- package/dist/cjs/syncedBlockPlugin.js +1 -2
- package/dist/cjs/ui/SyncBlockRefresher.js +1 -17
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +1 -2
- package/dist/es2019/pm-plugins/main.js +31 -125
- package/dist/es2019/pm-plugins/utils/utils.js +1 -6
- package/dist/es2019/syncedBlockPlugin.js +1 -2
- package/dist/es2019/ui/SyncBlockRefresher.js +0 -16
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +1 -2
- package/dist/esm/pm-plugins/main.js +33 -130
- package/dist/esm/pm-plugins/utils/utils.js +1 -6
- package/dist/esm/syncedBlockPlugin.js +1 -2
- package/dist/esm/ui/SyncBlockRefresher.js +0 -16
- package/dist/types/ui/SyncBlockRefresher.d.ts +0 -1
- package/dist/types-ts4.5/ui/SyncBlockRefresher.d.ts +0 -1
- package/docs/0-intro.tsx +10 -10
- package/package.json +5 -8
- package/dist/cjs/nodeviews/bodiedLazySyncedBlock.js +0 -27
- package/dist/es2019/nodeviews/bodiedLazySyncedBlock.js +0 -17
- package/dist/esm/nodeviews/bodiedLazySyncedBlock.js +0 -16
- package/dist/types/nodeviews/bodiedLazySyncedBlock.d.ts +0 -3
- package/dist/types-ts4.5/nodeviews/bodiedLazySyncedBlock.d.ts +0 -3
|
@@ -8,9 +8,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
8
8
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
|
-
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
14
12
|
import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
|
|
15
13
|
import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
|
|
16
14
|
import { FLAG_ID } from '../types';
|
|
@@ -205,17 +203,13 @@ class SyncedBlockPluginContext {
|
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api) => {
|
|
208
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
209
206
|
const {
|
|
210
207
|
useLongPressSelection = false
|
|
211
208
|
} = options || {};
|
|
212
|
-
const ctx =
|
|
213
|
-
const confirmationTransactionRef =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
let isCopyEvent = false;
|
|
217
|
-
const unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
218
|
-
const extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
209
|
+
const ctx = new SyncedBlockPluginContext();
|
|
210
|
+
const confirmationTransactionRef = ctx.confirmationTransactionRef;
|
|
211
|
+
const unpublishedFlagShown = ctx.unpublishedFlagShown;
|
|
212
|
+
const extensionFlagShown = ctx.extensionFlagShown;
|
|
219
213
|
|
|
220
214
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
221
215
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(resourceId => {
|
|
@@ -244,7 +238,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
244
238
|
activeFlag: false,
|
|
245
239
|
syncBlockStore: syncBlockStore,
|
|
246
240
|
retryCreationPosMap: new Map(),
|
|
247
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
241
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
248
242
|
};
|
|
249
243
|
},
|
|
250
244
|
apply: (tr, currentPluginState, oldEditorState) => {
|
|
@@ -256,11 +250,11 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
256
250
|
bodiedSyncBlockDeletionStatus,
|
|
257
251
|
retryCreationPosMap
|
|
258
252
|
} = currentPluginState;
|
|
259
|
-
let newDecorationSet =
|
|
260
|
-
: selectionDecorationSet
|
|
253
|
+
let newDecorationSet = tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
|
|
254
|
+
: selectionDecorationSet;
|
|
261
255
|
if (!tr.selection.eq(oldEditorState.selection)) {
|
|
262
256
|
newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
|
|
263
|
-
} else if (tr.docChanged
|
|
257
|
+
} else if (tr.docChanged) {
|
|
264
258
|
const existingDecorationsLength = selectionDecorationSet.find().length;
|
|
265
259
|
const newDecorationsLength = newDecorationSet.find().length;
|
|
266
260
|
|
|
@@ -279,7 +273,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
279
273
|
syncBlockStore: syncBlockStore,
|
|
280
274
|
retryCreationPosMap: newRetryCreationPosMap,
|
|
281
275
|
bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
|
|
282
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
276
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
283
277
|
};
|
|
284
278
|
}
|
|
285
279
|
},
|
|
@@ -300,7 +294,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
300
294
|
eventDispatcher: pmPluginFactoryParams.eventDispatcher,
|
|
301
295
|
syncBlockStore: syncBlockStore
|
|
302
296
|
}).init(),
|
|
303
|
-
bodiedSyncBlock:
|
|
297
|
+
bodiedSyncBlock: editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
|
|
304
298
|
exposure: true
|
|
305
299
|
}) ? bodiedSyncBlockNodeView({
|
|
306
300
|
pluginOptions: options,
|
|
@@ -312,10 +306,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
312
306
|
pmPluginFactoryParams,
|
|
313
307
|
api,
|
|
314
308
|
syncBlockStore
|
|
315
|
-
}) : lazyBodiedSyncBlockView({
|
|
316
|
-
pluginOptions: options,
|
|
317
|
-
pmPluginFactoryParams,
|
|
318
|
-
api
|
|
319
309
|
})
|
|
320
310
|
},
|
|
321
311
|
decorations: state => {
|
|
@@ -328,7 +318,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
328
318
|
} = state;
|
|
329
319
|
const isOffline = isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 ? void 0 : (_api$connectivity2$sh = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2$sh === void 0 ? void 0 : _api$connectivity2$sh.mode);
|
|
330
320
|
const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
|
|
331
|
-
const isDragging =
|
|
321
|
+
const isDragging = (api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent) === 'dragging';
|
|
332
322
|
const offlineDecorations = [];
|
|
333
323
|
const viewModeDecorations = [];
|
|
334
324
|
const loadingDecorations = [];
|
|
@@ -351,7 +341,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
351
341
|
}
|
|
352
342
|
|
|
353
343
|
// Show sync block border while the user is dragging
|
|
354
|
-
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')
|
|
344
|
+
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
|
|
355
345
|
dragDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
356
346
|
class: SyncBlockStateCssClassName.draggingClassName
|
|
357
347
|
}));
|
|
@@ -377,11 +367,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
377
367
|
return shouldIgnoreDomEvent(view, event, api);
|
|
378
368
|
},
|
|
379
369
|
copy: () => {
|
|
380
|
-
|
|
381
|
-
ctx.markCopyEvent();
|
|
382
|
-
} else {
|
|
383
|
-
isCopyEvent = true;
|
|
384
|
-
}
|
|
370
|
+
ctx.markCopyEvent();
|
|
385
371
|
return false;
|
|
386
372
|
}
|
|
387
373
|
},
|
|
@@ -393,10 +379,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
393
379
|
const {
|
|
394
380
|
schema
|
|
395
381
|
} = state;
|
|
396
|
-
const isCopy = ctx
|
|
397
|
-
if (!ctx) {
|
|
398
|
-
isCopyEvent = false;
|
|
399
|
-
}
|
|
382
|
+
const isCopy = ctx.consumeCopyEvent();
|
|
400
383
|
if (!syncBlockStore || !isCopy) {
|
|
401
384
|
return slice;
|
|
402
385
|
}
|
|
@@ -453,100 +436,23 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
453
436
|
removed: bodiedSyncBlockRemoved,
|
|
454
437
|
added: bodiedSyncBlockAdded
|
|
455
438
|
} = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
if (!isOffline) {
|
|
476
|
-
const {
|
|
477
|
-
removed: syncBlockRemoved,
|
|
478
|
-
added: syncBlockAdded
|
|
479
|
-
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
480
|
-
syncBlockRemoved.forEach(syncBlock => {
|
|
481
|
-
var _api$analytics3, _api$analytics3$actio;
|
|
482
|
-
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : (_api$analytics3$actio = _api$analytics3.actions) === null || _api$analytics3$actio === void 0 ? void 0 : _api$analytics3$actio.fireAnalyticsEvent({
|
|
483
|
-
action: ACTION.DELETED,
|
|
484
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
485
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
486
|
-
attributes: {
|
|
487
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
488
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
489
|
-
},
|
|
490
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
syncBlockAdded.forEach(syncBlock => {
|
|
494
|
-
var _api$analytics4, _api$analytics4$actio;
|
|
495
|
-
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : (_api$analytics4$actio = _api$analytics4.actions) === null || _api$analytics4$actio === void 0 ? void 0 : _api$analytics4$actio.fireAnalyticsEvent({
|
|
496
|
-
action: ACTION.INSERTED,
|
|
497
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
498
|
-
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
499
|
-
attributes: {
|
|
500
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
501
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
502
|
-
},
|
|
503
|
-
eventType: EVENT_TYPE.TRACK
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
if (bodiedSyncBlockRemoved.length > 0) {
|
|
507
|
-
confirmationTransactionRef.current = tr;
|
|
508
|
-
return handleBodiedSyncBlockRemoval(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
|
|
509
|
-
}
|
|
510
|
-
if (bodiedSyncBlockAdded.length > 0) {
|
|
511
|
-
if (tr.getMeta(pmHistoryPluginKey)) {
|
|
512
|
-
// We don't allow bodiedSyncBlock creation via redo, however, we need to return true here to let transaction through so history can be updated properly.
|
|
513
|
-
// If we simply returns false, creation from redo is blocked as desired, but this results in editor showing redo as possible even though it's not.
|
|
514
|
-
// After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
|
|
515
|
-
return true;
|
|
516
|
-
}
|
|
517
|
-
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
518
|
-
return true;
|
|
519
|
-
}
|
|
520
|
-
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
521
|
-
return true;
|
|
522
|
-
}
|
|
523
|
-
const {
|
|
524
|
-
removed: syncBlockRemoved,
|
|
525
|
-
added: syncBlockAdded
|
|
526
|
-
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
527
|
-
let errorFlag = false;
|
|
528
|
-
|
|
529
|
-
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
530
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
|
|
531
|
-
errorFlag = FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
532
|
-
} else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
|
|
533
|
-
errorFlag = FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
534
|
-
} else if (hasEditInSyncBlock(tr, state)) {
|
|
535
|
-
errorFlag = FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
536
|
-
}
|
|
537
|
-
if (errorFlag) {
|
|
538
|
-
deferDispatch(() => {
|
|
539
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
540
|
-
tr
|
|
541
|
-
}) => tr.setMeta(syncedBlockPluginKey, {
|
|
542
|
-
activeFlag: {
|
|
543
|
-
id: errorFlag
|
|
544
|
-
}
|
|
545
|
-
}));
|
|
546
|
-
});
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
return true;
|
|
439
|
+
return isOffline ? filterTransactionOffline({
|
|
440
|
+
tr,
|
|
441
|
+
state,
|
|
442
|
+
api,
|
|
443
|
+
isConfirmedSyncBlockDeletion,
|
|
444
|
+
bodiedSyncBlockRemoved,
|
|
445
|
+
bodiedSyncBlockAdded
|
|
446
|
+
}) : filterTransactionOnline({
|
|
447
|
+
tr,
|
|
448
|
+
state,
|
|
449
|
+
syncBlockStore,
|
|
450
|
+
api,
|
|
451
|
+
confirmationTransactionRef,
|
|
452
|
+
bodiedSyncBlockRemoved,
|
|
453
|
+
bodiedSyncBlockAdded,
|
|
454
|
+
extensionFlagShown
|
|
455
|
+
});
|
|
550
456
|
},
|
|
551
457
|
appendTransaction: (trs, oldState, newState) => {
|
|
552
458
|
trs.filter(tr => tr.docChanged).forEach(tr => {
|
|
@@ -2,7 +2,6 @@ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -10,11 +9,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
10
9
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
11
10
|
*/
|
|
12
11
|
export const deferDispatch = fn => {
|
|
13
|
-
|
|
14
|
-
queueMicrotask(fn);
|
|
15
|
-
} else {
|
|
16
|
-
setTimeout(fn, 0);
|
|
17
|
-
}
|
|
12
|
+
queueMicrotask(fn);
|
|
18
13
|
};
|
|
19
14
|
export const findSyncBlock = (schema, selection) => {
|
|
20
15
|
const {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
5
|
import { flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
7
6
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
@@ -117,7 +116,7 @@ export const syncedBlockPlugin = ({
|
|
|
117
116
|
syncBlockStore: currentSyncBlockStore,
|
|
118
117
|
bodiedSyncBlockDeletionStatus,
|
|
119
118
|
retryCreationPosMap,
|
|
120
|
-
hasUnsavedBodiedSyncBlockChanges
|
|
119
|
+
hasUnsavedBodiedSyncBlockChanges
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
4
|
-
export const SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
|
-
|
|
6
4
|
// Component that manages synced block data synchronization.
|
|
7
5
|
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
8
6
|
// Falls back to polling at regular intervals when offline.
|
|
@@ -23,19 +21,5 @@ export const SyncBlockRefresher = ({
|
|
|
23
21
|
const useRealTimeSubscriptions = isOnline;
|
|
24
22
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
25
23
|
}, [syncBlockStoreManager, isOnline]);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (isOnline) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const interval = window.setInterval(() => {
|
|
31
|
-
var _document;
|
|
32
|
-
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
33
|
-
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
34
|
-
}
|
|
35
|
-
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
36
|
-
return () => {
|
|
37
|
-
window.clearInterval(interval);
|
|
38
|
-
};
|
|
39
|
-
}, [syncBlockStoreManager, isOnline]);
|
|
40
24
|
return null;
|
|
41
25
|
};
|
|
@@ -12,7 +12,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
12
12
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
13
13
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
14
14
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
15
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
17
16
|
import { SyncBlockLabel } from '../ui/SyncBlockLabel';
|
|
18
17
|
var toDOMOld = function toDOMOld() {
|
|
@@ -110,7 +109,7 @@ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
110
109
|
dom = _DOMSerializer$render.dom,
|
|
111
110
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
112
111
|
// In SSR, the first check won't work, so fallback to nodeType check
|
|
113
|
-
if (dom instanceof HTMLElement || dom.nodeType === 1
|
|
112
|
+
if (dom instanceof HTMLElement || dom.nodeType === 1) {
|
|
114
113
|
this.updateContentEditable({
|
|
115
114
|
contentDOM: contentDOM
|
|
116
115
|
});
|
|
@@ -16,9 +16,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
16
16
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
17
17
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
18
18
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
19
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
21
|
-
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
22
20
|
import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
|
|
23
21
|
import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
|
|
24
22
|
import { FLAG_ID } from '../types';
|
|
@@ -233,17 +231,13 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
233
231
|
}]);
|
|
234
232
|
}();
|
|
235
233
|
export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
236
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
237
234
|
var _ref6 = options || {},
|
|
238
235
|
_ref6$useLongPressSel = _ref6.useLongPressSelection,
|
|
239
236
|
useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
|
|
240
|
-
var ctx =
|
|
241
|
-
var confirmationTransactionRef =
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
var isCopyEvent = false;
|
|
245
|
-
var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
246
|
-
var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
237
|
+
var ctx = new SyncedBlockPluginContext();
|
|
238
|
+
var confirmationTransactionRef = ctx.confirmationTransactionRef;
|
|
239
|
+
var unpublishedFlagShown = ctx.unpublishedFlagShown;
|
|
240
|
+
var extensionFlagShown = ctx.extensionFlagShown;
|
|
247
241
|
|
|
248
242
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
249
243
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
@@ -275,7 +269,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
275
269
|
activeFlag: false,
|
|
276
270
|
syncBlockStore: syncBlockStore,
|
|
277
271
|
retryCreationPosMap: new Map(),
|
|
278
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
272
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
279
273
|
};
|
|
280
274
|
},
|
|
281
275
|
apply: function apply(tr, currentPluginState, oldEditorState) {
|
|
@@ -285,11 +279,11 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
285
279
|
selectionDecorationSet = currentPluginState.selectionDecorationSet,
|
|
286
280
|
bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
|
|
287
281
|
retryCreationPosMap = currentPluginState.retryCreationPosMap;
|
|
288
|
-
var newDecorationSet =
|
|
289
|
-
: selectionDecorationSet
|
|
282
|
+
var newDecorationSet = tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
|
|
283
|
+
: selectionDecorationSet;
|
|
290
284
|
if (!tr.selection.eq(oldEditorState.selection)) {
|
|
291
285
|
newDecorationSet = calculateDecorations(tr.doc, tr.selection, tr.doc.type.schema);
|
|
292
|
-
} else if (tr.docChanged
|
|
286
|
+
} else if (tr.docChanged) {
|
|
293
287
|
var existingDecorationsLength = selectionDecorationSet.find().length;
|
|
294
288
|
var newDecorationsLength = newDecorationSet.find().length;
|
|
295
289
|
|
|
@@ -308,7 +302,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
308
302
|
syncBlockStore: syncBlockStore,
|
|
309
303
|
retryCreationPosMap: newRetryCreationPosMap,
|
|
310
304
|
bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
|
|
311
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
305
|
+
hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
|
|
312
306
|
};
|
|
313
307
|
}
|
|
314
308
|
},
|
|
@@ -332,7 +326,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
332
326
|
}).init()
|
|
333
327
|
);
|
|
334
328
|
},
|
|
335
|
-
bodiedSyncBlock:
|
|
329
|
+
bodiedSyncBlock: editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
|
|
336
330
|
exposure: true
|
|
337
331
|
}) ? bodiedSyncBlockNodeView({
|
|
338
332
|
pluginOptions: options,
|
|
@@ -344,10 +338,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
344
338
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
345
339
|
api: api,
|
|
346
340
|
syncBlockStore: syncBlockStore
|
|
347
|
-
}) : lazyBodiedSyncBlockView({
|
|
348
|
-
pluginOptions: options,
|
|
349
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
350
|
-
api: api
|
|
351
341
|
})
|
|
352
342
|
},
|
|
353
343
|
decorations: function decorations(state) {
|
|
@@ -358,7 +348,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
358
348
|
var doc = state.doc;
|
|
359
349
|
var isOffline = isOfflineMode(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
|
|
360
350
|
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
361
|
-
var isDragging =
|
|
351
|
+
var isDragging = (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'dragging';
|
|
362
352
|
var offlineDecorations = [];
|
|
363
353
|
var viewModeDecorations = [];
|
|
364
354
|
var loadingDecorations = [];
|
|
@@ -381,7 +371,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
381
371
|
}
|
|
382
372
|
|
|
383
373
|
// Show sync block border while the user is dragging
|
|
384
|
-
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')
|
|
374
|
+
if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
|
|
385
375
|
dragDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
386
376
|
class: SyncBlockStateCssClassName.draggingClassName
|
|
387
377
|
}));
|
|
@@ -409,11 +399,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
409
399
|
return shouldIgnoreDomEvent(view, event, api);
|
|
410
400
|
},
|
|
411
401
|
copy: function copy() {
|
|
412
|
-
|
|
413
|
-
ctx.markCopyEvent();
|
|
414
|
-
} else {
|
|
415
|
-
isCopyEvent = true;
|
|
416
|
-
}
|
|
402
|
+
ctx.markCopyEvent();
|
|
417
403
|
return false;
|
|
418
404
|
}
|
|
419
405
|
},
|
|
@@ -422,10 +408,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
422
408
|
var pluginState = syncedBlockPluginKey.getState(state);
|
|
423
409
|
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
424
410
|
var schema = state.schema;
|
|
425
|
-
var isCopy = ctx
|
|
426
|
-
if (!ctx) {
|
|
427
|
-
isCopyEvent = false;
|
|
428
|
-
}
|
|
411
|
+
var isCopy = ctx.consumeCopyEvent();
|
|
429
412
|
if (!syncBlockStore || !isCopy) {
|
|
430
413
|
return slice;
|
|
431
414
|
}
|
|
@@ -481,103 +464,23 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
481
464
|
var _trackSyncBlocks4 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
482
465
|
bodiedSyncBlockRemoved = _trackSyncBlocks4.removed,
|
|
483
466
|
bodiedSyncBlockAdded = _trackSyncBlocks4.added;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
if (!isOffline) {
|
|
504
|
-
var _trackSyncBlocks5 = trackSyncBlocks(function (node) {
|
|
505
|
-
return node.type.name === 'syncBlock';
|
|
506
|
-
}, tr, state),
|
|
507
|
-
_syncBlockRemoved = _trackSyncBlocks5.removed,
|
|
508
|
-
_syncBlockAdded = _trackSyncBlocks5.added;
|
|
509
|
-
_syncBlockRemoved.forEach(function (syncBlock) {
|
|
510
|
-
var _api$analytics3;
|
|
511
|
-
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || (_api$analytics3 = _api$analytics3.actions) === null || _api$analytics3 === void 0 || _api$analytics3.fireAnalyticsEvent({
|
|
512
|
-
action: ACTION.DELETED,
|
|
513
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
514
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
515
|
-
attributes: {
|
|
516
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
517
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
518
|
-
},
|
|
519
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
_syncBlockAdded.forEach(function (syncBlock) {
|
|
523
|
-
var _api$analytics4;
|
|
524
|
-
api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || (_api$analytics4 = _api$analytics4.actions) === null || _api$analytics4 === void 0 || _api$analytics4.fireAnalyticsEvent({
|
|
525
|
-
action: ACTION.INSERTED,
|
|
526
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
527
|
-
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
528
|
-
attributes: {
|
|
529
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
530
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
531
|
-
},
|
|
532
|
-
eventType: EVENT_TYPE.TRACK
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
if (bodiedSyncBlockRemoved.length > 0) {
|
|
536
|
-
confirmationTransactionRef.current = tr;
|
|
537
|
-
return handleBodiedSyncBlockRemoval(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
|
|
538
|
-
}
|
|
539
|
-
if (bodiedSyncBlockAdded.length > 0) {
|
|
540
|
-
if (tr.getMeta(pmHistoryPluginKey)) {
|
|
541
|
-
// We don't allow bodiedSyncBlock creation via redo, however, we need to return true here to let transaction through so history can be updated properly.
|
|
542
|
-
// If we simply returns false, creation from redo is blocked as desired, but this results in editor showing redo as possible even though it's not.
|
|
543
|
-
// After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
546
|
-
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
547
|
-
return true;
|
|
548
|
-
}
|
|
549
|
-
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
550
|
-
return true;
|
|
551
|
-
}
|
|
552
|
-
var _trackSyncBlocks6 = trackSyncBlocks(function (node) {
|
|
553
|
-
return node.type.name === 'syncBlock';
|
|
554
|
-
}, tr, state),
|
|
555
|
-
syncBlockRemoved = _trackSyncBlocks6.removed,
|
|
556
|
-
syncBlockAdded = _trackSyncBlocks6.added;
|
|
557
|
-
var errorFlag = false;
|
|
558
|
-
|
|
559
|
-
// Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
|
|
560
|
-
if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
|
|
561
|
-
errorFlag = FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
|
|
562
|
-
} else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
|
|
563
|
-
errorFlag = FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
|
|
564
|
-
} else if (hasEditInSyncBlock(tr, state)) {
|
|
565
|
-
errorFlag = FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
|
|
566
|
-
}
|
|
567
|
-
if (errorFlag) {
|
|
568
|
-
deferDispatch(function () {
|
|
569
|
-
api === null || api === void 0 || api.core.actions.execute(function (_ref9) {
|
|
570
|
-
var tr = _ref9.tr;
|
|
571
|
-
return tr.setMeta(syncedBlockPluginKey, {
|
|
572
|
-
activeFlag: {
|
|
573
|
-
id: errorFlag
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
return true;
|
|
467
|
+
return isOffline ? filterTransactionOffline({
|
|
468
|
+
tr: tr,
|
|
469
|
+
state: state,
|
|
470
|
+
api: api,
|
|
471
|
+
isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
|
|
472
|
+
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
473
|
+
bodiedSyncBlockAdded: bodiedSyncBlockAdded
|
|
474
|
+
}) : filterTransactionOnline({
|
|
475
|
+
tr: tr,
|
|
476
|
+
state: state,
|
|
477
|
+
syncBlockStore: syncBlockStore,
|
|
478
|
+
api: api,
|
|
479
|
+
confirmationTransactionRef: confirmationTransactionRef,
|
|
480
|
+
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
481
|
+
bodiedSyncBlockAdded: bodiedSyncBlockAdded,
|
|
482
|
+
extensionFlagShown: extensionFlagShown
|
|
483
|
+
});
|
|
581
484
|
},
|
|
582
485
|
appendTransaction: function appendTransaction(trs, oldState, newState) {
|
|
583
486
|
trs.filter(function (tr) {
|
|
@@ -593,8 +496,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
593
496
|
var _loop = function _loop() {
|
|
594
497
|
var tr = _step2.value;
|
|
595
498
|
if (tr.getMeta(pmHistoryPluginKey)) {
|
|
596
|
-
var
|
|
597
|
-
added =
|
|
499
|
+
var _trackSyncBlocks5 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
|
|
500
|
+
added = _trackSyncBlocks5.added;
|
|
598
501
|
if (added.length > 0) {
|
|
599
502
|
// Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
|
|
600
503
|
// See filterTransaction above for more details
|
|
@@ -2,7 +2,6 @@ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -10,11 +9,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
10
9
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
11
10
|
*/
|
|
12
11
|
export var deferDispatch = function deferDispatch(fn) {
|
|
13
|
-
|
|
14
|
-
queueMicrotask(fn);
|
|
15
|
-
} else {
|
|
16
|
-
setTimeout(fn, 0);
|
|
17
|
-
}
|
|
12
|
+
queueMicrotask(fn);
|
|
18
13
|
};
|
|
19
14
|
export var findSyncBlock = function findSyncBlock(schema, selection) {
|
|
20
15
|
var syncBlock = schema.nodes.syncBlock;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
5
|
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
7
6
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
@@ -123,7 +122,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
123
122
|
syncBlockStore: currentSyncBlockStore,
|
|
124
123
|
bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
|
|
125
124
|
retryCreationPosMap: retryCreationPosMap,
|
|
126
|
-
hasUnsavedBodiedSyncBlockChanges:
|
|
125
|
+
hasUnsavedBodiedSyncBlockChanges: hasUnsavedBodiedSyncBlockChanges
|
|
127
126
|
};
|
|
128
127
|
}
|
|
129
128
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
4
|
-
export var SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
5
|
-
|
|
6
4
|
// Component that manages synced block data synchronization.
|
|
7
5
|
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
8
6
|
// Falls back to polling at regular intervals when offline.
|
|
@@ -21,19 +19,5 @@ export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
|
21
19
|
var useRealTimeSubscriptions = isOnline;
|
|
22
20
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
23
21
|
}, [syncBlockStoreManager, isOnline]);
|
|
24
|
-
useEffect(function () {
|
|
25
|
-
if (isOnline) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var interval = window.setInterval(function () {
|
|
29
|
-
var _document;
|
|
30
|
-
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
31
|
-
syncBlockStoreManager.referenceManager.refreshSubscriptions();
|
|
32
|
-
}
|
|
33
|
-
}, SYNC_BLOCK_FETCH_INTERVAL);
|
|
34
|
-
return function () {
|
|
35
|
-
window.clearInterval(interval);
|
|
36
|
-
};
|
|
37
|
-
}, [syncBlockStoreManager, isOnline]);
|
|
38
22
|
return null;
|
|
39
23
|
};
|