@atlaskit/editor-plugin-synced-block 4.5.0 → 4.5.2

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 (47) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/afm-cc/tsconfig.json +9 -0
  3. package/afm-jira/tsconfig.json +9 -0
  4. package/afm-products/tsconfig.json +9 -0
  5. package/dist/cjs/editor-actions/index.js +4 -1
  6. package/dist/cjs/editor-commands/index.js +19 -5
  7. package/dist/cjs/pm-plugins/main.js +24 -18
  8. package/dist/cjs/syncedBlockPlugin.js +4 -1
  9. package/dist/cjs/types/index.js +1 -0
  10. package/dist/cjs/ui/Flag.js +49 -14
  11. package/dist/cjs/ui/floating-toolbar.js +1 -1
  12. package/dist/cjs/ui/toolbar-components.js +9 -29
  13. package/dist/es2019/editor-actions/index.js +3 -0
  14. package/dist/es2019/editor-commands/index.js +20 -5
  15. package/dist/es2019/pm-plugins/main.js +24 -17
  16. package/dist/es2019/syncedBlockPlugin.js +5 -2
  17. package/dist/es2019/types/index.js +1 -0
  18. package/dist/es2019/ui/Flag.js +50 -14
  19. package/dist/es2019/ui/floating-toolbar.js +1 -1
  20. package/dist/es2019/ui/toolbar-components.js +9 -31
  21. package/dist/esm/editor-actions/index.js +3 -0
  22. package/dist/esm/editor-commands/index.js +19 -5
  23. package/dist/esm/pm-plugins/main.js +24 -18
  24. package/dist/esm/syncedBlockPlugin.js +5 -2
  25. package/dist/esm/types/index.js +1 -0
  26. package/dist/esm/ui/Flag.js +50 -15
  27. package/dist/esm/ui/floating-toolbar.js +1 -1
  28. package/dist/esm/ui/toolbar-components.js +10 -30
  29. package/dist/types/editor-actions/index.d.ts +1 -0
  30. package/dist/types/editor-commands/index.d.ts +2 -2
  31. package/dist/types/syncedBlockPluginType.d.ts +8 -0
  32. package/dist/types/types/index.d.ts +2 -1
  33. package/dist/types-ts4.5/editor-actions/index.d.ts +1 -0
  34. package/dist/types-ts4.5/editor-commands/index.d.ts +2 -2
  35. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +8 -0
  36. package/dist/types-ts4.5/types/index.d.ts +2 -1
  37. package/package.json +4 -3
  38. package/dist/cjs/ui/CreateSyncedBlockItem.js +0 -53
  39. package/dist/cjs/ui/OverflowMenuSection.js +0 -20
  40. package/dist/es2019/ui/CreateSyncedBlockItem.js +0 -46
  41. package/dist/es2019/ui/OverflowMenuSection.js +0 -15
  42. package/dist/esm/ui/CreateSyncedBlockItem.js +0 -44
  43. package/dist/esm/ui/OverflowMenuSection.js +0 -13
  44. package/dist/types/ui/CreateSyncedBlockItem.d.ts +0 -8
  45. package/dist/types/ui/OverflowMenuSection.d.ts +0 -6
  46. package/dist/types-ts4.5/ui/CreateSyncedBlockItem.d.ts +0 -8
  47. package/dist/types-ts4.5/ui/OverflowMenuSection.d.ts +0 -6
@@ -2,26 +2,37 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
- import AkFlag, { FlagGroup } from '@atlaskit/flag';
5
+ import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
6
+ import ImageIcon from '@atlaskit/icon/core/image';
6
7
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
7
8
  import { syncedBlockPluginKey } from '../pm-plugins/main';
8
9
  import { FLAG_ID } from '../types';
9
10
  const flagMap = {
10
11
  [FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE]: {
11
12
  title: messages.failToDeleteTitle,
12
- description: messages.failToDeleteWhenOfflineDescription
13
+ description: messages.failToDeleteWhenOfflineDescription,
14
+ type: 'error'
13
15
  },
14
16
  [FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE]: {
15
17
  title: messages.failToEditTitle,
16
- description: messages.failToEditWhenOfflineDescription
18
+ description: messages.failToEditWhenOfflineDescription,
19
+ type: 'error'
17
20
  },
18
21
  [FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE]: {
19
22
  title: messages.failToCreateTitle,
20
- description: messages.failToCreateWhenOfflineDescription
23
+ description: messages.failToCreateWhenOfflineDescription,
24
+ type: 'error'
21
25
  },
22
26
  [FLAG_ID.FAIL_TO_DELETE]: {
23
27
  title: messages.cannotDeleteTitle,
24
- description: messages.cannotDeleteDescription
28
+ description: messages.cannotDeleteDescription,
29
+ type: 'error'
30
+ },
31
+ [FLAG_ID.SYNC_BLOCK_COPIED]: {
32
+ title: messages.syncBlockCopiedTitle,
33
+ description: messages.syncBlockCopiedDescription,
34
+ action: messages.syncBlockCopiedAction,
35
+ type: 'info'
25
36
  }
26
37
  };
27
38
  export const Flag = ({
@@ -45,7 +56,9 @@ export const Flag = ({
45
56
  }
46
57
  const {
47
58
  title,
48
- description
59
+ description,
60
+ action,
61
+ type
49
62
  } = flagMap[activeFlag.id];
50
63
  const {
51
64
  onRetry,
@@ -78,19 +91,42 @@ export const Flag = ({
78
91
  });
79
92
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
80
93
  };
81
- return /*#__PURE__*/React.createElement(FlagGroup, null, /*#__PURE__*/React.createElement(AkFlag, {
94
+ const typeToActions = () => {
95
+ if (type === 'error') {
96
+ if (onRetry) {
97
+ return [{
98
+ content: formatMessage(messages.deleteRetryButton),
99
+ onClick: onRetry
100
+ }];
101
+ }
102
+ } else if (type === 'info' && action) {
103
+ return [{
104
+ content: formatMessage(action),
105
+ href: 'https://atlaskit.atlassian.com/',
106
+ target: '_blank'
107
+ }];
108
+ }
109
+ return undefined;
110
+ };
111
+ const FlagComponent = type === 'info' ? AutoDismissFlag : AkFlag;
112
+ return /*#__PURE__*/React.createElement(FlagGroup, null, /*#__PURE__*/React.createElement(FlagComponent, {
82
113
  onDismissed: onDismissed,
83
114
  title: formatMessage(title),
84
115
  description: formatMessage(description),
85
116
  id: activeFlag.id,
86
117
  testId: activeFlag.id,
87
- icon: /*#__PURE__*/React.createElement(StatusWarningIcon, {
118
+ icon: typeToIcon(type),
119
+ actions: typeToActions()
120
+ }));
121
+ };
122
+ const typeToIcon = type => {
123
+ if (type === 'error') {
124
+ return /*#__PURE__*/React.createElement(StatusWarningIcon, {
88
125
  label: "",
89
126
  color: "var(--ds-icon-warning, #E06C00)"
90
- }),
91
- actions: onRetry ? [{
92
- content: formatMessage(messages.deleteRetryButton),
93
- onClick: onRetry
94
- }] : undefined
95
- }));
127
+ });
128
+ }
129
+ return /*#__PURE__*/React.createElement(ImageIcon, {
130
+ label: ""
131
+ });
96
132
  };
@@ -41,7 +41,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
41
41
  title: formatMessage(messages.copySyncBlockLabel),
42
42
  showTitle: false,
43
43
  tooltipContent: formatMessage(messages.copySyncBlockTooltip),
44
- onClick: copySyncedBlockReferenceToClipboard(syncBlockStore),
44
+ onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, api),
45
45
  ...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
46
46
  };
47
47
  items.push(copyButton);
@@ -1,25 +1,16 @@
1
1
  import React from 'react';
2
- import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, OVERFLOW_MENU, OVERFLOW_MENU_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_ITEM, SYNCED_BLOCK_SECTION, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
2
+ import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
3
+ import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
5
  import { CreateSyncedBlockButton } from './CreateSyncedBlockButton';
4
- import { CreateSyncedBlockItem } from './CreateSyncedBlockItem';
5
- import { OverflowMenuSection } from './OverflowMenuSection';
6
- const SYNCED_BLOCK_OVERFLOW_MENU_SECTION = {
7
- type: SYNCED_BLOCK_SECTION.type,
8
- key: SYNCED_BLOCK_SECTION.key,
9
- parents: [{
10
- type: OVERFLOW_MENU.type,
11
- key: OVERFLOW_MENU.key,
12
- rank: OVERFLOW_MENU_RANK[SYNCED_BLOCK_SECTION.key]
13
- }],
14
- component: ({
15
- children
16
- }) => {
17
- return /*#__PURE__*/React.createElement(OverflowMenuSection, null, children);
18
- }
19
- };
20
6
  const SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
21
7
  type: SYNCED_BLOCK_GROUP.type,
22
8
  key: SYNCED_BLOCK_GROUP.key,
9
+ component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? ({
10
+ children
11
+ }) => /*#__PURE__*/React.createElement(Show, {
12
+ above: "md"
13
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children)) : undefined,
23
14
  parents: [{
24
15
  type: INSERT_BLOCK_SECTION.type,
25
16
  key: INSERT_BLOCK_SECTION.key,
@@ -27,7 +18,7 @@ const SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
27
18
  }]
28
19
  };
29
20
  export const getToolbarComponents = api => {
30
- return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, SYNCED_BLOCK_OVERFLOW_MENU_SECTION, {
21
+ return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
31
22
  type: SYNCED_BLOCK_BUTTON.type,
32
23
  key: SYNCED_BLOCK_BUTTON.key,
33
24
  component: () => /*#__PURE__*/React.createElement(CreateSyncedBlockButton, {
@@ -38,18 +29,5 @@ export const getToolbarComponents = api => {
38
29
  key: SYNCED_BLOCK_GROUP.key,
39
30
  rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_BUTTON.key]
40
31
  }]
41
- }, {
42
- type: SYNCED_BLOCK_ITEM.type,
43
- key: SYNCED_BLOCK_ITEM.key,
44
- parents: [{
45
- type: SYNCED_BLOCK_SECTION.type,
46
- key: SYNCED_BLOCK_SECTION.key,
47
- rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_ITEM.key]
48
- }],
49
- component: () => {
50
- return /*#__PURE__*/React.createElement(CreateSyncedBlockItem, {
51
- api: api
52
- });
53
- }
54
32
  }];
55
33
  };
@@ -1,3 +1,6 @@
1
1
  export var flushBodiedSyncBlocks = function flushBodiedSyncBlocks(syncBlockStore) {
2
2
  return syncBlockStore.sourceManager.flush();
3
+ };
4
+ export var flushSyncBlocks = function flushSyncBlocks(syncBlockStore) {
5
+ return syncBlockStore.referenceManager.flush();
3
6
  };
@@ -2,7 +2,9 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
2
2
  import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
5
+ import { syncedBlockPluginKey } from '../pm-plugins/main';
5
6
  import { canBeConvertedToSyncBlock, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
7
+ import { FLAG_ID } from '../types';
6
8
  export var createSyncedBlock = function createSyncedBlock(_ref) {
7
9
  var tr = _ref.tr,
8
10
  syncBlockStore = _ref.syncBlockStore,
@@ -53,21 +55,21 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
53
55
  // see filterTransaction for more details
54
56
  return tr;
55
57
  };
56
- export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore) {
58
+ export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, api) {
57
59
  return function (_ref2) {
58
60
  var tr = _ref2.tr;
59
- if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore)) {
61
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, api)) {
60
62
  return tr;
61
63
  }
62
64
  return null;
63
65
  };
64
66
  };
65
- export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore) {
67
+ export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore, api) {
66
68
  return function (state, _dispatch, _view) {
67
- return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore);
69
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, api);
68
70
  };
69
71
  };
70
- var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore) {
72
+ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore, api) {
71
73
  var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
72
74
  if (!syncBlockFindResult) {
73
75
  return false;
@@ -92,6 +94,18 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
92
94
  }
93
95
  var domNode = toDOM(referenceSyncBlockNode, schema);
94
96
  copyDomNode(domNode, referenceSyncBlockNode.type, selection);
97
+
98
+ // Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
99
+ setTimeout(function () {
100
+ api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
101
+ var tr = _ref3.tr;
102
+ return tr.setMeta(syncedBlockPluginKey, {
103
+ activeFlag: {
104
+ id: FLAG_ID.SYNC_BLOCK_COPIED
105
+ }
106
+ });
107
+ });
108
+ }, 0);
95
109
  return true;
96
110
  };
97
111
  export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
@@ -111,27 +111,33 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
111
111
  var pluginState = syncedBlockPluginKey.getState(state);
112
112
  var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
113
113
  var schema = state.schema;
114
+ // Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
115
+ setTimeout(function () {
116
+ api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
117
+ var tr = _ref3.tr;
118
+ return tr.setMeta(syncedBlockPluginKey, {
119
+ activeFlag: {
120
+ id: FLAG_ID.SYNC_BLOCK_COPIED
121
+ }
122
+ });
123
+ });
124
+ }, 0);
114
125
  if (!syncBlockStore) {
115
126
  return slice;
116
127
  }
117
128
  return mapSlice(slice, function (node) {
118
129
  if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
119
- try {
120
- var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
121
- // Convert bodiedSyncBlock to syncBlock
122
- // The paste transformation will regenrate the localId
123
- var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
124
- resourceId: newResourceId
125
- });
126
- var newMarks = schema.nodes.syncBlock.markSet ? node.marks.filter(function (mark) {
127
- var _schema$nodes$syncBlo;
128
- return (_schema$nodes$syncBlo = schema.nodes.syncBlock.markSet) === null || _schema$nodes$syncBlo === void 0 ? void 0 : _schema$nodes$syncBlo.includes(mark.type);
129
- }) : node.marks;
130
- return schema.nodes.syncBlock.create(newAttrs, null, newMarks);
131
- } catch (error) {
132
- // If generateResourceIdForReference died, return the original node
133
- return node;
134
- }
130
+ var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
131
+ // Convert bodiedSyncBlock to syncBlock
132
+ // The paste transformation will regenrate the localId
133
+ var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
134
+ resourceId: newResourceId
135
+ });
136
+ var newMarks = schema.nodes.syncBlock.markSet ? node.marks.filter(function (mark) {
137
+ var _schema$nodes$syncBlo;
138
+ return (_schema$nodes$syncBlo = schema.nodes.syncBlock.markSet) === null || _schema$nodes$syncBlo === void 0 ? void 0 : _schema$nodes$syncBlo.includes(mark.type);
139
+ }) : node.marks;
140
+ return schema.nodes.syncBlock.create(newAttrs, null, newMarks);
135
141
  }
136
142
  return node;
137
143
  });
@@ -195,8 +201,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
195
201
  if (errorFlag) {
196
202
  // Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
197
203
  setTimeout(function () {
198
- api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
199
- var tr = _ref3.tr;
204
+ api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
205
+ var tr = _ref4.tr;
200
206
  return tr.setMeta(syncedBlockPluginKey, {
201
207
  activeFlag: {
202
208
  id: errorFlag
@@ -4,7 +4,7 @@ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
4
4
  import { IconSyncBlock } from '@atlaskit/editor-common/quick-insert';
5
5
  import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
6
6
  import Lozenge from '@atlaskit/lozenge';
7
- import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks } from './editor-actions';
7
+ import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
8
8
  import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
9
9
  import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
10
10
  import { getBlockMenuComponents } from './ui/block-menu-components';
@@ -41,7 +41,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
41
41
  },
42
42
  commands: {
43
43
  copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
44
- return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore);
44
+ return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, api);
45
45
  },
46
46
  insertSyncedBlock: function insertSyncedBlock() {
47
47
  return function (_ref2) {
@@ -56,6 +56,9 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
56
56
  actions: {
57
57
  flushBodiedSyncBlocks: function flushBodiedSyncBlocks() {
58
58
  return _flushBodiedSyncBlocks(syncBlockStore);
59
+ },
60
+ flushSyncedBlocks: function flushSyncedBlocks() {
61
+ return flushSyncBlocks(syncBlockStore);
59
62
  }
60
63
  },
61
64
  pluginsOptions: {
@@ -3,5 +3,6 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
3
3
  FLAG_ID["CANNOT_EDIT_WHEN_OFFLINE"] = "cannot-edit-when-offline";
4
4
  FLAG_ID["CANNOT_CREATE_WHEN_OFFLINE"] = "cannot-create-when-offline";
5
5
  FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
6
+ FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
6
7
  return FLAG_ID;
7
8
  }({});
@@ -5,22 +5,32 @@ import React from 'react';
5
5
  import { useIntl } from 'react-intl-next';
6
6
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
7
7
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
8
- import AkFlag, { FlagGroup } from '@atlaskit/flag';
8
+ import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
9
+ import ImageIcon from '@atlaskit/icon/core/image';
9
10
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
10
11
  import { syncedBlockPluginKey } from '../pm-plugins/main';
11
12
  import { FLAG_ID } from '../types';
12
- var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
13
+ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
13
14
  title: messages.failToDeleteTitle,
14
- description: messages.failToDeleteWhenOfflineDescription
15
+ description: messages.failToDeleteWhenOfflineDescription,
16
+ type: 'error'
15
17
  }), FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE, {
16
18
  title: messages.failToEditTitle,
17
- description: messages.failToEditWhenOfflineDescription
19
+ description: messages.failToEditWhenOfflineDescription,
20
+ type: 'error'
18
21
  }), FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE, {
19
22
  title: messages.failToCreateTitle,
20
- description: messages.failToCreateWhenOfflineDescription
23
+ description: messages.failToCreateWhenOfflineDescription,
24
+ type: 'error'
21
25
  }), FLAG_ID.FAIL_TO_DELETE, {
22
26
  title: messages.cannotDeleteTitle,
23
- description: messages.cannotDeleteDescription
27
+ description: messages.cannotDeleteDescription,
28
+ type: 'error'
29
+ }), FLAG_ID.SYNC_BLOCK_COPIED, {
30
+ title: messages.syncBlockCopiedTitle,
31
+ description: messages.syncBlockCopiedDescription,
32
+ action: messages.syncBlockCopiedAction,
33
+ type: 'info'
24
34
  });
25
35
  export var Flag = function Flag(_ref) {
26
36
  var api = _ref.api;
@@ -40,7 +50,9 @@ export var Flag = function Flag(_ref) {
40
50
  }
41
51
  var _flagMap$activeFlag$i = flagMap[activeFlag.id],
42
52
  title = _flagMap$activeFlag$i.title,
43
- description = _flagMap$activeFlag$i.description;
53
+ description = _flagMap$activeFlag$i.description,
54
+ action = _flagMap$activeFlag$i.action,
55
+ type = _flagMap$activeFlag$i.type;
44
56
  var onRetry = activeFlag.onRetry,
45
57
  onDismissedCallback = activeFlag.onDismissed;
46
58
 
@@ -67,19 +79,42 @@ export var Flag = function Flag(_ref) {
67
79
  });
68
80
  api === null || api === void 0 || api.core.actions.focus();
69
81
  };
70
- return /*#__PURE__*/React.createElement(FlagGroup, null, /*#__PURE__*/React.createElement(AkFlag, {
82
+ var typeToActions = function typeToActions() {
83
+ if (type === 'error') {
84
+ if (onRetry) {
85
+ return [{
86
+ content: formatMessage(messages.deleteRetryButton),
87
+ onClick: onRetry
88
+ }];
89
+ }
90
+ } else if (type === 'info' && action) {
91
+ return [{
92
+ content: formatMessage(action),
93
+ href: 'https://atlaskit.atlassian.com/',
94
+ target: '_blank'
95
+ }];
96
+ }
97
+ return undefined;
98
+ };
99
+ var FlagComponent = type === 'info' ? AutoDismissFlag : AkFlag;
100
+ return /*#__PURE__*/React.createElement(FlagGroup, null, /*#__PURE__*/React.createElement(FlagComponent, {
71
101
  onDismissed: onDismissed,
72
102
  title: formatMessage(title),
73
103
  description: formatMessage(description),
74
104
  id: activeFlag.id,
75
105
  testId: activeFlag.id,
76
- icon: /*#__PURE__*/React.createElement(StatusWarningIcon, {
106
+ icon: typeToIcon(type),
107
+ actions: typeToActions()
108
+ }));
109
+ };
110
+ var typeToIcon = function typeToIcon(type) {
111
+ if (type === 'error') {
112
+ return /*#__PURE__*/React.createElement(StatusWarningIcon, {
77
113
  label: "",
78
114
  color: "var(--ds-icon-warning, #E06C00)"
79
- }),
80
- actions: onRetry ? [{
81
- content: formatMessage(messages.deleteRetryButton),
82
- onClick: onRetry
83
- }] : undefined
84
- }));
115
+ });
116
+ }
117
+ return /*#__PURE__*/React.createElement(ImageIcon, {
118
+ label: ""
119
+ });
85
120
  };
@@ -38,7 +38,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
38
38
  title: formatMessage(messages.copySyncBlockLabel),
39
39
  showTitle: false,
40
40
  tooltipContent: formatMessage(messages.copySyncBlockTooltip),
41
- onClick: copySyncedBlockReferenceToClipboard(syncBlockStore)
41
+ onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, api)
42
42
  }, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
43
43
  items.push(copyButton);
44
44
  var disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
@@ -1,24 +1,17 @@
1
1
  import React from 'react';
2
- import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, OVERFLOW_MENU, OVERFLOW_MENU_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_ITEM, SYNCED_BLOCK_SECTION, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
2
+ import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
3
+ import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
5
  import { CreateSyncedBlockButton } from './CreateSyncedBlockButton';
4
- import { CreateSyncedBlockItem } from './CreateSyncedBlockItem';
5
- import { OverflowMenuSection } from './OverflowMenuSection';
6
- var SYNCED_BLOCK_OVERFLOW_MENU_SECTION = {
7
- type: SYNCED_BLOCK_SECTION.type,
8
- key: SYNCED_BLOCK_SECTION.key,
9
- parents: [{
10
- type: OVERFLOW_MENU.type,
11
- key: OVERFLOW_MENU.key,
12
- rank: OVERFLOW_MENU_RANK[SYNCED_BLOCK_SECTION.key]
13
- }],
14
- component: function component(_ref) {
15
- var children = _ref.children;
16
- return /*#__PURE__*/React.createElement(OverflowMenuSection, null, children);
17
- }
18
- };
19
6
  var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
20
7
  type: SYNCED_BLOCK_GROUP.type,
21
8
  key: SYNCED_BLOCK_GROUP.key,
9
+ component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? function (_ref) {
10
+ var children = _ref.children;
11
+ return /*#__PURE__*/React.createElement(Show, {
12
+ above: "md"
13
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
14
+ } : undefined,
22
15
  parents: [{
23
16
  type: INSERT_BLOCK_SECTION.type,
24
17
  key: INSERT_BLOCK_SECTION.key,
@@ -26,7 +19,7 @@ var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
26
19
  }]
27
20
  };
28
21
  export var getToolbarComponents = function getToolbarComponents(api) {
29
- return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, SYNCED_BLOCK_OVERFLOW_MENU_SECTION, {
22
+ return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
30
23
  type: SYNCED_BLOCK_BUTTON.type,
31
24
  key: SYNCED_BLOCK_BUTTON.key,
32
25
  component: function component() {
@@ -39,18 +32,5 @@ export var getToolbarComponents = function getToolbarComponents(api) {
39
32
  key: SYNCED_BLOCK_GROUP.key,
40
33
  rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_BUTTON.key]
41
34
  }]
42
- }, {
43
- type: SYNCED_BLOCK_ITEM.type,
44
- key: SYNCED_BLOCK_ITEM.key,
45
- parents: [{
46
- type: SYNCED_BLOCK_SECTION.type,
47
- key: SYNCED_BLOCK_SECTION.key,
48
- rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_ITEM.key]
49
- }],
50
- component: function component() {
51
- return /*#__PURE__*/React.createElement(CreateSyncedBlockItem, {
52
- api: api
53
- });
54
- }
55
35
  }];
56
36
  };
@@ -1,2 +1,3 @@
1
1
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
2
2
  export declare const flushBodiedSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
3
+ export declare const flushSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
@@ -8,8 +8,8 @@ type createSyncedBlockProps = {
8
8
  typeAheadInsert?: TypeAheadInsert;
9
9
  };
10
10
  export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
11
- export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager) => EditorCommand;
12
- export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager) => Command;
11
+ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
12
+ export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
13
13
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
14
14
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
15
15
  export {};
@@ -53,6 +53,14 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
53
53
  * @returns true if saving all nodes successfully, false if fail to save some/all nodes
54
54
  */
55
55
  flushBodiedSyncBlocks: () => Promise<boolean>;
56
+ /**
57
+ * Save reference synced blocks on the document (tracked by local cache)to the backend.
58
+ * This action allows syncBlock on the document to be saved in sync with product saving experience
59
+ * as per {@link https://hello.atlassian.net/wiki/spaces/egcuc/pages/5932393240/Synced+Blocks+Save+refresh+principles}
60
+ *
61
+ * @returns true if flushing all syncBlocks successfully, false otherwise
62
+ */
63
+ flushSyncedBlocks: () => Promise<boolean>;
56
64
  };
57
65
  commands: {
58
66
  copySyncedBlockReferenceToClipboard: () => EditorCommand;
@@ -4,7 +4,8 @@ export declare enum FLAG_ID {
4
4
  CANNOT_DELETE_WHEN_OFFLINE = "cannot-delete-when-offline",
5
5
  CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
6
6
  CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
7
- FAIL_TO_DELETE = "fail-to-delete"
7
+ FAIL_TO_DELETE = "fail-to-delete",
8
+ SYNC_BLOCK_COPIED = "sync-block-copied"
8
9
  }
9
10
  type FlagConfig = {
10
11
  id: FLAG_ID;
@@ -1,2 +1,3 @@
1
1
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
2
2
  export declare const flushBodiedSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
3
+ export declare const flushSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
@@ -8,8 +8,8 @@ type createSyncedBlockProps = {
8
8
  typeAheadInsert?: TypeAheadInsert;
9
9
  };
10
10
  export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
11
- export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager) => EditorCommand;
12
- export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager) => Command;
11
+ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
12
+ export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
13
13
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
14
14
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
15
15
  export {};
@@ -53,6 +53,14 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
53
53
  * @returns true if saving all nodes successfully, false if fail to save some/all nodes
54
54
  */
55
55
  flushBodiedSyncBlocks: () => Promise<boolean>;
56
+ /**
57
+ * Save reference synced blocks on the document (tracked by local cache)to the backend.
58
+ * This action allows syncBlock on the document to be saved in sync with product saving experience
59
+ * as per {@link https://hello.atlassian.net/wiki/spaces/egcuc/pages/5932393240/Synced+Blocks+Save+refresh+principles}
60
+ *
61
+ * @returns true if flushing all syncBlocks successfully, false otherwise
62
+ */
63
+ flushSyncedBlocks: () => Promise<boolean>;
56
64
  };
57
65
  commands: {
58
66
  copySyncedBlockReferenceToClipboard: () => EditorCommand;
@@ -4,7 +4,8 @@ export declare enum FLAG_ID {
4
4
  CANNOT_DELETE_WHEN_OFFLINE = "cannot-delete-when-offline",
5
5
  CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
6
6
  CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
7
- FAIL_TO_DELETE = "fail-to-delete"
7
+ FAIL_TO_DELETE = "fail-to-delete",
8
+ SYNC_BLOCK_COPIED = "sync-block-copied"
8
9
  }
9
10
  type FlagConfig = {
10
11
  id: FLAG_ID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "4.5.0",
3
+ "version": "4.5.2",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^51.5.1",
31
+ "@atlaskit/adf-schema": "^51.5.0",
32
32
  "@atlaskit/button": "23.7.0",
33
33
  "@atlaskit/editor-json-transformer": "^8.31.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
38
38
  "@atlaskit/editor-plugin-floating-toolbar": "^8.2.0",
39
39
  "@atlaskit/editor-plugin-selection": "^6.1.0",
40
- "@atlaskit/editor-prosemirror": "7.0.0",
40
+ "@atlaskit/editor-prosemirror": "^7.2.0",
41
41
  "@atlaskit/editor-shared-styles": "^3.10.0",
42
42
  "@atlaskit/editor-synced-block-provider": "^2.15.0",
43
43
  "@atlaskit/editor-tables": "^2.9.0",
@@ -49,6 +49,7 @@
49
49
  "@atlaskit/lozenge": "^13.1.0",
50
50
  "@atlaskit/modal-dialog": "^14.8.0",
51
51
  "@atlaskit/primitives": "^16.4.0",
52
+ "@atlaskit/tmp-editor-statsig": "^15.9.0",
52
53
  "@atlaskit/tokens": "8.4.1",
53
54
  "@atlaskit/tooltip": "^20.11.0",
54
55
  "@atlaskit/visually-hidden": "^3.0.0",