@atlaskit/editor-plugin-synced-block 10.3.4 → 10.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 10.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 10.3.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [`ead18351c8a3c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ead18351c8a3c) -
14
+ Add educational guidance to synced block copy confirmation flags in the activation experiment.
15
+ - Updated dependencies
16
+
3
17
  ## 10.3.4
4
18
 
5
19
  ### Patch Changes
@@ -12,11 +12,12 @@ var _copyButton = require("@atlaskit/editor-common/copy-button");
12
12
  var _model = require("@atlaskit/editor-prosemirror/model");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _utils = require("@atlaskit/editor-prosemirror/utils");
15
+ var _utils2 = require("@atlaskit/editor-synced-block-provider/utils");
15
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _main = require("../pm-plugins/main");
17
- var _utils2 = require("../pm-plugins/utils/utils");
18
+ var _utils3 = require("../pm-plugins/utils/utils");
18
19
  var _types = require("../types");
19
- var _utils3 = require("./utils");
20
+ var _utils4 = require("./utils");
20
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
23
  /**
@@ -118,7 +119,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
118
119
  }
119
120
  }
120
121
  } else {
121
- var conversionInfo = (0, _utils2.canBeConvertedToSyncBlock)(tr.selection);
122
+ var conversionInfo = (0, _utils3.canBeConvertedToSyncBlock)(tr.selection);
122
123
  if (!conversionInfo) {
123
124
  fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
124
125
  action: _analytics.ACTION.ERROR,
@@ -165,22 +166,23 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
165
166
  });
166
167
  return tr;
167
168
  };
168
- var copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api) {
169
+ var copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api, isLivePage) {
169
170
  return function (_ref2) {
170
171
  var tr = _ref2.tr;
171
- if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api)) {
172
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api, isLivePage)) {
172
173
  return tr;
173
174
  }
174
175
  return null;
175
176
  };
176
177
  };
177
- var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore, inputMethod, api) {
178
+ var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore, inputMethod, api, isLivePage) {
178
179
  return function (state, _dispatch, _view) {
179
- return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api);
180
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api, isLivePage);
180
181
  };
181
182
  };
182
- var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore, inputMethod, api) {
183
- var syncBlockFindResult = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(schema, selection);
183
+ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore, inputMethod, api, isLivePage) {
184
+ var _syncBlockStore$refer;
185
+ var syncBlockFindResult = (0, _utils3.findSyncBlockOrBodiedSyncBlock)(schema, selection);
184
186
  if (!syncBlockFindResult) {
185
187
  var _api$analytics;
186
188
  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({
@@ -195,7 +197,7 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
195
197
  });
196
198
  return false;
197
199
  }
198
- var isBodiedSyncBlock = (0, _utils2.isBodiedSyncBlockNode)(syncBlockFindResult.node, schema.nodes.bodiedSyncBlock);
200
+ var isBodiedSyncBlock = (0, _utils3.isBodiedSyncBlockNode)(syncBlockFindResult.node, schema.nodes.bodiedSyncBlock);
199
201
  var referenceSyncBlockNode = null;
200
202
  if (isBodiedSyncBlock) {
201
203
  var syncBlock = schema.nodes.syncBlock;
@@ -242,7 +244,9 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
242
244
  // Bare-uuid join key shared with the create/delete events: for a source
243
245
  // bodiedSyncBlock its `localId` is the source uuid (copy was page-form only).
244
246
  var sourceJoinKey = isBodiedSyncBlock ? syncBlockFindResult.node.attrs.localId : undefined;
245
- (0, _utils2.deferDispatch)(function () {
247
+ var isSourceContentUnpublished = isBodiedSyncBlock ? syncBlockStore.sourceManager.getStatus(syncBlockFindResult.node.attrs.resourceId) !== 'active' : ((_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(referenceSyncBlockNode.attrs.resourceId)) === null || _syncBlockStore$refer === void 0 || (_syncBlockStore$refer = _syncBlockStore$refer.data) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.status) === 'unpublished';
248
+ var sourceProduct = (0, _utils2.getSourceProductFromResourceIdSafe)(referenceSyncBlockNode.attrs.resourceId);
249
+ (0, _utils3.deferDispatch)(function () {
246
250
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
247
251
  var _api$analytics4;
248
252
  var tr = _ref3.tr;
@@ -260,7 +264,10 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
260
264
  });
261
265
  return tr.setMeta(_main.syncedBlockPluginKey, {
262
266
  activeFlag: {
263
- id: _types.FLAG_ID.SYNC_BLOCK_COPIED
267
+ id: _types.FLAG_ID.SYNC_BLOCK_COPIED,
268
+ isLivePage: isLivePage,
269
+ isSourceContentUnpublished: isSourceContentUnpublished,
270
+ sourceProduct: sourceProduct
264
271
  }
265
272
  });
266
273
  });
@@ -269,16 +276,16 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
269
276
  };
270
277
  var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
271
278
  return function (state, dispatch, _view) {
272
- var _syncBlock$node, _syncBlockStore$refer;
273
- var syncBlock = (0, _utils2.findSyncBlock)(state.schema, state.selection);
279
+ var _syncBlock$node, _syncBlockStore$refer2;
280
+ var syncBlock = (0, _utils3.findSyncBlock)(state.schema, state.selection);
274
281
  var resourceId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.resourceId;
275
282
  if (!resourceId) {
276
283
  return false;
277
284
  }
278
285
  var syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
279
- var syncBlockData = (_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.data;
286
+ var syncBlockData = (_syncBlockStore$refer2 = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer2 === void 0 ? void 0 : _syncBlockStore$refer2.data;
280
287
  var isOnSameDocument = (syncBlockData === null || syncBlockData === void 0 ? void 0 : syncBlockData.onSameDocument) === true;
281
- var sourceBlock = isOnSameDocument && syncBlockData ? (0, _utils3.findBodiedSyncBlockByLocalId)(state, syncBlockData.blockInstanceId) : undefined;
288
+ var sourceBlock = isOnSameDocument && syncBlockData ? (0, _utils4.findBodiedSyncBlockByLocalId)(state, syncBlockData.blockInstanceId) : undefined;
282
289
  if (syncBlockURL) {
283
290
  var _api$analytics5;
284
291
  api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || _api$analytics5.actions.fireAnalyticsEvent({
@@ -362,7 +369,7 @@ var unsync = exports.unsync = function unsync(storeManager, isBodiedSyncBlock, v
362
369
  return false;
363
370
  }
364
371
  var state = view.state;
365
- var syncBlock = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state.schema, state.selection);
372
+ var syncBlock = (0, _utils3.findSyncBlockOrBodiedSyncBlock)(state.schema, state.selection);
366
373
  if (!syncBlock) {
367
374
  return false;
368
375
  }
@@ -383,5 +390,5 @@ var unsync = exports.unsync = function unsync(storeManager, isBodiedSyncBlock, v
383
390
  // use defaultSchema for serialization so we can serialize any type of nodes and marks despite current editor's schema might not allow it
384
391
  var contentFragment = _model.Fragment.fromJSON(_schemaDefault.defaultSchema, syncBlockContent);
385
392
  var contentDOM = _model.DOMSerializer.fromSchema(_schemaDefault.defaultSchema).serializeFragment(contentFragment);
386
- return (0, _utils3.pasteSyncBlockHTMLContent)(contentDOM, view);
393
+ return (0, _utils4.pasteSyncBlockHTMLContent)(contentDOM, view);
387
394
  };
@@ -103,13 +103,16 @@ var mapRetryCreationPosMap = function mapRetryCreationPosMap(oldMap, newRetryCre
103
103
  }
104
104
  return newMap;
105
105
  };
106
- var showCopiedFlag = function showCopiedFlag(api) {
106
+ var showCopiedFlag = function showCopiedFlag(api, isLivePage, isSourceContentUnpublished, sourceProduct) {
107
107
  (0, _utils3.deferDispatch)(function () {
108
108
  api === null || api === void 0 || api.core.actions.execute(function (_ref) {
109
109
  var tr = _ref.tr;
110
110
  return tr.setMeta(syncedBlockPluginKey, {
111
111
  activeFlag: {
112
- id: _types.FLAG_ID.SYNC_BLOCK_COPIED
112
+ id: _types.FLAG_ID.SYNC_BLOCK_COPIED,
113
+ isLivePage: isLivePage,
114
+ isSourceContentUnpublished: isSourceContentUnpublished,
115
+ sourceProduct: sourceProduct
113
116
  }
114
117
  });
115
118
  });
@@ -859,10 +862,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
859
862
  }
860
863
  return (0, _utils.mapSlice)(slice, function (node) {
861
864
  if (syncBlockStore.referenceManager.isReferenceBlock(node)) {
865
+ var _syncBlockStore$refer;
862
866
  if (isCut) {
863
867
  return node;
864
868
  }
865
- showCopiedFlag(api);
869
+ showCopiedFlag(api, options === null || options === void 0 ? void 0 : options.__livePage, ((_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId)) === null || _syncBlockStore$refer === void 0 || (_syncBlockStore$refer = _syncBlockStore$refer.data) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.status) === 'unpublished', (0, _utils2.getSourceProductFromResourceIdSafe)(node.attrs.resourceId));
866
870
  return node;
867
871
  }
868
872
  if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
@@ -874,8 +878,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
874
878
  if (isSyncedBlockPatch13Enabled && isCut) {
875
879
  return node;
876
880
  }
877
- showCopiedFlag(api);
878
881
  var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
882
+ showCopiedFlag(api, options === null || options === void 0 ? void 0 : options.__livePage, syncBlockStore.sourceManager.getStatus(node.attrs.resourceId) !== 'active', (0, _utils2.getSourceProductFromResourceIdSafe)(newResourceId));
879
883
  // Convert bodiedSyncBlock to syncBlock
880
884
  // The paste transformation will regenrate the localId
881
885
  var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
@@ -105,7 +105,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
105
105
  },
106
106
  commands: {
107
107
  copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard(inputMethod) {
108
- return (0, _editorCommands.copySyncedBlockReferenceToClipboardEditorCommand)(syncBlockStore, inputMethod, api);
108
+ return (0, _editorCommands.copySyncedBlockReferenceToClipboardEditorCommand)(syncBlockStore, inputMethod, api, config === null || config === void 0 ? void 0 : config.__livePage);
109
109
  },
110
110
  insertSyncedBlock: function insertSyncedBlock(inputMethod) {
111
111
  return function (_ref3) {
@@ -147,7 +147,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
147
147
  if (!((_syncedBlockPluginKey = _main.syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
148
148
  return undefined;
149
149
  }
150
- return (0, _floatingToolbar.getToolbarConfig)(state, intl, api, syncBlockStore);
150
+ return (0, _floatingToolbar.getToolbarConfig)(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage);
151
151
  }
152
152
  },
153
153
  contentComponent: function contentComponent(_ref4) {
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.Flag = void 0;
8
+ exports.getSyncBlockCopiedDescription = exports.Flag = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _reactIntl = require("react-intl");
@@ -16,6 +16,7 @@ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
16
16
  var _flag = _interopRequireWildcard(require("@atlaskit/flag"));
17
17
  var _statusSuccess = _interopRequireDefault(require("@atlaskit/icon/core/status-success"));
18
18
  var _statusWarning = _interopRequireDefault(require("@atlaskit/icon/core/status-warning"));
19
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
19
20
  var _main = require("../pm-plugins/main");
20
21
  var _types = require("../types");
21
22
  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" != _typeof(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); }
@@ -61,6 +62,12 @@ var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _d
61
62
  description: _messages.syncBlockMessages.duplicateSourceSyncBlockDescription,
62
63
  type: 'error'
63
64
  });
65
+ var getSyncBlockCopiedDescription = exports.getSyncBlockCopiedDescription = function getSyncBlockCopiedDescription(activeFlag, isSyncBlockActivationEnabled) {
66
+ if (!activeFlag || activeFlag.id !== _types.FLAG_ID.SYNC_BLOCK_COPIED || activeFlag.sourceProduct !== 'confluence-page' || !isSyncBlockActivationEnabled) {
67
+ return undefined;
68
+ }
69
+ return activeFlag.isLivePage || !activeFlag.isSourceContentUnpublished ? _messages.syncBlockMessages.syncBlockCopiedLivePageDescription : _messages.syncBlockMessages.syncBlockCopiedUnpublishedDescription;
70
+ };
64
71
  var Flag = exports.Flag = function Flag(_ref) {
65
72
  var api = _ref.api;
66
73
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['syncedBlock', 'connectivity'], function (states) {
@@ -88,8 +95,9 @@ var Flag = exports.Flag = function Flag(_ref) {
88
95
  // For the unpublished-paste flag, swap to the Jira-flavoured copy when the source
89
96
  // is a Jira work item. Other flags don't currently vary by product.
90
97
  var isJiraUnpublishedPaste = activeFlag.id === _types.FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED && activeFlag.sourceProduct === 'jira-work-item';
98
+ var copiedDescription = getSyncBlockCopiedDescription(activeFlag, activeFlag.id === _types.FLAG_ID.SYNC_BLOCK_COPIED && (0, _expValEquals.expValEquals)('platform_editor_sync_block_activation', 'isEnabled', true));
91
99
  var title = isJiraUnpublishedPaste ? _messages.syncBlockMessages.unpublishedSyncBlockPastedTitleJiraWorkItem : defaultTitle;
92
- var description = isJiraUnpublishedPaste ? _messages.syncBlockMessages.unpublishedSyncBlockPastedDescriptionJiraWorkItem : defaultDescription;
100
+ var description = copiedDescription !== null && copiedDescription !== void 0 ? copiedDescription : isJiraUnpublishedPaste ? _messages.syncBlockMessages.unpublishedSyncBlockPastedDescriptionJiraWorkItem : defaultDescription;
93
101
 
94
102
  // Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
95
103
  if ((0, _editorPluginConnectivity.isOfflineMode)(mode) && !!onRetry) {
@@ -27,7 +27,7 @@ var _SyncedLocationDropdown = require("./SyncedLocationDropdown");
27
27
  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" != _typeof(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); }
28
28
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
29
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
30
- var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore) {
30
+ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage) {
31
31
  var _syncBlockInstance$er, _api$decorations, _api$connectivity;
32
32
  var syncBlockObject = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state.schema, state.selection);
33
33
  if (!syncBlockObject) {
@@ -80,7 +80,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
80
80
  showTitle: isSyncBlockActivationEnabled,
81
81
  tooltipContent: isSyncBlockActivationEnabled ? undefined : formatMessage(_messages.syncBlockMessages.copySyncedBlockTooltip),
82
82
  testId: isSyncBlockActivationEnabled ? _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarCopy : undefined,
83
- onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(syncBlockStore, _analytics.INPUT_METHOD.SYNCED_BLOCK_TB, api)
83
+ onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(syncBlockStore, _analytics.INPUT_METHOD.SYNCED_BLOCK_TB, api, isLivePage)
84
84
  }, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
85
85
 
86
86
  // In the activation experience the primary "Copy to sync" action leads the
@@ -4,6 +4,7 @@ import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
4
4
  import { DOMSerializer, Fragment } from '@atlaskit/editor-prosemirror/model';
5
5
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
+ import { getSourceProductFromResourceIdSafe } from '@atlaskit/editor-synced-block-provider/utils';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { creationMetaKey, deleteMechanismMetaKey, syncedBlockPluginKey } from '../pm-plugins/main';
9
10
  import { canBeConvertedToSyncBlock, deferDispatch, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
@@ -161,16 +162,17 @@ export const createSyncedBlock = ({
161
162
  });
162
163
  return tr;
163
164
  };
164
- export const copySyncedBlockReferenceToClipboardEditorCommand = (syncBlockStore, inputMethod, api) => ({
165
+ export const copySyncedBlockReferenceToClipboardEditorCommand = (syncBlockStore, inputMethod, api, isLivePage) => ({
165
166
  tr
166
167
  }) => {
167
- if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api)) {
168
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api, isLivePage)) {
168
169
  return tr;
169
170
  }
170
171
  return null;
171
172
  };
172
- export const copySyncedBlockReferenceToClipboard = (syncBlockStore, inputMethod, api) => (state, _dispatch, _view) => copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api);
173
- const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBlockStore, inputMethod, api) => {
173
+ export const copySyncedBlockReferenceToClipboard = (syncBlockStore, inputMethod, api, isLivePage) => (state, _dispatch, _view) => copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api, isLivePage);
174
+ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBlockStore, inputMethod, api, isLivePage) => {
175
+ var _syncBlockStore$refer, _syncBlockStore$refer2;
174
176
  const syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
175
177
  if (!syncBlockFindResult) {
176
178
  var _api$analytics, _api$analytics$action;
@@ -237,6 +239,8 @@ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBloc
237
239
  // Bare-uuid join key shared with the create/delete events: for a source
238
240
  // bodiedSyncBlock its `localId` is the source uuid (copy was page-form only).
239
241
  const sourceJoinKey = isBodiedSyncBlock ? syncBlockFindResult.node.attrs.localId : undefined;
242
+ const isSourceContentUnpublished = isBodiedSyncBlock ? syncBlockStore.sourceManager.getStatus(syncBlockFindResult.node.attrs.resourceId) !== 'active' : ((_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(referenceSyncBlockNode.attrs.resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : (_syncBlockStore$refer2 = _syncBlockStore$refer.data) === null || _syncBlockStore$refer2 === void 0 ? void 0 : _syncBlockStore$refer2.status) === 'unpublished';
243
+ const sourceProduct = getSourceProductFromResourceIdSafe(referenceSyncBlockNode.attrs.resourceId);
240
244
  deferDispatch(() => {
241
245
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
242
246
  tr
@@ -257,7 +261,10 @@ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBloc
257
261
  });
258
262
  return tr.setMeta(syncedBlockPluginKey, {
259
263
  activeFlag: {
260
- id: FLAG_ID.SYNC_BLOCK_COPIED
264
+ id: FLAG_ID.SYNC_BLOCK_COPIED,
265
+ isLivePage,
266
+ isSourceContentUnpublished,
267
+ sourceProduct
261
268
  }
262
269
  });
263
270
  });
@@ -265,14 +272,14 @@ const copySyncedBlockReferenceToClipboardInternal = (schema, selection, syncBloc
265
272
  return true;
266
273
  };
267
274
  export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch, _view) => {
268
- var _syncBlock$node, _syncBlock$node$attrs, _syncBlockStore$refer;
275
+ var _syncBlock$node, _syncBlock$node$attrs, _syncBlockStore$refer3;
269
276
  const syncBlock = findSyncBlock(state.schema, state.selection);
270
277
  const resourceId = syncBlock === null || syncBlock === void 0 ? void 0 : (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 ? void 0 : (_syncBlock$node$attrs = _syncBlock$node.attrs) === null || _syncBlock$node$attrs === void 0 ? void 0 : _syncBlock$node$attrs.resourceId;
271
278
  if (!resourceId) {
272
279
  return false;
273
280
  }
274
281
  const syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
275
- const syncBlockData = (_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.data;
282
+ const syncBlockData = (_syncBlockStore$refer3 = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer3 === void 0 ? void 0 : _syncBlockStore$refer3.data;
276
283
  const isOnSameDocument = (syncBlockData === null || syncBlockData === void 0 ? void 0 : syncBlockData.onSameDocument) === true;
277
284
  const sourceBlock = isOnSameDocument && syncBlockData ? findBodiedSyncBlockByLocalId(state, syncBlockData.blockInstanceId) : undefined;
278
285
  if (syncBlockURL) {
@@ -78,13 +78,16 @@ const mapRetryCreationPosMap = (oldMap, newRetryCreationPos, mapPos, isPerfExper
78
78
  }
79
79
  return newMap;
80
80
  };
81
- const showCopiedFlag = api => {
81
+ const showCopiedFlag = (api, isLivePage, isSourceContentUnpublished, sourceProduct) => {
82
82
  deferDispatch(() => {
83
83
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
84
84
  tr
85
85
  }) => tr.setMeta(syncedBlockPluginKey, {
86
86
  activeFlag: {
87
- id: FLAG_ID.SYNC_BLOCK_COPIED
87
+ id: FLAG_ID.SYNC_BLOCK_COPIED,
88
+ isLivePage,
89
+ isSourceContentUnpublished,
90
+ sourceProduct
88
91
  }
89
92
  }));
90
93
  });
@@ -825,10 +828,11 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
825
828
  }
826
829
  return mapSlice(slice, node => {
827
830
  if (syncBlockStore.referenceManager.isReferenceBlock(node)) {
831
+ var _syncBlockStore$refer, _syncBlockStore$refer2;
828
832
  if (isCut) {
829
833
  return node;
830
834
  }
831
- showCopiedFlag(api);
835
+ showCopiedFlag(api, options === null || options === void 0 ? void 0 : options.__livePage, ((_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : (_syncBlockStore$refer2 = _syncBlockStore$refer.data) === null || _syncBlockStore$refer2 === void 0 ? void 0 : _syncBlockStore$refer2.status) === 'unpublished', getSourceProductFromResourceIdSafe(node.attrs.resourceId));
832
836
  return node;
833
837
  }
834
838
  if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
@@ -840,8 +844,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
840
844
  if (isSyncedBlockPatch13Enabled && isCut) {
841
845
  return node;
842
846
  }
843
- showCopiedFlag(api);
844
847
  const newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
848
+ showCopiedFlag(api, options === null || options === void 0 ? void 0 : options.__livePage, syncBlockStore.sourceManager.getStatus(node.attrs.resourceId) !== 'active', getSourceProductFromResourceIdSafe(newResourceId));
845
849
  // Convert bodiedSyncBlock to syncBlock
846
850
  // The paste transformation will regenrate the localId
847
851
  const newAttrs = {
@@ -96,7 +96,7 @@ export const syncedBlockPlugin = ({
96
96
  }];
97
97
  },
98
98
  commands: {
99
- copySyncedBlockReferenceToClipboard: inputMethod => copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api),
99
+ copySyncedBlockReferenceToClipboard: inputMethod => copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api, config === null || config === void 0 ? void 0 : config.__livePage),
100
100
  insertSyncedBlock: inputMethod => ({
101
101
  tr
102
102
  }) => {
@@ -136,7 +136,7 @@ export const syncedBlockPlugin = ({
136
136
  if (!((_syncedBlockPluginKey = syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
137
137
  return undefined;
138
138
  }
139
- return getToolbarConfig(state, intl, api, syncBlockStore);
139
+ return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage);
140
140
  }
141
141
  },
142
142
  contentComponent: ({
@@ -7,6 +7,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
7
  import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
8
8
  import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
9
9
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { syncedBlockPluginKey } from '../pm-plugins/main';
11
12
  import { FLAG_ID } from '../types';
12
13
  const flagMap = {
@@ -60,6 +61,12 @@ const flagMap = {
60
61
  type: 'error'
61
62
  }
62
63
  };
64
+ export const getSyncBlockCopiedDescription = (activeFlag, isSyncBlockActivationEnabled) => {
65
+ if (!activeFlag || activeFlag.id !== FLAG_ID.SYNC_BLOCK_COPIED || activeFlag.sourceProduct !== 'confluence-page' || !isSyncBlockActivationEnabled) {
66
+ return undefined;
67
+ }
68
+ return activeFlag.isLivePage || !activeFlag.isSourceContentUnpublished ? messages.syncBlockCopiedLivePageDescription : messages.syncBlockCopiedUnpublishedDescription;
69
+ };
63
70
  export const Flag = ({
64
71
  api
65
72
  }) => {
@@ -93,8 +100,9 @@ export const Flag = ({
93
100
  // For the unpublished-paste flag, swap to the Jira-flavoured copy when the source
94
101
  // is a Jira work item. Other flags don't currently vary by product.
95
102
  const isJiraUnpublishedPaste = activeFlag.id === FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED && activeFlag.sourceProduct === 'jira-work-item';
103
+ const copiedDescription = getSyncBlockCopiedDescription(activeFlag, activeFlag.id === FLAG_ID.SYNC_BLOCK_COPIED && expValEquals('platform_editor_sync_block_activation', 'isEnabled', true));
96
104
  const title = isJiraUnpublishedPaste ? messages.unpublishedSyncBlockPastedTitleJiraWorkItem : defaultTitle;
97
- const description = isJiraUnpublishedPaste ? messages.unpublishedSyncBlockPastedDescriptionJiraWorkItem : defaultDescription;
105
+ const description = copiedDescription !== null && copiedDescription !== void 0 ? copiedDescription : isJiraUnpublishedPaste ? messages.unpublishedSyncBlockPastedDescriptionJiraWorkItem : defaultDescription;
98
106
 
99
107
  // Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
100
108
  if (isOfflineMode(mode) && !!onRetry) {
@@ -15,7 +15,7 @@ import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSynce
15
15
  import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
16
16
  import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
17
17
  import { SyncedLocationDropdown } from './SyncedLocationDropdown';
18
- export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
18
+ export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage) => {
19
19
  var _syncBlockInstance$er, _api$decorations, _api$connectivity, _api$connectivity$sha;
20
20
  const syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
21
21
  if (!syncBlockObject) {
@@ -76,7 +76,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
76
76
  showTitle: isSyncBlockActivationEnabled,
77
77
  tooltipContent: isSyncBlockActivationEnabled ? undefined : formatMessage(messages.copySyncedBlockTooltip),
78
78
  testId: isSyncBlockActivationEnabled ? SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarCopy : undefined,
79
- onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, INPUT_METHOD.SYNCED_BLOCK_TB, api),
79
+ onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, INPUT_METHOD.SYNCED_BLOCK_TB, api, isLivePage),
80
80
  ...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
81
81
  };
82
82
 
@@ -7,6 +7,7 @@ import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
7
7
  import { DOMSerializer, Fragment } from '@atlaskit/editor-prosemirror/model';
8
8
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
+ import { getSourceProductFromResourceIdSafe } from '@atlaskit/editor-synced-block-provider/utils';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { creationMetaKey, deleteMechanismMetaKey, syncedBlockPluginKey } from '../pm-plugins/main';
12
13
  import { canBeConvertedToSyncBlock, deferDispatch, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
@@ -158,21 +159,22 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
158
159
  });
159
160
  return tr;
160
161
  };
161
- export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api) {
162
+ export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api, isLivePage) {
162
163
  return function (_ref2) {
163
164
  var tr = _ref2.tr;
164
- if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api)) {
165
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, inputMethod, api, isLivePage)) {
165
166
  return tr;
166
167
  }
167
168
  return null;
168
169
  };
169
170
  };
170
- export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore, inputMethod, api) {
171
+ export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore, inputMethod, api, isLivePage) {
171
172
  return function (state, _dispatch, _view) {
172
- return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api);
173
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, inputMethod, api, isLivePage);
173
174
  };
174
175
  };
175
- var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore, inputMethod, api) {
176
+ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore, inputMethod, api, isLivePage) {
177
+ var _syncBlockStore$refer;
176
178
  var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
177
179
  if (!syncBlockFindResult) {
178
180
  var _api$analytics;
@@ -235,6 +237,8 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
235
237
  // Bare-uuid join key shared with the create/delete events: for a source
236
238
  // bodiedSyncBlock its `localId` is the source uuid (copy was page-form only).
237
239
  var sourceJoinKey = isBodiedSyncBlock ? syncBlockFindResult.node.attrs.localId : undefined;
240
+ var isSourceContentUnpublished = isBodiedSyncBlock ? syncBlockStore.sourceManager.getStatus(syncBlockFindResult.node.attrs.resourceId) !== 'active' : ((_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(referenceSyncBlockNode.attrs.resourceId)) === null || _syncBlockStore$refer === void 0 || (_syncBlockStore$refer = _syncBlockStore$refer.data) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.status) === 'unpublished';
241
+ var sourceProduct = getSourceProductFromResourceIdSafe(referenceSyncBlockNode.attrs.resourceId);
238
242
  deferDispatch(function () {
239
243
  api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
240
244
  var _api$analytics4;
@@ -253,7 +257,10 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
253
257
  });
254
258
  return tr.setMeta(syncedBlockPluginKey, {
255
259
  activeFlag: {
256
- id: FLAG_ID.SYNC_BLOCK_COPIED
260
+ id: FLAG_ID.SYNC_BLOCK_COPIED,
261
+ isLivePage: isLivePage,
262
+ isSourceContentUnpublished: isSourceContentUnpublished,
263
+ sourceProduct: sourceProduct
257
264
  }
258
265
  });
259
266
  });
@@ -262,14 +269,14 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
262
269
  };
263
270
  export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
264
271
  return function (state, dispatch, _view) {
265
- var _syncBlock$node, _syncBlockStore$refer;
272
+ var _syncBlock$node, _syncBlockStore$refer2;
266
273
  var syncBlock = findSyncBlock(state.schema, state.selection);
267
274
  var resourceId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.resourceId;
268
275
  if (!resourceId) {
269
276
  return false;
270
277
  }
271
278
  var syncBlockURL = syncBlockStore.referenceManager.getSyncBlockURL(resourceId);
272
- var syncBlockData = (_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.data;
279
+ var syncBlockData = (_syncBlockStore$refer2 = syncBlockStore.referenceManager.getFromCache(resourceId)) === null || _syncBlockStore$refer2 === void 0 ? void 0 : _syncBlockStore$refer2.data;
273
280
  var isOnSameDocument = (syncBlockData === null || syncBlockData === void 0 ? void 0 : syncBlockData.onSameDocument) === true;
274
281
  var sourceBlock = isOnSameDocument && syncBlockData ? findBodiedSyncBlockByLocalId(state, syncBlockData.blockInstanceId) : undefined;
275
282
  if (syncBlockURL) {
@@ -96,13 +96,16 @@ var mapRetryCreationPosMap = function mapRetryCreationPosMap(oldMap, newRetryCre
96
96
  }
97
97
  return newMap;
98
98
  };
99
- var showCopiedFlag = function showCopiedFlag(api) {
99
+ var showCopiedFlag = function showCopiedFlag(api, isLivePage, isSourceContentUnpublished, sourceProduct) {
100
100
  deferDispatch(function () {
101
101
  api === null || api === void 0 || api.core.actions.execute(function (_ref) {
102
102
  var tr = _ref.tr;
103
103
  return tr.setMeta(syncedBlockPluginKey, {
104
104
  activeFlag: {
105
- id: FLAG_ID.SYNC_BLOCK_COPIED
105
+ id: FLAG_ID.SYNC_BLOCK_COPIED,
106
+ isLivePage: isLivePage,
107
+ isSourceContentUnpublished: isSourceContentUnpublished,
108
+ sourceProduct: sourceProduct
106
109
  }
107
110
  });
108
111
  });
@@ -852,10 +855,11 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
852
855
  }
853
856
  return mapSlice(slice, function (node) {
854
857
  if (syncBlockStore.referenceManager.isReferenceBlock(node)) {
858
+ var _syncBlockStore$refer;
855
859
  if (isCut) {
856
860
  return node;
857
861
  }
858
- showCopiedFlag(api);
862
+ showCopiedFlag(api, options === null || options === void 0 ? void 0 : options.__livePage, ((_syncBlockStore$refer = syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId)) === null || _syncBlockStore$refer === void 0 || (_syncBlockStore$refer = _syncBlockStore$refer.data) === null || _syncBlockStore$refer === void 0 ? void 0 : _syncBlockStore$refer.status) === 'unpublished', getSourceProductFromResourceIdSafe(node.attrs.resourceId));
859
863
  return node;
860
864
  }
861
865
  if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
@@ -867,8 +871,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
867
871
  if (isSyncedBlockPatch13Enabled && isCut) {
868
872
  return node;
869
873
  }
870
- showCopiedFlag(api);
871
874
  var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
875
+ showCopiedFlag(api, options === null || options === void 0 ? void 0 : options.__livePage, syncBlockStore.sourceManager.getStatus(node.attrs.resourceId) !== 'active', getSourceProductFromResourceIdSafe(newResourceId));
872
876
  // Convert bodiedSyncBlock to syncBlock
873
877
  // The paste transformation will regenrate the localId
874
878
  var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
@@ -99,7 +99,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
99
99
  },
100
100
  commands: {
101
101
  copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard(inputMethod) {
102
- return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api);
102
+ return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api, config === null || config === void 0 ? void 0 : config.__livePage);
103
103
  },
104
104
  insertSyncedBlock: function insertSyncedBlock(inputMethod) {
105
105
  return function (_ref3) {
@@ -141,7 +141,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
141
141
  if (!((_syncedBlockPluginKey = syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
142
142
  return undefined;
143
143
  }
144
- return getToolbarConfig(state, intl, api, syncBlockStore);
144
+ return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage);
145
145
  }
146
146
  },
147
147
  contentComponent: function contentComponent(_ref4) {
@@ -10,6 +10,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
10
10
  import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
11
11
  import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
12
12
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
13
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
14
  import { syncedBlockPluginKey } from '../pm-plugins/main';
14
15
  import { FLAG_ID } from '../types';
15
16
  var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
@@ -52,6 +53,12 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_d
52
53
  description: messages.duplicateSourceSyncBlockDescription,
53
54
  type: 'error'
54
55
  });
56
+ export var getSyncBlockCopiedDescription = function getSyncBlockCopiedDescription(activeFlag, isSyncBlockActivationEnabled) {
57
+ if (!activeFlag || activeFlag.id !== FLAG_ID.SYNC_BLOCK_COPIED || activeFlag.sourceProduct !== 'confluence-page' || !isSyncBlockActivationEnabled) {
58
+ return undefined;
59
+ }
60
+ return activeFlag.isLivePage || !activeFlag.isSourceContentUnpublished ? messages.syncBlockCopiedLivePageDescription : messages.syncBlockCopiedUnpublishedDescription;
61
+ };
55
62
  export var Flag = function Flag(_ref) {
56
63
  var api = _ref.api;
57
64
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['syncedBlock', 'connectivity'], function (states) {
@@ -79,8 +86,9 @@ export var Flag = function Flag(_ref) {
79
86
  // For the unpublished-paste flag, swap to the Jira-flavoured copy when the source
80
87
  // is a Jira work item. Other flags don't currently vary by product.
81
88
  var isJiraUnpublishedPaste = activeFlag.id === FLAG_ID.UNPUBLISHED_SYNC_BLOCK_PASTED && activeFlag.sourceProduct === 'jira-work-item';
89
+ var copiedDescription = getSyncBlockCopiedDescription(activeFlag, activeFlag.id === FLAG_ID.SYNC_BLOCK_COPIED && expValEquals('platform_editor_sync_block_activation', 'isEnabled', true));
82
90
  var title = isJiraUnpublishedPaste ? messages.unpublishedSyncBlockPastedTitleJiraWorkItem : defaultTitle;
83
- var description = isJiraUnpublishedPaste ? messages.unpublishedSyncBlockPastedDescriptionJiraWorkItem : defaultDescription;
91
+ var description = copiedDescription !== null && copiedDescription !== void 0 ? copiedDescription : isJiraUnpublishedPaste ? messages.unpublishedSyncBlockPastedDescriptionJiraWorkItem : defaultDescription;
84
92
 
85
93
  // Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
86
94
  if (isOfflineMode(mode) && !!onRetry) {
@@ -18,7 +18,7 @@ import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSynce
18
18
  import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
19
19
  import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
20
20
  import { SyncedLocationDropdown } from './SyncedLocationDropdown';
21
- export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore) {
21
+ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage) {
22
22
  var _syncBlockInstance$er, _api$decorations, _api$connectivity;
23
23
  var syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
24
24
  if (!syncBlockObject) {
@@ -71,7 +71,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
71
71
  showTitle: isSyncBlockActivationEnabled,
72
72
  tooltipContent: isSyncBlockActivationEnabled ? undefined : formatMessage(messages.copySyncedBlockTooltip),
73
73
  testId: isSyncBlockActivationEnabled ? SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarCopy : undefined,
74
- onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, INPUT_METHOD.SYNCED_BLOCK_TB, api)
74
+ onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, INPUT_METHOD.SYNCED_BLOCK_TB, api, isLivePage)
75
75
  }, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
76
76
 
77
77
  // In the activation experience the primary "Copy to sync" action leads the
@@ -16,8 +16,8 @@ type createSyncedBlockProps = {
16
16
  typeAheadInsert?: TypeAheadInsert;
17
17
  };
18
18
  export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, fireAnalyticsEvent, inputMethod, }: createSyncedBlockProps) => false | Transaction;
19
- export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, inputMethod: INPUT_METHOD, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
20
- export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, inputMethod: INPUT_METHOD, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
19
+ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, inputMethod: INPUT_METHOD, api?: ExtractInjectionAPI<SyncedBlockPlugin>, isLivePage?: boolean) => EditorCommand;
20
+ export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, inputMethod: INPUT_METHOD, api?: ExtractInjectionAPI<SyncedBlockPlugin>, isLivePage?: boolean) => Command;
21
21
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
22
22
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
23
23
  export declare const removeSyncedBlockAtPos: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, pos: number) => void;
@@ -15,12 +15,15 @@ export declare enum FLAG_ID {
15
15
  }
16
16
  type FlagConfig = {
17
17
  id: FLAG_ID;
18
+ /** Whether the copied synced block confirmation originated from a live page. */
19
+ isLivePage?: boolean;
20
+ /** Whether the copied synced block's source content must be published before it can be reused. */
21
+ isSourceContentUnpublished?: boolean;
18
22
  onDismissed?: (tr: Transaction) => Transaction | void;
19
23
  onRetry?: () => void;
20
24
  /**
21
- * Optional source product for the synced block triggering this flag. Currently used
22
- * by the UNPUBLISHED_SYNC_BLOCK_PASTED flag so the displayed copy can be tailored
23
- * for Jira work items vs Confluence pages.
25
+ * Optional source product for the synced block triggering this flag. Used to tailor
26
+ * unpublished paste copy and to limit educational copy confirmation to Confluence.
24
27
  */
25
28
  sourceProduct?: SyncBlockProduct;
26
29
  };
@@ -1,8 +1,11 @@
1
1
  import React from 'react';
2
+ import type { MessageDescriptor } from 'react-intl';
2
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
4
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
5
+ import { type ActiveFlag } from '../types';
4
6
  type Props = {
5
7
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
6
8
  };
9
+ export declare const getSyncBlockCopiedDescription: (activeFlag: ActiveFlag, isSyncBlockActivationEnabled: boolean) => MessageDescriptor | undefined;
7
10
  export declare const Flag: ({ api }: Props) => React.JSX.Element | undefined;
8
11
  export {};
@@ -3,4 +3,4 @@ import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/edito
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
5
5
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
6
- export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, syncBlockStore: SyncBlockStoreManager) => FloatingToolbarConfig | undefined;
6
+ export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, syncBlockStore: SyncBlockStoreManager, isLivePage?: boolean) => FloatingToolbarConfig | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "10.3.4",
3
+ "version": "10.3.6",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -43,21 +43,21 @@
43
43
  "@atlaskit/logo": "^21.4.0",
44
44
  "@atlaskit/lozenge": "^14.1.0",
45
45
  "@atlaskit/modal-dialog": "^16.1.0",
46
- "@atlaskit/platform-feature-flags": "^2.0.0",
47
- "@atlaskit/primitives": "^22.0.0",
46
+ "@atlaskit/platform-feature-flags": "^2.1.0",
47
+ "@atlaskit/primitives": "^22.1.0",
48
48
  "@atlaskit/spinner": "20.1.1",
49
- "@atlaskit/tmp-editor-statsig": "^130.0.0",
50
- "@atlaskit/tokens": "16.1.0",
49
+ "@atlaskit/tmp-editor-statsig": "^131.0.0",
50
+ "@atlaskit/tokens": "16.2.0",
51
51
  "@atlaskit/tooltip": "^23.1.0",
52
52
  "@atlaskit/visually-hidden": "^4.2.0",
53
53
  "@babel/runtime": "^7.0.0",
54
- "@compiled/react": "^0.22.2",
54
+ "@compiled/react": "^1.0.0",
55
55
  "bind-event-listener": "^3.0.0",
56
56
  "date-fns": "^2.17.0",
57
57
  "memoize-one": "^6.0.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^116.33.0",
60
+ "@atlaskit/editor-common": "^116.35.0",
61
61
  "react": "^18.2.0",
62
62
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
63
63
  },