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

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 (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/editor-commands/index.js +19 -5
  4. package/dist/cjs/pm-plugins/main.js +24 -18
  5. package/dist/cjs/syncedBlockPlugin.js +1 -1
  6. package/dist/cjs/types/index.js +1 -0
  7. package/dist/cjs/ui/Flag.js +49 -14
  8. package/dist/cjs/ui/floating-toolbar.js +1 -1
  9. package/dist/cjs/ui/toolbar-components.js +9 -29
  10. package/dist/es2019/editor-commands/index.js +20 -5
  11. package/dist/es2019/pm-plugins/main.js +24 -17
  12. package/dist/es2019/syncedBlockPlugin.js +1 -1
  13. package/dist/es2019/types/index.js +1 -0
  14. package/dist/es2019/ui/Flag.js +50 -14
  15. package/dist/es2019/ui/floating-toolbar.js +1 -1
  16. package/dist/es2019/ui/toolbar-components.js +9 -31
  17. package/dist/esm/editor-commands/index.js +19 -5
  18. package/dist/esm/pm-plugins/main.js +24 -18
  19. package/dist/esm/syncedBlockPlugin.js +1 -1
  20. package/dist/esm/types/index.js +1 -0
  21. package/dist/esm/ui/Flag.js +50 -15
  22. package/dist/esm/ui/floating-toolbar.js +1 -1
  23. package/dist/esm/ui/toolbar-components.js +10 -30
  24. package/dist/types/editor-commands/index.d.ts +2 -2
  25. package/dist/types/types/index.d.ts +2 -1
  26. package/dist/types-ts4.5/editor-commands/index.d.ts +2 -2
  27. package/dist/types-ts4.5/types/index.d.ts +2 -1
  28. package/package.json +2 -1
  29. package/dist/cjs/ui/CreateSyncedBlockItem.js +0 -53
  30. package/dist/cjs/ui/OverflowMenuSection.js +0 -20
  31. package/dist/es2019/ui/CreateSyncedBlockItem.js +0 -46
  32. package/dist/es2019/ui/OverflowMenuSection.js +0 -15
  33. package/dist/esm/ui/CreateSyncedBlockItem.js +0 -44
  34. package/dist/esm/ui/OverflowMenuSection.js +0 -13
  35. package/dist/types/ui/CreateSyncedBlockItem.d.ts +0 -8
  36. package/dist/types/ui/OverflowMenuSection.d.ts +0 -6
  37. package/dist/types-ts4.5/ui/CreateSyncedBlockItem.d.ts +0 -8
  38. package/dist/types-ts4.5/ui/OverflowMenuSection.d.ts +0 -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
@@ -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) {
@@ -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
  };
@@ -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 {};
@@ -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;
@@ -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 {};
@@ -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.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.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",
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.CreateSyncedBlockItem = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _reactIntlNext = require("react-intl-next");
11
- var _hooks = require("@atlaskit/editor-common/hooks");
12
- var _messages = require("@atlaskit/editor-common/messages");
13
- var _editorToolbar = require("@atlaskit/editor-toolbar");
14
- var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
15
- var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
16
- var _utils = require("../pm-plugins/utils/utils");
17
- 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); }
18
- var CreateSyncedBlockItem = exports.CreateSyncedBlockItem = function CreateSyncedBlockItem(_ref) {
19
- var api = _ref.api;
20
- var _useIntl = (0, _reactIntlNext.useIntl)(),
21
- formatMessage = _useIntl.formatMessage;
22
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection', 'connectivity'], function (states) {
23
- var _states$selectionStat, _states$connectivityS;
24
- return {
25
- selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
26
- mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
27
- };
28
- }),
29
- selection = _useSharedPluginState.selection,
30
- mode = _useSharedPluginState.mode;
31
- var isDisabled = Boolean(!selection || !(0, _utils.canBeConvertedToSyncBlock)(selection) || mode === 'offline');
32
- var onClick = (0, _react.useCallback)(function () {
33
- var _api$core, _api$core2;
34
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
35
- var tr = _ref2.tr;
36
- return api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock()({
37
- tr: tr
38
- });
39
- });
40
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
41
- }, [api]);
42
- return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
43
- onClick: onClick,
44
- isDisabled: isDisabled,
45
- elemBefore: /*#__PURE__*/_react.default.createElement(_blockSynced.default, {
46
- size: "small",
47
- label: ""
48
- }),
49
- elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
50
- appearance: "new"
51
- }, formatMessage(_messages.syncBlockMessages.newLozenge))
52
- }, formatMessage(_messages.syncBlockMessages.createSyncBlockLabel));
53
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.OverflowMenuSection = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _toolbar = require("@atlaskit/editor-common/toolbar");
10
- var _editorToolbar = require("@atlaskit/editor-toolbar");
11
- var OverflowMenuSection = exports.OverflowMenuSection = function OverflowMenuSection(_ref) {
12
- var children = _ref.children;
13
- var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
14
- editorViewMode = _useEditorToolbar.editorViewMode;
15
- var isEdit = editorViewMode === 'edit';
16
- if (!isEdit) {
17
- return null;
18
- }
19
- return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, children);
20
- };
@@ -1,46 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import { useIntl } from 'react-intl-next';
3
- import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
- import { syncBlockMessages } from '@atlaskit/editor-common/messages';
5
- import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
- import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
7
- import Lozenge from '@atlaskit/lozenge';
8
- import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
9
- export const CreateSyncedBlockItem = ({
10
- api
11
- }) => {
12
- const {
13
- formatMessage
14
- } = useIntl();
15
- const {
16
- selection,
17
- mode
18
- } = useSharedPluginStateWithSelector(api, ['selection', 'connectivity'], states => {
19
- var _states$selectionStat, _states$connectivityS;
20
- return {
21
- selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
22
- mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
23
- };
24
- });
25
- const isDisabled = Boolean(!selection || !canBeConvertedToSyncBlock(selection) || mode === 'offline');
26
- const onClick = useCallback(() => {
27
- var _api$core, _api$core2;
28
- api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
29
- tr
30
- }) => api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock()({
31
- tr
32
- }));
33
- api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.focus();
34
- }, [api]);
35
- return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
36
- onClick: onClick,
37
- isDisabled: isDisabled,
38
- elemBefore: /*#__PURE__*/React.createElement(BlockSyncedIcon, {
39
- size: "small",
40
- label: ""
41
- }),
42
- elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
43
- appearance: "new"
44
- }, formatMessage(syncBlockMessages.newLozenge))
45
- }, formatMessage(syncBlockMessages.createSyncBlockLabel));
46
- };
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
3
- import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
4
- export const OverflowMenuSection = ({
5
- children
6
- }) => {
7
- const {
8
- editorViewMode
9
- } = useEditorToolbar();
10
- const isEdit = editorViewMode === 'edit';
11
- if (!isEdit) {
12
- return null;
13
- }
14
- return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
15
- };
@@ -1,44 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import { useIntl } from 'react-intl-next';
3
- import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
- import { syncBlockMessages } from '@atlaskit/editor-common/messages';
5
- import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
- import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
7
- import Lozenge from '@atlaskit/lozenge';
8
- import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
9
- export var CreateSyncedBlockItem = function CreateSyncedBlockItem(_ref) {
10
- var api = _ref.api;
11
- var _useIntl = useIntl(),
12
- formatMessage = _useIntl.formatMessage;
13
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['selection', 'connectivity'], function (states) {
14
- var _states$selectionStat, _states$connectivityS;
15
- return {
16
- selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
17
- mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
18
- };
19
- }),
20
- selection = _useSharedPluginState.selection,
21
- mode = _useSharedPluginState.mode;
22
- var isDisabled = Boolean(!selection || !canBeConvertedToSyncBlock(selection) || mode === 'offline');
23
- var onClick = useCallback(function () {
24
- var _api$core, _api$core2;
25
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
26
- var tr = _ref2.tr;
27
- return api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock()({
28
- tr: tr
29
- });
30
- });
31
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
32
- }, [api]);
33
- return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
34
- onClick: onClick,
35
- isDisabled: isDisabled,
36
- elemBefore: /*#__PURE__*/React.createElement(BlockSyncedIcon, {
37
- size: "small",
38
- label: ""
39
- }),
40
- elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
41
- appearance: "new"
42
- }, formatMessage(syncBlockMessages.newLozenge))
43
- }, formatMessage(syncBlockMessages.createSyncBlockLabel));
44
- };
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
3
- import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
4
- export var OverflowMenuSection = function OverflowMenuSection(_ref) {
5
- var children = _ref.children;
6
- var _useEditorToolbar = useEditorToolbar(),
7
- editorViewMode = _useEditorToolbar.editorViewMode;
8
- var isEdit = editorViewMode === 'edit';
9
- if (!isEdit) {
10
- return null;
11
- }
12
- return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
13
- };
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
4
- type CreateSyncedBlockItemProps = {
5
- api?: ExtractInjectionAPI<SyncedBlockPlugin>;
6
- };
7
- export declare const CreateSyncedBlockItem: ({ api }: CreateSyncedBlockItemProps) => React.JSX.Element;
8
- export {};
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- type OverflowMenuSectionProps = {
3
- children: React.ReactNode;
4
- };
5
- export declare const OverflowMenuSection: ({ children, }: OverflowMenuSectionProps) => React.JSX.Element | null;
6
- export {};
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
4
- type CreateSyncedBlockItemProps = {
5
- api?: ExtractInjectionAPI<SyncedBlockPlugin>;
6
- };
7
- export declare const CreateSyncedBlockItem: ({ api }: CreateSyncedBlockItemProps) => React.JSX.Element;
8
- export {};
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- type OverflowMenuSectionProps = {
3
- children: React.ReactNode;
4
- };
5
- export declare const OverflowMenuSection: ({ children, }: OverflowMenuSectionProps) => React.JSX.Element | null;
6
- export {};