@atlaskit/editor-plugin-synced-block 5.4.5 → 5.4.6

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,15 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 5.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2e6129d5b39bc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2e6129d5b39bc) -
8
+ EDITOR-5529 clean up platform_synced_block_patch_3 and platform_synced_block_patch_4
9
+ - [`b853527230a60`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b853527230a60) -
10
+ [EDITOR-5520] Fix reference sync block shows old page data when transitioning between live pages
11
+ - Updated dependencies
12
+
3
13
  ## 5.4.5
4
14
 
5
15
  ### Patch Changes
@@ -17,6 +17,7 @@ var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
17
17
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
18
18
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
19
19
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
20
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
21
  var _editorCommands = require("../editor-commands");
21
22
  var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
22
23
  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)); }
@@ -40,6 +41,20 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
40
41
  domRef.classList.add(_syncBlock.SyncBlockSharedCssClassName.prefix);
41
42
  return domRef;
42
43
  }
44
+ }, {
45
+ key: "validUpdate",
46
+ value: function validUpdate(currentNode, newNode) {
47
+ // Only consider as the valid update if the localId and resourceId are the same
48
+ // This prevents PM reusing the same node view for different sync block node in live page transition
49
+ return currentNode.attrs.localId === newNode.attrs.localId && currentNode.attrs.resourceId === newNode.attrs.resourceId;
50
+ }
51
+ }, {
52
+ key: "update",
53
+ value: function update(node, decorations, innerDecorations) {
54
+ return _superPropGet(SyncBlock, "update", this, 3)([node, decorations, innerDecorations, (0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
55
+ exposure: true
56
+ }) ? this.validUpdate : undefined]);
57
+ }
43
58
  }, {
44
59
  key: "render",
45
60
  value: function render(_ref) {
@@ -83,9 +83,6 @@ var showCopiedFlag = function showCopiedFlag(api) {
83
83
  };
84
84
  var showInlineExtensionInSyncBlockWarningIfNeeded = function showInlineExtensionInSyncBlockWarningIfNeeded(tr, state, api, inlineExtensionFlagShown) {
85
85
  var _api$connectivity;
86
- if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
87
- return;
88
- }
89
86
  if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(_utils.pmHistoryPluginKey)) || (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode)) {
90
87
  return;
91
88
  }
@@ -140,31 +137,17 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
140
137
  });
141
138
  });
142
139
  syncBlockAdded.forEach(function (syncBlock) {
143
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
144
- var _api$analytics2;
145
- api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
146
- action: _analytics.ACTION.INSERTED,
147
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
148
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
149
- attributes: {
150
- resourceId: syncBlock.attrs.resourceId,
151
- blockInstanceId: syncBlock.attrs.localId
152
- },
153
- eventType: _analytics.EVENT_TYPE.TRACK
154
- });
155
- } else {
156
- var _api$analytics3;
157
- 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({
158
- action: _analytics.ACTION.INSERTED,
159
- actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
160
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
161
- attributes: {
162
- resourceId: syncBlock.attrs.resourceId,
163
- blockInstanceId: syncBlock.attrs.localId
164
- },
165
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
166
- });
167
- }
140
+ var _api$analytics2;
141
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
142
+ action: _analytics.ACTION.INSERTED,
143
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
144
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
145
+ attributes: {
146
+ resourceId: syncBlock.attrs.resourceId,
147
+ blockInstanceId: syncBlock.attrs.localId
148
+ },
149
+ eventType: _analytics.EVENT_TYPE.TRACK
150
+ });
168
151
  });
169
152
  if (bodiedSyncBlockRemoved.length > 0) {
170
153
  // eslint-disable-next-line no-param-reassign
@@ -529,8 +512,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
529
512
  _syncBlockRemoved = _trackSyncBlocks5.removed,
530
513
  _syncBlockAdded = _trackSyncBlocks5.added;
531
514
  _syncBlockRemoved.forEach(function (syncBlock) {
532
- var _api$analytics4;
533
- 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({
515
+ var _api$analytics3;
516
+ 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({
534
517
  action: _analytics.ACTION.DELETED,
535
518
  actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
536
519
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -542,31 +525,17 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
542
525
  });
543
526
  });
544
527
  _syncBlockAdded.forEach(function (syncBlock) {
545
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
546
- var _api$analytics5;
547
- api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || (_api$analytics5 = _api$analytics5.actions) === null || _api$analytics5 === void 0 || _api$analytics5.fireAnalyticsEvent({
548
- action: _analytics.ACTION.INSERTED,
549
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
550
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
551
- attributes: {
552
- resourceId: syncBlock.attrs.resourceId,
553
- blockInstanceId: syncBlock.attrs.localId
554
- },
555
- eventType: _analytics.EVENT_TYPE.TRACK
556
- });
557
- } else {
558
- var _api$analytics6;
559
- api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || (_api$analytics6 = _api$analytics6.actions) === null || _api$analytics6 === void 0 || _api$analytics6.fireAnalyticsEvent({
560
- action: _analytics.ACTION.INSERTED,
561
- actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
562
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
563
- attributes: {
564
- resourceId: syncBlock.attrs.resourceId,
565
- blockInstanceId: syncBlock.attrs.localId
566
- },
567
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
568
- });
569
- }
528
+ var _api$analytics4;
529
+ 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({
530
+ action: _analytics.ACTION.INSERTED,
531
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
532
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
533
+ attributes: {
534
+ resourceId: syncBlock.attrs.resourceId,
535
+ blockInstanceId: syncBlock.attrs.localId
536
+ },
537
+ eventType: _analytics.EVENT_TYPE.TRACK
538
+ });
570
539
  });
571
540
  if (bodiedSyncBlockRemoved.length > 0) {
572
541
  confirmationTransactionRef.current = tr;
@@ -6,10 +6,6 @@ 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
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
9
  var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
14
10
  var removed = {};
15
11
  var added = {};
@@ -26,10 +22,10 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
26
22
  });
27
23
 
28
24
  // this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
29
- var hasBodiedSyncBlockChanges = replaceSteps.some(function (step, idx) {
25
+ var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
30
26
  var from = step.from,
31
27
  to = step.to;
32
- var docAtStep = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? tr.docs[tr.steps.indexOf(step)] : tr.docs[idx];
28
+ var docAtStep = tr.docs[tr.steps.indexOf(step)];
33
29
  var hasChange = false;
34
30
  if (from !== to) {
35
31
  step.getMap().forEach(function (oldStart, oldEnd) {
@@ -109,70 +105,32 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
109
105
  */
110
106
  var hasEditInSyncBlock = exports.hasEditInSyncBlock = function hasEditInSyncBlock(tr, state) {
111
107
  var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
112
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
113
- for (var i = 0; i < tr.steps.length; i++) {
114
- var _tr$docs;
115
- var step = tr.steps[i];
116
- var map = step.getMap();
117
- var docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
118
- var positions = [];
108
+ for (var i = 0; i < tr.steps.length; i++) {
109
+ var _tr$docs;
110
+ var step = tr.steps[i];
111
+ var map = step.getMap();
112
+ var docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
113
+ var positions = [];
119
114
 
120
- // Extract positions from steps dynamically based on applicable properties
121
- if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
122
- var _ref = step,
123
- from = _ref.from,
124
- to = _ref.to;
125
- positions.push(from, to);
126
- } else if ('pos' in step && typeof step.pos === 'number') {
127
- var _ref2 = step,
128
- pos = _ref2.pos;
129
- positions.push(pos);
130
- }
131
- for (var _i = 0, _positions = positions; _i < _positions.length; _i++) {
132
- var _pos = _positions[_i];
133
- var newPos = map.map(_pos);
134
- if (newPos >= 0 && newPos <= docAfterStep.content.size) {
135
- if ((0, _utils.findParentNodeOfTypeClosestToPos)(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
136
- return true;
137
- }
138
- }
139
- }
115
+ // Extract positions from steps dynamically based on applicable properties
116
+ if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
117
+ var _ref = step,
118
+ from = _ref.from,
119
+ to = _ref.to;
120
+ positions.push(from, to);
121
+ } else if ('pos' in step && typeof step.pos === 'number') {
122
+ var _ref2 = step,
123
+ pos = _ref2.pos;
124
+ positions.push(pos);
140
125
  }
141
- } else {
142
- var _iterator = _createForOfIteratorHelper(tr.steps),
143
- _step;
144
- try {
145
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
146
- var _step2 = _step.value;
147
- var _map = _step2.getMap();
148
- var doc = tr.doc;
149
- var _positions2 = [];
150
-
151
- // Extract positions from steps dynamically based on applicable properties
152
- if ('from' in _step2 && typeof _step2.from === 'number' && 'to' in _step2 && typeof _step2.to === 'number') {
153
- var _ref3 = _step2,
154
- _from = _ref3.from,
155
- _to = _ref3.to;
156
- _positions2.push(_from, _to);
157
- } else if ('pos' in _step2 && typeof _step2.pos === 'number') {
158
- var _ref4 = _step2,
159
- _pos2 = _ref4.pos;
160
- _positions2.push(_pos2);
161
- }
162
- for (var _i2 = 0, _positions3 = _positions2; _i2 < _positions3.length; _i2++) {
163
- var _pos3 = _positions3[_i2];
164
- var _newPos = _map.map(_pos3);
165
- if (_newPos >= 0 && _newPos <= doc.content.size) {
166
- if ((0, _utils.findParentNodeOfTypeClosestToPos)(doc.resolve(_newPos), bodiedSyncBlock)) {
167
- return true;
168
- }
169
- }
126
+ for (var _i = 0, _positions = positions; _i < _positions.length; _i++) {
127
+ var _pos = _positions[_i];
128
+ var newPos = map.map(_pos);
129
+ if (newPos >= 0 && newPos <= docAfterStep.content.size) {
130
+ if ((0, _utils.findParentNodeOfTypeClosestToPos)(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
131
+ return true;
170
132
  }
171
133
  }
172
- } catch (err) {
173
- _iterator.e(err);
174
- } finally {
175
- _iterator.f();
176
134
  }
177
135
  }
178
136
  return false;
@@ -39,9 +39,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
39
39
  node: _adfSchema.syncBlock
40
40
  }, {
41
41
  name: 'bodiedSyncBlock',
42
- node:
43
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning
44
- (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') && !(0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
42
+ node: !(0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
45
43
  exposure: true
46
44
  }) ?
47
45
  // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
@@ -31,7 +31,6 @@ var _quotationMark = _interopRequireDefault(require("@atlaskit/icon/core/quotati
31
31
  var _statusError = _interopRequireDefault(require("@atlaskit/icon/core/status-error"));
32
32
  var _logo = require("@atlaskit/logo");
33
33
  var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
34
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
35
34
  var _compiled = require("@atlaskit/primitives/compiled");
36
35
  var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
37
36
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
@@ -89,31 +88,23 @@ var productIconMap = {
89
88
  'jira-work-item': _logo.JiraIcon
90
89
  };
91
90
  var subTypeIconMap = {
92
- live: _pageLiveDoc.default,
93
- page: _page.default,
94
- blogpost: _quotationMark.default
95
- };
96
- var subTypeIconMapNew = {
97
91
  live: _pageLiveDoc.default,
98
92
  page: _page.default
99
93
  };
100
94
  var getConfluenceSubTypeIcon = function getConfluenceSubTypeIcon(sourceAri, subType) {
101
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
102
- try {
103
- var _getPageIdAndTypeFrom = (0, _editorSyncedBlockProvider.getPageIdAndTypeFromConfluencePageAri)({
104
- ari: sourceAri
105
- }),
106
- pageType = _getPageIdAndTypeFrom.type;
107
- if (pageType === 'blogpost') {
108
- return _quotationMark.default;
109
- } else {
110
- return subType && subType in subTypeIconMapNew ? subTypeIconMapNew[subType] : _page.default;
111
- }
112
- } catch (_unused) {
113
- return _page.default;
95
+ try {
96
+ var _getPageIdAndTypeFrom = (0, _editorSyncedBlockProvider.getPageIdAndTypeFromConfluencePageAri)({
97
+ ari: sourceAri
98
+ }),
99
+ pageType = _getPageIdAndTypeFrom.type;
100
+ if (pageType === 'blogpost') {
101
+ return _quotationMark.default;
102
+ } else {
103
+ return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : _page.default;
114
104
  }
105
+ } catch (_unused) {
106
+ return _page.default;
115
107
  }
116
- return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : _page.default;
117
108
  };
118
109
  var ProductIcon = function ProductIcon(_ref2) {
119
110
  var _productIconMap$produ;
@@ -4,6 +4,7 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
4
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import { SyncBlockSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
6
6
  import { useFetchSyncBlockData, useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
7
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import { removeSyncedBlockAtPos } from '../editor-commands';
8
9
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
9
10
  export class SyncBlock extends ReactNodeView {
@@ -18,6 +19,16 @@ export class SyncBlock extends ReactNodeView {
18
19
  domRef.classList.add(SyncBlockSharedCssClassName.prefix);
19
20
  return domRef;
20
21
  }
22
+ validUpdate(currentNode, newNode) {
23
+ // Only consider as the valid update if the localId and resourceId are the same
24
+ // This prevents PM reusing the same node view for different sync block node in live page transition
25
+ return currentNode.attrs.localId === newNode.attrs.localId && currentNode.attrs.resourceId === newNode.attrs.resourceId;
26
+ }
27
+ update(node, decorations, innerDecorations) {
28
+ return super.update(node, decorations, innerDecorations, editorExperiment('platform_synced_block_patch_6', true, {
29
+ exposure: true
30
+ }) ? this.validUpdate : undefined);
31
+ }
21
32
  render({
22
33
  getPos
23
34
  }) {
@@ -58,9 +58,6 @@ const showCopiedFlag = api => {
58
58
  };
59
59
  const showInlineExtensionInSyncBlockWarningIfNeeded = (tr, state, api, inlineExtensionFlagShown) => {
60
60
  var _api$connectivity, _api$connectivity$sha;
61
- if (!fg('platform_synced_block_patch_3')) {
62
- return;
63
- }
64
61
  if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(pmHistoryPluginKey)) || isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState.currentState()) === null || _api$connectivity$sha === void 0 ? void 0 : _api$connectivity$sha.mode)) {
65
62
  return;
66
63
  }
@@ -114,31 +111,17 @@ const filterTransactionOnline = ({
114
111
  });
115
112
  });
116
113
  syncBlockAdded.forEach(syncBlock => {
117
- if (fg('platform_synced_block_patch_3')) {
118
- var _api$analytics2, _api$analytics2$actio;
119
- api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.fireAnalyticsEvent({
120
- action: ACTION.INSERTED,
121
- actionSubject: ACTION_SUBJECT.DOCUMENT,
122
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
123
- attributes: {
124
- resourceId: syncBlock.attrs.resourceId,
125
- blockInstanceId: syncBlock.attrs.localId
126
- },
127
- eventType: EVENT_TYPE.TRACK
128
- });
129
- } else {
130
- var _api$analytics3, _api$analytics3$actio;
131
- api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : (_api$analytics3$actio = _api$analytics3.actions) === null || _api$analytics3$actio === void 0 ? void 0 : _api$analytics3$actio.fireAnalyticsEvent({
132
- action: ACTION.INSERTED,
133
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
134
- actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
135
- attributes: {
136
- resourceId: syncBlock.attrs.resourceId,
137
- blockInstanceId: syncBlock.attrs.localId
138
- },
139
- eventType: EVENT_TYPE.OPERATIONAL
140
- });
141
- }
114
+ var _api$analytics2, _api$analytics2$actio;
115
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.fireAnalyticsEvent({
116
+ action: ACTION.INSERTED,
117
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
118
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
119
+ attributes: {
120
+ resourceId: syncBlock.attrs.resourceId,
121
+ blockInstanceId: syncBlock.attrs.localId
122
+ },
123
+ eventType: EVENT_TYPE.TRACK
124
+ });
142
125
  });
143
126
  if (bodiedSyncBlockRemoved.length > 0) {
144
127
  // eslint-disable-next-line no-param-reassign
@@ -493,8 +476,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
493
476
  added: syncBlockAdded
494
477
  } = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
495
478
  syncBlockRemoved.forEach(syncBlock => {
496
- var _api$analytics4, _api$analytics4$actio;
497
- api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : (_api$analytics4$actio = _api$analytics4.actions) === null || _api$analytics4$actio === void 0 ? void 0 : _api$analytics4$actio.fireAnalyticsEvent({
479
+ var _api$analytics3, _api$analytics3$actio;
480
+ api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : (_api$analytics3$actio = _api$analytics3.actions) === null || _api$analytics3$actio === void 0 ? void 0 : _api$analytics3$actio.fireAnalyticsEvent({
498
481
  action: ACTION.DELETED,
499
482
  actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
500
483
  actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -506,31 +489,17 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
506
489
  });
507
490
  });
508
491
  syncBlockAdded.forEach(syncBlock => {
509
- if (fg('platform_synced_block_patch_3')) {
510
- var _api$analytics5, _api$analytics5$actio;
511
- api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : (_api$analytics5$actio = _api$analytics5.actions) === null || _api$analytics5$actio === void 0 ? void 0 : _api$analytics5$actio.fireAnalyticsEvent({
512
- action: ACTION.INSERTED,
513
- actionSubject: ACTION_SUBJECT.DOCUMENT,
514
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
515
- attributes: {
516
- resourceId: syncBlock.attrs.resourceId,
517
- blockInstanceId: syncBlock.attrs.localId
518
- },
519
- eventType: EVENT_TYPE.TRACK
520
- });
521
- } else {
522
- var _api$analytics6, _api$analytics6$actio;
523
- api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : (_api$analytics6$actio = _api$analytics6.actions) === null || _api$analytics6$actio === void 0 ? void 0 : _api$analytics6$actio.fireAnalyticsEvent({
524
- action: ACTION.INSERTED,
525
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
526
- actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
527
- attributes: {
528
- resourceId: syncBlock.attrs.resourceId,
529
- blockInstanceId: syncBlock.attrs.localId
530
- },
531
- eventType: EVENT_TYPE.OPERATIONAL
532
- });
533
- }
492
+ var _api$analytics4, _api$analytics4$actio;
493
+ api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : (_api$analytics4$actio = _api$analytics4.actions) === null || _api$analytics4$actio === void 0 ? void 0 : _api$analytics4$actio.fireAnalyticsEvent({
494
+ action: ACTION.INSERTED,
495
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
496
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
497
+ attributes: {
498
+ resourceId: syncBlock.attrs.resourceId,
499
+ blockInstanceId: syncBlock.attrs.localId
500
+ },
501
+ eventType: EVENT_TYPE.TRACK
502
+ });
534
503
  });
535
504
  if (bodiedSyncBlockRemoved.length > 0) {
536
505
  confirmationTransactionRef.current = tr;
@@ -1,6 +1,5 @@
1
1
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
2
2
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  export const trackSyncBlocks = (predicate, tr, state) => {
5
4
  const removed = {};
6
5
  const added = {};
@@ -15,12 +14,12 @@ export const trackSyncBlocks = (predicate, tr, state) => {
15
14
  const replaceSteps = tr.steps.filter(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
16
15
 
17
16
  // this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
18
- const hasBodiedSyncBlockChanges = replaceSteps.some((step, idx) => {
17
+ const hasBodiedSyncBlockChanges = replaceSteps.some(step => {
19
18
  const {
20
19
  from,
21
20
  to
22
21
  } = step;
23
- const docAtStep = fg('platform_synced_block_patch_3') ? tr.docs[tr.steps.indexOf(step)] : tr.docs[idx];
22
+ const docAtStep = tr.docs[tr.steps.indexOf(step)];
24
23
  let hasChange = false;
25
24
  if (from !== to) {
26
25
  step.getMap().forEach((oldStart, oldEnd) => {
@@ -102,63 +101,31 @@ export const hasEditInSyncBlock = (tr, state) => {
102
101
  const {
103
102
  bodiedSyncBlock
104
103
  } = state.schema.nodes;
105
- if (fg('platform_synced_block_patch_3')) {
106
- for (let i = 0; i < tr.steps.length; i++) {
107
- var _tr$docs;
108
- const step = tr.steps[i];
109
- const map = step.getMap();
110
- const docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
111
- const positions = [];
104
+ for (let i = 0; i < tr.steps.length; i++) {
105
+ var _tr$docs;
106
+ const step = tr.steps[i];
107
+ const map = step.getMap();
108
+ const docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
109
+ const positions = [];
112
110
 
113
- // Extract positions from steps dynamically based on applicable properties
114
- if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
115
- const {
116
- from,
117
- to
118
- } = step;
119
- positions.push(from, to);
120
- } else if ('pos' in step && typeof step.pos === 'number') {
121
- const {
122
- pos
123
- } = step;
124
- positions.push(pos);
125
- }
126
- for (const pos of positions) {
127
- const newPos = map.map(pos);
128
- if (newPos >= 0 && newPos <= docAfterStep.content.size) {
129
- if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
130
- return true;
131
- }
132
- }
133
- }
134
- }
135
- } else {
136
- for (const step of tr.steps) {
137
- const map = step.getMap();
111
+ // Extract positions from steps dynamically based on applicable properties
112
+ if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
138
113
  const {
139
- doc
140
- } = tr;
141
- const positions = [];
142
-
143
- // Extract positions from steps dynamically based on applicable properties
144
- if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
145
- const {
146
- from,
147
- to
148
- } = step;
149
- positions.push(from, to);
150
- } else if ('pos' in step && typeof step.pos === 'number') {
151
- const {
152
- pos
153
- } = step;
154
- positions.push(pos);
155
- }
156
- for (const pos of positions) {
157
- const newPos = map.map(pos);
158
- if (newPos >= 0 && newPos <= doc.content.size) {
159
- if (findParentNodeOfTypeClosestToPos(doc.resolve(newPos), bodiedSyncBlock)) {
160
- return true;
161
- }
114
+ from,
115
+ to
116
+ } = step;
117
+ positions.push(from, to);
118
+ } else if ('pos' in step && typeof step.pos === 'number') {
119
+ const {
120
+ pos
121
+ } = step;
122
+ positions.push(pos);
123
+ }
124
+ for (const pos of positions) {
125
+ const newPos = map.map(pos);
126
+ if (newPos >= 0 && newPos <= docAfterStep.content.size) {
127
+ if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
128
+ return true;
162
129
  }
163
130
  }
164
131
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
2
+ import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
3
3
  import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -33,9 +33,7 @@ export const syncedBlockPlugin = ({
33
33
  node: syncBlock
34
34
  }, {
35
35
  name: 'bodiedSyncBlock',
36
- node:
37
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning
38
- fg('platform_synced_block_patch_3') && !editorExperiment('platform_synced_block_patch_6', true, {
36
+ node: !editorExperiment('platform_synced_block_patch_6', true, {
39
37
  exposure: true
40
38
  }) ?
41
39
  // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
@@ -19,7 +19,6 @@ import QuotationMarkIcon from '@atlaskit/icon/core/quotation-mark';
19
19
  import StatusErrorIcon from '@atlaskit/icon/core/status-error';
20
20
  import { ConfluenceIcon, JiraIcon, AtlassianIcon } from '@atlaskit/logo';
21
21
  import Lozenge from '@atlaskit/lozenge';
22
- import { fg } from '@atlaskit/platform-feature-flags';
23
22
  import { Box, Text, Inline, Anchor, Stack } from '@atlaskit/primitives/compiled';
24
23
  import Spinner from '@atlaskit/spinner';
25
24
  import Tooltip from '@atlaskit/tooltip';
@@ -73,32 +72,24 @@ const productIconMap = {
73
72
  'jira-work-item': JiraIcon
74
73
  };
75
74
  const subTypeIconMap = {
76
- live: PageLiveDocIcon,
77
- page: PageIcon,
78
- blogpost: QuotationMarkIcon
79
- };
80
- const subTypeIconMapNew = {
81
75
  live: PageLiveDocIcon,
82
76
  page: PageIcon
83
77
  };
84
78
  const getConfluenceSubTypeIcon = (sourceAri, subType) => {
85
- if (fg('platform_synced_block_patch_3')) {
86
- try {
87
- const {
88
- type: pageType
89
- } = getPageIdAndTypeFromConfluencePageAri({
90
- ari: sourceAri
91
- });
92
- if (pageType === 'blogpost') {
93
- return QuotationMarkIcon;
94
- } else {
95
- return subType && subType in subTypeIconMapNew ? subTypeIconMapNew[subType] : PageIcon;
96
- }
97
- } catch {
98
- return PageIcon;
79
+ try {
80
+ const {
81
+ type: pageType
82
+ } = getPageIdAndTypeFromConfluencePageAri({
83
+ ari: sourceAri
84
+ });
85
+ if (pageType === 'blogpost') {
86
+ return QuotationMarkIcon;
87
+ } else {
88
+ return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : PageIcon;
99
89
  }
90
+ } catch {
91
+ return PageIcon;
100
92
  }
101
- return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : PageIcon;
102
93
  };
103
94
  const ProductIcon = ({
104
95
  product
@@ -13,6 +13,7 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
13
13
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
14
14
  import { SyncBlockSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
15
15
  import { useFetchSyncBlockData as _useFetchSyncBlockData, useFetchSyncBlockTitle as _useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
16
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
17
  import { removeSyncedBlockAtPos } from '../editor-commands';
17
18
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
18
19
  export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
@@ -33,6 +34,20 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
33
34
  domRef.classList.add(SyncBlockSharedCssClassName.prefix);
34
35
  return domRef;
35
36
  }
37
+ }, {
38
+ key: "validUpdate",
39
+ value: function validUpdate(currentNode, newNode) {
40
+ // Only consider as the valid update if the localId and resourceId are the same
41
+ // This prevents PM reusing the same node view for different sync block node in live page transition
42
+ return currentNode.attrs.localId === newNode.attrs.localId && currentNode.attrs.resourceId === newNode.attrs.resourceId;
43
+ }
44
+ }, {
45
+ key: "update",
46
+ value: function update(node, decorations, innerDecorations) {
47
+ return _superPropGet(SyncBlock, "update", this, 3)([node, decorations, innerDecorations, editorExperiment('platform_synced_block_patch_6', true, {
48
+ exposure: true
49
+ }) ? this.validUpdate : undefined]);
50
+ }
36
51
  }, {
37
52
  key: "render",
38
53
  value: function render(_ref) {
@@ -76,9 +76,6 @@ var showCopiedFlag = function showCopiedFlag(api) {
76
76
  };
77
77
  var showInlineExtensionInSyncBlockWarningIfNeeded = function showInlineExtensionInSyncBlockWarningIfNeeded(tr, state, api, inlineExtensionFlagShown) {
78
78
  var _api$connectivity;
79
- if (!fg('platform_synced_block_patch_3')) {
80
- return;
81
- }
82
79
  if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(pmHistoryPluginKey)) || isOfflineMode(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode)) {
83
80
  return;
84
81
  }
@@ -133,31 +130,17 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
133
130
  });
134
131
  });
135
132
  syncBlockAdded.forEach(function (syncBlock) {
136
- if (fg('platform_synced_block_patch_3')) {
137
- var _api$analytics2;
138
- api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
139
- action: ACTION.INSERTED,
140
- actionSubject: ACTION_SUBJECT.DOCUMENT,
141
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
142
- attributes: {
143
- resourceId: syncBlock.attrs.resourceId,
144
- blockInstanceId: syncBlock.attrs.localId
145
- },
146
- eventType: EVENT_TYPE.TRACK
147
- });
148
- } else {
149
- var _api$analytics3;
150
- 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({
151
- action: ACTION.INSERTED,
152
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
153
- actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
154
- attributes: {
155
- resourceId: syncBlock.attrs.resourceId,
156
- blockInstanceId: syncBlock.attrs.localId
157
- },
158
- eventType: EVENT_TYPE.OPERATIONAL
159
- });
160
- }
133
+ var _api$analytics2;
134
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
135
+ action: ACTION.INSERTED,
136
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
137
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
138
+ attributes: {
139
+ resourceId: syncBlock.attrs.resourceId,
140
+ blockInstanceId: syncBlock.attrs.localId
141
+ },
142
+ eventType: EVENT_TYPE.TRACK
143
+ });
161
144
  });
162
145
  if (bodiedSyncBlockRemoved.length > 0) {
163
146
  // eslint-disable-next-line no-param-reassign
@@ -522,8 +505,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
522
505
  _syncBlockRemoved = _trackSyncBlocks5.removed,
523
506
  _syncBlockAdded = _trackSyncBlocks5.added;
524
507
  _syncBlockRemoved.forEach(function (syncBlock) {
525
- var _api$analytics4;
526
- 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({
508
+ var _api$analytics3;
509
+ 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({
527
510
  action: ACTION.DELETED,
528
511
  actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
529
512
  actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -535,31 +518,17 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
535
518
  });
536
519
  });
537
520
  _syncBlockAdded.forEach(function (syncBlock) {
538
- if (fg('platform_synced_block_patch_3')) {
539
- var _api$analytics5;
540
- api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || (_api$analytics5 = _api$analytics5.actions) === null || _api$analytics5 === void 0 || _api$analytics5.fireAnalyticsEvent({
541
- action: ACTION.INSERTED,
542
- actionSubject: ACTION_SUBJECT.DOCUMENT,
543
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
544
- attributes: {
545
- resourceId: syncBlock.attrs.resourceId,
546
- blockInstanceId: syncBlock.attrs.localId
547
- },
548
- eventType: EVENT_TYPE.TRACK
549
- });
550
- } else {
551
- var _api$analytics6;
552
- api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || (_api$analytics6 = _api$analytics6.actions) === null || _api$analytics6 === void 0 || _api$analytics6.fireAnalyticsEvent({
553
- action: ACTION.INSERTED,
554
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
555
- actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
556
- attributes: {
557
- resourceId: syncBlock.attrs.resourceId,
558
- blockInstanceId: syncBlock.attrs.localId
559
- },
560
- eventType: EVENT_TYPE.OPERATIONAL
561
- });
562
- }
521
+ var _api$analytics4;
522
+ 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({
523
+ action: ACTION.INSERTED,
524
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
525
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
526
+ attributes: {
527
+ resourceId: syncBlock.attrs.resourceId,
528
+ blockInstanceId: syncBlock.attrs.localId
529
+ },
530
+ eventType: EVENT_TYPE.TRACK
531
+ });
563
532
  });
564
533
  if (bodiedSyncBlockRemoved.length > 0) {
565
534
  confirmationTransactionRef.current = tr;
@@ -1,9 +1,5 @@
1
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
1
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
5
2
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
3
  export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
8
4
  var removed = {};
9
5
  var added = {};
@@ -20,10 +16,10 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
20
16
  });
21
17
 
22
18
  // this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
23
- var hasBodiedSyncBlockChanges = replaceSteps.some(function (step, idx) {
19
+ var hasBodiedSyncBlockChanges = replaceSteps.some(function (step) {
24
20
  var from = step.from,
25
21
  to = step.to;
26
- var docAtStep = fg('platform_synced_block_patch_3') ? tr.docs[tr.steps.indexOf(step)] : tr.docs[idx];
22
+ var docAtStep = tr.docs[tr.steps.indexOf(step)];
27
23
  var hasChange = false;
28
24
  if (from !== to) {
29
25
  step.getMap().forEach(function (oldStart, oldEnd) {
@@ -103,70 +99,32 @@ export var trackSyncBlocks = function trackSyncBlocks(predicate, tr, state) {
103
99
  */
104
100
  export var hasEditInSyncBlock = function hasEditInSyncBlock(tr, state) {
105
101
  var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
106
- if (fg('platform_synced_block_patch_3')) {
107
- for (var i = 0; i < tr.steps.length; i++) {
108
- var _tr$docs;
109
- var step = tr.steps[i];
110
- var map = step.getMap();
111
- var docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
112
- var positions = [];
102
+ for (var i = 0; i < tr.steps.length; i++) {
103
+ var _tr$docs;
104
+ var step = tr.steps[i];
105
+ var map = step.getMap();
106
+ var docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
107
+ var positions = [];
113
108
 
114
- // Extract positions from steps dynamically based on applicable properties
115
- if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
116
- var _ref = step,
117
- from = _ref.from,
118
- to = _ref.to;
119
- positions.push(from, to);
120
- } else if ('pos' in step && typeof step.pos === 'number') {
121
- var _ref2 = step,
122
- pos = _ref2.pos;
123
- positions.push(pos);
124
- }
125
- for (var _i = 0, _positions = positions; _i < _positions.length; _i++) {
126
- var _pos = _positions[_i];
127
- var newPos = map.map(_pos);
128
- if (newPos >= 0 && newPos <= docAfterStep.content.size) {
129
- if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
130
- return true;
131
- }
132
- }
133
- }
109
+ // Extract positions from steps dynamically based on applicable properties
110
+ if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
111
+ var _ref = step,
112
+ from = _ref.from,
113
+ to = _ref.to;
114
+ positions.push(from, to);
115
+ } else if ('pos' in step && typeof step.pos === 'number') {
116
+ var _ref2 = step,
117
+ pos = _ref2.pos;
118
+ positions.push(pos);
134
119
  }
135
- } else {
136
- var _iterator = _createForOfIteratorHelper(tr.steps),
137
- _step;
138
- try {
139
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
140
- var _step2 = _step.value;
141
- var _map = _step2.getMap();
142
- var doc = tr.doc;
143
- var _positions2 = [];
144
-
145
- // Extract positions from steps dynamically based on applicable properties
146
- if ('from' in _step2 && typeof _step2.from === 'number' && 'to' in _step2 && typeof _step2.to === 'number') {
147
- var _ref3 = _step2,
148
- _from = _ref3.from,
149
- _to = _ref3.to;
150
- _positions2.push(_from, _to);
151
- } else if ('pos' in _step2 && typeof _step2.pos === 'number') {
152
- var _ref4 = _step2,
153
- _pos2 = _ref4.pos;
154
- _positions2.push(_pos2);
155
- }
156
- for (var _i2 = 0, _positions3 = _positions2; _i2 < _positions3.length; _i2++) {
157
- var _pos3 = _positions3[_i2];
158
- var _newPos = _map.map(_pos3);
159
- if (_newPos >= 0 && _newPos <= doc.content.size) {
160
- if (findParentNodeOfTypeClosestToPos(doc.resolve(_newPos), bodiedSyncBlock)) {
161
- return true;
162
- }
163
- }
120
+ for (var _i = 0, _positions = positions; _i < _positions.length; _i++) {
121
+ var _pos = _positions[_i];
122
+ var newPos = map.map(_pos);
123
+ if (newPos >= 0 && newPos <= docAfterStep.content.size) {
124
+ if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
125
+ return true;
164
126
  }
165
127
  }
166
- } catch (err) {
167
- _iterator.e(err);
168
- } finally {
169
- _iterator.f();
170
128
  }
171
129
  }
172
130
  return false;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
2
+ import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
3
3
  import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -32,9 +32,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
32
32
  node: syncBlock
33
33
  }, {
34
34
  name: 'bodiedSyncBlock',
35
- node:
36
- // eslint-disable-next-line @atlaskit/platform/no-preconditioning
37
- fg('platform_synced_block_patch_3') && !editorExperiment('platform_synced_block_patch_6', true, {
35
+ node: !editorExperiment('platform_synced_block_patch_6', true, {
38
36
  exposure: true
39
37
  }) ?
40
38
  // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
@@ -27,7 +27,6 @@ import QuotationMarkIcon from '@atlaskit/icon/core/quotation-mark';
27
27
  import StatusErrorIcon from '@atlaskit/icon/core/status-error';
28
28
  import { ConfluenceIcon, JiraIcon, AtlassianIcon } from '@atlaskit/logo';
29
29
  import Lozenge from '@atlaskit/lozenge';
30
- import { fg } from '@atlaskit/platform-feature-flags';
31
30
  import { Box, Text, Inline, Anchor, Stack } from '@atlaskit/primitives/compiled';
32
31
  import Spinner from '@atlaskit/spinner';
33
32
  import Tooltip from '@atlaskit/tooltip';
@@ -80,31 +79,23 @@ var productIconMap = {
80
79
  'jira-work-item': JiraIcon
81
80
  };
82
81
  var subTypeIconMap = {
83
- live: PageLiveDocIcon,
84
- page: PageIcon,
85
- blogpost: QuotationMarkIcon
86
- };
87
- var subTypeIconMapNew = {
88
82
  live: PageLiveDocIcon,
89
83
  page: PageIcon
90
84
  };
91
85
  var getConfluenceSubTypeIcon = function getConfluenceSubTypeIcon(sourceAri, subType) {
92
- if (fg('platform_synced_block_patch_3')) {
93
- try {
94
- var _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
95
- ari: sourceAri
96
- }),
97
- pageType = _getPageIdAndTypeFrom.type;
98
- if (pageType === 'blogpost') {
99
- return QuotationMarkIcon;
100
- } else {
101
- return subType && subType in subTypeIconMapNew ? subTypeIconMapNew[subType] : PageIcon;
102
- }
103
- } catch (_unused) {
104
- return PageIcon;
86
+ try {
87
+ var _getPageIdAndTypeFrom = getPageIdAndTypeFromConfluencePageAri({
88
+ ari: sourceAri
89
+ }),
90
+ pageType = _getPageIdAndTypeFrom.type;
91
+ if (pageType === 'blogpost') {
92
+ return QuotationMarkIcon;
93
+ } else {
94
+ return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : PageIcon;
105
95
  }
96
+ } catch (_unused) {
97
+ return PageIcon;
106
98
  }
107
- return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : PageIcon;
108
99
  };
109
100
  var ProductIcon = function ProductIcon(_ref2) {
110
101
  var _productIconMap$produ;
@@ -5,7 +5,7 @@ import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react
5
5
  import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
6
  import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
+ import type { EditorView, Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/view';
9
9
  import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
10
10
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
11
11
  export interface SyncBlockNodeViewProps extends ReactComponentProps {
@@ -26,6 +26,8 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
26
26
  constructor(props: SyncBlockNodeViewProps);
27
27
  unsubscribe: (() => void) | undefined;
28
28
  createDomRef(): HTMLElement;
29
+ validUpdate(currentNode: PMNode, newNode: PMNode): boolean;
30
+ update(node: PMNode, decorations: ReadonlyArray<Decoration>, innerDecorations?: DecorationSource): boolean;
29
31
  render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
30
32
  destroy(): void;
31
33
  }
@@ -5,7 +5,7 @@ import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react
5
5
  import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
6
  import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
+ import type { EditorView, Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/view';
9
9
  import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
10
10
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
11
11
  export interface SyncBlockNodeViewProps extends ReactComponentProps {
@@ -26,6 +26,8 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
26
26
  constructor(props: SyncBlockNodeViewProps);
27
27
  unsubscribe: (() => void) | undefined;
28
28
  createDomRef(): HTMLElement;
29
+ validUpdate(currentNode: PMNode, newNode: PMNode): boolean;
30
+ update(node: PMNode, decorations: ReadonlyArray<Decoration>, innerDecorations?: DecorationSource): boolean;
29
31
  render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
30
32
  destroy(): void;
31
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.4.5",
3
+ "version": "5.4.6",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -54,7 +54,7 @@
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": "^34.1.0",
57
+ "@atlaskit/tmp-editor-statsig": "^34.2.0",
58
58
  "@atlaskit/tokens": "11.0.2",
59
59
  "@atlaskit/tooltip": "^20.14.0",
60
60
  "@atlaskit/visually-hidden": "^3.0.0",
@@ -108,9 +108,6 @@
108
108
  }
109
109
  },
110
110
  "platform-feature-flags": {
111
- "platform_synced_block_patch_3": {
112
- "type": "boolean"
113
- },
114
111
  "platform_synced_block_patch_5": {
115
112
  "type": "boolean"
116
113
  },