@atlaskit/editor-plugin-synced-block 5.3.11 → 5.3.13

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 (62) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/afm-cc/tsconfig.json +0 -3
  3. package/afm-jira/tsconfig.json +0 -3
  4. package/afm-products/tsconfig.json +0 -3
  5. package/dist/cjs/editor-commands/index.js +99 -40
  6. package/dist/cjs/nodeviews/bodiedSyncedBlock.js +2 -7
  7. package/dist/cjs/nodeviews/syncedBlock.js +4 -18
  8. package/dist/cjs/pm-plugins/main.js +34 -43
  9. package/dist/cjs/pm-plugins/menu-and-toolbar-experiences.js +221 -81
  10. package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +1 -2
  11. package/dist/cjs/pm-plugins/utils/utils.js +1 -46
  12. package/dist/cjs/syncedBlockPlugin.js +5 -7
  13. package/dist/cjs/types/index.js +5 -1
  14. package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +2 -1
  15. package/dist/cjs/ui/DeleteConfirmationModal.js +4 -20
  16. package/dist/cjs/ui/SyncBlockLabel.js +4 -10
  17. package/dist/cjs/ui/SyncBlockRefresher.js +7 -9
  18. package/dist/cjs/ui/SyncedLocationDropdown.js +32 -6
  19. package/dist/cjs/ui/floating-toolbar.js +11 -7
  20. package/dist/es2019/editor-commands/index.js +99 -40
  21. package/dist/es2019/nodeviews/bodiedSyncedBlock.js +2 -7
  22. package/dist/es2019/nodeviews/syncedBlock.js +4 -15
  23. package/dist/es2019/pm-plugins/main.js +33 -42
  24. package/dist/es2019/pm-plugins/menu-and-toolbar-experiences.js +206 -71
  25. package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +1 -2
  26. package/dist/es2019/pm-plugins/utils/utils.js +0 -47
  27. package/dist/es2019/syncedBlockPlugin.js +4 -5
  28. package/dist/es2019/types/index.js +5 -1
  29. package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +2 -1
  30. package/dist/es2019/ui/DeleteConfirmationModal.js +4 -20
  31. package/dist/es2019/ui/SyncBlockLabel.js +4 -10
  32. package/dist/es2019/ui/SyncBlockRefresher.js +7 -9
  33. package/dist/es2019/ui/SyncedLocationDropdown.js +30 -6
  34. package/dist/es2019/ui/floating-toolbar.js +10 -6
  35. package/dist/esm/editor-commands/index.js +99 -40
  36. package/dist/esm/nodeviews/bodiedSyncedBlock.js +2 -7
  37. package/dist/esm/nodeviews/syncedBlock.js +4 -18
  38. package/dist/esm/pm-plugins/main.js +34 -43
  39. package/dist/esm/pm-plugins/menu-and-toolbar-experiences.js +221 -81
  40. package/dist/esm/pm-plugins/utils/track-sync-blocks.js +1 -2
  41. package/dist/esm/pm-plugins/utils/utils.js +0 -45
  42. package/dist/esm/syncedBlockPlugin.js +5 -7
  43. package/dist/esm/types/index.js +5 -1
  44. package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +2 -1
  45. package/dist/esm/ui/DeleteConfirmationModal.js +4 -20
  46. package/dist/esm/ui/SyncBlockLabel.js +4 -10
  47. package/dist/esm/ui/SyncBlockRefresher.js +7 -9
  48. package/dist/esm/ui/SyncedLocationDropdown.js +32 -6
  49. package/dist/esm/ui/floating-toolbar.js +11 -7
  50. package/dist/types/editor-commands/index.d.ts +3 -2
  51. package/dist/types/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +1 -1
  52. package/dist/types/pm-plugins/utils/utils.d.ts +1 -3
  53. package/dist/types/syncedBlockPluginType.d.ts +2 -1
  54. package/dist/types/types/index.d.ts +4 -0
  55. package/dist/types/ui/SyncedLocationDropdown.d.ts +4 -1
  56. package/dist/types-ts4.5/editor-commands/index.d.ts +3 -2
  57. package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +1 -1
  58. package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +1 -3
  59. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +2 -1
  60. package/dist/types-ts4.5/types/index.d.ts +4 -0
  61. package/dist/types-ts4.5/ui/SyncedLocationDropdown.d.ts +4 -1
  62. package/package.json +5 -6
@@ -12,7 +12,6 @@ var _reactIntlNext = require("react-intl-next");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
14
14
  var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
15
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
15
  var _compiled = require("@atlaskit/primitives/compiled");
17
16
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
18
17
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
@@ -32,17 +31,12 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
32
31
  tooltipContent = _useState2[0],
33
32
  setTooltipContent = _useState2[1];
34
33
  var tooltipMessage = formatMessage(_messages.syncBlockMessages.defaultSyncBlockTooltip);
35
- if (isSource && !(0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
36
- tooltipMessage = formatMessage(_messages.syncBlockMessages.sourceSyncBlockTooltip);
37
- } else if (title) {
34
+ if (title) {
38
35
  tooltipMessage = formatMessage(_messages.syncBlockMessages.referenceSyncBlockTooltip, {
39
36
  title: title
40
37
  });
41
38
  }
42
39
  var updateTooltipContent = (0, _react.useCallback)(function () {
43
- if (!(0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
44
- return;
45
- }
46
40
  var tooltipContent = tooltipMessage;
47
41
  if (contentUpdatedAt) {
48
42
  var elapsedTime = (0, _time.formatElapsedTime)(contentUpdatedAt, intl);
@@ -62,7 +56,7 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
62
56
  }, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
63
57
  var ariaDescribedById = "sync-block-label-description-".concat(localId);
64
58
  var getLabelContent = (0, _react.useMemo)(function () {
65
- if (isUnsyncedBlock && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
59
+ if (isUnsyncedBlock) {
66
60
  return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
67
61
  size: "small",
68
62
  color: "color.text.subtle"
@@ -91,12 +85,12 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
91
85
  size: "small",
92
86
  label: ""
93
87
  }), getLabelContent);
94
- if ((isSource || isUnsyncedBlock) && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
88
+ if (isSource || isUnsyncedBlock) {
95
89
  return label;
96
90
  }
97
91
  return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
98
92
  position: "top",
99
- content: (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? tooltipContent : tooltipMessage
93
+ content: tooltipContent
100
94
  // workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
101
95
  // this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
102
96
  // tooltip content is available for screen readers in visually hidden content after the label
@@ -7,13 +7,12 @@ exports.SyncBlockRefresher = exports.SYNC_BLOCK_FETCH_INTERVAL = void 0;
7
7
  var _react = require("react");
8
8
  var _hooks = require("@atlaskit/editor-common/hooks");
9
9
  var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
10
  var SYNC_BLOCK_FETCH_INTERVAL = exports.SYNC_BLOCK_FETCH_INTERVAL = 3000;
12
11
 
13
12
  // Component that manages synced block data synchronization.
14
- // When the feature flag 'platform_synced_block_dogfooding' is enabled,
15
- // it uses provider-based GraphQL subscriptions for updates.
16
- // When disabled, it falls back to polling at regular intervals.
13
+ // Component that manages synced block data synchronization.
14
+ // Uses provider-based GraphQL subscriptions for updates when online.
15
+ // Falls back to polling at regular intervals when offline.
17
16
  var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefresher(_ref) {
18
17
  var syncBlockStoreManager = _ref.syncBlockStoreManager,
19
18
  api = _ref.api;
@@ -24,14 +23,13 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
24
23
  };
25
24
  }),
26
25
  mode = _useSharedPluginState.mode;
27
- var featureFlagEnabled = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding');
28
26
  var isOnline = !(0, _editorPluginConnectivity.isOfflineMode)(mode);
29
27
  (0, _react.useEffect)(function () {
30
- var useRealTimeSubscriptions = featureFlagEnabled && isOnline;
28
+ var useRealTimeSubscriptions = isOnline;
31
29
  syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
32
- }, [syncBlockStoreManager, featureFlagEnabled, isOnline]);
30
+ }, [syncBlockStoreManager, isOnline]);
33
31
  (0, _react.useEffect)(function () {
34
- var useRealTimeSubscriptions = featureFlagEnabled && isOnline;
32
+ var useRealTimeSubscriptions = isOnline;
35
33
  if (useRealTimeSubscriptions) {
36
34
  return;
37
35
  }
@@ -50,6 +48,6 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
50
48
  return function () {
51
49
  window.clearInterval(interval);
52
50
  };
53
- }, [syncBlockStoreManager, isOnline, featureFlagEnabled]);
51
+ }, [syncBlockStoreManager, isOnline]);
54
52
  return null;
55
53
  };
@@ -18,6 +18,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
18
18
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
19
  var _react2 = require("@compiled/react");
20
20
  var _dropdownMenu = _interopRequireWildcard(require("@atlaskit/dropdown-menu"));
21
+ var _analytics = require("@atlaskit/editor-common/analytics");
21
22
  var _messages = require("@atlaskit/editor-common/messages");
22
23
  var _ui = require("@atlaskit/editor-common/ui");
23
24
  var _icon = require("@atlaskit/icon");
@@ -28,6 +29,7 @@ var _quotationMark = _interopRequireDefault(require("@atlaskit/icon/core/quotati
28
29
  var _statusError = _interopRequireDefault(require("@atlaskit/icon/core/status-error"));
29
30
  var _logo = require("@atlaskit/logo");
30
31
  var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
32
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
31
33
  var _compiled = require("@atlaskit/primitives/compiled");
32
34
  var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
33
35
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
@@ -168,7 +170,8 @@ var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLoc
168
170
  resourceId = _ref4.resourceId,
169
171
  intl = _ref4.intl,
170
172
  isSource = _ref4.isSource,
171
- localId = _ref4.localId;
173
+ localId = _ref4.localId,
174
+ api = _ref4.api;
172
175
  var formatMessage = intl.formatMessage;
173
176
  var triggerTitle = formatMessage(_messages.syncBlockMessages.syncedLocationDropdownTitle);
174
177
  var _useState = (0, _react.useState)(false),
@@ -181,12 +184,14 @@ var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLoc
181
184
  var isOpen = _ref5.isOpen;
182
185
  return setIsOpen(isOpen);
183
186
  },
187
+ testId: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? 'synced-block-synced-locations-dropdown' : undefined,
184
188
  trigger: function trigger(_ref6) {
185
189
  var triggerRef = _ref6.triggerRef,
186
190
  triggerProps = (0, _objectWithoutProperties2.default)(_ref6, _excluded);
187
191
  return /*#__PURE__*/React.createElement(_ui.FloatingToolbarButton, (0, _extends2.default)({
188
192
  ref: triggerRef,
189
193
  areAnyNewToolbarFlagsEnabled: true,
194
+ selected: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? isOpen : undefined,
190
195
  iconAfter: /*#__PURE__*/React.createElement(_chevronDown.default, {
191
196
  color: "currentColor",
192
197
  spacing: "spacious",
@@ -201,7 +206,8 @@ var SyncedLocationDropdown = exports.SyncedLocationDropdown = function SyncedLoc
201
206
  resourceId: resourceId,
202
207
  intl: intl,
203
208
  isSource: isSource,
204
- localId: localId
209
+ localId: localId,
210
+ api: api
205
211
  }));
206
212
  };
207
213
  var DropdownContent = function DropdownContent(_ref7) {
@@ -209,7 +215,8 @@ var DropdownContent = function DropdownContent(_ref7) {
209
215
  resourceId = _ref7.resourceId,
210
216
  intl = _ref7.intl,
211
217
  isSource = _ref7.isSource,
212
- localId = _ref7.localId;
218
+ localId = _ref7.localId,
219
+ api = _ref7.api;
213
220
  var formatMessage = intl.formatMessage;
214
221
  var _useState3 = (0, _react.useState)('none'),
215
222
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
@@ -252,6 +259,20 @@ var DropdownContent = function DropdownContent(_ref7) {
252
259
  }();
253
260
  getReferenceData();
254
261
  }, [syncBlockStore, intl, isSource, localId, resourceId]);
262
+ var handleLocationClick = function handleLocationClick() {
263
+ if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
264
+ var _api$analytics;
265
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
266
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL,
267
+ action: _analytics.ACTION.CLICKED,
268
+ actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
269
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CLICK_SYNCED_LOCATION,
270
+ attributes: {
271
+ resourceId: resourceId
272
+ }
273
+ });
274
+ }
275
+ };
255
276
  var content = function content() {
256
277
  switch (fetchStatus) {
257
278
  case 'loading':
@@ -281,7 +302,10 @@ var DropdownContent = function DropdownContent(_ref7) {
281
302
  }),
282
303
  href: reference.url,
283
304
  target: "_blank",
284
- key: reference.title
305
+ key: reference.title,
306
+ onClick: function onClick() {
307
+ return handleLocationClick();
308
+ }
285
309
  }, /*#__PURE__*/React.createElement(ItemTitle, {
286
310
  title: reference.title || reference.url || '',
287
311
  formatMessage: formatMessage,
@@ -308,7 +332,8 @@ var LoadingScreen = function LoadingScreen() {
308
332
  var ErrorScreen = function ErrorScreen(_ref9) {
309
333
  var formatMessage = _ref9.formatMessage;
310
334
  return /*#__PURE__*/React.createElement(_compiled.Box, {
311
- xcss: styles.errorContainer
335
+ xcss: styles.errorContainer,
336
+ testId: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? 'synced-locations-dropdown-content-error' : undefined
312
337
  }, /*#__PURE__*/React.createElement(_compiled.Box, {
313
338
  xcss: styles.errorIcon
314
339
  }, /*#__PURE__*/React.createElement(_statusError.default, {
@@ -325,7 +350,8 @@ var NoResultScreen = function NoResultScreen(_ref0) {
325
350
  var formatMessage = _ref0.formatMessage;
326
351
  return /*#__PURE__*/React.createElement(_compiled.Stack, {
327
352
  xcss: styles.noResultsContainer,
328
- space: "space.100"
353
+ space: "space.100",
354
+ testId: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? 'synced-locations-dropdown-content-no-results' : undefined
329
355
  }, /*#__PURE__*/React.createElement(_compiled.Text, {
330
356
  as: "p"
331
357
  }, formatMessage(_messages.syncBlockMessages.syncedLocationDropdownNoResults)), /*#__PURE__*/React.createElement(_compiled.Text, {
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.getToolbarConfig = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _react = _interopRequireDefault(require("react"));
11
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
12
  var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
12
13
  var _ui = require("@atlaskit/editor-common/ui");
13
14
  var _utils = require("@atlaskit/editor-prosemirror/utils");
@@ -57,11 +58,11 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
57
58
  title: formatMessage(_messages.default.delete),
58
59
  onClick: (0, _editorCommands.removeSyncedBlock)(api),
59
60
  icon: _delete.default,
60
- testId: (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete : undefined
61
- }, hoverDecorationProps(nodeType, (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? undefined : _consts.akEditorSelectedNodeClassName));
61
+ testId: _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete
62
+ }, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
62
63
  items.push(deleteButton);
63
64
  } else {
64
- if (!isErroredBlock && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
65
+ if (!isErroredBlock) {
65
66
  var syncedLocation = {
66
67
  type: 'custom',
67
68
  fallback: [],
@@ -71,7 +72,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
71
72
  resourceId: resourceId,
72
73
  localId: localId,
73
74
  intl: intl,
74
- isSource: isBodiedSyncBlock
75
+ isSource: isBodiedSyncBlock,
76
+ api: api
75
77
  });
76
78
  }
77
79
  };
@@ -87,7 +89,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
87
89
  title: formatMessage(_messages.syncBlockMessages.unsyncButton),
88
90
  onClick: function onClick() {
89
91
  return (0, _editorCommands.unsync)(syncBlockStore, isBodiedSyncBlock, view);
90
- }
92
+ },
93
+ testId: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? isBodiedSyncBlock ? _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSourceUnsync : _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceUnsync : undefined
91
94
  });
92
95
  }
93
96
  };
@@ -101,7 +104,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
101
104
  title: formatMessage(_messages.syncBlockMessages.copySyncBlockLabel),
102
105
  showTitle: false,
103
106
  tooltipContent: formatMessage(_messages.syncBlockMessages.copySyncedBlockTooltip),
104
- onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(syncBlockStore, api)
107
+ onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(syncBlockStore, _analytics.INPUT_METHOD.SYNCED_BLOCK_TB, api)
105
108
  }, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
106
109
  items.push(copyButton);
107
110
  var disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
@@ -131,7 +134,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
131
134
  onClick: (0, _editorCommands.removeSyncedBlock)(api),
132
135
  icon: /*#__PURE__*/_react.default.createElement(_delete.default, {
133
136
  label: ""
134
- })
137
+ }),
138
+ testId: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? isBodiedSyncBlock ? _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSourceDelete : _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete : undefined
135
139
  }, hoverDecorationProps(nodeType))]
136
140
  }];
137
141
  items.push.apply(items, overflowMenuConfig);
@@ -30,17 +30,15 @@ export const createSyncedBlock = ({
30
30
  const paragraphNode = paragraph.createAndFill({});
31
31
  const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
32
32
  if (!newBodiedSyncBlockNode) {
33
- if (fg('platform_synced_block_dogfooding')) {
34
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
35
- action: ACTION.ERROR,
36
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
37
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
38
- attributes: {
39
- error: 'Create and fill for empty content failed'
40
- },
41
- eventType: EVENT_TYPE.OPERATIONAL
42
- });
43
- }
33
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
34
+ action: ACTION.ERROR,
35
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
36
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
37
+ attributes: {
38
+ error: 'Create and fill for empty content failed'
39
+ },
40
+ eventType: EVENT_TYPE.OPERATIONAL
41
+ });
44
42
  return false;
45
43
  }
46
44
 
@@ -55,33 +53,29 @@ export const createSyncedBlock = ({
55
53
  } else {
56
54
  const conversionInfo = canBeConvertedToSyncBlock(tr.selection);
57
55
  if (!conversionInfo) {
58
- if (fg('platform_synced_block_dogfooding')) {
59
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
60
- action: ACTION.ERROR,
61
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
62
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
63
- attributes: {
64
- error: 'Content cannot be converted to sync block'
65
- },
66
- eventType: EVENT_TYPE.OPERATIONAL
67
- });
68
- }
56
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
57
+ action: ACTION.ERROR,
58
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
59
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
60
+ attributes: {
61
+ error: 'Content cannot be converted to sync block'
62
+ },
63
+ eventType: EVENT_TYPE.OPERATIONAL
64
+ });
69
65
  return false;
70
66
  }
71
67
  const attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
72
68
  const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, conversionInfo.contentToInclude);
73
69
  if (!newBodiedSyncBlockNode) {
74
- if (fg('platform_synced_block_dogfooding')) {
75
- fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
76
- action: ACTION.ERROR,
77
- actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
78
- actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
79
- attributes: {
80
- error: 'Create and fill for content failed'
81
- },
82
- eventType: EVENT_TYPE.OPERATIONAL
83
- });
84
- }
70
+ fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
71
+ action: ACTION.ERROR,
72
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
73
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
74
+ attributes: {
75
+ error: 'Create and fill for content failed'
76
+ },
77
+ eventType: EVENT_TYPE.OPERATIONAL
78
+ });
85
79
  return false;
86
80
  }
87
81
 
@@ -98,20 +92,33 @@ export const createSyncedBlock = ({
98
92
  // see filterTransaction for more details
99
93
  return tr;
100
94
  };
101
- export const copySyncedBlockReferenceToClipboardEditorCommand = (syncBlockStore, api) => ({
95
+ export const copySyncedBlockReferenceToClipboardEditorCommand = (syncBlockStore, inputMethod, api) => ({
102
96
  tr
103
97
  }) => {
104
- if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, api)) {
98
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api)) {
105
99
  return tr;
106
100
  }
107
101
  return null;
108
102
  };
109
- export const copySyncedBlockReferenceToClipboard = (syncBlockStore, api) => (state, _dispatch, _view) => {
110
- return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, api);
103
+ export const copySyncedBlockReferenceToClipboard = (syncBlockStore, inputMethod, api) => (state, _dispatch, _view) => {
104
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api);
111
105
  };
112
- const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBlockStore, api) => {
106
+ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBlockStore, inputMethod, api) => {
113
107
  const syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
114
108
  if (!syncBlockFindResult) {
109
+ if (fg('platform_synced_block_patch_1')) {
110
+ var _api$analytics, _api$analytics$action;
111
+ api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent({
112
+ eventType: EVENT_TYPE.OPERATIONAL,
113
+ action: ACTION.ERROR,
114
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
115
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_COPY,
116
+ attributes: {
117
+ error: 'No sync block found in selection',
118
+ inputMethod
119
+ }
120
+ });
121
+ }
115
122
  return false;
116
123
  }
117
124
  const isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockFindResult.node, schema.nodes.bodiedSyncBlock);
@@ -128,12 +135,39 @@ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBloc
128
135
  resourceId: syncBlockStore.referenceManager.generateResourceIdForReference(syncBlockFindResult.node.attrs.resourceId)
129
136
  });
130
137
  if (!referenceSyncBlockNode) {
138
+ if (fg('platform_synced_block_patch_1')) {
139
+ var _api$analytics2, _api$analytics2$actio;
140
+ 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({
141
+ eventType: EVENT_TYPE.OPERATIONAL,
142
+ action: ACTION.ERROR,
143
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
144
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_COPY,
145
+ attributes: {
146
+ error: 'Failed to create reference sync block node',
147
+ resourceId: syncBlockFindResult.node.attrs.resourceId,
148
+ inputMethod
149
+ }
150
+ });
151
+ }
131
152
  return false;
132
153
  }
133
154
  } else {
134
155
  referenceSyncBlockNode = syncBlockFindResult.node;
135
156
  }
136
157
  if (!referenceSyncBlockNode) {
158
+ if (fg('platform_synced_block_patch_1')) {
159
+ var _api$analytics3, _api$analytics3$actio;
160
+ 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({
161
+ eventType: EVENT_TYPE.OPERATIONAL,
162
+ action: ACTION.ERROR,
163
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
164
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_COPY,
165
+ attributes: {
166
+ error: 'No reference sync block node available',
167
+ inputMethod
168
+ }
169
+ });
170
+ }
137
171
  return false;
138
172
  }
139
173
  const domNode = toDOM(referenceSyncBlockNode, schema);
@@ -144,6 +178,19 @@ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBloc
144
178
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
145
179
  tr
146
180
  }) => {
181
+ if (fg('platform_synced_block_patch_1')) {
182
+ var _api$analytics4, _api$analytics4$actio;
183
+ 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({
184
+ eventType: EVENT_TYPE.OPERATIONAL,
185
+ action: ACTION.COPIED,
186
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
187
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_COPY,
188
+ attributes: {
189
+ resourceId: referenceSyncBlockNode.attrs.resourceId,
190
+ inputMethod
191
+ }
192
+ });
193
+ }
147
194
  return tr.setMeta(syncedBlockPluginKey, {
148
195
  activeFlag: {
149
196
  id: FLAG_ID.SYNC_BLOCK_COPIED
@@ -162,11 +209,23 @@ export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch,
162
209
  }
163
210
  const syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
164
211
  if (syncBlockURL) {
212
+ if (fg('platform_synced_block_patch_1')) {
213
+ var _api$analytics5;
214
+ api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions.fireAnalyticsEvent({
215
+ eventType: EVENT_TYPE.OPERATIONAL,
216
+ action: ACTION.SYNCED_BLOCK_EDIT_SOURCE,
217
+ actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
218
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_SOURCE_URL,
219
+ attributes: {
220
+ resourceId: resourceId
221
+ }
222
+ });
223
+ }
165
224
  window.open(syncBlockURL, '_blank');
166
225
  } else {
167
- var _api$analytics, _api$analytics$action;
226
+ var _api$analytics6, _api$analytics6$actio;
168
227
  const tr = state.tr;
169
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
228
+ 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.attachAnalyticsEvent({
170
229
  eventType: EVENT_TYPE.OPERATIONAL,
171
230
  action: ACTION.ERROR,
172
231
  actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
@@ -5,7 +5,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
5
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
6
6
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
7
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
10
9
  const toDOM = () => ['div', {
11
10
  class: BodiedSyncBlockSharedCssClassName.content,
@@ -68,7 +67,7 @@ class BodiedSyncBlock extends ReactNodeView {
68
67
  if (!syncBlockStore) {
69
68
  return null;
70
69
  }
71
- return fg('platform_synced_block_dogfooding') ? /*#__PURE__*/React.createElement(ErrorBoundary, {
70
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
72
71
  component: ACTION_SUBJECT.SYNCED_BLOCK,
73
72
  dispatchAnalyticsEvent: (_this$api6 = this.api) === null || _this$api6 === void 0 ? void 0 : (_this$api6$analytics = _this$api6.analytics) === null || _this$api6$analytics === void 0 ? void 0 : _this$api6$analytics.actions.fireAnalyticsEvent,
74
73
  fallbackComponent: null
@@ -76,11 +75,7 @@ class BodiedSyncBlock extends ReactNodeView {
76
75
  ref: forwardRef,
77
76
  syncBlockStore: syncBlockStore,
78
77
  node: this.node
79
- })) : /*#__PURE__*/React.createElement(BodiedSyncBlockWrapper, {
80
- ref: forwardRef,
81
- syncBlockStore: syncBlockStore,
82
- node: this.node
83
- });
78
+ }));
84
79
  }
85
80
  getContentDOM() {
86
81
  const {
@@ -4,7 +4,6 @@ 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 { fg } from '@atlaskit/platform-feature-flags';
8
7
  import { removeSyncedBlockAtPos } from '../editor-commands';
9
8
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
10
9
  export class SyncBlock extends ReactNodeView {
@@ -22,7 +21,7 @@ export class SyncBlock extends ReactNodeView {
22
21
  render({
23
22
  getPos
24
23
  }) {
25
- var _this$options, _this$api$syncedBlock, _this$api, _this$api$syncedBlock2, _this$api$syncedBlock3, _this$api2, _this$api2$analytics, _this$options2, _this$options3;
24
+ var _this$options, _this$api$syncedBlock, _this$api, _this$api$syncedBlock2, _this$api$syncedBlock3, _this$api2, _this$api2$analytics, _this$options2;
26
25
  if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
27
26
  return null;
28
27
  }
@@ -33,14 +32,13 @@ export class SyncBlock extends ReactNodeView {
33
32
  if (!resourceId || !localId) {
34
33
  return null;
35
34
  }
36
- const initialSyncBlockStore = fg('platform_synced_block_dogfooding') ? this.syncBlockStore : undefined;
37
- const syncBlockStore = (_this$api$syncedBlock = (_this$api = this.api) === null || _this$api === void 0 ? void 0 : (_this$api$syncedBlock2 = _this$api.syncedBlock) === null || _this$api$syncedBlock2 === void 0 ? void 0 : (_this$api$syncedBlock3 = _this$api$syncedBlock2.sharedState.currentState()) === null || _this$api$syncedBlock3 === void 0 ? void 0 : _this$api$syncedBlock3.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : initialSyncBlockStore;
35
+ const syncBlockStore = (_this$api$syncedBlock = (_this$api = this.api) === null || _this$api === void 0 ? void 0 : (_this$api$syncedBlock2 = _this$api.syncedBlock) === null || _this$api$syncedBlock2 === void 0 ? void 0 : (_this$api$syncedBlock3 = _this$api$syncedBlock2.sharedState.currentState()) === null || _this$api$syncedBlock3 === void 0 ? void 0 : _this$api$syncedBlock3.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : this.syncBlockStore;
38
36
  if (!syncBlockStore) {
39
37
  return null;
40
38
  }
41
39
 
42
40
  // get document node from data provider
43
- return fg('platform_synced_block_dogfooding') ? /*#__PURE__*/React.createElement(ErrorBoundary, {
41
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
44
42
  component: ACTION_SUBJECT.SYNCED_BLOCK,
45
43
  dispatchAnalyticsEvent: (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : (_this$api2$analytics = _this$api2.analytics) === null || _this$api2$analytics === void 0 ? void 0 : _this$api2$analytics.actions.fireAnalyticsEvent,
46
44
  fallbackComponent: null
@@ -61,16 +59,7 @@ export class SyncBlock extends ReactNodeView {
61
59
  return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : (_this$api3$analytics = _this$api3.analytics) === null || _this$api3$analytics === void 0 ? void 0 : (_this$api3$analytics$ = _this$api3$analytics.actions) === null || _this$api3$analytics$ === void 0 ? void 0 : _this$api3$analytics$.fireAnalyticsEvent);
62
60
  },
63
61
  api: this.api
64
- }))) : /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
65
- localId: this.node.attrs.localId,
66
- syncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncedBlockRenderer,
67
- useFetchSyncBlockTitle: () => useFetchSyncBlockTitle(syncBlockStore, this.node),
68
- useFetchSyncBlockData: () => {
69
- var _this$api4, _this$api4$analytics, _this$api4$analytics$;
70
- return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : (_this$api4$analytics = _this$api4.analytics) === null || _this$api4$analytics === void 0 ? void 0 : (_this$api4$analytics$ = _this$api4$analytics.actions) === null || _this$api4$analytics$ === void 0 ? void 0 : _this$api4$analytics$.fireAnalyticsEvent);
71
- },
72
- api: this.api
73
- });
62
+ })));
74
63
  }
75
64
  destroy() {
76
65
  var _this$unsubscribe;