@atlaskit/editor-plugin-expand 7.5.1 → 7.5.3

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-expand
2
2
 
3
+ ## 7.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b5d004bf834f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b5d004bf834f8) -
8
+ [ux] Adds block menu action to check if 'Turn into' item should be rendered or not.
9
+ - Updated dependencies
10
+
11
+ ## 7.5.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 7.5.1
4
18
 
5
19
  ### Patch Changes
@@ -1,35 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createExpandBlockMenuItem = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
10
9
  var _reactIntlNext = require("react-intl-next");
11
10
  var _analytics = require("@atlaskit/editor-common/analytics");
12
11
  var _messages = require("@atlaskit/editor-common/messages");
13
- var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
14
- var _state = require("@atlaskit/editor-prosemirror/state");
15
12
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
13
  var _expandElement = _interopRequireDefault(require("@atlaskit/icon-lab/core/expand-element"));
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
14
  var nodeName = 'expand';
19
15
  var ExpandBlockMenuItem = function ExpandBlockMenuItem(_ref) {
16
+ var _api$blockMenu2;
20
17
  var api = _ref.api;
21
18
  var _useIntl = (0, _reactIntlNext.useIntl)(),
22
19
  formatMessage = _useIntl.formatMessage;
23
- var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
24
- var isExpandSelected = (0, _react.useMemo)(function () {
25
- if (!selection) {
26
- return false;
27
- }
28
- if (selection instanceof _state.NodeSelection) {
29
- return selection.node.type.name === nodeName;
30
- }
31
- return false;
32
- }, [selection]);
33
20
  var handleClick = function handleClick(event) {
34
21
  var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE;
35
22
  var inputMethod = _analytics.INPUT_METHOD.BLOCK_MENU;
@@ -46,9 +33,12 @@ var ExpandBlockMenuItem = function ExpandBlockMenuItem(_ref) {
46
33
  }) : null;
47
34
  });
48
35
  };
36
+ var isTransfromToPanelDisabled = api === null || api === void 0 || (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(nodeName);
37
+ if (isTransfromToPanelDisabled) {
38
+ return null;
39
+ }
49
40
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
50
41
  onClick: handleClick,
51
- isSelected: isExpandSelected,
52
42
  elemBefore: /*#__PURE__*/_react.default.createElement(_expandElement.default, {
53
43
  label: ""
54
44
  })
@@ -1,28 +1,17 @@
1
- import React, { useMemo } from 'react';
1
+ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
5
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
6
  import ExpandElementIcon from '@atlaskit/icon-lab/core/expand-element';
9
7
  const nodeName = 'expand';
10
8
  const ExpandBlockMenuItem = ({
11
9
  api
12
10
  }) => {
11
+ var _api$blockMenu2;
13
12
  const {
14
13
  formatMessage
15
14
  } = useIntl();
16
- const selection = useSharedPluginStateSelector(api, 'selection.selection');
17
- const isExpandSelected = useMemo(() => {
18
- if (!selection) {
19
- return false;
20
- }
21
- if (selection instanceof NodeSelection) {
22
- return selection.node.type.name === nodeName;
23
- }
24
- return false;
25
- }, [selection]);
26
15
  const handleClick = event => {
27
16
  const triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
28
17
  const inputMethod = INPUT_METHOD.BLOCK_MENU;
@@ -40,9 +29,12 @@ const ExpandBlockMenuItem = ({
40
29
  }) : null;
41
30
  });
42
31
  };
32
+ const isTransfromToPanelDisabled = api === null || api === void 0 ? void 0 : (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(nodeName);
33
+ if (isTransfromToPanelDisabled) {
34
+ return null;
35
+ }
43
36
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
44
37
  onClick: handleClick,
45
- isSelected: isExpandSelected,
46
38
  elemBefore: /*#__PURE__*/React.createElement(ExpandElementIcon, {
47
39
  label: ""
48
40
  })
@@ -1,26 +1,15 @@
1
- import React, { useMemo } from 'react';
1
+ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
5
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
6
  import ExpandElementIcon from '@atlaskit/icon-lab/core/expand-element';
9
7
  var nodeName = 'expand';
10
8
  var ExpandBlockMenuItem = function ExpandBlockMenuItem(_ref) {
9
+ var _api$blockMenu2;
11
10
  var api = _ref.api;
12
11
  var _useIntl = useIntl(),
13
12
  formatMessage = _useIntl.formatMessage;
14
- var selection = useSharedPluginStateSelector(api, 'selection.selection');
15
- var isExpandSelected = useMemo(function () {
16
- if (!selection) {
17
- return false;
18
- }
19
- if (selection instanceof NodeSelection) {
20
- return selection.node.type.name === nodeName;
21
- }
22
- return false;
23
- }, [selection]);
24
13
  var handleClick = function handleClick(event) {
25
14
  var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
26
15
  var inputMethod = INPUT_METHOD.BLOCK_MENU;
@@ -37,9 +26,12 @@ var ExpandBlockMenuItem = function ExpandBlockMenuItem(_ref) {
37
26
  }) : null;
38
27
  });
39
28
  };
29
+ var isTransfromToPanelDisabled = api === null || api === void 0 || (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(nodeName);
30
+ if (isTransfromToPanelDisabled) {
31
+ return null;
32
+ }
40
33
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
41
34
  onClick: handleClick,
42
- isSelected: isExpandSelected,
43
35
  elemBefore: /*#__PURE__*/React.createElement(ExpandElementIcon, {
44
36
  label: ""
45
37
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "7.5.1",
3
+ "version": "7.5.3",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -48,8 +48,8 @@
48
48
  "@atlaskit/icon-lab": "^5.13.0",
49
49
  "@atlaskit/platform-feature-flags": "^1.1.0",
50
50
  "@atlaskit/prosemirror-history": "^0.2.0",
51
- "@atlaskit/tmp-editor-statsig": "^16.0.0",
52
- "@atlaskit/tokens": "^8.6.0",
51
+ "@atlaskit/tmp-editor-statsig": "^16.1.0",
52
+ "@atlaskit/tokens": "^9.0.0",
53
53
  "@atlaskit/tooltip": "^20.11.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
@@ -57,7 +57,7 @@
57
57
  "w3c-keyname": "^2.1.8"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^110.46.0",
60
+ "@atlaskit/editor-common": "^110.48.0",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0",
63
63
  "react-intl-next": "npm:react-intl@^5.18.1"