@atlaskit/editor-plugin-synced-block 6.0.50 → 6.1.1

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,24 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 6.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 6.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`dd9c0778c3832`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dd9c0778c3832) -
14
+ Add \_\_livePage option to syncedBlock plugin and store managers. Add isReferenceBlock/isSyncBlock
15
+ methods. Use predicate functions instead of hardcoded node type names. Fix isDirty logic for
16
+ remote transactions. Fix flush() view-mode return value.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 6.0.50
4
23
 
5
24
  ### Patch Changes
@@ -209,7 +209,7 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
209
209
  // When fg is ON, cache is populated in state.init() and updated in appendTransaction
210
210
  if (!(0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
211
211
  var _this$syncedBlockStor;
212
- (_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 || _this$syncedBlockStor.sourceManager.updateSyncBlockData(node);
212
+ (_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 || _this$syncedBlockStor.sourceManager.updateSyncBlockData(node, false);
213
213
  }
214
214
  }
215
215
  return (0, _createClass2.default)(BodiedSyncBlock, [{
@@ -270,7 +270,7 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
270
270
  // filter out non-user changes (remote collab, table auto-scale, etc.)
271
271
  if (!(0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
272
272
  var _this$syncedBlockStor2;
273
- (_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 || _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node);
273
+ (_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 || _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node, false);
274
274
  }
275
275
  }
276
276
  this.node = node;
@@ -29,7 +29,7 @@ var _handleBodiedSyncBlockCreation = require("./utils/handle-bodied-sync-block-c
29
29
  var _handleBodiedSyncBlockRemoval = require("./utils/handle-bodied-sync-block-removal");
30
30
  var _ignoreDomEvent = require("./utils/ignore-dom-event");
31
31
  var _selectionDecorations = require("./utils/selection-decorations");
32
- var _trackSyncBlocks6 = require("./utils/track-sync-blocks");
32
+ var _trackSyncBlocks7 = require("./utils/track-sync-blocks");
33
33
  var _utils2 = require("./utils/utils");
34
34
  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; }
35
35
  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; }
@@ -121,9 +121,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
121
121
  bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
122
122
  bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
123
123
  extensionFlagShown = _ref3.extensionFlagShown;
124
- var _trackSyncBlocks = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
125
- return node.type.name === 'syncBlock';
126
- }, tr, state),
124
+ var _trackSyncBlocks = (0, _trackSyncBlocks7.trackSyncBlocks)(syncBlockStore.referenceManager.isReferenceBlock, tr, state),
127
125
  syncBlockRemoved = _trackSyncBlocks.removed,
128
126
  syncBlockAdded = _trackSyncBlocks.added;
129
127
  syncBlockRemoved.forEach(function (syncBlock) {
@@ -173,13 +171,12 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
173
171
  var filterTransactionOffline = function filterTransactionOffline(_ref4) {
174
172
  var tr = _ref4.tr,
175
173
  state = _ref4.state,
174
+ syncBlockStore = _ref4.syncBlockStore,
176
175
  api = _ref4.api,
177
176
  isConfirmedSyncBlockDeletion = _ref4.isConfirmedSyncBlockDeletion,
178
177
  bodiedSyncBlockRemoved = _ref4.bodiedSyncBlockRemoved,
179
178
  bodiedSyncBlockAdded = _ref4.bodiedSyncBlockAdded;
180
- var _trackSyncBlocks2 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
181
- return node.type.name === 'syncBlock';
182
- }, tr, state),
179
+ var _trackSyncBlocks2 = (0, _trackSyncBlocks7.trackSyncBlocks)(syncBlockStore.referenceManager.isReferenceBlock, tr, state),
183
180
  syncBlockRemoved = _trackSyncBlocks2.removed,
184
181
  syncBlockAdded = _trackSyncBlocks2.added;
185
182
  var errorFlag = false;
@@ -187,7 +184,7 @@ var filterTransactionOffline = function filterTransactionOffline(_ref4) {
187
184
  errorFlag = _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
188
185
  } else if (bodiedSyncBlockAdded.length > 0 || syncBlockAdded.length > 0) {
189
186
  errorFlag = _types.FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE;
190
- } else if ((0, _trackSyncBlocks6.hasEditInSyncBlock)(tr, state)) {
187
+ } else if ((0, _trackSyncBlocks7.hasEditInSyncBlock)(tr, state)) {
191
188
  errorFlag = _types.FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE;
192
189
  }
193
190
  if (errorFlag) {
@@ -282,9 +279,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
282
279
  key: syncedBlockPluginKey,
283
280
  state: {
284
281
  init: function init(_, instance) {
285
- var syncBlockNodes = instance.doc.children.filter(function (node) {
286
- return node.type.name === 'syncBlock';
287
- });
282
+ var syncBlockNodes = instance.doc.children.filter(syncBlockStore.referenceManager.isReferenceBlock);
288
283
  syncBlockStore.referenceManager.fetchSyncBlocksData((0, _editorSyncedBlockProvider.convertPMNodesToSyncBlockNodes)(syncBlockNodes));
289
284
 
290
285
  // Populate source sync block cache from initial document
@@ -292,7 +287,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
292
287
  if ((0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
293
288
  instance.doc.forEach(function (node) {
294
289
  if (syncBlockStore.sourceManager.isSourceBlock(node)) {
295
- syncBlockStore.sourceManager.updateSyncBlockData(node);
290
+ syncBlockStore.sourceManager.updateSyncBlockData(node, false);
296
291
  }
297
292
  });
298
293
  }
@@ -391,7 +386,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
391
386
  class: _syncBlock.SyncBlockStateCssClassName.disabledClassName
392
387
  }));
393
388
  }
394
- if ((node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock') && isViewMode) {
389
+ if (syncBlockStore.isSyncBlock(node) && isViewMode) {
395
390
  viewModeDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
396
391
  class: _syncBlock.SyncBlockStateCssClassName.viewModeClassName
397
392
  }));
@@ -403,7 +398,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
403
398
  }
404
399
 
405
400
  // Show sync block border while the user is dragging
406
- if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
401
+ if (isDragging && syncBlockStore.isSyncBlock(node)) {
407
402
  dragDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
408
403
  class: _syncBlock.SyncBlockStateCssClassName.draggingClassName
409
404
  }));
@@ -445,7 +440,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
445
440
  return slice;
446
441
  }
447
442
  return (0, _utils.mapSlice)(slice, function (node) {
448
- if (node.type.name === 'syncBlock') {
443
+ if (syncBlockStore.referenceManager.isReferenceBlock(node)) {
449
444
  showCopiedFlag(api);
450
445
  return node;
451
446
  }
@@ -483,9 +478,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
483
478
 
484
479
  // Track newly added reference sync blocks before processing the transaction
485
480
  if (tr.docChanged && !tr.getMeta('isRemote')) {
486
- var _trackSyncBlocks3 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
487
- return node.type.name === 'syncBlock';
488
- }, tr, state),
481
+ var _trackSyncBlocks3 = (0, _trackSyncBlocks7.trackSyncBlocks)(syncBlockStore.referenceManager.isReferenceBlock, tr, state),
489
482
  added = _trackSyncBlocks3.added;
490
483
  added.forEach(function (nodeInfo) {
491
484
  var _nodeInfo$attrs;
@@ -494,15 +487,45 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
494
487
  }
495
488
  });
496
489
  }
490
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_update_refactor')) {
491
+ // if doc changed and it's a remote transaction, check if any synced block were added,
492
+ // and if so, for source synced blocks, ensure we update the cache with them
493
+ // and for reference synced blocks, ensure we fetch the data from the server
494
+ if (tr.docChanged && tr.getMeta('isRemote')) {
495
+ var _trackSyncBlocks4 = (0, _trackSyncBlocks7.trackSyncBlocks)(function (node) {
496
+ return syncBlockStore.isSyncBlock(node);
497
+ }, tr, state),
498
+ _added = _trackSyncBlocks4.added;
499
+ var sourceSyncBlockNodes = _added.filter(function (nodeInfo) {
500
+ return nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node);
501
+ });
502
+ var referenceSyncBlockNodes = _added.filter(function (nodeInfo) {
503
+ return nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node);
504
+ });
505
+ sourceSyncBlockNodes.forEach(function (nodeInfo) {
506
+ var _nodeInfo$attrs2;
507
+ if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
508
+ syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
509
+ }
510
+ });
511
+ var syncBlockNodes = referenceSyncBlockNodes.map(function (nodeInfo) {
512
+ return nodeInfo.node;
513
+ }).filter(function (node) {
514
+ return node !== undefined;
515
+ });
516
+ syncBlockStore.referenceManager.fetchSyncBlocksData((0, _editorSyncedBlockProvider.convertPMNodesToSyncBlockNodes)(syncBlockNodes));
517
+ }
518
+ }
497
519
  if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
498
520
  return true;
499
521
  }
500
- var _trackSyncBlocks4 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
501
- bodiedSyncBlockRemoved = _trackSyncBlocks4.removed,
502
- bodiedSyncBlockAdded = _trackSyncBlocks4.added;
522
+ var _trackSyncBlocks5 = (0, _trackSyncBlocks7.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
523
+ bodiedSyncBlockRemoved = _trackSyncBlocks5.removed,
524
+ bodiedSyncBlockAdded = _trackSyncBlocks5.added;
503
525
  return isOffline ? filterTransactionOffline({
504
526
  tr: tr,
505
527
  state: state,
528
+ syncBlockStore: syncBlockStore,
506
529
  api: api,
507
530
  isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
508
531
  bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
@@ -532,12 +555,12 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
532
555
  return tr.docChanged && !(0, _collab.isDirtyTransaction)(tr) && !tr.getMeta('isRemote');
533
556
  };
534
557
  var hasSourceBlockEdit = trs.some(function (tr) {
535
- return isUserChange(tr) && (0, _trackSyncBlocks6.hasEditInSyncBlock)(tr, oldState);
558
+ return isUserChange(tr) && (0, _trackSyncBlocks7.hasEditInSyncBlock)(tr, oldState);
536
559
  });
537
560
  if (hasSourceBlockEdit) {
538
561
  newState.doc.forEach(function (node) {
539
562
  if (syncBlockStore.sourceManager.isSourceBlock(node)) {
540
- syncBlockStore.sourceManager.updateSyncBlockData(node);
563
+ syncBlockStore.sourceManager.updateSyncBlockData(node, false);
541
564
  }
542
565
  });
543
566
  }
@@ -555,8 +578,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
555
578
  var _loop = function _loop() {
556
579
  var tr = _step2.value;
557
580
  if (tr.getMeta(_utils.pmHistoryPluginKey)) {
558
- var _trackSyncBlocks5 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
559
- added = _trackSyncBlocks5.added;
581
+ var _trackSyncBlocks6 = (0, _trackSyncBlocks7.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
582
+ added = _trackSyncBlocks6.added;
560
583
  if (added.length > 0) {
561
584
  // Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
562
585
  // See filterTransaction above for more details
@@ -6,6 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.trackSyncBlocks = exports.hasEditInSyncBlock = void 0;
7
7
  var _transform = require("@atlaskit/editor-prosemirror/transform");
8
8
  var _utils = require("@atlaskit/editor-prosemirror/utils");
9
+ /**
10
+ * Tracks changes to sync blocks in a transaction.
11
+ * @param predicate - A function that returns true if a node is a sync block (source or reference or both).
12
+ * @param tr - The transaction to track changes in.
13
+ * @param state - The editor state.
14
+ * @returns An object containing the removed and added sync blocks.
15
+ */
9
16
  var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
10
17
  var removed = {};
11
18
  var added = {};
@@ -21,8 +28,8 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
21
28
  return step instanceof _transform.ReplaceStep || step instanceof _transform.ReplaceAroundStep;
22
29
  });
23
30
 
24
- // this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
25
- var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
31
+ // this is a quick check to see if any insertion/deletion of sync block happened
32
+ var hasSyncBlockChanges = replaceSteps.some(function (step) {
26
33
  var from = step.from,
27
34
  to = step.to;
28
35
  var docAtStep = tr.docs[tr.steps.indexOf(step)];
@@ -54,7 +61,7 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
54
61
  }
55
62
  return hasChange;
56
63
  });
57
- if (hasBodiedSyncBlockChanges) {
64
+ if (hasSyncBlockChanges) {
58
65
  var oldDoc = state.doc;
59
66
  var newDoc = tr.doc;
60
67
  var syncBlockMapOld = {};
@@ -27,7 +27,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
27
27
  api = _ref.api;
28
28
  var refs = {};
29
29
  var viewMode = 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;
30
- var syncBlockStore = new _editorSyncedBlockProvider.SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode);
30
+ var syncBlockStore = new _editorSyncedBlockProvider.SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode, config === null || config === void 0 ? void 0 : config.__livePage);
31
31
  syncBlockStore.setFireAnalyticsEvent(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent);
32
32
  api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents((0, _blockMenuComponents.getBlockMenuComponents)(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
33
33
  api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api, (_config$enableSourceC2 = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC2 !== void 0 ? _config$enableSourceC2 : false));
@@ -174,7 +174,7 @@ export class BodiedSyncBlock {
174
174
  // When fg is ON, cache is populated in state.init() and updated in appendTransaction
175
175
  if (!fg('platform_synced_block_update_refactor')) {
176
176
  var _this$syncedBlockStor;
177
- (_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 ? void 0 : _this$syncedBlockStor.sourceManager.updateSyncBlockData(node);
177
+ (_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 ? void 0 : _this$syncedBlockStor.sourceManager.updateSyncBlockData(node, false);
178
178
  }
179
179
  }
180
180
  updateContentEditable({
@@ -226,7 +226,7 @@ export class BodiedSyncBlock {
226
226
  // filter out non-user changes (remote collab, table auto-scale, etc.)
227
227
  if (!fg('platform_synced_block_update_refactor')) {
228
228
  var _this$syncedBlockStor2;
229
- (_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 ? void 0 : _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node);
229
+ (_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 ? void 0 : _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node, false);
230
230
  }
231
231
  }
232
232
  this.node = node;
@@ -99,7 +99,7 @@ const filterTransactionOnline = ({
99
99
  const {
100
100
  removed: syncBlockRemoved,
101
101
  added: syncBlockAdded
102
- } = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
102
+ } = trackSyncBlocks(syncBlockStore.referenceManager.isReferenceBlock, tr, state);
103
103
  syncBlockRemoved.forEach(syncBlock => {
104
104
  var _api$analytics, _api$analytics$action;
105
105
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent({
@@ -147,6 +147,7 @@ const filterTransactionOnline = ({
147
147
  const filterTransactionOffline = ({
148
148
  tr,
149
149
  state,
150
+ syncBlockStore,
150
151
  api,
151
152
  isConfirmedSyncBlockDeletion,
152
153
  bodiedSyncBlockRemoved,
@@ -155,7 +156,7 @@ const filterTransactionOffline = ({
155
156
  const {
156
157
  removed: syncBlockRemoved,
157
158
  added: syncBlockAdded
158
- } = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
159
+ } = trackSyncBlocks(syncBlockStore.referenceManager.isReferenceBlock, tr, state);
159
160
  let errorFlag = false;
160
161
  if (isConfirmedSyncBlockDeletion || bodiedSyncBlockRemoved.length > 0 || syncBlockRemoved.length > 0) {
161
162
  errorFlag = FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE;
@@ -245,7 +246,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
245
246
  key: syncedBlockPluginKey,
246
247
  state: {
247
248
  init(_, instance) {
248
- const syncBlockNodes = instance.doc.children.filter(node => node.type.name === 'syncBlock');
249
+ const syncBlockNodes = instance.doc.children.filter(syncBlockStore.referenceManager.isReferenceBlock);
249
250
  syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
250
251
 
251
252
  // Populate source sync block cache from initial document
@@ -253,7 +254,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
253
254
  if (fg('platform_synced_block_update_refactor')) {
254
255
  instance.doc.forEach(node => {
255
256
  if (syncBlockStore.sourceManager.isSourceBlock(node)) {
256
- syncBlockStore.sourceManager.updateSyncBlockData(node);
257
+ syncBlockStore.sourceManager.updateSyncBlockData(node, false);
257
258
  }
258
259
  });
259
260
  }
@@ -353,7 +354,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
353
354
  class: SyncBlockStateCssClassName.disabledClassName
354
355
  }));
355
356
  }
356
- if ((node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock') && isViewMode) {
357
+ if (syncBlockStore.isSyncBlock(node) && isViewMode) {
357
358
  viewModeDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
358
359
  class: SyncBlockStateCssClassName.viewModeClassName
359
360
  }));
@@ -365,7 +366,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
365
366
  }
366
367
 
367
368
  // Show sync block border while the user is dragging
368
- if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
369
+ if (isDragging && syncBlockStore.isSyncBlock(node)) {
369
370
  dragDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
370
371
  class: SyncBlockStateCssClassName.draggingClassName
371
372
  }));
@@ -408,7 +409,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
408
409
  return slice;
409
410
  }
410
411
  return mapSlice(slice, node => {
411
- if (node.type.name === 'syncBlock') {
412
+ if (syncBlockStore.referenceManager.isReferenceBlock(node)) {
412
413
  showCopiedFlag(api);
413
414
  return node;
414
415
  }
@@ -449,7 +450,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
449
450
  if (tr.docChanged && !tr.getMeta('isRemote')) {
450
451
  const {
451
452
  added
452
- } = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
453
+ } = trackSyncBlocks(syncBlockStore.referenceManager.isReferenceBlock, tr, state);
453
454
  added.forEach(nodeInfo => {
454
455
  var _nodeInfo$attrs;
455
456
  if ((_nodeInfo$attrs = nodeInfo.attrs) !== null && _nodeInfo$attrs !== void 0 && _nodeInfo$attrs.resourceId) {
@@ -457,6 +458,26 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
457
458
  }
458
459
  });
459
460
  }
461
+ if (fg('platform_synced_block_update_refactor')) {
462
+ // if doc changed and it's a remote transaction, check if any synced block were added,
463
+ // and if so, for source synced blocks, ensure we update the cache with them
464
+ // and for reference synced blocks, ensure we fetch the data from the server
465
+ if (tr.docChanged && tr.getMeta('isRemote')) {
466
+ const {
467
+ added
468
+ } = trackSyncBlocks(node => syncBlockStore.isSyncBlock(node), tr, state);
469
+ const sourceSyncBlockNodes = added.filter(nodeInfo => nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node));
470
+ const referenceSyncBlockNodes = added.filter(nodeInfo => nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node));
471
+ sourceSyncBlockNodes.forEach(nodeInfo => {
472
+ var _nodeInfo$attrs2;
473
+ if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
474
+ syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
475
+ }
476
+ });
477
+ const syncBlockNodes = referenceSyncBlockNodes.map(nodeInfo => nodeInfo.node).filter(node => node !== undefined);
478
+ syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
479
+ }
480
+ }
460
481
  if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
461
482
  return true;
462
483
  }
@@ -467,6 +488,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
467
488
  return isOffline ? filterTransactionOffline({
468
489
  tr,
469
490
  state,
491
+ syncBlockStore,
470
492
  api,
471
493
  isConfirmedSyncBlockDeletion,
472
494
  bodiedSyncBlockRemoved,
@@ -497,7 +519,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
497
519
  if (hasSourceBlockEdit) {
498
520
  newState.doc.forEach(node => {
499
521
  if (syncBlockStore.sourceManager.isSourceBlock(node)) {
500
- syncBlockStore.sourceManager.updateSyncBlockData(node);
522
+ syncBlockStore.sourceManager.updateSyncBlockData(node, false);
501
523
  }
502
524
  });
503
525
  }
@@ -1,5 +1,12 @@
1
1
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
2
2
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
3
+ /**
4
+ * Tracks changes to sync blocks in a transaction.
5
+ * @param predicate - A function that returns true if a node is a sync block (source or reference or both).
6
+ * @param tr - The transaction to track changes in.
7
+ * @param state - The editor state.
8
+ * @returns An object containing the removed and added sync blocks.
9
+ */
3
10
  export const trackSyncBlocks = (predicate, tr, state) => {
4
11
  const removed = {};
5
12
  const added = {};
@@ -13,8 +20,8 @@ export const trackSyncBlocks = (predicate, tr, state) => {
13
20
  // and cast to specific step types
14
21
  const replaceSteps = tr.steps.filter(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
15
22
 
16
- // this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
17
- const hasBodiedSyncBlockChanges = replaceSteps.some(step => {
23
+ // this is a quick check to see if any insertion/deletion of sync block happened
24
+ const hasSyncBlockChanges = replaceSteps.some(step => {
18
25
  const {
19
26
  from,
20
27
  to
@@ -48,7 +55,7 @@ export const trackSyncBlocks = (predicate, tr, state) => {
48
55
  }
49
56
  return hasChange;
50
57
  });
51
- if (hasBodiedSyncBlockChanges) {
58
+ if (hasSyncBlockChanges) {
52
59
  const oldDoc = state.doc;
53
60
  const newDoc = tr.doc;
54
61
  const syncBlockMapOld = {};
@@ -21,7 +21,7 @@ export const syncedBlockPlugin = ({
21
21
  var _api$editorViewMode, _api$editorViewMode$s, _api$analytics, _api$analytics$action, _api$blockMenu, _config$enableSourceC, _api$toolbar, _config$enableSourceC2;
22
22
  const refs = {};
23
23
  const viewMode = 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;
24
- const syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode);
24
+ const syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode, config === null || config === void 0 ? void 0 : config.__livePage);
25
25
  syncBlockStore.setFireAnalyticsEvent(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent);
26
26
  api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
27
27
  api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponents(api, (_config$enableSourceC2 = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC2 !== void 0 ? _config$enableSourceC2 : false));
@@ -202,7 +202,7 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
202
202
  // When fg is ON, cache is populated in state.init() and updated in appendTransaction
203
203
  if (!fg('platform_synced_block_update_refactor')) {
204
204
  var _this$syncedBlockStor;
205
- (_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 || _this$syncedBlockStor.sourceManager.updateSyncBlockData(node);
205
+ (_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 || _this$syncedBlockStor.sourceManager.updateSyncBlockData(node, false);
206
206
  }
207
207
  }
208
208
  return _createClass(BodiedSyncBlock, [{
@@ -263,7 +263,7 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
263
263
  // filter out non-user changes (remote collab, table auto-scale, etc.)
264
264
  if (!fg('platform_synced_block_update_refactor')) {
265
265
  var _this$syncedBlockStor2;
266
- (_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 || _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node);
266
+ (_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 || _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node, false);
267
267
  }
268
268
  }
269
269
  this.node = node;
@@ -114,9 +114,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
114
114
  bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
115
115
  bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
116
116
  extensionFlagShown = _ref3.extensionFlagShown;
117
- var _trackSyncBlocks = trackSyncBlocks(function (node) {
118
- return node.type.name === 'syncBlock';
119
- }, tr, state),
117
+ var _trackSyncBlocks = trackSyncBlocks(syncBlockStore.referenceManager.isReferenceBlock, tr, state),
120
118
  syncBlockRemoved = _trackSyncBlocks.removed,
121
119
  syncBlockAdded = _trackSyncBlocks.added;
122
120
  syncBlockRemoved.forEach(function (syncBlock) {
@@ -166,13 +164,12 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
166
164
  var filterTransactionOffline = function filterTransactionOffline(_ref4) {
167
165
  var tr = _ref4.tr,
168
166
  state = _ref4.state,
167
+ syncBlockStore = _ref4.syncBlockStore,
169
168
  api = _ref4.api,
170
169
  isConfirmedSyncBlockDeletion = _ref4.isConfirmedSyncBlockDeletion,
171
170
  bodiedSyncBlockRemoved = _ref4.bodiedSyncBlockRemoved,
172
171
  bodiedSyncBlockAdded = _ref4.bodiedSyncBlockAdded;
173
- var _trackSyncBlocks2 = trackSyncBlocks(function (node) {
174
- return node.type.name === 'syncBlock';
175
- }, tr, state),
172
+ var _trackSyncBlocks2 = trackSyncBlocks(syncBlockStore.referenceManager.isReferenceBlock, tr, state),
176
173
  syncBlockRemoved = _trackSyncBlocks2.removed,
177
174
  syncBlockAdded = _trackSyncBlocks2.added;
178
175
  var errorFlag = false;
@@ -275,9 +272,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
275
272
  key: syncedBlockPluginKey,
276
273
  state: {
277
274
  init: function init(_, instance) {
278
- var syncBlockNodes = instance.doc.children.filter(function (node) {
279
- return node.type.name === 'syncBlock';
280
- });
275
+ var syncBlockNodes = instance.doc.children.filter(syncBlockStore.referenceManager.isReferenceBlock);
281
276
  syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
282
277
 
283
278
  // Populate source sync block cache from initial document
@@ -285,7 +280,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
285
280
  if (fg('platform_synced_block_update_refactor')) {
286
281
  instance.doc.forEach(function (node) {
287
282
  if (syncBlockStore.sourceManager.isSourceBlock(node)) {
288
- syncBlockStore.sourceManager.updateSyncBlockData(node);
283
+ syncBlockStore.sourceManager.updateSyncBlockData(node, false);
289
284
  }
290
285
  });
291
286
  }
@@ -384,7 +379,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
384
379
  class: SyncBlockStateCssClassName.disabledClassName
385
380
  }));
386
381
  }
387
- if ((node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock') && isViewMode) {
382
+ if (syncBlockStore.isSyncBlock(node) && isViewMode) {
388
383
  viewModeDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
389
384
  class: SyncBlockStateCssClassName.viewModeClassName
390
385
  }));
@@ -396,7 +391,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
396
391
  }
397
392
 
398
393
  // Show sync block border while the user is dragging
399
- if (isDragging && (node.type.name === 'bodiedSyncBlock' || node.type.name === 'syncBlock')) {
394
+ if (isDragging && syncBlockStore.isSyncBlock(node)) {
400
395
  dragDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
401
396
  class: SyncBlockStateCssClassName.draggingClassName
402
397
  }));
@@ -438,7 +433,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
438
433
  return slice;
439
434
  }
440
435
  return mapSlice(slice, function (node) {
441
- if (node.type.name === 'syncBlock') {
436
+ if (syncBlockStore.referenceManager.isReferenceBlock(node)) {
442
437
  showCopiedFlag(api);
443
438
  return node;
444
439
  }
@@ -476,9 +471,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
476
471
 
477
472
  // Track newly added reference sync blocks before processing the transaction
478
473
  if (tr.docChanged && !tr.getMeta('isRemote')) {
479
- var _trackSyncBlocks3 = trackSyncBlocks(function (node) {
480
- return node.type.name === 'syncBlock';
481
- }, tr, state),
474
+ var _trackSyncBlocks3 = trackSyncBlocks(syncBlockStore.referenceManager.isReferenceBlock, tr, state),
482
475
  added = _trackSyncBlocks3.added;
483
476
  added.forEach(function (nodeInfo) {
484
477
  var _nodeInfo$attrs;
@@ -487,15 +480,45 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
487
480
  }
488
481
  });
489
482
  }
483
+ if (fg('platform_synced_block_update_refactor')) {
484
+ // if doc changed and it's a remote transaction, check if any synced block were added,
485
+ // and if so, for source synced blocks, ensure we update the cache with them
486
+ // and for reference synced blocks, ensure we fetch the data from the server
487
+ if (tr.docChanged && tr.getMeta('isRemote')) {
488
+ var _trackSyncBlocks4 = trackSyncBlocks(function (node) {
489
+ return syncBlockStore.isSyncBlock(node);
490
+ }, tr, state),
491
+ _added = _trackSyncBlocks4.added;
492
+ var sourceSyncBlockNodes = _added.filter(function (nodeInfo) {
493
+ return nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node);
494
+ });
495
+ var referenceSyncBlockNodes = _added.filter(function (nodeInfo) {
496
+ return nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node);
497
+ });
498
+ sourceSyncBlockNodes.forEach(function (nodeInfo) {
499
+ var _nodeInfo$attrs2;
500
+ if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
501
+ syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
502
+ }
503
+ });
504
+ var syncBlockNodes = referenceSyncBlockNodes.map(function (nodeInfo) {
505
+ return nodeInfo.node;
506
+ }).filter(function (node) {
507
+ return node !== undefined;
508
+ });
509
+ syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
510
+ }
511
+ }
490
512
  if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
491
513
  return true;
492
514
  }
493
- var _trackSyncBlocks4 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state),
494
- bodiedSyncBlockRemoved = _trackSyncBlocks4.removed,
495
- bodiedSyncBlockAdded = _trackSyncBlocks4.added;
515
+ var _trackSyncBlocks5 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, state),
516
+ bodiedSyncBlockRemoved = _trackSyncBlocks5.removed,
517
+ bodiedSyncBlockAdded = _trackSyncBlocks5.added;
496
518
  return isOffline ? filterTransactionOffline({
497
519
  tr: tr,
498
520
  state: state,
521
+ syncBlockStore: syncBlockStore,
499
522
  api: api,
500
523
  isConfirmedSyncBlockDeletion: isConfirmedSyncBlockDeletion,
501
524
  bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
@@ -530,7 +553,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
530
553
  if (hasSourceBlockEdit) {
531
554
  newState.doc.forEach(function (node) {
532
555
  if (syncBlockStore.sourceManager.isSourceBlock(node)) {
533
- syncBlockStore.sourceManager.updateSyncBlockData(node);
556
+ syncBlockStore.sourceManager.updateSyncBlockData(node, false);
534
557
  }
535
558
  });
536
559
  }
@@ -548,8 +571,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
548
571
  var _loop = function _loop() {
549
572
  var tr = _step2.value;
550
573
  if (tr.getMeta(pmHistoryPluginKey)) {
551
- var _trackSyncBlocks5 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
552
- added = _trackSyncBlocks5.added;
574
+ var _trackSyncBlocks6 = trackSyncBlocks(syncBlockStore.sourceManager.isSourceBlock, tr, oldState),
575
+ added = _trackSyncBlocks6.added;
553
576
  if (added.length > 0) {
554
577
  // Delete bodiedSyncBlock if it's originated from history, i.e. redo creation
555
578
  // See filterTransaction above for more details
@@ -1,5 +1,12 @@
1
1
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
2
2
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
3
+ /**
4
+ * Tracks changes to sync blocks in a transaction.
5
+ * @param predicate - A function that returns true if a node is a sync block (source or reference or both).
6
+ * @param tr - The transaction to track changes in.
7
+ * @param state - The editor state.
8
+ * @returns An object containing the removed and added sync blocks.
9
+ */
3
10
  export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
4
11
  var removed = {};
5
12
  var added = {};
@@ -15,8 +22,8 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
15
22
  return step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
16
23
  });
17
24
 
18
- // this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
19
- var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
25
+ // this is a quick check to see if any insertion/deletion of sync block happened
26
+ var hasSyncBlockChanges = replaceSteps.some(function (step) {
20
27
  var from = step.from,
21
28
  to = step.to;
22
29
  var docAtStep = tr.docs[tr.steps.indexOf(step)];
@@ -48,7 +55,7 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
48
55
  }
49
56
  return hasChange;
50
57
  });
51
- if (hasBodiedSyncBlockChanges) {
58
+ if (hasSyncBlockChanges) {
52
59
  var oldDoc = state.doc;
53
60
  var newDoc = tr.doc;
54
61
  var syncBlockMapOld = {};
@@ -20,7 +20,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
20
20
  api = _ref.api;
21
21
  var refs = {};
22
22
  var viewMode = 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;
23
- var syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode);
23
+ var syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode, config === null || config === void 0 ? void 0 : config.__livePage);
24
24
  syncBlockStore.setFireAnalyticsEvent(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent);
25
25
  api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
26
26
  api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents(api, (_config$enableSourceC2 = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC2 !== void 0 ? _config$enableSourceC2 : false));
@@ -1,9 +1,16 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { SyncBlockInfo } from '../../types';
4
+ /**
5
+ * Tracks changes to sync blocks in a transaction.
6
+ * @param predicate - A function that returns true if a node is a sync block (source or reference or both).
7
+ * @param tr - The transaction to track changes in.
8
+ * @param state - The editor state.
9
+ * @returns An object containing the removed and added sync blocks.
10
+ */
4
11
  export declare const trackSyncBlocks: (predicate: (node: PMNode) => boolean, tr: Transaction, state: EditorState) => {
5
- removed: SyncBlockInfo[];
6
12
  added: SyncBlockInfo[];
13
+ removed: SyncBlockInfo[];
7
14
  };
8
15
  /**
9
16
  *
@@ -44,6 +44,14 @@ export type SyncedBlockRendererProps = {
44
44
  syncBlockFetchResult: UseFetchSyncBlockDataResult;
45
45
  };
46
46
  export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
47
+ /**
48
+ * Enables Live Page specific behaviour for the synced block plugin.
49
+ *
50
+ * It is only supported for use by Confluence.
51
+ *
52
+ * @default false
53
+ */
54
+ __livePage?: boolean;
47
55
  enableSourceCreation?: boolean;
48
56
  syncBlockDataProvider: SyncBlockDataProviderInterface;
49
57
  syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
@@ -1,9 +1,16 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { SyncBlockInfo } from '../../types';
4
+ /**
5
+ * Tracks changes to sync blocks in a transaction.
6
+ * @param predicate - A function that returns true if a node is a sync block (source or reference or both).
7
+ * @param tr - The transaction to track changes in.
8
+ * @param state - The editor state.
9
+ * @returns An object containing the removed and added sync blocks.
10
+ */
4
11
  export declare const trackSyncBlocks: (predicate: (node: PMNode) => boolean, tr: Transaction, state: EditorState) => {
5
- removed: SyncBlockInfo[];
6
12
  added: SyncBlockInfo[];
13
+ removed: SyncBlockInfo[];
7
14
  };
8
15
  /**
9
16
  *
@@ -44,6 +44,14 @@ export type SyncedBlockRendererProps = {
44
44
  syncBlockFetchResult: UseFetchSyncBlockDataResult;
45
45
  };
46
46
  export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
47
+ /**
48
+ * Enables Live Page specific behaviour for the synced block plugin.
49
+ *
50
+ * It is only supported for use by Confluence.
51
+ *
52
+ * @default false
53
+ */
54
+ __livePage?: boolean;
47
55
  enableSourceCreation?: boolean;
48
56
  syncBlockDataProvider: SyncBlockDataProviderInterface;
49
57
  syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "6.0.50",
3
+ "version": "6.1.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,8 +29,8 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^52.4.0",
32
- "@atlaskit/button": "23.11.0",
33
- "@atlaskit/dropdown-menu": "16.8.6",
32
+ "@atlaskit/button": "23.11.1",
33
+ "@atlaskit/dropdown-menu": "16.8.7",
34
34
  "@atlaskit/editor-json-transformer": "^8.31.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^8.0.0",
36
36
  "@atlaskit/editor-plugin-block-menu": "^7.0.0",
@@ -43,7 +43,7 @@
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.3.0",
46
+ "@atlaskit/editor-synced-block-provider": "^4.4.0",
47
47
  "@atlaskit/editor-toolbar": "^0.20.0",
48
48
  "@atlaskit/flag": "^17.9.0",
49
49
  "@atlaskit/icon": "34.0.2",