@atlaskit/editor-plugin-synced-block 5.4.4 → 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.
Files changed (44) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/afm-cc/tsconfig.json +12 -0
  3. package/afm-jira/tsconfig.json +12 -0
  4. package/afm-products/tsconfig.json +12 -0
  5. package/dist/cjs/nodeviews/bodiedLazySyncedBlock.js +1 -0
  6. package/dist/cjs/nodeviews/bodiedSyncedBlock.js +137 -11
  7. package/dist/cjs/nodeviews/syncedBlock.js +15 -0
  8. package/dist/cjs/pm-plugins/main.js +42 -58
  9. package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +24 -66
  10. package/dist/cjs/syncedBlockPlugin.js +6 -1
  11. package/dist/cjs/ui/BodiedSyncBlockWrapper.js +1 -0
  12. package/dist/cjs/ui/DeleteConfirmationModal.js +1 -1
  13. package/dist/cjs/ui/SyncBlockLabel.js +4 -1
  14. package/dist/cjs/ui/SyncedLocationDropdown.js +12 -21
  15. package/dist/cjs/ui/quick-insert.js +1 -1
  16. package/dist/es2019/nodeviews/bodiedLazySyncedBlock.js +1 -0
  17. package/dist/es2019/nodeviews/bodiedSyncedBlock.js +121 -6
  18. package/dist/es2019/nodeviews/syncedBlock.js +11 -0
  19. package/dist/es2019/pm-plugins/main.js +43 -59
  20. package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +25 -58
  21. package/dist/es2019/syncedBlockPlugin.js +7 -2
  22. package/dist/es2019/ui/BodiedSyncBlockWrapper.js +1 -0
  23. package/dist/es2019/ui/DeleteConfirmationModal.js +1 -1
  24. package/dist/es2019/ui/SyncBlockLabel.js +4 -1
  25. package/dist/es2019/ui/SyncedLocationDropdown.js +13 -22
  26. package/dist/es2019/ui/quick-insert.js +1 -1
  27. package/dist/esm/nodeviews/bodiedLazySyncedBlock.js +1 -0
  28. package/dist/esm/nodeviews/bodiedSyncedBlock.js +137 -11
  29. package/dist/esm/nodeviews/syncedBlock.js +15 -0
  30. package/dist/esm/pm-plugins/main.js +43 -59
  31. package/dist/esm/pm-plugins/utils/track-sync-blocks.js +24 -66
  32. package/dist/esm/syncedBlockPlugin.js +7 -2
  33. package/dist/esm/ui/BodiedSyncBlockWrapper.js +1 -0
  34. package/dist/esm/ui/DeleteConfirmationModal.js +1 -1
  35. package/dist/esm/ui/SyncBlockLabel.js +4 -1
  36. package/dist/esm/ui/SyncedLocationDropdown.js +12 -21
  37. package/dist/esm/ui/quick-insert.js +1 -1
  38. package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +27 -21
  39. package/dist/types/nodeviews/syncedBlock.d.ts +3 -1
  40. package/dist/types/syncedBlockPluginType.d.ts +3 -1
  41. package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +27 -21
  42. package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +3 -1
  43. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +3 -1
  44. package/package.json +7 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
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
+
13
+ ## 5.4.5
14
+
15
+ ### Patch Changes
16
+
17
+ - [`1a05924d64777`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1a05924d64777) -
18
+ [EDITOR-5528] Fix bodiedSyncBlock mutation
19
+ - Updated dependencies
20
+
3
21
  ## 5.4.4
4
22
 
5
23
  ### Patch Changes
@@ -44,15 +44,24 @@
44
44
  {
45
45
  "path": "../../editor-plugin-connectivity/afm-cc/tsconfig.json"
46
46
  },
47
+ {
48
+ "path": "../../editor-plugin-content-format/afm-cc/tsconfig.json"
49
+ },
47
50
  {
48
51
  "path": "../../editor-plugin-decorations/afm-cc/tsconfig.json"
49
52
  },
50
53
  {
51
54
  "path": "../../editor-plugin-floating-toolbar/afm-cc/tsconfig.json"
52
55
  },
56
+ {
57
+ "path": "../../editor-plugin-focus/afm-cc/tsconfig.json"
58
+ },
53
59
  {
54
60
  "path": "../../editor-plugin-selection/afm-cc/tsconfig.json"
55
61
  },
62
+ {
63
+ "path": "../../editor-plugin-user-intent/afm-cc/tsconfig.json"
64
+ },
56
65
  {
57
66
  "path": "../../editor-prosemirror/afm-cc/tsconfig.json"
58
67
  },
@@ -92,6 +101,9 @@
92
101
  {
93
102
  "path": "../../../design-system/spinner/afm-cc/tsconfig.json"
94
103
  },
104
+ {
105
+ "path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
106
+ },
95
107
  {
96
108
  "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
97
109
  },
@@ -44,15 +44,24 @@
44
44
  {
45
45
  "path": "../../editor-plugin-connectivity/afm-jira/tsconfig.json"
46
46
  },
47
+ {
48
+ "path": "../../editor-plugin-content-format/afm-jira/tsconfig.json"
49
+ },
47
50
  {
48
51
  "path": "../../editor-plugin-decorations/afm-jira/tsconfig.json"
49
52
  },
50
53
  {
51
54
  "path": "../../editor-plugin-floating-toolbar/afm-jira/tsconfig.json"
52
55
  },
56
+ {
57
+ "path": "../../editor-plugin-focus/afm-jira/tsconfig.json"
58
+ },
53
59
  {
54
60
  "path": "../../editor-plugin-selection/afm-jira/tsconfig.json"
55
61
  },
62
+ {
63
+ "path": "../../editor-plugin-user-intent/afm-jira/tsconfig.json"
64
+ },
56
65
  {
57
66
  "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
58
67
  },
@@ -92,6 +101,9 @@
92
101
  {
93
102
  "path": "../../../design-system/spinner/afm-jira/tsconfig.json"
94
103
  },
104
+ {
105
+ "path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
106
+ },
95
107
  {
96
108
  "path": "../../../design-system/tokens/afm-jira/tsconfig.json"
97
109
  },
@@ -44,15 +44,24 @@
44
44
  {
45
45
  "path": "../../editor-plugin-connectivity/afm-products/tsconfig.json"
46
46
  },
47
+ {
48
+ "path": "../../editor-plugin-content-format/afm-products/tsconfig.json"
49
+ },
47
50
  {
48
51
  "path": "../../editor-plugin-decorations/afm-products/tsconfig.json"
49
52
  },
50
53
  {
51
54
  "path": "../../editor-plugin-floating-toolbar/afm-products/tsconfig.json"
52
55
  },
56
+ {
57
+ "path": "../../editor-plugin-focus/afm-products/tsconfig.json"
58
+ },
53
59
  {
54
60
  "path": "../../editor-plugin-selection/afm-products/tsconfig.json"
55
61
  },
62
+ {
63
+ "path": "../../editor-plugin-user-intent/afm-products/tsconfig.json"
64
+ },
56
65
  {
57
66
  "path": "../../editor-prosemirror/afm-products/tsconfig.json"
58
67
  },
@@ -92,6 +101,9 @@
92
101
  {
93
102
  "path": "../../../design-system/spinner/afm-products/tsconfig.json"
94
103
  },
104
+ {
105
+ "path": "../../tmp-editor-statsig/afm-products/tsconfig.json"
106
+ },
95
107
  {
96
108
  "path": "../../../design-system/tokens/afm-products/tsconfig.json"
97
109
  },
@@ -8,6 +8,7 @@ exports.lazyBodiedSyncBlockView = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
11
+ // Delete this file when cleaning up platform_synced_block_patch_5
11
12
  var lazyBodiedSyncBlockView = exports.lazyBodiedSyncBlockView = function lazyBodiedSyncBlockView(props) {
12
13
  return (0, _lazyNodeView.withLazyLoading)({
13
14
  nodeName: 'bodiedSyncBlock',
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.bodiedSyncBlockNodeView = exports.BodiedSyncBlock = void 0;
7
+ exports.bodiedSyncBlockNodeViewOld = exports.bodiedSyncBlockNodeView = exports.BodiedSyncBlock = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -19,27 +19,28 @@ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
19
19
  var _model = require("@atlaskit/editor-prosemirror/model");
20
20
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
21
  var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
22
+ var _SyncBlockLabel = require("../ui/SyncBlockLabel");
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)); }
23
24
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
- var toDOM = function toDOM() {
25
+ var toDOMOld = function toDOMOld() {
25
26
  return ['div', {
26
27
  class: _syncBlock.BodiedSyncBlockSharedCssClassName.content,
27
28
  contenteditable: true
28
29
  }, 0];
29
30
  };
30
- var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
31
- function BodiedSyncBlock(props) {
31
+ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
32
+ function BodiedSyncBlockOld(props) {
32
33
  var _this;
33
- (0, _classCallCheck2.default)(this, BodiedSyncBlock);
34
- _this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
34
+ (0, _classCallCheck2.default)(this, BodiedSyncBlockOld);
35
+ _this = _callSuper(this, BodiedSyncBlockOld, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
35
36
  _this.api = props.api;
36
37
  _this.syncBlockStore = props.syncBlockStore;
37
38
  _this.handleConnectivityModeChange();
38
39
  _this.handleViewModeChange();
39
40
  return _this;
40
41
  }
41
- (0, _inherits2.default)(BodiedSyncBlock, _ReactNodeView);
42
- return (0, _createClass2.default)(BodiedSyncBlock, [{
42
+ (0, _inherits2.default)(BodiedSyncBlockOld, _ReactNodeView);
43
+ return (0, _createClass2.default)(BodiedSyncBlockOld, [{
43
44
  key: "updateContentEditable",
44
45
  value: function updateContentEditable(_ref) {
45
46
  var _this$api, _this$api2;
@@ -112,7 +113,7 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNod
112
113
  }, {
113
114
  key: "getContentDOM",
114
115
  value: function getContentDOM() {
115
- var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM()),
116
+ var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOMOld()),
116
117
  dom = _DOMSerializer$render.dom,
117
118
  contentDOM = _DOMSerializer$render.contentDOM;
118
119
  // In SSR, the first check won't work, so fallback to nodeType check
@@ -140,7 +141,7 @@ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function (_ReactNod
140
141
  }
141
142
  }]);
142
143
  }(_reactNodeView.default);
143
- var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
144
+ var bodiedSyncBlockNodeViewOld = exports.bodiedSyncBlockNodeViewOld = function bodiedSyncBlockNodeViewOld(_ref4) {
144
145
  var pluginOptions = _ref4.pluginOptions,
145
146
  pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
146
147
  api = _ref4.api,
@@ -148,7 +149,7 @@ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedS
148
149
  return function (node, view, getPos) {
149
150
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
150
151
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
151
- return new BodiedSyncBlock({
152
+ return new BodiedSyncBlockOld({
152
153
  api: api,
153
154
  pluginOptions: pluginOptions,
154
155
  node: node,
@@ -159,4 +160,129 @@ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedS
159
160
  syncBlockStore: syncBlockStore
160
161
  }).init();
161
162
  };
163
+ };
164
+ var toDOM = function toDOM(node) {
165
+ return ['div', {
166
+ class: "".concat(_syncBlock.BodiedSyncBlockSharedCssClassName.prefix, " bodiedSyncBlockView-content-wrap"),
167
+ localid: node.attrs.localId,
168
+ resourceid: node.attrs.resourceId
169
+ }, ['div', {
170
+ class: _syncBlock.BodiedSyncBlockSharedCssClassName.content,
171
+ contenteditable: 'true'
172
+ }, 0]];
173
+ };
174
+ var BodiedSyncBlock = exports.BodiedSyncBlock = /*#__PURE__*/function () {
175
+ function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore) {
176
+ var _this4 = this;
177
+ (0, _classCallCheck2.default)(this, BodiedSyncBlock);
178
+ this.node = node;
179
+ this.view = view;
180
+ this.getPos = getPos;
181
+ this.api = api;
182
+ this.syncBlockStore = syncBlockStore;
183
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
184
+ var _DOMSerializer$render2 = _model.DOMSerializer.renderSpec(document, toDOM(this.node)),
185
+ dom = _DOMSerializer$render2.dom,
186
+ contentDOM = _DOMSerializer$render2.contentDOM;
187
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
188
+ this.dom = dom;
189
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
190
+ this.contentDOM = contentDOM;
191
+ this.labelKey = crypto.randomUUID();
192
+ this.nodeViewPortalProviderAPI.render(function () {
193
+ var _this4$api;
194
+ return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
195
+ component: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
196
+ componentId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
197
+ dispatchAnalyticsEvent: (_this4$api = _this4.api) === null || _this4$api === void 0 || (_this4$api = _this4$api.analytics) === null || _this4$api === void 0 ? void 0 : _this4$api.actions.fireAnalyticsEvent,
198
+ fallbackComponent: null
199
+ }, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, {
200
+ isSource: true,
201
+ localId: node.attrs.localId
202
+ }));
203
+ }, this.dom, this.labelKey);
204
+ this.updateContentEditable({});
205
+ this.handleConnectivityModeChange();
206
+ this.handleViewModeChange();
207
+ }
208
+ return (0, _createClass2.default)(BodiedSyncBlock, [{
209
+ key: "updateContentEditable",
210
+ value: function updateContentEditable(_ref5) {
211
+ var _this$api7, _this$api8;
212
+ var nextConnectivityMode = _ref5.nextConnectivityMode,
213
+ nextViewMode = _ref5.nextViewMode;
214
+ var connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api7 = this.api) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.connectivity) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.sharedState) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.currentState()) === null || _this$api7 === void 0 ? void 0 : _this$api7.mode;
215
+ var viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api8 = this.api) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.editorViewMode) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.sharedState) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.currentState()) === null || _this$api8 === void 0 ? void 0 : _this$api8.mode;
216
+ var isOnline = !(0, _editorPluginConnectivity.isOfflineMode)(connectivityMode);
217
+ var isEditMode = viewMode !== 'view';
218
+ var shouldBeEditable = isOnline && isEditMode;
219
+ this.contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
220
+ }
221
+ }, {
222
+ key: "handleConnectivityModeChange",
223
+ value: function handleConnectivityModeChange() {
224
+ var _this$api9,
225
+ _this5 = this;
226
+ if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.connectivity) {
227
+ this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (_ref6) {
228
+ var nextSharedState = _ref6.nextSharedState;
229
+ _this5.updateContentEditable({
230
+ nextConnectivityMode: nextSharedState.mode
231
+ });
232
+ });
233
+ }
234
+ }
235
+ }, {
236
+ key: "handleViewModeChange",
237
+ value: function handleViewModeChange() {
238
+ var _this$api0,
239
+ _this6 = this;
240
+ if ((_this$api0 = this.api) !== null && _this$api0 !== void 0 && _this$api0.editorViewMode) {
241
+ this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (_ref7) {
242
+ var nextSharedState = _ref7.nextSharedState;
243
+ _this6.updateContentEditable({
244
+ nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
245
+ });
246
+ });
247
+ }
248
+ }
249
+ }, {
250
+ key: "update",
251
+ value: function update(node) {
252
+ if (this.node.type !== node.type) {
253
+ return false;
254
+ }
255
+ if (node !== this.node) {
256
+ var _this$api$syncedBlock2, _this$api1;
257
+ var syncBlockStore = (_this$api$syncedBlock2 = (_this$api1 = this.api) === null || _this$api1 === void 0 || (_this$api1 = _this$api1.syncedBlock.sharedState) === null || _this$api1 === void 0 || (_this$api1 = _this$api1.currentState()) === null || _this$api1 === void 0 ? void 0 : _this$api1.syncBlockStore) !== null && _this$api$syncedBlock2 !== void 0 ? _this$api$syncedBlock2 : this.syncBlockStore;
258
+ syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.sourceManager.updateSyncBlockData(node);
259
+ }
260
+ this.node = node;
261
+ return true;
262
+ }
263
+ }, {
264
+ key: "ignoreMutation",
265
+ value: function ignoreMutation(mutation) {
266
+ if (mutation.type === 'selection') {
267
+ return false;
268
+ }
269
+ return true;
270
+ }
271
+ }, {
272
+ key: "destroy",
273
+ value: function destroy() {
274
+ var _this$cleanupConnecti, _this$cleanupViewMode;
275
+ (_this$cleanupConnecti = this.cleanupConnectivityModeListener) === null || _this$cleanupConnecti === void 0 || _this$cleanupConnecti.call(this);
276
+ (_this$cleanupViewMode = this.cleanupViewModeListener) === null || _this$cleanupViewMode === void 0 || _this$cleanupViewMode.call(this);
277
+ this.nodeViewPortalProviderAPI.remove(this.labelKey);
278
+ }
279
+ }]);
280
+ }();
281
+ var bodiedSyncBlockNodeView = exports.bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(props) {
282
+ var api = props.api,
283
+ syncBlockStore = props.syncBlockStore,
284
+ nodeViewPortalProviderAPI = props.pmPluginFactoryParams.nodeViewPortalProviderAPI;
285
+ return function (node, view, getPos) {
286
+ return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore);
287
+ };
162
288
  };
@@ -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) {
@@ -19,6 +19,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
19
19
  var _view = require("@atlaskit/editor-prosemirror/view");
20
20
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
22
23
  var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
23
24
  var _bodiedSyncedBlock = require("../nodeviews/bodiedSyncedBlock");
24
25
  var _syncedBlock = require("../nodeviews/syncedBlock");
@@ -82,9 +83,6 @@ var showCopiedFlag = function showCopiedFlag(api) {
82
83
  };
83
84
  var showInlineExtensionInSyncBlockWarningIfNeeded = function showInlineExtensionInSyncBlockWarningIfNeeded(tr, state, api, inlineExtensionFlagShown) {
84
85
  var _api$connectivity;
85
- if (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
86
- return;
87
- }
88
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)) {
89
87
  return;
90
88
  }
@@ -139,31 +137,17 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
139
137
  });
140
138
  });
141
139
  syncBlockAdded.forEach(function (syncBlock) {
142
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
143
- var _api$analytics2;
144
- 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({
145
- action: _analytics.ACTION.INSERTED,
146
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
147
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
148
- attributes: {
149
- resourceId: syncBlock.attrs.resourceId,
150
- blockInstanceId: syncBlock.attrs.localId
151
- },
152
- eventType: _analytics.EVENT_TYPE.TRACK
153
- });
154
- } else {
155
- var _api$analytics3;
156
- 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({
157
- action: _analytics.ACTION.INSERTED,
158
- actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
159
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
160
- attributes: {
161
- resourceId: syncBlock.attrs.resourceId,
162
- blockInstanceId: syncBlock.attrs.localId
163
- },
164
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
165
- });
166
- }
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
+ });
167
151
  });
168
152
  if (bodiedSyncBlockRemoved.length > 0) {
169
153
  // eslint-disable-next-line no-param-reassign
@@ -353,7 +337,14 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
353
337
  }).init()
354
338
  );
355
339
  },
356
- bodiedSyncBlock: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
340
+ bodiedSyncBlock: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? (0, _experiments.editorExperiment)('platform_synced_block_use_new_source_nodeview', true, {
341
+ exposure: true
342
+ }) ? (0, _bodiedSyncedBlock.bodiedSyncBlockNodeView)({
343
+ pluginOptions: options,
344
+ pmPluginFactoryParams: pmPluginFactoryParams,
345
+ api: api,
346
+ syncBlockStore: syncBlockStore
347
+ }) : (0, _bodiedSyncedBlock.bodiedSyncBlockNodeViewOld)({
357
348
  pluginOptions: options,
358
349
  pmPluginFactoryParams: pmPluginFactoryParams,
359
350
  api: api,
@@ -365,7 +356,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
365
356
  })
366
357
  },
367
358
  decorations: function decorations(state) {
368
- var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent;
359
+ var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent, _api$focus;
369
360
  var currentPluginState = syncedBlockPluginKey.getState(state);
370
361
  var selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : _view.DecorationSet.empty;
371
362
  var syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
@@ -401,7 +392,14 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
401
392
  }));
402
393
  }
403
394
  });
404
- return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
395
+ if (api !== null && api !== void 0 && (_api$focus = api.focus) !== null && _api$focus !== void 0 && (_api$focus = _api$focus.sharedState) !== null && _api$focus !== void 0 && (_api$focus = _api$focus.currentState()) !== null && _api$focus !== void 0 && _api$focus.hasFocus || !(0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
396
+ exposure: true
397
+ })) {
398
+ // Don't show decorations if the editor is not focused
399
+ return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
400
+ } else {
401
+ return _view.DecorationSet.empty.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
402
+ }
405
403
  },
406
404
  handleClickOn: (0, _selection.createSelectionClickHandler)(['bodiedSyncBlock'], function (target) {
407
405
  return !!target.closest(".".concat(_syncBlock.BodiedSyncBlockSharedCssClassName.prefix));
@@ -514,8 +512,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
514
512
  _syncBlockRemoved = _trackSyncBlocks5.removed,
515
513
  _syncBlockAdded = _trackSyncBlocks5.added;
516
514
  _syncBlockRemoved.forEach(function (syncBlock) {
517
- var _api$analytics4;
518
- 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({
519
517
  action: _analytics.ACTION.DELETED,
520
518
  actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
521
519
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -527,31 +525,17 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
527
525
  });
528
526
  });
529
527
  _syncBlockAdded.forEach(function (syncBlock) {
530
- if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
531
- var _api$analytics5;
532
- 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({
533
- action: _analytics.ACTION.INSERTED,
534
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
535
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK,
536
- attributes: {
537
- resourceId: syncBlock.attrs.resourceId,
538
- blockInstanceId: syncBlock.attrs.localId
539
- },
540
- eventType: _analytics.EVENT_TYPE.TRACK
541
- });
542
- } else {
543
- var _api$analytics6;
544
- 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({
545
- action: _analytics.ACTION.INSERTED,
546
- actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
547
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
548
- attributes: {
549
- resourceId: syncBlock.attrs.resourceId,
550
- blockInstanceId: syncBlock.attrs.localId
551
- },
552
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
553
- });
554
- }
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
+ });
555
539
  });
556
540
  if (bodiedSyncBlockRemoved.length > 0) {
557
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;