@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 6.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7428d9bf3aa13`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7428d9bf3aa13) -
8
+ Clean up platform_synced_block_patch_5 feature gate
9
+ - Updated dependencies
10
+
11
+ ## 6.0.13
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
17
+ ## 6.0.12
18
+
19
+ ### Patch Changes
20
+
21
+ - [`10827e937e450`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/10827e937e450) -
22
+ [EDITOR-5750] Fix instrumentation issues with sync block experience tracking
23
+ - Updated dependencies
24
+
3
25
  ## 6.0.11
4
26
 
5
27
  ### Patch Changes
@@ -17,7 +17,6 @@ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/rea
17
17
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
18
18
  var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
19
19
  var _model = require("@atlaskit/editor-prosemirror/model");
20
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
20
  var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
22
21
  var _SyncBlockLabel = require("../ui/SyncBlockLabel");
23
22
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -117,7 +116,7 @@ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
117
116
  dom = _DOMSerializer$render.dom,
118
117
  contentDOM = _DOMSerializer$render.contentDOM;
119
118
  // In SSR, the first check won't work, so fallback to nodeType check
120
- if (dom instanceof HTMLElement || dom.nodeType === 1 && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
119
+ if (dom instanceof HTMLElement || dom.nodeType === 1) {
121
120
  this.updateContentEditable({
122
121
  contentDOM: contentDOM
123
122
  });
@@ -18,9 +18,7 @@ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
18
18
  var _state = require("@atlaskit/editor-prosemirror/state");
19
19
  var _view = require("@atlaskit/editor-prosemirror/view");
20
20
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
21
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
21
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
23
- var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
24
22
  var _bodiedSyncedBlock = require("../nodeviews/bodiedSyncedBlock");
25
23
  var _syncedBlock = require("../nodeviews/syncedBlock");
26
24
  var _types = require("../types");
@@ -28,7 +26,7 @@ var _handleBodiedSyncBlockCreation = require("./utils/handle-bodied-sync-block-c
28
26
  var _handleBodiedSyncBlockRemoval = require("./utils/handle-bodied-sync-block-removal");
29
27
  var _ignoreDomEvent = require("./utils/ignore-dom-event");
30
28
  var _selectionDecorations = require("./utils/selection-decorations");
31
- var _trackSyncBlocks8 = require("./utils/track-sync-blocks");
29
+ var _trackSyncBlocks6 = require("./utils/track-sync-blocks");
32
30
  var _utils2 = require("./utils/utils");
33
31
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
34
32
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -120,7 +118,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
120
118
  bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
121
119
  bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
122
120
  extensionFlagShown = _ref3.extensionFlagShown;
123
- var _trackSyncBlocks = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
121
+ var _trackSyncBlocks = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
124
122
  return node.type.name === 'syncBlock';
125
123
  }, tr, state),
126
124
  syncBlockRemoved = _trackSyncBlocks.removed,
@@ -176,7 +174,7 @@ var filterTransactionOffline = function filterTransactionOffline(_ref4) {
176
174
  isConfirmedSyncBlockDeletion = _ref4.isConfirmedSyncBlockDeletion,
177
175
  bodiedSyncBlockRemoved = _ref4.bodiedSyncBlockRemoved,
178
176
  bodiedSyncBlockAdded = _ref4.bodiedSyncBlockAdded;
179
- var _trackSyncBlocks2 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
177
+ var _trackSyncBlocks2 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
180
178
  return node.type.name === 'syncBlock';
181
179
  }, tr, state),
182
180
  syncBlockRemoved = _trackSyncBlocks2.removed,
@@ -186,7 +184,7 @@ var filterTransactionOffline = function filterTransactionOffline(_ref4) {
186
184
  errorFlag = _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
187
185
  } else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
188
186
  errorFlag = _types.FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
189
- } else if ((0, _trackSyncBlocks8.hasEditInSyncBlock)(tr, state)) {
187
+ } else if ((0, _trackSyncBlocks6.hasEditInSyncBlock)(tr, state)) {
190
188
  errorFlag = _types.FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
191
189
  }
192
190
  if (errorFlag) {
@@ -240,17 +238,13 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
240
238
  }]);
241
239
  }();
242
240
  var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
243
- var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
244
241
  var _ref6 = options || {},
245
242
  _ref6$useLongPressSel = _ref6.useLongPressSelection,
246
243
  useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
247
- var ctx = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? new SyncedBlockPluginContext() : undefined;
248
- var confirmationTransactionRef = (_ctx$confirmationTran = ctx === null || ctx === void 0 ? void 0 : ctx.confirmationTransactionRef) !== null && _ctx$confirmationTran !== void 0 ? _ctx$confirmationTran : {
249
- current: undefined
250
- };
251
- var isCopyEvent = false;
252
- var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
253
- var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
244
+ var ctx = new SyncedBlockPluginContext();
245
+ var confirmationTransactionRef = ctx.confirmationTransactionRef;
246
+ var unpublishedFlagShown = ctx.unpublishedFlagShown;
247
+ var extensionFlagShown = ctx.extensionFlagShown;
254
248
 
255
249
  // Set up callback to detect unpublished sync blocks when they're fetched
256
250
  syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
@@ -282,7 +276,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
282
276
  activeFlag: false,
283
277
  syncBlockStore: syncBlockStore,
284
278
  retryCreationPosMap: new Map(),
285
- hasUnsavedBodiedSyncBlockChanges: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
279
+ hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
286
280
  };
287
281
  },
288
282
  apply: function apply(tr, currentPluginState, oldEditorState) {
@@ -292,11 +286,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
292
286
  selectionDecorationSet = currentPluginState.selectionDecorationSet,
293
287
  bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
294
288
  retryCreationPosMap = currentPluginState.retryCreationPosMap;
295
- var newDecorationSet = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
296
- : selectionDecorationSet : selectionDecorationSet.map(tr.mapping, tr.doc);
289
+ var newDecorationSet = tr.docChanged ? selectionDecorationSet.map(tr.mapping, tr.doc) // only map if document changed
290
+ : selectionDecorationSet;
297
291
  if (!tr.selection.eq(oldEditorState.selection)) {
298
292
  newDecorationSet = (0, _selectionDecorations.calculateDecorations)(tr.doc, tr.selection, tr.doc.type.schema);
299
- } else if (tr.docChanged && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
293
+ } else if (tr.docChanged) {
300
294
  var existingDecorationsLength = selectionDecorationSet.find().length;
301
295
  var newDecorationsLength = newDecorationSet.find().length;
302
296
 
@@ -315,7 +309,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
315
309
  syncBlockStore: syncBlockStore,
316
310
  retryCreationPosMap: newRetryCreationPosMap,
317
311
  bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus,
318
- hasUnsavedBodiedSyncBlockChanges: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? syncBlockStore.sourceManager.hasUnsavedChanges() : undefined
312
+ hasUnsavedBodiedSyncBlockChanges: syncBlockStore.sourceManager.hasUnsavedChanges()
319
313
  };
320
314
  }
321
315
  },
@@ -339,7 +333,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
339
333
  }).init()
340
334
  );
341
335
  },
342
- bodiedSyncBlock: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (0, _experiments.editorExperiment)('platform_synced_block_use_new_source_nodeview', true, {
336
+ bodiedSyncBlock: (0, _experiments.editorExperiment)('platform_synced_block_use_new_source_nodeview', true, {
343
337
  exposure: true
344
338
  }) ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
345
339
  pluginOptions: options,
@@ -351,10 +345,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
351
345
  pmPluginFactoryParams: pmPluginFactoryParams,
352
346
  api: api,
353
347
  syncBlockStore: syncBlockStore
354
- }) : (0, _bodiedLazySyncedBlock.lazyBodiedSyncBlockView)({
355
- pluginOptions: options,
356
- pmPluginFactoryParams: pmPluginFactoryParams,
357
- api: api
358
348
  })
359
349
  },
360
350
  decorations: function decorations(state) {
@@ -365,7 +355,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
365
355
  var doc = state.doc;
366
356
  var isOffline = (0, _editorPluginConnectivity.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);
367
357
  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';
368
- var isDragging = (0, _platformFeatureFlags.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;
358
+ 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';
369
359
  var offlineDecorations = [];
370
360
  var viewModeDecorations = [];
371
361
  var loadingDecorations = [];
@@ -388,7 +378,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
388
378
  }
389
379
 
390
380
  // Show sync block border while the user is dragging
391
- if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock') && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
381
+ if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
392
382
  dragDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
393
383
  class: _syncBlock.SyncBlockStateCssClassName.draggingClassName
394
384
  }));
@@ -416,11 +406,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
416
406
  return (0, _ignoreDomEvent.shouldIgnoreDomEvent)(view, event, api);
417
407
  },
418
408
  copy: function copy() {
419
- if (ctx) {
420
- ctx.markCopyEvent();
421
- } else {
422
- isCopyEvent = true;
423
- }
409
+ ctx.markCopyEvent();
424
410
  return false;
425
411
  }
426
412
  },
@@ -429,10 +415,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
429
415
  var pluginState = syncedBlockPluginKey.getState(state);
430
416
  var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
431
417
  var schema = state.schema;
432
- var isCopy = ctx ? ctx.consumeCopyEvent() : isCopyEvent;
433
- if (!ctx) {
434
- isCopyEvent = false;
435
- }
418
+ var isCopy = ctx.consumeCopyEvent();
436
419
  if (!syncBlockStore || !isCopy) {
437
420
  return slice;
438
421
  }
@@ -471,7 +454,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
471
454
 
472
455
  // Track newly added reference sync blocks before processing the transaction
473
456
  if (tr.docChanged && !tr.getMeta('isRemote')) {
474
- var _trackSyncBlocks3 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
457
+ var _trackSyncBlocks3 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
475
458
  return node.type.name === 'syncBlock';
476
459
  }, tr, state),
477
460
  added = _trackSyncBlocks3.added;
@@ -485,106 +468,26 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
485
468
  if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
486
469
  return true;
487
470
  }
488
- var _trackSyncBlocks4 = (0, _trackSyncBlocks8.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
471
+ var _trackSyncBlocks4 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
489
472
  bodiedSyncBlockRemoved = _trackSyncBlocks4.removed,
490
473
  bodiedSyncBlockAdded = _trackSyncBlocks4.added;
491
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
492
- return isOffline ? filterTransactionOffline({
493
- tr: tr,
494
- state: state,
495
- api: api,
496
- isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
497
- bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
498
- bodiedSyncBlockAdded: bodiedSyncBlockAdded
499
- }) : filterTransactionOnline({
500
- tr: tr,
501
- state: state,
502
- syncBlockStore: syncBlockStore,
503
- api: api,
504
- confirmationTransactionRef: confirmationTransactionRef,
505
- bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
506
- bodiedSyncBlockAdded: bodiedSyncBlockAdded,
507
- extensionFlagShown: extensionFlagShown
508
- });
509
- }
510
- if (!isOffline) {
511
- var _trackSyncBlocks5 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
512
- return node.type.name === 'syncBlock';
513
- }, tr, state),
514
- _syncBlockRemoved = _trackSyncBlocks5.removed,
515
- _syncBlockAdded = _trackSyncBlocks5.added;
516
- _syncBlockRemoved.forEach(function (syncBlock) {
517
- var _api$analytics3;
518
- 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({
519
- action: _analytics.ACTION.DELETED,
520
- actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
521
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
522
- attributes: {
523
- resourceId: syncBlock.attrs.resourceId,
524
- blockInstanceId: syncBlock.attrs.localId
525
- },
526
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
527
- });
528
- });
529
- _syncBlockAdded.forEach(function (syncBlock) {
530
- var _api$analytics4;
531
- 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({
532
- action: _analytics.ACTION.INSERTED,
533
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
534
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
535
- attributes: {
536
- resourceId: syncBlock.attrs.resourceId,
537
- blockInstanceId: syncBlock.attrs.localId
538
- },
539
- eventType: _analytics.EVENT_TYPE.TRACK
540
- });
541
- });
542
- if (bodiedSyncBlockRemoved.length > 0) {
543
- confirmationTransactionRef.current = tr;
544
- return (0, _handleBodiedSyncBlockRemoval.handleBodiedSyncBlockRemoval)(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
545
- }
546
- if (bodiedSyncBlockAdded.length > 0) {
547
- if (tr.getMeta(_utils.pmHistoryPluginKey)) {
548
- // 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.
549
- // 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.
550
- // After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
551
- return true;
552
- }
553
- (0, _handleBodiedSyncBlockCreation.handleBodiedSyncBlockCreation)(bodiedSyncBlockAdded, state, api);
554
- return true;
555
- }
556
- showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
557
- return true;
558
- }
559
- var _trackSyncBlocks6 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
560
- return node.type.name === 'syncBlock';
561
- }, tr, state),
562
- syncBlockRemoved = _trackSyncBlocks6.removed,
563
- syncBlockAdded = _trackSyncBlocks6.added;
564
- var errorFlag = false;
565
-
566
- // Disable (bodied)syncBlock node deletion/creation/edition in offline mode and trigger an error flag instead
567
- if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
568
- errorFlag = _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
569
- } else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
570
- errorFlag = _types.FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
571
- } else if ((0, _trackSyncBlocks8.hasEditInSyncBlock)(tr, state)) {
572
- errorFlag = _types.FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
573
- }
574
- if (errorFlag) {
575
- (0, _utils2.deferDispatch)(function () {
576
- api === null || api === void 0 || api.core.actions.execute(function (_ref9) {
577
- var tr = _ref9.tr;
578
- return tr.setMeta(syncedBlockPluginKey, {
579
- activeFlag: {
580
- id: errorFlag
581
- }
582
- });
583
- });
584
- });
585
- return false;
586
- }
587
- return true;
474
+ return isOffline ? filterTransactionOffline({
475
+ tr: tr,
476
+ state: state,
477
+ api: api,
478
+ isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
479
+ bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
480
+ bodiedSyncBlockAdded: bodiedSyncBlockAdded
481
+ }) : filterTransactionOnline({
482
+ tr: tr,
483
+ state: state,
484
+ syncBlockStore: syncBlockStore,
485
+ api: api,
486
+ confirmationTransactionRef: confirmationTransactionRef,
487
+ bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
488
+ bodiedSyncBlockAdded: bodiedSyncBlockAdded,
489
+ extensionFlagShown: extensionFlagShown
490
+ });
588
491
  },
589
492
  appendTransaction: function appendTransaction(trs, oldState, newState) {
590
493
  trs.filter(function (tr) {
@@ -600,8 +503,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
600
503
  var _loop = function _loop() {
601
504
  var tr = _step2.value;
602
505
  if (tr.getMeta(_utils.pmHistoryPluginKey)) {
603
- var _trackSyncBlocks7 = (0, _trackSyncBlocks8.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
604
- added = _trackSyncBlocks7.added;
506
+ var _trackSyncBlocks5 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
507
+ added = _trackSyncBlocks5.added;
605
508
  if (added.length > 0) {
606
509
  // Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
607
510
  // See filterTransaction above for more details
@@ -11,6 +11,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _experiences = require("@atlaskit/editor-common/experiences");
12
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _types = require("../types");
15
16
  var TIMEOUT_DURATION = 30000;
16
17
  var pluginKey = new _state.PluginKey('syncedBlockMenuAndToolbarExperience');
@@ -21,10 +22,13 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
21
22
  var refs = _ref.refs,
22
23
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
23
24
  var popupsTargetEl;
24
- var editorViewEl;
25
+ var editorViewRef = {
26
+ current: undefined
27
+ };
25
28
  var getPopupsTarget = function getPopupsTarget() {
26
29
  if (!popupsTargetEl) {
27
- popupsTargetEl = refs.popupsMountPoint || refs.wrapperElement || (0, _experiences.getPopupContainerFromEditorView)(editorViewEl);
30
+ var _editorViewRef$curren;
31
+ popupsTargetEl = refs.popupsMountPoint || refs.wrapperElement || (0, _experiences.getPopupContainerFromEditorView)(editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren = editorViewRef.current) === null || _editorViewRef$curren === void 0 ? void 0 : _editorViewRef$curren.dom);
28
32
  }
29
33
  return popupsTargetEl;
30
34
  };
@@ -34,7 +38,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
34
38
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
35
39
  checks: [new _experiences.ExperienceCheckTimeout({
36
40
  durationMs: TIMEOUT_DURATION
37
- }), syncedBlockAddedToDomCheck(refs)]
41
+ }), syncedBlockAddedToDomCheck(refs, editorViewRef)]
38
42
  });
39
43
  var createSourceBlockMenuExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
40
44
  action: _analytics.ACTION.SYNCED_BLOCK_CREATE,
@@ -42,7 +46,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
42
46
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
43
47
  checks: [new _experiences.ExperienceCheckTimeout({
44
48
  durationMs: TIMEOUT_DURATION
45
- }), syncedBlockAddedToDomCheck(refs)]
49
+ }), syncedBlockAddedToDomCheck(refs, editorViewRef)]
46
50
  });
47
51
  var createSourceQuickInsertMenuExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_ACTION, {
48
52
  action: _analytics.ACTION.SYNCED_BLOCK_CREATE,
@@ -50,7 +54,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
50
54
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
51
55
  checks: [new _experiences.ExperienceCheckTimeout({
52
56
  durationMs: TIMEOUT_DURATION
53
- }), syncedBlockAddedToDomCheck(refs)]
57
+ }), syncedBlockAddedToDomCheck(refs, editorViewRef)]
54
58
  });
55
59
  var deleteReferenceSyncedBlockExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.TOOLBAR_ACTION, {
56
60
  action: _analytics.ACTION.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -58,7 +62,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
58
62
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
59
63
  checks: [new _experiences.ExperienceCheckTimeout({
60
64
  durationMs: TIMEOUT_DURATION
61
- }), referenceSyncBlockRemovedFromDomCheck(refs)]
65
+ }), referenceSyncBlockRemovedFromDomCheck(refs, editorViewRef)]
62
66
  });
63
67
  var unsyncReferenceSyncedBlockExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.TOOLBAR_ACTION, {
64
68
  action: _analytics.ACTION.REFERENCE_SYNCED_BLOCK_UNSYNC,
@@ -66,7 +70,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
66
70
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
67
71
  checks: [new _experiences.ExperienceCheckTimeout({
68
72
  durationMs: TIMEOUT_DURATION
69
- }), referenceSyncBlockRemovedFromDomCheck(refs)]
73
+ }), referenceSyncBlockRemovedFromDomCheck(refs, editorViewRef)]
70
74
  });
71
75
  var unsyncSourceSyncedBlockExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.TOOLBAR_ACTION, {
72
76
  action: _analytics.ACTION.SYNCED_BLOCK_UNSYNC,
@@ -74,7 +78,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
74
78
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
75
79
  checks: [new _experiences.ExperienceCheckTimeout({
76
80
  durationMs: TIMEOUT_DURATION
77
- }), syncBlockDeleteConfirmationModalAddedCheck(refs)]
81
+ }), syncBlockDeleteConfirmationModalAddedCheck()]
78
82
  });
79
83
  var deleteSourceSyncedBlockExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.TOOLBAR_ACTION, {
80
84
  action: _analytics.ACTION.SYNCED_BLOCK_DELETE,
@@ -82,7 +86,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
82
86
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
83
87
  checks: [new _experiences.ExperienceCheckTimeout({
84
88
  durationMs: TIMEOUT_DURATION
85
- }), syncBlockDeleteConfirmationModalAddedCheck(refs)]
89
+ }), syncBlockDeleteConfirmationModalAddedCheck()]
86
90
  });
87
91
  var syncedLocationsExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.TOOLBAR_ACTION, {
88
92
  action: _analytics.ACTION.SYNCED_BLOCK_VIEW_SYNCED_LOCATIONS,
@@ -90,7 +94,7 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
90
94
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
91
95
  checks: [new _experiences.ExperienceCheckTimeout({
92
96
  durationMs: TIMEOUT_DURATION
93
- }), syncedLocationsDropdownOpenedCheck(refs)]
97
+ }), syncedLocationsDropdownOpenedCheck()]
94
98
  });
95
99
  var unbindClickListener = (0, _bindEventListener.bind)(document, {
96
100
  type: 'click',
@@ -135,11 +139,11 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
135
139
  if (!typeaheadPopup || !(typeaheadPopup instanceof HTMLElement)) {
136
140
  return;
137
141
  }
138
- var firstItem = typeaheadPopup.querySelector('[role="option"]');
139
- if (!firstItem || !(firstItem instanceof HTMLElement)) {
142
+ var targetElement = (0, _platformFeatureFlags.fg)('platform_synced_block_fix_experience_tracking') ? typeaheadPopup.querySelector('[role="option"][aria-selected="true"]') : typeaheadPopup.querySelector('[role="option"]');
143
+ if (!targetElement || !(targetElement instanceof HTMLElement)) {
140
144
  return;
141
145
  }
142
- var testId = firstItem.dataset.testid;
146
+ var testId = targetElement.dataset.testid;
143
147
  if (testId === _types.SYNCED_BLOCK_BUTTON_TEST_ID.quickInsertCreate) {
144
148
  createSourceQuickInsertMenuExperience.start();
145
149
  }
@@ -151,8 +155,8 @@ var getMenuAndToolbarExperiencesPlugin = exports.getMenuAndToolbarExperiencesPlu
151
155
  });
152
156
  return new _safePlugin.SafePlugin({
153
157
  key: pluginKey,
154
- view: function view(editorView) {
155
- editorViewEl = editorView.dom;
158
+ view: function view(_view) {
159
+ editorViewRef.current = _view;
156
160
  return {
157
161
  destroy: function destroy() {
158
162
  createSourcePrimaryToolbarExperience.abort({
@@ -266,7 +270,7 @@ var getTarget = function getTarget(containerElement) {
266
270
  }
267
271
  return targetEl;
268
272
  };
269
- var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs) {
273
+ var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs, editorViewRef) {
270
274
  return new _experiences.ExperienceCheckDomMutation({
271
275
  onDomMutation: function onDomMutation(_ref3) {
272
276
  var mutations = _ref3.mutations;
@@ -278,12 +282,19 @@ var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs) {
278
282
  return undefined;
279
283
  },
280
284
  observeConfig: function observeConfig() {
281
- return {
282
- target: getTarget(refs.containerElement),
285
+ var _editorViewRef$curren2;
286
+ return [{
287
+ target: (0, _platformFeatureFlags.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),
283
288
  options: {
284
289
  childList: true
285
290
  }
286
- };
291
+ }].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform_synced_block_fix_experience_tracking') ? [{
292
+ target: (0, _experiences.getSelectionAncestorDOM)(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
293
+ options: {
294
+ childList: true,
295
+ subtree: true
296
+ }
297
+ }] : []));
287
298
  }
288
299
  });
289
300
  };
@@ -295,7 +306,7 @@ var isBodiedSyncBlockAddedInMutation = function isBodiedSyncBlockAddedInMutation
295
306
  var isBodiedSyncBlockWithinNode = function isBodiedSyncBlockWithinNode(node) {
296
307
  return (0, _experiences.getNodeQuery)('[data-prosemirror-node-name="bodiedSyncBlock"]')(node);
297
308
  };
298
- var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFromDomCheck(refs) {
309
+ var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFromDomCheck(refs, editorViewRef) {
299
310
  return new _experiences.ExperienceCheckDomMutation({
300
311
  onDomMutation: function onDomMutation(_ref5) {
301
312
  var mutations = _ref5.mutations;
@@ -307,12 +318,19 @@ var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFr
307
318
  return undefined;
308
319
  },
309
320
  observeConfig: function observeConfig() {
310
- return {
311
- target: getTarget(refs.containerElement),
321
+ var _editorViewRef$curren3;
322
+ return [{
323
+ target: (0, _platformFeatureFlags.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),
312
324
  options: {
313
325
  childList: true
314
326
  }
315
- };
327
+ }].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform_synced_block_fix_experience_tracking') ? [{
328
+ target: (0, _experiences.getSelectionAncestorDOM)(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
329
+ options: {
330
+ childList: true,
331
+ subtree: true
332
+ }
333
+ }] : []));
316
334
  }
317
335
  });
318
336
  };
@@ -324,7 +342,7 @@ var isSyncBlockRemovedInMutation = function isSyncBlockRemovedInMutation(_ref6)
324
342
  var isSyncBlockWithinNode = function isSyncBlockWithinNode(node) {
325
343
  return (0, _experiences.getNodeQuery)('[data-prosemirror-node-name="syncBlock"]')(node);
326
344
  };
327
- var syncBlockDeleteConfirmationModalAddedCheck = function syncBlockDeleteConfirmationModalAddedCheck(refs) {
345
+ var syncBlockDeleteConfirmationModalAddedCheck = function syncBlockDeleteConfirmationModalAddedCheck() {
328
346
  return new _experiences.ExperienceCheckDomMutation({
329
347
  onDomMutation: function onDomMutation(_ref7) {
330
348
  var mutations = _ref7.mutations;
@@ -354,7 +372,7 @@ var isDeleteConfirmationModalAddedInMutation = function isDeleteConfirmationModa
354
372
  var isDeleteConfirmationModalWithinNode = function isDeleteConfirmationModalWithinNode(node) {
355
373
  return (0, _experiences.getNodeQuery)('[data-testid="sync-block-delete-confirmation"]')(node);
356
374
  };
357
- var syncedLocationsDropdownOpenedCheck = function syncedLocationsDropdownOpenedCheck(refs) {
375
+ var syncedLocationsDropdownOpenedCheck = function syncedLocationsDropdownOpenedCheck() {
358
376
  return new _experiences.ExperienceCheckDomMutation({
359
377
  onDomMutation: function onDomMutation(_ref9) {
360
378
  var mutations = _ref9.mutations;
@@ -8,18 +8,13 @@ var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _model = require("@atlaskit/editor-prosemirror/model");
9
9
  var _transform = require("@atlaskit/editor-prosemirror/transform");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
12
  /**
14
13
  * Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
15
14
  * Used to avoid re-entrant ProseMirror dispatch cycles.
16
15
  */
17
16
  var deferDispatch = exports.deferDispatch = function deferDispatch(fn) {
18
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
19
- queueMicrotask(fn);
20
- } else {
21
- setTimeout(fn, 0);
22
- }
17
+ queueMicrotask(fn);
23
18
  };
24
19
  var findSyncBlock = exports.findSyncBlock = function findSyncBlock(schema, selection) {
25
20
  var syncBlock = schema.nodes.syncBlock;
@@ -8,7 +8,6 @@ exports.syncedBlockPlugin = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
12
  var _editorActions = require("./editor-actions");
14
13
  var _editorCommands = require("./editor-commands");
@@ -130,7 +129,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
130
129
  syncBlockStore: currentSyncBlockStore,
131
130
  bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
132
131
  retryCreationPosMap: retryCreationPosMap,
133
- hasUnsavedBodiedSyncBlockChanges: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? hasUnsavedBodiedSyncBlockChanges : undefined
132
+ hasUnsavedBodiedSyncBlockChanges: hasUnsavedBodiedSyncBlockChanges
134
133
  };
135
134
  }
136
135
  };
@@ -3,12 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SyncBlockRefresher = exports.SYNC_BLOCK_FETCH_INTERVAL = void 0;
6
+ exports.SyncBlockRefresher = void 0;
7
7
  var _react = require("react");
8
8
  var _hooks = require("@atlaskit/editor-common/hooks");
9
9
  var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
10
- var SYNC_BLOCK_FETCH_INTERVAL = exports.SYNC_BLOCK_FETCH_INTERVAL = 3000;
11
-
12
10
  // Component that manages synced block data synchronization.
13
11
  // Uses provider-based GraphQL subscriptions for updates when online.
14
12
  // Falls back to polling at regular intervals when offline.
@@ -27,19 +25,5 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
27
25
  var useRealTimeSubscriptions = isOnline;
28
26
  syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
29
27
  }, [syncBlockStoreManager, isOnline]);
30
- (0, _react.useEffect)(function () {
31
- if (isOnline) {
32
- return;
33
- }
34
- var interval = window.setInterval(function () {
35
- var _document;
36
- if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
37
- syncBlockStoreManager.referenceManager.refreshSubscriptions();
38
- }
39
- }, SYNC_BLOCK_FETCH_INTERVAL);
40
- return function () {
41
- window.clearInterval(interval);
42
- };
43
- }, [syncBlockStoreManager, isOnline]);
44
28
  return null;
45
29
  };
@@ -5,7 +5,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
6
6
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
7
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
10
9
  import { SyncBlockLabel } from '../ui/SyncBlockLabel';
11
10
  const toDOMOld = () => ['div', {
@@ -87,7 +86,7 @@ class BodiedSyncBlockOld extends ReactNodeView {
87
86
  contentDOM
88
87
  } = DOMSerializer.renderSpec(document, toDOMOld());
89
88
  // In SSR, the first check won't work, so fallback to nodeType check
90
- if (dom instanceof HTMLElement || dom.nodeType === 1 && fg('platform_synced_block_patch_5')) {
89
+ if (dom instanceof HTMLElement || dom.nodeType === 1) {
91
90
  this.updateContentEditable({
92
91
  contentDOM
93
92
  });