@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
@@ -4,6 +4,7 @@ import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages'
4
4
  import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
5
5
  import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
6
6
  import { Text } from '@atlaskit/primitives/compiled';
7
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import Tooltip from '@atlaskit/tooltip';
8
9
  import VisuallyHidden from '@atlaskit/visually-hidden';
9
10
  import { formatElapsedTime } from './utils/time';
@@ -69,7 +70,9 @@ const SyncBlockLabelComponent = ({
69
70
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
70
71
  ,
71
72
  className: SyncBlockLabelSharedCssClassName.labelClassName,
72
- "aria-describedby": ariaDescribedById
73
+ "aria-describedby": (isSource || isUnsyncedBlock) && editorExperiment('platform_synced_block_patch_6', true, {
74
+ exposure: true
75
+ }) ? undefined : ariaDescribedById
73
76
  }, /*#__PURE__*/React.createElement(BlockSyncedIcon, {
74
77
  color: "var(--ds-icon-subtle, #505258)",
75
78
  size: "small",
@@ -1,4 +1,4 @@
1
- /* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./SyncedLocationDropdown.compiled.css";
4
4
  import * as React from 'react';
@@ -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
@@ -1,4 +1,4 @@
1
- /* quick-insert.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* quick-insert.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import "./quick-insert.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,5 @@
1
1
  import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
2
+ // Delete this file when cleaning up platform_synced_block_patch_5
2
3
  export var lazyBodiedSyncBlockView = function lazyBodiedSyncBlockView(props) {
3
4
  return withLazyLoading({
4
5
  nodeName: 'bodiedSyncBlock',
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import React from 'react';
9
- import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
9
+ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
10
10
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
11
11
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
12
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
@@ -14,25 +14,26 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
14
14
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
17
- var toDOM = function toDOM() {
17
+ import { SyncBlockLabel } from '../ui/SyncBlockLabel';
18
+ var toDOMOld = function toDOMOld() {
18
19
  return ['div', {
19
20
  class: BodiedSyncBlockSharedCssClassName.content,
20
21
  contenteditable: true
21
22
  }, 0];
22
23
  };
23
- export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
24
- function BodiedSyncBlock(props) {
24
+ var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
25
+ function BodiedSyncBlockOld(props) {
25
26
  var _this;
26
- _classCallCheck(this, BodiedSyncBlock);
27
- _this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
27
+ _classCallCheck(this, BodiedSyncBlockOld);
28
+ _this = _callSuper(this, BodiedSyncBlockOld, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
28
29
  _this.api = props.api;
29
30
  _this.syncBlockStore = props.syncBlockStore;
30
31
  _this.handleConnectivityModeChange();
31
32
  _this.handleViewModeChange();
32
33
  return _this;
33
34
  }
34
- _inherits(BodiedSyncBlock, _ReactNodeView);
35
- return _createClass(BodiedSyncBlock, [{
35
+ _inherits(BodiedSyncBlockOld, _ReactNodeView);
36
+ return _createClass(BodiedSyncBlockOld, [{
36
37
  key: "updateContentEditable",
37
38
  value: function updateContentEditable(_ref) {
38
39
  var _this$api, _this$api2;
@@ -105,7 +106,7 @@ export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
105
106
  }, {
106
107
  key: "getContentDOM",
107
108
  value: function getContentDOM() {
108
- var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM()),
109
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOMOld()),
109
110
  dom = _DOMSerializer$render.dom,
110
111
  contentDOM = _DOMSerializer$render.contentDOM;
111
112
  // In SSR, the first check won't work, so fallback to nodeType check
@@ -133,7 +134,7 @@ export var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
133
134
  }
134
135
  }]);
135
136
  }(ReactNodeView);
136
- export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
137
+ export var bodiedSyncBlockNodeViewOld = function bodiedSyncBlockNodeViewOld(_ref4) {
137
138
  var pluginOptions = _ref4.pluginOptions,
138
139
  pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
139
140
  api = _ref4.api,
@@ -141,7 +142,7 @@ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
141
142
  return function (node, view, getPos) {
142
143
  var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
143
144
  eventDispatcher = pmPluginFactoryParams.eventDispatcher;
144
- return new BodiedSyncBlock({
145
+ return new BodiedSyncBlockOld({
145
146
  api: api,
146
147
  pluginOptions: pluginOptions,
147
148
  node: node,
@@ -152,4 +153,129 @@ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(_ref4) {
152
153
  syncBlockStore: syncBlockStore
153
154
  }).init();
154
155
  };
156
+ };
157
+ var toDOM = function toDOM(node) {
158
+ return ['div', {
159
+ class: "".concat(BodiedSyncBlockSharedCssClassName.prefix, " bodiedSyncBlockView-content-wrap"),
160
+ localid: node.attrs.localId,
161
+ resourceid: node.attrs.resourceId
162
+ }, ['div', {
163
+ class: BodiedSyncBlockSharedCssClassName.content,
164
+ contenteditable: 'true'
165
+ }, 0]];
166
+ };
167
+ export var BodiedSyncBlock = /*#__PURE__*/function () {
168
+ function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore) {
169
+ var _this4 = this;
170
+ _classCallCheck(this, BodiedSyncBlock);
171
+ this.node = node;
172
+ this.view = view;
173
+ this.getPos = getPos;
174
+ this.api = api;
175
+ this.syncBlockStore = syncBlockStore;
176
+ this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
177
+ var _DOMSerializer$render2 = DOMSerializer.renderSpec(document, toDOM(this.node)),
178
+ dom = _DOMSerializer$render2.dom,
179
+ contentDOM = _DOMSerializer$render2.contentDOM;
180
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
181
+ this.dom = dom;
182
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
183
+ this.contentDOM = contentDOM;
184
+ this.labelKey = crypto.randomUUID();
185
+ this.nodeViewPortalProviderAPI.render(function () {
186
+ var _this4$api;
187
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
188
+ component: ACTION_SUBJECT.SYNCED_BLOCK,
189
+ componentId: ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
190
+ 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,
191
+ fallbackComponent: null
192
+ }, /*#__PURE__*/React.createElement(SyncBlockLabel, {
193
+ isSource: true,
194
+ localId: node.attrs.localId
195
+ }));
196
+ }, this.dom, this.labelKey);
197
+ this.updateContentEditable({});
198
+ this.handleConnectivityModeChange();
199
+ this.handleViewModeChange();
200
+ }
201
+ return _createClass(BodiedSyncBlock, [{
202
+ key: "updateContentEditable",
203
+ value: function updateContentEditable(_ref5) {
204
+ var _this$api7, _this$api8;
205
+ var nextConnectivityMode = _ref5.nextConnectivityMode,
206
+ nextViewMode = _ref5.nextViewMode;
207
+ 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;
208
+ 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;
209
+ var isOnline = !isOfflineMode(connectivityMode);
210
+ var isEditMode = viewMode !== 'view';
211
+ var shouldBeEditable = isOnline && isEditMode;
212
+ this.contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
213
+ }
214
+ }, {
215
+ key: "handleConnectivityModeChange",
216
+ value: function handleConnectivityModeChange() {
217
+ var _this$api9,
218
+ _this5 = this;
219
+ if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.connectivity) {
220
+ this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (_ref6) {
221
+ var nextSharedState = _ref6.nextSharedState;
222
+ _this5.updateContentEditable({
223
+ nextConnectivityMode: nextSharedState.mode
224
+ });
225
+ });
226
+ }
227
+ }
228
+ }, {
229
+ key: "handleViewModeChange",
230
+ value: function handleViewModeChange() {
231
+ var _this$api0,
232
+ _this6 = this;
233
+ if ((_this$api0 = this.api) !== null && _this$api0 !== void 0 && _this$api0.editorViewMode) {
234
+ this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (_ref7) {
235
+ var nextSharedState = _ref7.nextSharedState;
236
+ _this6.updateContentEditable({
237
+ nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
238
+ });
239
+ });
240
+ }
241
+ }
242
+ }, {
243
+ key: "update",
244
+ value: function update(node) {
245
+ if (this.node.type !== node.type) {
246
+ return false;
247
+ }
248
+ if (node !== this.node) {
249
+ var _this$api$syncedBlock2, _this$api1;
250
+ 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;
251
+ syncBlockStore === null || syncBlockStore === void 0 || syncBlockStore.sourceManager.updateSyncBlockData(node);
252
+ }
253
+ this.node = node;
254
+ return true;
255
+ }
256
+ }, {
257
+ key: "ignoreMutation",
258
+ value: function ignoreMutation(mutation) {
259
+ if (mutation.type === 'selection') {
260
+ return false;
261
+ }
262
+ return true;
263
+ }
264
+ }, {
265
+ key: "destroy",
266
+ value: function destroy() {
267
+ var _this$cleanupConnecti, _this$cleanupViewMode;
268
+ (_this$cleanupConnecti = this.cleanupConnectivityModeListener) === null || _this$cleanupConnecti === void 0 || _this$cleanupConnecti.call(this);
269
+ (_this$cleanupViewMode = this.cleanupViewModeListener) === null || _this$cleanupViewMode === void 0 || _this$cleanupViewMode.call(this);
270
+ this.nodeViewPortalProviderAPI.remove(this.labelKey);
271
+ }
272
+ }]);
273
+ }();
274
+ export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(props) {
275
+ var api = props.api,
276
+ syncBlockStore = props.syncBlockStore,
277
+ nodeViewPortalProviderAPI = props.pmPluginFactoryParams.nodeViewPortalProviderAPI;
278
+ return function (node, view, getPos) {
279
+ return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore);
280
+ };
155
281
  };
@@ -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) {
@@ -17,8 +17,9 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
17
17
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
18
18
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
19
19
  import { fg } from '@atlaskit/platform-feature-flags';
20
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
21
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
21
- import { bodiedSyncBlockNodeView } from '../nodeviews/bodiedSyncedBlock';
22
+ import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
22
23
  import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
23
24
  import { FLAG_ID } from '../types';
24
25
  import { handleBodiedSyncBlockCreation } from './utils/handle-bodied-sync-block-creation';
@@ -75,9 +76,6 @@ var showCopiedFlag = function showCopiedFlag(api) {
75
76
  };
76
77
  var showInlineExtensionInSyncBlockWarningIfNeeded = function showInlineExtensionInSyncBlockWarningIfNeeded(tr, state, api, inlineExtensionFlagShown) {
77
78
  var _api$connectivity;
78
- if (!fg('platform_synced_block_patch_3')) {
79
- return;
80
- }
81
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)) {
82
80
  return;
83
81
  }
@@ -132,31 +130,17 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
132
130
  });
133
131
  });
134
132
  syncBlockAdded.forEach(function (syncBlock) {
135
- if (fg('platform_synced_block_patch_3')) {
136
- var _api$analytics2;
137
- 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({
138
- action: ACTION.INSERTED,
139
- actionSubject: ACTION_SUBJECT.DOCUMENT,
140
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
141
- attributes: {
142
- resourceId: syncBlock.attrs.resourceId,
143
- blockInstanceId: syncBlock.attrs.localId
144
- },
145
- eventType: EVENT_TYPE.TRACK
146
- });
147
- } else {
148
- var _api$analytics3;
149
- 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({
150
- action: ACTION.INSERTED,
151
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
152
- actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
153
- attributes: {
154
- resourceId: syncBlock.attrs.resourceId,
155
- blockInstanceId: syncBlock.attrs.localId
156
- },
157
- eventType: EVENT_TYPE.OPERATIONAL
158
- });
159
- }
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
+ });
160
144
  });
161
145
  if (bodiedSyncBlockRemoved.length > 0) {
162
146
  // eslint-disable-next-line no-param-reassign
@@ -346,7 +330,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
346
330
  }).init()
347
331
  );
348
332
  },
349
- bodiedSyncBlock: fg('platform_synced_block_patch_5') ? bodiedSyncBlockNodeView({
333
+ bodiedSyncBlock: fg('platform_synced_block_patch_5') ? editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
334
+ exposure: true
335
+ }) ? bodiedSyncBlockNodeView({
336
+ pluginOptions: options,
337
+ pmPluginFactoryParams: pmPluginFactoryParams,
338
+ api: api,
339
+ syncBlockStore: syncBlockStore
340
+ }) : bodiedSyncBlockNodeViewOld({
350
341
  pluginOptions: options,
351
342
  pmPluginFactoryParams: pmPluginFactoryParams,
352
343
  api: api,
@@ -358,7 +349,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
358
349
  })
359
350
  },
360
351
  decorations: function decorations(state) {
361
- var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent;
352
+ var _currentPluginState$s, _api$connectivity2, _api$editorViewMode, _api$userIntent, _api$focus;
362
353
  var currentPluginState = syncedBlockPluginKey.getState(state);
363
354
  var selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : DecorationSet.empty;
364
355
  var syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
@@ -394,7 +385,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
394
385
  }));
395
386
  }
396
387
  });
397
- return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
388
+ 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 || !editorExperiment('platform_synced_block_patch_6', true, {
389
+ exposure: true
390
+ })) {
391
+ // Don't show decorations if the editor is not focused
392
+ return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
393
+ } else {
394
+ return DecorationSet.empty.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
395
+ }
398
396
  },
399
397
  handleClickOn: createSelectionClickHandler(['bodiedSyncBlock'], function (target) {
400
398
  return !!target.closest(".".concat(BodiedSyncBlockSharedCssClassName.prefix));
@@ -507,8 +505,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
507
505
  _syncBlockRemoved = _trackSyncBlocks5.removed,
508
506
  _syncBlockAdded = _trackSyncBlocks5.added;
509
507
  _syncBlockRemoved.forEach(function (syncBlock) {
510
- var _api$analytics4;
511
- 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({
512
510
  action: ACTION.DELETED,
513
511
  actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
514
512
  actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
@@ -520,31 +518,17 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
520
518
  });
521
519
  });
522
520
  _syncBlockAdded.forEach(function (syncBlock) {
523
- if (fg('platform_synced_block_patch_3')) {
524
- var _api$analytics5;
525
- 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({
526
- action: ACTION.INSERTED,
527
- actionSubject: ACTION_SUBJECT.DOCUMENT,
528
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
529
- attributes: {
530
- resourceId: syncBlock.attrs.resourceId,
531
- blockInstanceId: syncBlock.attrs.localId
532
- },
533
- eventType: EVENT_TYPE.TRACK
534
- });
535
- } else {
536
- var _api$analytics6;
537
- 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({
538
- action: ACTION.INSERTED,
539
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
540
- actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
541
- attributes: {
542
- resourceId: syncBlock.attrs.resourceId,
543
- blockInstanceId: syncBlock.attrs.localId
544
- },
545
- eventType: EVENT_TYPE.OPERATIONAL
546
- });
547
- }
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
+ });
548
532
  });
549
533
  if (bodiedSyncBlockRemoved.length > 0) {
550
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,7 +1,8 @@
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
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
6
7
  import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
7
8
  import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
@@ -31,7 +32,11 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
31
32
  node: syncBlock
32
33
  }, {
33
34
  name: 'bodiedSyncBlock',
34
- node: fg('platform_synced_block_patch_3') ? bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
35
+ node: !editorExperiment('platform_synced_block_patch_6', true, {
36
+ exposure: true
37
+ }) ?
38
+ // delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
39
+ bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
35
40
  }];
36
41
  },
37
42
  pmPlugins: function pmPlugins() {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useHandleContentChanges } from '@atlaskit/editor-synced-block-provider';
3
3
  import { SyncBlockLabel } from './SyncBlockLabel';
4
+ // Delete this file when cleaning up platform_synced_block_use_new_source_nodeview
4
5
  export var BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
5
6
  var node = _ref.node,
6
7
  syncBlockStore = _ref.syncBlockStore;
@@ -1,4 +1,4 @@
1
- /* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.39.1 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import "./DeleteConfirmationModal.compiled.css";