@atlaskit/editor-plugin-synced-block 4.2.2 → 4.2.4

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
+ ## 4.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.2.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`9aaeaa5054b55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9aaeaa5054b55) -
14
+ EDITOR-2863 Add copy sync block option to block menu
15
+ - Updated dependencies
16
+
3
17
  ## 4.2.2
4
18
 
5
19
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboard = void 0;
6
+ exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboard = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _copyButton = require("@atlaskit/editor-common/copy-button");
9
9
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -59,42 +59,47 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
59
59
  // see filterTransaction for more details
60
60
  return tr;
61
61
  };
62
- var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(api) {
63
- return function (state, _dispatch, _view) {
64
- if (!(api !== null && api !== void 0 && api.floatingToolbar)) {
65
- return false;
66
- }
67
- var syncBlockFindResult = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state);
68
- if (!syncBlockFindResult) {
69
- return false;
70
- }
71
- var isBodiedSyncBlock = (0, _utils2.isBodiedSyncBlockNode)(syncBlockFindResult.node, state.schema.nodes.bodiedSyncBlock);
72
- var referenceSyncBlockNode = null;
73
- if (isBodiedSyncBlock) {
74
- var syncBlock = state.tr.doc.type.schema.nodes.syncBlock;
62
+ var copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(_ref2) {
63
+ var tr = _ref2.tr;
64
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection)) {
65
+ return tr;
66
+ }
67
+ return null;
68
+ };
69
+ var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(state, _dispatch, _view) {
70
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection);
71
+ };
72
+ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection) {
73
+ var syncBlockFindResult = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(schema, selection);
74
+ if (!syncBlockFindResult) {
75
+ return false;
76
+ }
77
+ var isBodiedSyncBlock = (0, _utils2.isBodiedSyncBlockNode)(syncBlockFindResult.node, schema.nodes.bodiedSyncBlock);
78
+ var referenceSyncBlockNode = null;
79
+ if (isBodiedSyncBlock) {
80
+ var syncBlock = schema.nodes.syncBlock;
75
81
 
76
- // create sync block reference node
77
- referenceSyncBlockNode = syncBlock.createAndFill({
78
- resourceId: syncBlockFindResult.node.attrs.resourceId
79
- });
80
- if (!referenceSyncBlockNode) {
81
- return false;
82
- }
83
- } else {
84
- referenceSyncBlockNode = syncBlockFindResult.node;
85
- }
82
+ // create sync block reference node
83
+ referenceSyncBlockNode = syncBlock.createAndFill({
84
+ resourceId: syncBlockFindResult.node.attrs.resourceId
85
+ });
86
86
  if (!referenceSyncBlockNode) {
87
87
  return false;
88
88
  }
89
- var domNode = (0, _copyButton.toDOM)(referenceSyncBlockNode, state.tr.doc.type.schema);
90
- (0, _copyButton.copyDomNode)(domNode, referenceSyncBlockNode.type, state.tr.selection);
91
- return true;
92
- };
89
+ } else {
90
+ referenceSyncBlockNode = syncBlockFindResult.node;
91
+ }
92
+ if (!referenceSyncBlockNode) {
93
+ return false;
94
+ }
95
+ var domNode = (0, _copyButton.toDOM)(referenceSyncBlockNode, schema);
96
+ (0, _copyButton.copyDomNode)(domNode, referenceSyncBlockNode.type, selection);
97
+ return true;
93
98
  };
94
99
  var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
95
100
  return function (state, dispatch, _view) {
96
101
  var _syncBlock$node;
97
- var syncBlock = (0, _utils2.findSyncBlock)(state);
102
+ var syncBlock = (0, _utils2.findSyncBlock)(state.schema, state.selection);
98
103
  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;
99
104
  if (!resourceId) {
100
105
  return false;
@@ -8,16 +8,15 @@ var _model = require("@atlaskit/editor-prosemirror/model");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _utils = require("@atlaskit/editor-prosemirror/utils");
10
10
  var _editorTables = require("@atlaskit/editor-tables");
11
- var findSyncBlock = exports.findSyncBlock = function findSyncBlock(state, selection) {
12
- var syncBlock = state.schema.nodes.syncBlock;
13
- return (0, _utils.findSelectedNodeOfType)(syncBlock)(selection || state.selection);
11
+ var findSyncBlock = exports.findSyncBlock = function findSyncBlock(schema, selection) {
12
+ var syncBlock = schema.nodes.syncBlock;
13
+ return (0, _utils.findSelectedNodeOfType)(syncBlock)(selection);
14
14
  };
15
- var findBodiedSyncBlock = exports.findBodiedSyncBlock = function findBodiedSyncBlock(state, selection) {
16
- var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
17
- return (0, _utils.findSelectedNodeOfType)(bodiedSyncBlock)(selection || state.selection) || (0, _utils.findParentNodeOfType)(bodiedSyncBlock)(selection || state.selection);
15
+ var findBodiedSyncBlock = exports.findBodiedSyncBlock = function findBodiedSyncBlock(schema, selection) {
16
+ return (0, _utils.findSelectedNodeOfType)(schema.nodes.bodiedSyncBlock)(selection) || (0, _utils.findParentNodeOfType)(schema.nodes.bodiedSyncBlock)(selection);
18
17
  };
19
- var findSyncBlockOrBodiedSyncBlock = exports.findSyncBlockOrBodiedSyncBlock = function findSyncBlockOrBodiedSyncBlock(state, selection) {
20
- return findSyncBlock(state, selection) || findBodiedSyncBlock(state, selection);
18
+ var findSyncBlockOrBodiedSyncBlock = exports.findSyncBlockOrBodiedSyncBlock = function findSyncBlockOrBodiedSyncBlock(schema, selection) {
19
+ return findSyncBlock(schema, selection) || findBodiedSyncBlock(schema, selection);
21
20
  };
22
21
  var isBodiedSyncBlockNode = exports.isBodiedSyncBlockNode = function isBodiedSyncBlockNode(node, bodiedSyncBlock) {
23
22
  return node.type === bodiedSyncBlock;
@@ -25,13 +24,13 @@ var isBodiedSyncBlockNode = exports.isBodiedSyncBlockNode = function isBodiedSyn
25
24
  var UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedExtension', 'syncBlock', 'bodiedSyncBlock']);
26
25
 
27
26
  /**
28
- * Checks whether the selection can be converted to sync block
29
- *
30
- * @param selection - the current editor selection to validate for sync block conversion
31
- * @returns A fragment containing the content to include in the synced block,
32
- * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
33
- * or false if conversion is not possible
34
- */
27
+ * Checks whether the selection can be converted to sync block
28
+ *
29
+ * @param selection - the current editor selection to validate for sync block conversion
30
+ * @returns A fragment containing the content to include in the synced block,
31
+ * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
32
+ * or false if conversion is not possible
33
+ */
35
34
  var canBeConvertedToSyncBlock = exports.canBeConvertedToSyncBlock = function canBeConvertedToSyncBlock(selection) {
36
35
  var schema = selection.$from.doc.type.schema;
37
36
  var nodes = schema.nodes;
@@ -45,6 +45,9 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
45
45
  }];
46
46
  },
47
47
  commands: {
48
+ copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
49
+ return _editorCommands.copySyncedBlockReferenceToClipboardEditorCommand;
50
+ },
48
51
  insertSyncedBlock: function insertSyncedBlock() {
49
52
  return function (_ref2) {
50
53
  var tr = _ref2.tr;
@@ -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.CreateSyncedBlockDropdownItem = void 0;
8
+ exports.CreateOrCopySyncedBlockDropdownItem = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
@@ -15,7 +15,7 @@ var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
15
15
  var _compiled = require("@atlaskit/primitives/compiled");
16
16
  var _utils = require("../pm-plugins/utils/utils");
17
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 CreateSyncedBlockDropdownItem = exports.CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
18
+ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
19
19
  var api = _ref.api;
20
20
  var _useIntl = (0, _reactIntlNext.useIntl)(),
21
21
  formatMessage = _useIntl.formatMessage;
@@ -53,4 +53,46 @@ var CreateSyncedBlockDropdownItem = exports.CreateSyncedBlockDropdownItem = func
53
53
  }, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, formatMessage(_messages.blockMenuMessages.createSyncedBlock)), /*#__PURE__*/_react.default.createElement(_lozenge.default, {
54
54
  appearance: "new"
55
55
  }, formatMessage(_messages.blockMenuMessages.newLozenge))));
56
+ };
57
+ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
58
+ var api = _ref2.api;
59
+ var _useIntl2 = (0, _reactIntlNext.useIntl)(),
60
+ formatMessage = _useIntl2.formatMessage;
61
+ var onClick = function onClick() {
62
+ var _api$core3, _api$core4, _api$blockControls2;
63
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 ? void 0 : api.syncedBlock.commands.copySyncedBlockReferenceToClipboard());
64
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.toggleBlockMenu({
65
+ closeMenu: true
66
+ }));
67
+ };
68
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
69
+ elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.SyncBlocksIcon, {
70
+ label: ""
71
+ }),
72
+ onClick: onClick
73
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
74
+ alignItems: "center",
75
+ gap: "space.050"
76
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, formatMessage(_messages.blockMenuMessages.copySyncedBlock)), /*#__PURE__*/_react.default.createElement(_lozenge.default, {
77
+ appearance: "new"
78
+ }, formatMessage(_messages.blockMenuMessages.newLozenge))));
79
+ };
80
+ var CreateOrCopySyncedBlockDropdownItem = exports.CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(_ref3) {
81
+ var api = _ref3.api;
82
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
83
+ var _states$blockControls2;
84
+ return {
85
+ menuTriggerBy: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.menuTriggerBy
86
+ };
87
+ }),
88
+ menuTriggerBy = _useSharedPluginState2.menuTriggerBy;
89
+ if (menuTriggerBy === 'syncBlock' || menuTriggerBy === 'bodiedSyncBlock') {
90
+ return /*#__PURE__*/_react.default.createElement(CopySyncedBlockDropdownItem, {
91
+ api: api
92
+ });
93
+ } else {
94
+ return /*#__PURE__*/_react.default.createElement(CreateSyncedBlockDropdownItem, {
95
+ api: api
96
+ });
97
+ }
56
98
  };
@@ -18,7 +18,7 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
18
18
  rank: _blockMenu.ADD_BLOCKS_MENU_SECTION_RANK[_blockMenu.CREATE_SYNCED_BLOCK_MENU_ITEM.key]
19
19
  },
20
20
  component: function component() {
21
- return /*#__PURE__*/_react.default.createElement(_CreateSyncedBlockDropdownItem.CreateSyncedBlockDropdownItem, {
21
+ return /*#__PURE__*/_react.default.createElement(_CreateSyncedBlockDropdownItem.CreateOrCopySyncedBlockDropdownItem, {
22
22
  api: api
23
23
  });
24
24
  }
@@ -21,7 +21,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
21
21
  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
22
  var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore) {
23
23
  var _api$decorations;
24
- var syncBlockObject = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state);
24
+ var syncBlockObject = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state.schema, state.selection);
25
25
  if (!syncBlockObject) {
26
26
  return;
27
27
  }
@@ -47,7 +47,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
47
47
  title: formatMessage(_messages.syncBlockMessages.copySyncBlockLabel),
48
48
  showTitle: false,
49
49
  tooltipContent: formatMessage(_messages.syncBlockMessages.copySyncBlockTooltip),
50
- onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(api)
50
+ onClick: _editorCommands.copySyncedBlockReferenceToClipboard
51
51
  }, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
52
52
  items.push(copyButton);
53
53
  var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
@@ -59,24 +59,30 @@ export const createSyncedBlock = ({
59
59
  // see filterTransaction for more details
60
60
  return tr;
61
61
  };
62
- export const copySyncedBlockReferenceToClipboard = api => (state, _dispatch, _view) => {
63
- if (!(api !== null && api !== void 0 && api.floatingToolbar)) {
64
- return false;
62
+ export const copySyncedBlockReferenceToClipboardEditorCommand = ({
63
+ tr
64
+ }) => {
65
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection)) {
66
+ return tr;
65
67
  }
66
- const syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(state);
68
+ return null;
69
+ };
70
+ export const copySyncedBlockReferenceToClipboard = (state, _dispatch, _view) => {
71
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection);
72
+ };
73
+ const copySyncedBlockReferenceToClipboardInternal = (schema, selection) => {
74
+ const syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
67
75
  if (!syncBlockFindResult) {
68
76
  return false;
69
77
  }
70
- const isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockFindResult.node, state.schema.nodes.bodiedSyncBlock);
78
+ const isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockFindResult.node, schema.nodes.bodiedSyncBlock);
71
79
  let referenceSyncBlockNode = null;
72
80
  if (isBodiedSyncBlock) {
73
81
  const {
74
- schema: {
75
- nodes: {
76
- syncBlock
77
- }
82
+ nodes: {
83
+ syncBlock
78
84
  }
79
- } = state.tr.doc.type;
85
+ } = schema;
80
86
 
81
87
  // create sync block reference node
82
88
  referenceSyncBlockNode = syncBlock.createAndFill({
@@ -91,13 +97,13 @@ export const copySyncedBlockReferenceToClipboard = api => (state, _dispatch, _vi
91
97
  if (!referenceSyncBlockNode) {
92
98
  return false;
93
99
  }
94
- const domNode = toDOM(referenceSyncBlockNode, state.tr.doc.type.schema);
95
- copyDomNode(domNode, referenceSyncBlockNode.type, state.tr.selection);
100
+ const domNode = toDOM(referenceSyncBlockNode, schema);
101
+ copyDomNode(domNode, referenceSyncBlockNode.type, selection);
96
102
  return true;
97
103
  };
98
104
  export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch, _view) => {
99
105
  var _syncBlock$node, _syncBlock$node$attrs;
100
- const syncBlock = findSyncBlock(state);
106
+ const syncBlock = findSyncBlock(state.schema, state.selection);
101
107
  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;
102
108
  if (!resourceId) {
103
109
  return false;
@@ -2,32 +2,29 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { CellSelection, findTable } from '@atlaskit/editor-tables';
5
- export const findSyncBlock = (state, selection) => {
5
+ export const findSyncBlock = (schema, selection) => {
6
6
  const {
7
7
  syncBlock
8
- } = state.schema.nodes;
9
- return findSelectedNodeOfType(syncBlock)(selection || state.selection);
8
+ } = schema.nodes;
9
+ return findSelectedNodeOfType(syncBlock)(selection);
10
10
  };
11
- export const findBodiedSyncBlock = (state, selection) => {
12
- const {
13
- bodiedSyncBlock
14
- } = state.schema.nodes;
15
- return findSelectedNodeOfType(bodiedSyncBlock)(selection || state.selection) || findParentNodeOfType(bodiedSyncBlock)(selection || state.selection);
11
+ export const findBodiedSyncBlock = (schema, selection) => {
12
+ return findSelectedNodeOfType(schema.nodes.bodiedSyncBlock)(selection) || findParentNodeOfType(schema.nodes.bodiedSyncBlock)(selection);
16
13
  };
17
- export const findSyncBlockOrBodiedSyncBlock = (state, selection) => {
18
- return findSyncBlock(state, selection) || findBodiedSyncBlock(state, selection);
14
+ export const findSyncBlockOrBodiedSyncBlock = (schema, selection) => {
15
+ return findSyncBlock(schema, selection) || findBodiedSyncBlock(schema, selection);
19
16
  };
20
17
  export const isBodiedSyncBlockNode = (node, bodiedSyncBlock) => node.type === bodiedSyncBlock;
21
18
  const UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedExtension', 'syncBlock', 'bodiedSyncBlock']);
22
19
 
23
20
  /**
24
- * Checks whether the selection can be converted to sync block
25
- *
26
- * @param selection - the current editor selection to validate for sync block conversion
27
- * @returns A fragment containing the content to include in the synced block,
28
- * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
29
- * or false if conversion is not possible
30
- */
21
+ * Checks whether the selection can be converted to sync block
22
+ *
23
+ * @param selection - the current editor selection to validate for sync block conversion
24
+ * @returns A fragment containing the content to include in the synced block,
25
+ * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
26
+ * or false if conversion is not possible
27
+ */
31
28
  export const canBeConvertedToSyncBlock = selection => {
32
29
  const schema = selection.$from.doc.type.schema;
33
30
  const {
@@ -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 { flushBodiedSyncBlocks } from './editor-actions';
7
- import { createSyncedBlock } from './editor-commands';
7
+ import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
8
8
  import { createPlugin } from './pm-plugins/main';
9
9
  import { getBlockMenuComponents } from './ui/block-menu-components';
10
10
  import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
@@ -37,6 +37,7 @@ export const syncedBlockPlugin = ({
37
37
  }];
38
38
  },
39
39
  commands: {
40
+ copySyncedBlockReferenceToClipboard: () => copySyncedBlockReferenceToClipboardEditorCommand,
40
41
  insertSyncedBlock: () => ({
41
42
  tr
42
43
  }) => createSyncedBlock({
@@ -6,7 +6,7 @@ import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
6
  import Lozenge from '@atlaskit/lozenge';
7
7
  import { Flex, Text } from '@atlaskit/primitives/compiled';
8
8
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
9
- export const CreateSyncedBlockDropdownItem = ({
9
+ const CreateSyncedBlockDropdownItem = ({
10
10
  api
11
11
  }) => {
12
12
  const {
@@ -45,4 +45,50 @@ export const CreateSyncedBlockDropdownItem = ({
45
45
  }, /*#__PURE__*/React.createElement(Text, null, formatMessage(blockMenuMessages.createSyncedBlock)), /*#__PURE__*/React.createElement(Lozenge, {
46
46
  appearance: "new"
47
47
  }, formatMessage(blockMenuMessages.newLozenge))));
48
+ };
49
+ const CopySyncedBlockDropdownItem = ({
50
+ api
51
+ }) => {
52
+ const {
53
+ formatMessage
54
+ } = useIntl();
55
+ const onClick = () => {
56
+ var _api$core3, _api$core4, _api$blockControls2, _api$blockControls2$c;
57
+ api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 ? void 0 : api.syncedBlock.commands.copySyncedBlockReferenceToClipboard());
58
+ api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.toggleBlockMenu({
59
+ closeMenu: true
60
+ }));
61
+ };
62
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
63
+ elemBefore: /*#__PURE__*/React.createElement(SyncBlocksIcon, {
64
+ label: ""
65
+ }),
66
+ onClick: onClick
67
+ }, /*#__PURE__*/React.createElement(Flex, {
68
+ alignItems: "center",
69
+ gap: "space.050"
70
+ }, /*#__PURE__*/React.createElement(Text, null, formatMessage(blockMenuMessages.copySyncedBlock)), /*#__PURE__*/React.createElement(Lozenge, {
71
+ appearance: "new"
72
+ }, formatMessage(blockMenuMessages.newLozenge))));
73
+ };
74
+ export const CreateOrCopySyncedBlockDropdownItem = ({
75
+ api
76
+ }) => {
77
+ const {
78
+ menuTriggerBy
79
+ } = useSharedPluginStateWithSelector(api, ['blockControls'], states => {
80
+ var _states$blockControls2;
81
+ return {
82
+ menuTriggerBy: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.menuTriggerBy
83
+ };
84
+ });
85
+ if (menuTriggerBy === 'syncBlock' || menuTriggerBy === 'bodiedSyncBlock') {
86
+ return /*#__PURE__*/React.createElement(CopySyncedBlockDropdownItem, {
87
+ api: api
88
+ });
89
+ } else {
90
+ return /*#__PURE__*/React.createElement(CreateSyncedBlockDropdownItem, {
91
+ api: api
92
+ });
93
+ }
48
94
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ADD_BLOCKS_MENU_SECTION, ADD_BLOCKS_MENU_SECTION_RANK, CREATE_SYNCED_BLOCK_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
3
- import { CreateSyncedBlockDropdownItem } from './CreateSyncedBlockDropdownItem';
3
+ import { CreateOrCopySyncedBlockDropdownItem } from './CreateSyncedBlockDropdownItem';
4
4
  export const getBlockMenuComponents = api => {
5
5
  return [{
6
6
  type: 'block-menu-item',
@@ -10,7 +10,7 @@ export const getBlockMenuComponents = api => {
10
10
  key: ADD_BLOCKS_MENU_SECTION.key,
11
11
  rank: ADD_BLOCKS_MENU_SECTION_RANK[CREATE_SYNCED_BLOCK_MENU_ITEM.key]
12
12
  },
13
- component: () => /*#__PURE__*/React.createElement(CreateSyncedBlockDropdownItem, {
13
+ component: () => /*#__PURE__*/React.createElement(CreateOrCopySyncedBlockDropdownItem, {
14
14
  api: api
15
15
  })
16
16
  }];
@@ -9,7 +9,7 @@ import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSynce
9
9
  import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
10
10
  export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
11
11
  var _api$decorations;
12
- const syncBlockObject = findSyncBlockOrBodiedSyncBlock(state);
12
+ const syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
13
13
  if (!syncBlockObject) {
14
14
  return;
15
15
  }
@@ -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(api),
44
+ onClick: copySyncedBlockReferenceToClipboard,
45
45
  ...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
46
46
  };
47
47
  items.push(copyButton);
@@ -53,42 +53,47 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
53
53
  // see filterTransaction for more details
54
54
  return tr;
55
55
  };
56
- export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(api) {
57
- return function (state, _dispatch, _view) {
58
- if (!(api !== null && api !== void 0 && api.floatingToolbar)) {
59
- return false;
60
- }
61
- var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(state);
62
- if (!syncBlockFindResult) {
63
- return false;
64
- }
65
- var isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockFindResult.node, state.schema.nodes.bodiedSyncBlock);
66
- var referenceSyncBlockNode = null;
67
- if (isBodiedSyncBlock) {
68
- var syncBlock = state.tr.doc.type.schema.nodes.syncBlock;
56
+ export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(_ref2) {
57
+ var tr = _ref2.tr;
58
+ if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection)) {
59
+ return tr;
60
+ }
61
+ return null;
62
+ };
63
+ export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(state, _dispatch, _view) {
64
+ return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection);
65
+ };
66
+ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection) {
67
+ var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
68
+ if (!syncBlockFindResult) {
69
+ return false;
70
+ }
71
+ var isBodiedSyncBlock = isBodiedSyncBlockNode(syncBlockFindResult.node, schema.nodes.bodiedSyncBlock);
72
+ var referenceSyncBlockNode = null;
73
+ if (isBodiedSyncBlock) {
74
+ var syncBlock = schema.nodes.syncBlock;
69
75
 
70
- // create sync block reference node
71
- referenceSyncBlockNode = syncBlock.createAndFill({
72
- resourceId: syncBlockFindResult.node.attrs.resourceId
73
- });
74
- if (!referenceSyncBlockNode) {
75
- return false;
76
- }
77
- } else {
78
- referenceSyncBlockNode = syncBlockFindResult.node;
79
- }
76
+ // create sync block reference node
77
+ referenceSyncBlockNode = syncBlock.createAndFill({
78
+ resourceId: syncBlockFindResult.node.attrs.resourceId
79
+ });
80
80
  if (!referenceSyncBlockNode) {
81
81
  return false;
82
82
  }
83
- var domNode = toDOM(referenceSyncBlockNode, state.tr.doc.type.schema);
84
- copyDomNode(domNode, referenceSyncBlockNode.type, state.tr.selection);
85
- return true;
86
- };
83
+ } else {
84
+ referenceSyncBlockNode = syncBlockFindResult.node;
85
+ }
86
+ if (!referenceSyncBlockNode) {
87
+ return false;
88
+ }
89
+ var domNode = toDOM(referenceSyncBlockNode, schema);
90
+ copyDomNode(domNode, referenceSyncBlockNode.type, selection);
91
+ return true;
87
92
  };
88
93
  export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
89
94
  return function (state, dispatch, _view) {
90
95
  var _syncBlock$node;
91
- var syncBlock = findSyncBlock(state);
96
+ var syncBlock = findSyncBlock(state.schema, state.selection);
92
97
  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;
93
98
  if (!resourceId) {
94
99
  return false;
@@ -2,16 +2,15 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { CellSelection, findTable } from '@atlaskit/editor-tables';
5
- export var findSyncBlock = function findSyncBlock(state, selection) {
6
- var syncBlock = state.schema.nodes.syncBlock;
7
- return findSelectedNodeOfType(syncBlock)(selection || state.selection);
5
+ export var findSyncBlock = function findSyncBlock(schema, selection) {
6
+ var syncBlock = schema.nodes.syncBlock;
7
+ return findSelectedNodeOfType(syncBlock)(selection);
8
8
  };
9
- export var findBodiedSyncBlock = function findBodiedSyncBlock(state, selection) {
10
- var bodiedSyncBlock = state.schema.nodes.bodiedSyncBlock;
11
- return findSelectedNodeOfType(bodiedSyncBlock)(selection || state.selection) || findParentNodeOfType(bodiedSyncBlock)(selection || state.selection);
9
+ export var findBodiedSyncBlock = function findBodiedSyncBlock(schema, selection) {
10
+ return findSelectedNodeOfType(schema.nodes.bodiedSyncBlock)(selection) || findParentNodeOfType(schema.nodes.bodiedSyncBlock)(selection);
12
11
  };
13
- export var findSyncBlockOrBodiedSyncBlock = function findSyncBlockOrBodiedSyncBlock(state, selection) {
14
- return findSyncBlock(state, selection) || findBodiedSyncBlock(state, selection);
12
+ export var findSyncBlockOrBodiedSyncBlock = function findSyncBlockOrBodiedSyncBlock(schema, selection) {
13
+ return findSyncBlock(schema, selection) || findBodiedSyncBlock(schema, selection);
15
14
  };
16
15
  export var isBodiedSyncBlockNode = function isBodiedSyncBlockNode(node, bodiedSyncBlock) {
17
16
  return node.type === bodiedSyncBlock;
@@ -19,13 +18,13 @@ export var isBodiedSyncBlockNode = function isBodiedSyncBlockNode(node, bodiedSy
19
18
  var UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedExtension', 'syncBlock', 'bodiedSyncBlock']);
20
19
 
21
20
  /**
22
- * Checks whether the selection can be converted to sync block
23
- *
24
- * @param selection - the current editor selection to validate for sync block conversion
25
- * @returns A fragment containing the content to include in the synced block,
26
- * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
27
- * or false if conversion is not possible
28
- */
21
+ * Checks whether the selection can be converted to sync block
22
+ *
23
+ * @param selection - the current editor selection to validate for sync block conversion
24
+ * @returns A fragment containing the content to include in the synced block,
25
+ * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
26
+ * or false if conversion is not possible
27
+ */
29
28
  export var canBeConvertedToSyncBlock = function canBeConvertedToSyncBlock(selection) {
30
29
  var schema = selection.$from.doc.type.schema;
31
30
  var nodes = schema.nodes;
@@ -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 { flushBodiedSyncBlocks as _flushBodiedSyncBlocks } from './editor-actions';
7
- import { createSyncedBlock } from './editor-commands';
7
+ import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
8
8
  import { createPlugin } from './pm-plugins/main';
9
9
  import { getBlockMenuComponents } from './ui/block-menu-components';
10
10
  import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
@@ -38,6 +38,9 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
38
38
  }];
39
39
  },
40
40
  commands: {
41
+ copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
42
+ return copySyncedBlockReferenceToClipboardEditorCommand;
43
+ },
41
44
  insertSyncedBlock: function insertSyncedBlock() {
42
45
  return function (_ref2) {
43
46
  var tr = _ref2.tr;
@@ -6,7 +6,7 @@ import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
6
  import Lozenge from '@atlaskit/lozenge';
7
7
  import { Flex, Text } from '@atlaskit/primitives/compiled';
8
8
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
9
- export var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
9
+ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
10
10
  var api = _ref.api;
11
11
  var _useIntl = useIntl(),
12
12
  formatMessage = _useIntl.formatMessage;
@@ -44,4 +44,46 @@ export var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownIte
44
44
  }, /*#__PURE__*/React.createElement(Text, null, formatMessage(blockMenuMessages.createSyncedBlock)), /*#__PURE__*/React.createElement(Lozenge, {
45
45
  appearance: "new"
46
46
  }, formatMessage(blockMenuMessages.newLozenge))));
47
+ };
48
+ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
49
+ var api = _ref2.api;
50
+ var _useIntl2 = useIntl(),
51
+ formatMessage = _useIntl2.formatMessage;
52
+ var onClick = function onClick() {
53
+ var _api$core3, _api$core4, _api$blockControls2;
54
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 ? void 0 : api.syncedBlock.commands.copySyncedBlockReferenceToClipboard());
55
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.toggleBlockMenu({
56
+ closeMenu: true
57
+ }));
58
+ };
59
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
60
+ elemBefore: /*#__PURE__*/React.createElement(SyncBlocksIcon, {
61
+ label: ""
62
+ }),
63
+ onClick: onClick
64
+ }, /*#__PURE__*/React.createElement(Flex, {
65
+ alignItems: "center",
66
+ gap: "space.050"
67
+ }, /*#__PURE__*/React.createElement(Text, null, formatMessage(blockMenuMessages.copySyncedBlock)), /*#__PURE__*/React.createElement(Lozenge, {
68
+ appearance: "new"
69
+ }, formatMessage(blockMenuMessages.newLozenge))));
70
+ };
71
+ export var CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(_ref3) {
72
+ var api = _ref3.api;
73
+ var _useSharedPluginState2 = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
74
+ var _states$blockControls2;
75
+ return {
76
+ menuTriggerBy: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.menuTriggerBy
77
+ };
78
+ }),
79
+ menuTriggerBy = _useSharedPluginState2.menuTriggerBy;
80
+ if (menuTriggerBy === 'syncBlock' || menuTriggerBy === 'bodiedSyncBlock') {
81
+ return /*#__PURE__*/React.createElement(CopySyncedBlockDropdownItem, {
82
+ api: api
83
+ });
84
+ } else {
85
+ return /*#__PURE__*/React.createElement(CreateSyncedBlockDropdownItem, {
86
+ api: api
87
+ });
88
+ }
47
89
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ADD_BLOCKS_MENU_SECTION, ADD_BLOCKS_MENU_SECTION_RANK, CREATE_SYNCED_BLOCK_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
3
- import { CreateSyncedBlockDropdownItem } from './CreateSyncedBlockDropdownItem';
3
+ import { CreateOrCopySyncedBlockDropdownItem } from './CreateSyncedBlockDropdownItem';
4
4
  export var getBlockMenuComponents = function getBlockMenuComponents(api) {
5
5
  return [{
6
6
  type: 'block-menu-item',
@@ -11,7 +11,7 @@ export var getBlockMenuComponents = function getBlockMenuComponents(api) {
11
11
  rank: ADD_BLOCKS_MENU_SECTION_RANK[CREATE_SYNCED_BLOCK_MENU_ITEM.key]
12
12
  },
13
13
  component: function component() {
14
- return /*#__PURE__*/React.createElement(CreateSyncedBlockDropdownItem, {
14
+ return /*#__PURE__*/React.createElement(CreateOrCopySyncedBlockDropdownItem, {
15
15
  api: api
16
16
  });
17
17
  }
@@ -12,7 +12,7 @@ import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSynce
12
12
  import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
13
13
  export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore) {
14
14
  var _api$decorations;
15
- var syncBlockObject = findSyncBlockOrBodiedSyncBlock(state);
15
+ var syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
16
16
  if (!syncBlockObject) {
17
17
  return;
18
18
  }
@@ -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(api)
41
+ onClick: copySyncedBlockReferenceToClipboard
42
42
  }, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
43
43
  items.push(copyButton);
44
44
  var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
@@ -1,4 +1,4 @@
1
- import type { Command, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
1
+ import type { Command, EditorCommand, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
2
2
  import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
@@ -8,7 +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 copySyncedBlockReferenceToClipboard: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
11
+ export declare const copySyncedBlockReferenceToClipboardEditorCommand: EditorCommand;
12
+ export declare const copySyncedBlockReferenceToClipboard: Command;
12
13
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
13
14
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
14
15
  export {};
@@ -1,10 +1,10 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { type EditorState, type Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
3
+ import { type Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- export declare const findSyncBlock: (state: EditorState, selection?: Selection | null) => ContentNodeWithPos | undefined;
6
- export declare const findBodiedSyncBlock: (state: EditorState, selection?: Selection | null) => ContentNodeWithPos | undefined;
7
- export declare const findSyncBlockOrBodiedSyncBlock: (state: EditorState, selection?: Selection | null) => ContentNodeWithPos | undefined;
5
+ export declare const findSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
6
+ export declare const findBodiedSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
7
+ export declare const findSyncBlockOrBodiedSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
8
8
  export declare const isBodiedSyncBlockNode: (node: PMNode, bodiedSyncBlock: NodeType) => boolean;
9
9
  export interface SyncBlockConversionInfo {
10
10
  contentToInclude: Fragment;
@@ -12,11 +12,11 @@ export interface SyncBlockConversionInfo {
12
12
  to: number;
13
13
  }
14
14
  /**
15
- * Checks whether the selection can be converted to sync block
16
- *
17
- * @param selection - the current editor selection to validate for sync block conversion
18
- * @returns A fragment containing the content to include in the synced block,
19
- * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
20
- * or false if conversion is not possible
21
- */
15
+ * Checks whether the selection can be converted to sync block
16
+ *
17
+ * @param selection - the current editor selection to validate for sync block conversion
18
+ * @returns A fragment containing the content to include in the synced block,
19
+ * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
20
+ * or false if conversion is not possible
21
+ */
22
22
  export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
@@ -51,6 +51,7 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
51
51
  flushBodiedSyncBlocks: () => Promise<boolean>;
52
52
  };
53
53
  commands: {
54
+ copySyncedBlockReferenceToClipboard: () => EditorCommand;
54
55
  insertSyncedBlock: () => EditorCommand;
55
56
  };
56
57
  dependencies: [
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
4
- export declare const CreateSyncedBlockDropdownItem: ({ api, }: {
4
+ export declare const CreateOrCopySyncedBlockDropdownItem: ({ api, }: {
5
5
  api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined;
6
- }) => React.JSX.Element | null;
6
+ }) => React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import type { Command, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
1
+ import type { Command, EditorCommand, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
2
2
  import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
@@ -8,7 +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 copySyncedBlockReferenceToClipboard: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
11
+ export declare const copySyncedBlockReferenceToClipboardEditorCommand: EditorCommand;
12
+ export declare const copySyncedBlockReferenceToClipboard: Command;
12
13
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
13
14
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
14
15
  export {};
@@ -1,10 +1,10 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import { type EditorState, type Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
3
+ import { type Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- export declare const findSyncBlock: (state: EditorState, selection?: Selection | null) => ContentNodeWithPos | undefined;
6
- export declare const findBodiedSyncBlock: (state: EditorState, selection?: Selection | null) => ContentNodeWithPos | undefined;
7
- export declare const findSyncBlockOrBodiedSyncBlock: (state: EditorState, selection?: Selection | null) => ContentNodeWithPos | undefined;
5
+ export declare const findSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
6
+ export declare const findBodiedSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
7
+ export declare const findSyncBlockOrBodiedSyncBlock: (schema: Schema, selection: Selection) => ContentNodeWithPos | undefined;
8
8
  export declare const isBodiedSyncBlockNode: (node: PMNode, bodiedSyncBlock: NodeType) => boolean;
9
9
  export interface SyncBlockConversionInfo {
10
10
  contentToInclude: Fragment;
@@ -12,11 +12,11 @@ export interface SyncBlockConversionInfo {
12
12
  to: number;
13
13
  }
14
14
  /**
15
- * Checks whether the selection can be converted to sync block
16
- *
17
- * @param selection - the current editor selection to validate for sync block conversion
18
- * @returns A fragment containing the content to include in the synced block,
19
- * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
20
- * or false if conversion is not possible
21
- */
15
+ * Checks whether the selection can be converted to sync block
16
+ *
17
+ * @param selection - the current editor selection to validate for sync block conversion
18
+ * @returns A fragment containing the content to include in the synced block,
19
+ * stripping out unsupported marks (breakout on codeblock/expand/layout), as well as from and to positions,
20
+ * or false if conversion is not possible
21
+ */
22
22
  export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
@@ -51,6 +51,7 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
51
51
  flushBodiedSyncBlocks: () => Promise<boolean>;
52
52
  };
53
53
  commands: {
54
+ copySyncedBlockReferenceToClipboard: () => EditorCommand;
54
55
  insertSyncedBlock: () => EditorCommand;
55
56
  };
56
57
  dependencies: [
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
4
- export declare const CreateSyncedBlockDropdownItem: ({ api, }: {
4
+ export declare const CreateOrCopySyncedBlockDropdownItem: ({ api, }: {
5
5
  api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined;
6
- }) => React.JSX.Element | null;
6
+ }) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^51.3.2",
32
- "@atlaskit/button": "23.6.0",
32
+ "@atlaskit/button": "23.6.1",
33
33
  "@atlaskit/editor-json-transformer": "^8.31.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
35
35
  "@atlaskit/editor-plugin-block-menu": "^5.0.0",
@@ -37,11 +37,11 @@
37
37
  "@atlaskit/editor-plugin-floating-toolbar": "^8.2.0",
38
38
  "@atlaskit/editor-plugin-selection": "^6.1.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
- "@atlaskit/editor-shared-styles": "^3.8.0",
40
+ "@atlaskit/editor-shared-styles": "^3.9.0",
41
41
  "@atlaskit/editor-synced-block-provider": "^2.7.0",
42
42
  "@atlaskit/editor-tables": "^2.9.0",
43
43
  "@atlaskit/editor-toolbar": "^0.17.0",
44
- "@atlaskit/icon": "28.5.4",
44
+ "@atlaskit/icon": "29.0.0",
45
45
  "@atlaskit/icon-lab": "^5.12.0",
46
46
  "@atlaskit/logo": "^19.9.0",
47
47
  "@atlaskit/lozenge": "^13.1.0",
@@ -53,7 +53,7 @@
53
53
  "react-intl-next": "npm:react-intl@^5.18.1"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^110.25.0",
56
+ "@atlaskit/editor-common": "^110.27.0",
57
57
  "react": "^18.2.0"
58
58
  },
59
59
  "devDependencies": {