@atlaskit/editor-plugin-synced-block 6.0.11 → 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.
@@ -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 = fg('platform_synced_block_patch_5') ? new SyncedBlockPluginContext() : undefined;
241
- var confirmationTransactionRef = (_ctx$confirmationTran = ctx === null || ctx === void 0 ? void 0 : ctx.confirmationTransactionRef) !== null && _ctx$confirmationTran !== void 0 ? _ctx$confirmationTran : {
242
- current: undefined
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: fg('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
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 = fg('platform_synced_block_patch_5') ? tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
289
- : selectionDecorationSet : selectionDecorationSet.map(tr.mapping, tr.doc);
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 && fg('platform_synced_block_patch_5')) {
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: fg('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
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: fg('platform_synced_block_patch_5') ? editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
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 = fg('platform_synced_block_patch_5') ? (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' : undefined;
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') && fg('platform_synced_block_patch_5')) {
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
- if (ctx) {
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 ? ctx.consumeCopyEvent() : isCopyEvent;
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
- if (fg('platform_synced_block_patch_5')) {
485
- return isOffline ? filterTransactionOffline({
486
- tr: tr,
487
- state: state,
488
- api: api,
489
- isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
490
- bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
491
- bodiedSyncBlockAdded: bodiedSyncBlockAdded
492
- }) : filterTransactionOnline({
493
- tr: tr,
494
- state: state,
495
- syncBlockStore: syncBlockStore,
496
- api: api,
497
- confirmationTransactionRef: confirmationTransactionRef,
498
- bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
499
- bodiedSyncBlockAdded: bodiedSyncBlockAdded,
500
- extensionFlagShown: extensionFlagShown
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 _trackSyncBlocks7 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
597
- added = _trackSyncBlocks7.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
@@ -1,9 +1,10 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { bind } from 'bind-event-listener';
3
3
  import { ACTION, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
4
- import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckTimeout, getNodeQuery, getPopupContainerFromEditorView, popupWithNestedElement } from '@atlaskit/editor-common/experiences';
4
+ import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckTimeout, getNodeQuery, getPopupContainerFromEditorView, popupWithNestedElement, getSelectionAncestorDOM } from '@atlaskit/editor-common/experiences';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
8
9
  var TIMEOUT_DURATION = 30000;
9
10
  var pluginKey = new PluginKey('syncedBlockMenuAndToolbarExperience');
@@ -14,10 +15,13 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
14
15
  var refs = _ref.refs,
15
16
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
16
17
  var popupsTargetEl;
17
- var editorViewEl;
18
+ var editorViewRef = {
19
+ current: undefined
20
+ };
18
21
  var getPopupsTarget = function getPopupsTarget() {
19
22
  if (!popupsTargetEl) {
20
- popupsTargetEl = refs.popupsMountPoint || refs.wrapperElement || getPopupContainerFromEditorView(editorViewEl);
23
+ var _editorViewRef$curren;
24
+ popupsTargetEl = refs.popupsMountPoint || refs.wrapperElement || getPopupContainerFromEditorView(editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren = editorViewRef.current) === null || _editorViewRef$curren === void 0 ? void 0 : _editorViewRef$curren.dom);
21
25
  }
22
26
  return popupsTargetEl;
23
27
  };
@@ -27,7 +31,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
27
31
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
28
32
  checks: [new ExperienceCheckTimeout({
29
33
  durationMs: TIMEOUT_DURATION
30
- }), syncedBlockAddedToDomCheck(refs)]
34
+ }), syncedBlockAddedToDomCheck(refs, editorViewRef)]
31
35
  });
32
36
  var createSourceBlockMenuExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
33
37
  action: ACTION.SYNCED_BLOCK_CREATE,
@@ -35,7 +39,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
35
39
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
36
40
  checks: [new ExperienceCheckTimeout({
37
41
  durationMs: TIMEOUT_DURATION
38
- }), syncedBlockAddedToDomCheck(refs)]
42
+ }), syncedBlockAddedToDomCheck(refs, editorViewRef)]
39
43
  });
40
44
  var createSourceQuickInsertMenuExperience = new Experience(EXPERIENCE_ID.MENU_ACTION, {
41
45
  action: ACTION.SYNCED_BLOCK_CREATE,
@@ -43,7 +47,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
43
47
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
44
48
  checks: [new ExperienceCheckTimeout({
45
49
  durationMs: TIMEOUT_DURATION
46
- }), syncedBlockAddedToDomCheck(refs)]
50
+ }), syncedBlockAddedToDomCheck(refs, editorViewRef)]
47
51
  });
48
52
  var deleteReferenceSyncedBlockExperience = new Experience(EXPERIENCE_ID.TOOLBAR_ACTION, {
49
53
  action: ACTION.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -51,7 +55,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
51
55
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
52
56
  checks: [new ExperienceCheckTimeout({
53
57
  durationMs: TIMEOUT_DURATION
54
- }), referenceSyncBlockRemovedFromDomCheck(refs)]
58
+ }), referenceSyncBlockRemovedFromDomCheck(refs, editorViewRef)]
55
59
  });
56
60
  var unsyncReferenceSyncedBlockExperience = new Experience(EXPERIENCE_ID.TOOLBAR_ACTION, {
57
61
  action: ACTION.REFERENCE_SYNCED_BLOCK_UNSYNC,
@@ -59,7 +63,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
59
63
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
60
64
  checks: [new ExperienceCheckTimeout({
61
65
  durationMs: TIMEOUT_DURATION
62
- }), referenceSyncBlockRemovedFromDomCheck(refs)]
66
+ }), referenceSyncBlockRemovedFromDomCheck(refs, editorViewRef)]
63
67
  });
64
68
  var unsyncSourceSyncedBlockExperience = new Experience(EXPERIENCE_ID.TOOLBAR_ACTION, {
65
69
  action: ACTION.SYNCED_BLOCK_UNSYNC,
@@ -67,7 +71,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
67
71
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
68
72
  checks: [new ExperienceCheckTimeout({
69
73
  durationMs: TIMEOUT_DURATION
70
- }), syncBlockDeleteConfirmationModalAddedCheck(refs)]
74
+ }), syncBlockDeleteConfirmationModalAddedCheck()]
71
75
  });
72
76
  var deleteSourceSyncedBlockExperience = new Experience(EXPERIENCE_ID.TOOLBAR_ACTION, {
73
77
  action: ACTION.SYNCED_BLOCK_DELETE,
@@ -75,7 +79,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
75
79
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
76
80
  checks: [new ExperienceCheckTimeout({
77
81
  durationMs: TIMEOUT_DURATION
78
- }), syncBlockDeleteConfirmationModalAddedCheck(refs)]
82
+ }), syncBlockDeleteConfirmationModalAddedCheck()]
79
83
  });
80
84
  var syncedLocationsExperience = new Experience(EXPERIENCE_ID.TOOLBAR_ACTION, {
81
85
  action: ACTION.SYNCED_BLOCK_VIEW_SYNCED_LOCATIONS,
@@ -83,7 +87,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
83
87
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
84
88
  checks: [new ExperienceCheckTimeout({
85
89
  durationMs: TIMEOUT_DURATION
86
- }), syncedLocationsDropdownOpenedCheck(refs)]
90
+ }), syncedLocationsDropdownOpenedCheck()]
87
91
  });
88
92
  var unbindClickListener = bind(document, {
89
93
  type: 'click',
@@ -128,11 +132,11 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
128
132
  if (!typeaheadPopup || !(typeaheadPopup instanceof HTMLElement)) {
129
133
  return;
130
134
  }
131
- var firstItem = typeaheadPopup.querySelector('[role="option"]');
132
- if (!firstItem || !(firstItem instanceof HTMLElement)) {
135
+ var targetElement = fg('platform_synced_block_fix_experience_tracking') ? typeaheadPopup.querySelector('[role="option"][aria-selected="true"]') : typeaheadPopup.querySelector('[role="option"]');
136
+ if (!targetElement || !(targetElement instanceof HTMLElement)) {
133
137
  return;
134
138
  }
135
- var testId = firstItem.dataset.testid;
139
+ var testId = targetElement.dataset.testid;
136
140
  if (testId === SYNCED_BLOCK_BUTTON_TEST_ID.quickInsertCreate) {
137
141
  createSourceQuickInsertMenuExperience.start();
138
142
  }
@@ -144,8 +148,8 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
144
148
  });
145
149
  return new SafePlugin({
146
150
  key: pluginKey,
147
- view: function view(editorView) {
148
- editorViewEl = editorView.dom;
151
+ view: function view(_view) {
152
+ editorViewRef.current = _view;
149
153
  return {
150
154
  destroy: function destroy() {
151
155
  createSourcePrimaryToolbarExperience.abort({
@@ -259,7 +263,7 @@ var getTarget = function getTarget(containerElement) {
259
263
  }
260
264
  return targetEl;
261
265
  };
262
- var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs) {
266
+ var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs, editorViewRef) {
263
267
  return new ExperienceCheckDomMutation({
264
268
  onDomMutation: function onDomMutation(_ref3) {
265
269
  var mutations = _ref3.mutations;
@@ -271,12 +275,19 @@ var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs) {
271
275
  return undefined;
272
276
  },
273
277
  observeConfig: function observeConfig() {
274
- return {
275
- target: getTarget(refs.containerElement),
278
+ var _editorViewRef$curren2;
279
+ return [{
280
+ target: fg('platform_synced_block_fix_experience_tracking') ? editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren2 = editorViewRef.current) === null || _editorViewRef$curren2 === void 0 ? void 0 : _editorViewRef$curren2.dom : getTarget(refs.containerElement),
276
281
  options: {
277
282
  childList: true
278
283
  }
279
- };
284
+ }].concat(_toConsumableArray(fg('platform_synced_block_fix_experience_tracking') ? [{
285
+ target: getSelectionAncestorDOM(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
286
+ options: {
287
+ childList: true,
288
+ subtree: true
289
+ }
290
+ }] : []));
280
291
  }
281
292
  });
282
293
  };
@@ -288,7 +299,7 @@ var isBodiedSyncBlockAddedInMutation = function isBodiedSyncBlockAddedInMutation
288
299
  var isBodiedSyncBlockWithinNode = function isBodiedSyncBlockWithinNode(node) {
289
300
  return getNodeQuery('[data-prosemirror-node-name="bodiedSyncBlock"]')(node);
290
301
  };
291
- var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFromDomCheck(refs) {
302
+ var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFromDomCheck(refs, editorViewRef) {
292
303
  return new ExperienceCheckDomMutation({
293
304
  onDomMutation: function onDomMutation(_ref5) {
294
305
  var mutations = _ref5.mutations;
@@ -300,12 +311,19 @@ var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFr
300
311
  return undefined;
301
312
  },
302
313
  observeConfig: function observeConfig() {
303
- return {
304
- target: getTarget(refs.containerElement),
314
+ var _editorViewRef$curren3;
315
+ return [{
316
+ target: fg('platform_synced_block_fix_experience_tracking') ? editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren3 = editorViewRef.current) === null || _editorViewRef$curren3 === void 0 ? void 0 : _editorViewRef$curren3.dom : getTarget(refs.containerElement),
305
317
  options: {
306
318
  childList: true
307
319
  }
308
- };
320
+ }].concat(_toConsumableArray(fg('platform_synced_block_fix_experience_tracking') ? [{
321
+ target: getSelectionAncestorDOM(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
322
+ options: {
323
+ childList: true,
324
+ subtree: true
325
+ }
326
+ }] : []));
309
327
  }
310
328
  });
311
329
  };
@@ -317,7 +335,7 @@ var isSyncBlockRemovedInMutation = function isSyncBlockRemovedInMutation(_ref6)
317
335
  var isSyncBlockWithinNode = function isSyncBlockWithinNode(node) {
318
336
  return getNodeQuery('[data-prosemirror-node-name="syncBlock"]')(node);
319
337
  };
320
- var syncBlockDeleteConfirmationModalAddedCheck = function syncBlockDeleteConfirmationModalAddedCheck(refs) {
338
+ var syncBlockDeleteConfirmationModalAddedCheck = function syncBlockDeleteConfirmationModalAddedCheck() {
321
339
  return new ExperienceCheckDomMutation({
322
340
  onDomMutation: function onDomMutation(_ref7) {
323
341
  var mutations = _ref7.mutations;
@@ -347,7 +365,7 @@ var isDeleteConfirmationModalAddedInMutation = function isDeleteConfirmationModa
347
365
  var isDeleteConfirmationModalWithinNode = function isDeleteConfirmationModalWithinNode(node) {
348
366
  return getNodeQuery('[data-testid="sync-block-delete-confirmation"]')(node);
349
367
  };
350
- var syncedLocationsDropdownOpenedCheck = function syncedLocationsDropdownOpenedCheck(refs) {
368
+ var syncedLocationsDropdownOpenedCheck = function syncedLocationsDropdownOpenedCheck() {
351
369
  return new ExperienceCheckDomMutation({
352
370
  onDomMutation: function onDomMutation(_ref9) {
353
371
  var mutations = _ref9.mutations;
@@ -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
- if (fg('platform_synced_block_patch_5')) {
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: fg('platform_synced_block_patch_5') ? hasUnsavedBodiedSyncBlockChanges : undefined
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
  };
@@ -1,7 +1,6 @@
1
1
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
3
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
4
- export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
5
4
  export declare const SyncBlockRefresher: ({ syncBlockStoreManager, api, }: {
6
5
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
7
6
  syncBlockStoreManager: SyncBlockStoreManager;
@@ -1,7 +1,6 @@
1
1
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
3
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
4
- export declare const SYNC_BLOCK_FETCH_INTERVAL = 3000;
5
4
  export declare const SyncBlockRefresher: ({ syncBlockStoreManager, api, }: {
6
5
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
7
6
  syncBlockStoreManager: SyncBlockStoreManager;
package/docs/0-intro.tsx CHANGED
@@ -5,21 +5,20 @@ import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
5
5
  import { createEditorUseOnlyNotice } from '@atlaskit/editor-common/doc-utils';
6
6
  import { token } from '@atlaskit/tokens';
7
7
 
8
- export default md`
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- md template from @atlaskit/docs
9
+ const _default_1: any = md`
9
10
 
10
11
  ${createEditorUseOnlyNotice('Editor Plugin Synced Block', [
11
- { name: 'Editor Core', link: '/packages/editor/editor-core' },
12
+ { name: 'Editor Core', link: '/packages/editor/editor-core' },
12
13
  ])}
13
14
 
14
15
 
15
- ${
16
- (
17
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
18
- <div style={{ marginTop: token('space.100', '8px') }}>
19
- <AtlassianInternalWarning />
20
- </div>
21
- )
22
- }
16
+ ${(
17
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
18
+ <div style={{ marginTop: token('space.100', '8px') }}>
19
+ <AtlassianInternalWarning />
20
+ </div>
21
+ )}
23
22
 
24
23
  This package includes the synced block plugin used by \`@atlaskit/editor-core\`.
25
24
 
@@ -41,3 +40,4 @@ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian
41
40
  ---
42
41
  Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
43
42
  `;
43
+ export default _default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "6.0.11",
3
+ "version": "6.0.14",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,8 +28,8 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^52.3.0",
32
- "@atlaskit/button": "23.10.3",
31
+ "@atlaskit/adf-schema": "^52.4.0",
32
+ "@atlaskit/button": "23.10.4",
33
33
  "@atlaskit/dropdown-menu": "16.7.1",
34
34
  "@atlaskit/editor-json-transformer": "^8.31.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^8.0.0",
@@ -43,10 +43,10 @@
43
43
  "@atlaskit/editor-plugin-user-intent": "^6.0.0",
44
44
  "@atlaskit/editor-prosemirror": "^7.3.0",
45
45
  "@atlaskit/editor-shared-styles": "^3.10.0",
46
- "@atlaskit/editor-synced-block-provider": "^4.0.0",
46
+ "@atlaskit/editor-synced-block-provider": "^4.1.0",
47
47
  "@atlaskit/editor-toolbar": "^0.20.0",
48
48
  "@atlaskit/flag": "^17.8.0",
49
- "@atlaskit/icon": "33.0.0",
49
+ "@atlaskit/icon": "33.0.1",
50
50
  "@atlaskit/icon-lab": "^6.0.0",
51
51
  "@atlaskit/logo": "^19.10.0",
52
52
  "@atlaskit/lozenge": "^13.5.0",
@@ -54,9 +54,9 @@
54
54
  "@atlaskit/platform-feature-flags": "^1.1.0",
55
55
  "@atlaskit/primitives": "^18.0.0",
56
56
  "@atlaskit/spinner": "19.0.11",
57
- "@atlaskit/tmp-editor-statsig": "^40.3.0",
57
+ "@atlaskit/tmp-editor-statsig": "^40.6.0",
58
58
  "@atlaskit/tokens": "11.1.1",
59
- "@atlaskit/tooltip": "^20.14.0",
59
+ "@atlaskit/tooltip": "^21.0.0",
60
60
  "@atlaskit/visually-hidden": "^3.0.0",
61
61
  "@babel/runtime": "^7.0.0",
62
62
  "@compiled/react": "^0.20.0",
@@ -65,7 +65,7 @@
65
65
  "react-intl-next": "npm:react-intl@^5.18.1"
66
66
  },
67
67
  "peerDependencies": {
68
- "@atlaskit/editor-common": "^112.4.0",
68
+ "@atlaskit/editor-common": "^112.6.0",
69
69
  "react": "^18.2.0"
70
70
  },
71
71
  "devDependencies": {
@@ -108,14 +108,14 @@
108
108
  }
109
109
  },
110
110
  "platform-feature-flags": {
111
- "platform_synced_block_patch_5": {
112
- "type": "boolean"
113
- },
114
111
  "platform_editor_block_menu_v2_patch_3": {
115
112
  "type": "boolean"
116
113
  },
117
114
  "confluence_fronend_labels_categorization_migration": {
118
115
  "type": "boolean"
116
+ },
117
+ "platform_synced_block_fix_experience_tracking": {
118
+ "type": "boolean"
119
119
  }
120
120
  }
121
121
  }