@atlaskit/editor-plugin-expand 4.3.1 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-expand
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5f1d8eb6b1fa2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5f1d8eb6b1fa2) -
8
+ EDITOR-1464 Update toDOM methods to include localId
9
+ - Updated dependencies
10
+
11
+ ## 5.0.0
12
+
13
+ ### Patch Changes
14
+
15
+ - [`e882e86092666`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e882e86092666) -
16
+ [ux] Register expand, layout and code block itmes in block menu. Update panel item.
17
+ - Updated dependencies
18
+
3
19
  ## 4.3.1
4
20
 
5
21
  ### Patch Changes
@@ -23,16 +23,20 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
23
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
24
24
  var _commands = require("../commands");
25
25
  var _ExpandIconButton = require("../ui/ExpandIconButton");
26
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
+ 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; }
26
28
  function buildExpandClassName(type, expanded) {
27
29
  return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
28
30
  }
29
31
  var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
30
- return ['div', {
32
+ return ['div', _objectSpread({
31
33
  // prettier-ignore
32
34
  'class': buildExpandClassName(node.type.name, __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
33
35
  'data-node-type': node.type.name,
34
36
  'data-title': node.attrs.title
35
- }, ['div', {
37
+ }, (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') && {
38
+ 'data-local-id': node.attrs.localId
39
+ }), ['div', {
36
40
  // prettier-ignore
37
41
  'class': _styles.expandClassNames.titleContainer,
38
42
  contenteditable: 'false',
@@ -8,9 +8,12 @@ exports.expandPlugin = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
11
12
  var _messages = require("@atlaskit/editor-common/messages");
12
13
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
13
14
  var _utils = require("@atlaskit/editor-common/utils");
15
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
16
+ var _ExpandBlockMenuItem = require("../ui/ExpandBlockMenuItem");
14
17
  var _commands = require("./commands");
15
18
  var _keymap = require("./pm-plugins/keymap");
16
19
  var _main = require("./pm-plugins/main");
@@ -22,6 +25,19 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
22
25
  var _ref$config = _ref.config,
23
26
  options = _ref$config === void 0 ? {} : _ref$config,
24
27
  api = _ref.api;
28
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
29
+ var _api$blockMenu;
30
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
31
+ type: 'block-menu-item',
32
+ key: _blockMenu.FORMAT_EXPAND_MENU_ITEM.key,
33
+ parent: {
34
+ type: 'block-menu-section',
35
+ key: _blockMenu.FORMAT_MENU_ITEM.key,
36
+ rank: _blockMenu.FORMAT_NESTED_MENU_RANK[_blockMenu.FORMAT_EXPAND_MENU_ITEM.key]
37
+ },
38
+ component: (0, _ExpandBlockMenuItem.createExpandBlockMenuItem)(api)
39
+ }]);
40
+ }
25
41
  return {
26
42
  name: 'expand',
27
43
  nodes: function nodes() {
@@ -8,10 +8,13 @@ exports.expandPlugin = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
11
12
  var _messages = require("@atlaskit/editor-common/messages");
12
13
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
13
14
  var _utils = require("@atlaskit/editor-common/utils");
14
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
17
+ var _ExpandBlockMenuItem = require("../ui/ExpandBlockMenuItem");
15
18
  var _commands = require("./commands");
16
19
  var _keymap = require("./pm-plugins/keymap");
17
20
  var _main = require("./pm-plugins/main");
@@ -23,6 +26,19 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
23
26
  var _ref$config = _ref.config,
24
27
  options = _ref$config === void 0 ? {} : _ref$config,
25
28
  api = _ref.api;
29
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
30
+ var _api$blockMenu;
31
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
32
+ type: 'block-menu-item',
33
+ key: _blockMenu.FORMAT_EXPAND_MENU_ITEM.key,
34
+ parent: {
35
+ type: 'block-menu-section',
36
+ key: _blockMenu.FORMAT_MENU_ITEM.key,
37
+ rank: _blockMenu.FORMAT_NESTED_MENU_RANK[_blockMenu.FORMAT_EXPAND_MENU_ITEM.key]
38
+ },
39
+ component: (0, _ExpandBlockMenuItem.createExpandBlockMenuItem)(api)
40
+ }]);
41
+ }
26
42
  return {
27
43
  name: 'expand',
28
44
  nodes: function nodes() {
@@ -1,23 +1,30 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.toDOM = exports.buildExpandClassName = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _expand = require("@atlaskit/editor-common/expand");
8
10
  var _styles = require("@atlaskit/editor-common/styles");
9
11
  var _ui = require("@atlaskit/editor-common/ui");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ 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; }
10
15
  var buildExpandClassName = exports.buildExpandClassName = function buildExpandClassName(type, expanded) {
11
16
  return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
12
17
  };
13
18
  var toDOM = exports.toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
14
19
  var _expandedState$get;
15
- return ['div', {
20
+ return ['div', _objectSpread({
16
21
  // prettier-ignore
17
22
  'class': buildExpandClassName(node.type.name, (_expandedState$get = _expand.expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false),
18
23
  'data-node-type': node.type.name,
19
24
  'data-title': node.attrs.title
20
- }, ['div', {
25
+ }, (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') && {
26
+ 'data-local-id': node.attrs.localId
27
+ }), ['div', {
21
28
  // prettier-ignore
22
29
  'class': _styles.expandClassNames.titleContainer,
23
30
  contenteditable: 'false',
@@ -0,0 +1,50 @@
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.createExpandBlockMenuItem = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _reactIntlNext = require("react-intl-next");
11
+ var _messages = require("@atlaskit/editor-common/messages");
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
13
+ var _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _expandElement = _interopRequireDefault(require("@atlaskit/icon-lab/core/expand-element"));
16
+ 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); }
17
+ var nodeName = 'expand';
18
+ var ExpandBlockMenuItem = function ExpandBlockMenuItem(_ref) {
19
+ var api = _ref.api;
20
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
21
+ formatMessage = _useIntl.formatMessage;
22
+ var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
23
+ var isExpandSelected = (0, _react.useMemo)(function () {
24
+ if (!selection) {
25
+ return false;
26
+ }
27
+ if (selection instanceof _state.NodeSelection) {
28
+ return selection.node.type.name === nodeName;
29
+ }
30
+ return false;
31
+ }, [selection]);
32
+ var handleClick = function handleClick() {
33
+ var _api$blockMenu;
34
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode(nodeName));
35
+ };
36
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
37
+ onClick: handleClick,
38
+ isSelected: isExpandSelected,
39
+ elemBefore: /*#__PURE__*/_react.default.createElement(_expandElement.default, {
40
+ label: ""
41
+ })
42
+ }, formatMessage(_messages.toolbarInsertBlockMessages.expand));
43
+ };
44
+ var createExpandBlockMenuItem = exports.createExpandBlockMenuItem = function createExpandBlockMenuItem(api) {
45
+ return function () {
46
+ return /*#__PURE__*/_react.default.createElement(ExpandBlockMenuItem, {
47
+ api: api
48
+ });
49
+ };
50
+ };
@@ -20,7 +20,10 @@ const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) => ['div'
20
20
  // prettier-ignore
21
21
  'class': buildExpandClassName(node.type.name, __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
22
22
  'data-node-type': node.type.name,
23
- 'data-title': node.attrs.title
23
+ 'data-title': node.attrs.title,
24
+ ...(fg('platform_editor_adf_with_localid') && {
25
+ 'data-local-id': node.attrs.localId
26
+ })
24
27
  }, ['div', {
25
28
  // prettier-ignore
26
29
  'class': expandClassNames.titleContainer,
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
2
  import { expandWithNestedExpand, nestedExpand } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { FORMAT_MENU_ITEM, FORMAT_EXPAND_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
4
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
6
  import { IconExpand } from '@atlaskit/editor-common/quick-insert';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
8
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
9
+ import { createExpandBlockMenuItem } from '../ui/ExpandBlockMenuItem';
7
10
  import { createExpandNode, insertExpand, insertExpandWithInputMethod, toggleExpandWithMatch } from './commands';
8
11
  import { expandKeymap } from './pm-plugins/keymap';
9
12
  import { createPlugin } from './pm-plugins/main';
@@ -16,6 +19,19 @@ export let expandPlugin = ({
16
19
  api
17
20
  }) => {
18
21
  var _api$analytics, _api$analytics2;
22
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
23
+ var _api$blockMenu;
24
+ api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents([{
25
+ type: 'block-menu-item',
26
+ key: FORMAT_EXPAND_MENU_ITEM.key,
27
+ parent: {
28
+ type: 'block-menu-section',
29
+ key: FORMAT_MENU_ITEM.key,
30
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_EXPAND_MENU_ITEM.key]
31
+ },
32
+ component: createExpandBlockMenuItem(api)
33
+ }]);
34
+ }
19
35
  return {
20
36
  name: 'expand',
21
37
  nodes() {
@@ -1,10 +1,13 @@
1
1
  import React from 'react';
2
2
  import { expandWithNestedExpand, expandWithNestedExpandLocalId, nestedExpand, nestedExpandWithLocalId } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { FORMAT_MENU_ITEM, FORMAT_EXPAND_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
4
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
6
  import { IconExpand } from '@atlaskit/editor-common/quick-insert';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
+ import { createExpandBlockMenuItem } from '../ui/ExpandBlockMenuItem';
8
11
  import { createExpandNode, insertExpand, insertExpandWithInputMethod, toggleExpandWithMatch } from './commands';
9
12
  import { expandKeymap } from './pm-plugins/keymap';
10
13
  import { createPlugin } from './pm-plugins/main';
@@ -17,6 +20,19 @@ export let expandPlugin = ({
17
20
  api
18
21
  }) => {
19
22
  var _api$analytics, _api$analytics2;
23
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
24
+ var _api$blockMenu;
25
+ api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents([{
26
+ type: 'block-menu-item',
27
+ key: FORMAT_EXPAND_MENU_ITEM.key,
28
+ parent: {
29
+ type: 'block-menu-section',
30
+ key: FORMAT_MENU_ITEM.key,
31
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_EXPAND_MENU_ITEM.key]
32
+ },
33
+ component: createExpandBlockMenuItem(api)
34
+ }]);
35
+ }
20
36
  return {
21
37
  name: 'expand',
22
38
  nodes() {
@@ -1,6 +1,7 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { expandClassNames } from '@atlaskit/editor-common/styles';
3
3
  import { expandMessages } from '@atlaskit/editor-common/ui';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  export const buildExpandClassName = (type, expanded) => {
5
6
  return `${expandClassNames.prefix} ${expandClassNames.type(type)} ${expanded ? expandClassNames.expanded : ''}`;
6
7
  };
@@ -10,7 +11,10 @@ export const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) =>
10
11
  // prettier-ignore
11
12
  'class': buildExpandClassName(node.type.name, (_expandedState$get = expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false),
12
13
  'data-node-type': node.type.name,
13
- 'data-title': node.attrs.title
14
+ 'data-title': node.attrs.title,
15
+ ...(fg('platform_editor_adf_with_localid') && {
16
+ 'data-local-id': node.attrs.localId
17
+ })
14
18
  }, ['div', {
15
19
  // prettier-ignore
16
20
  'class': expandClassNames.titleContainer,
@@ -0,0 +1,41 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import ExpandElementIcon from '@atlaskit/icon-lab/core/expand-element';
8
+ const nodeName = 'expand';
9
+ const ExpandBlockMenuItem = ({
10
+ api
11
+ }) => {
12
+ const {
13
+ formatMessage
14
+ } = useIntl();
15
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
16
+ const isExpandSelected = useMemo(() => {
17
+ if (!selection) {
18
+ return false;
19
+ }
20
+ if (selection instanceof NodeSelection) {
21
+ return selection.node.type.name === nodeName;
22
+ }
23
+ return false;
24
+ }, [selection]);
25
+ const handleClick = () => {
26
+ var _api$blockMenu;
27
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode(nodeName));
28
+ };
29
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
30
+ onClick: handleClick,
31
+ isSelected: isExpandSelected,
32
+ elemBefore: /*#__PURE__*/React.createElement(ExpandElementIcon, {
33
+ label: ""
34
+ })
35
+ }, formatMessage(toolbarInsertBlockMessages.expand));
36
+ };
37
+ export const createExpandBlockMenuItem = api => {
38
+ return () => /*#__PURE__*/React.createElement(ExpandBlockMenuItem, {
39
+ api: api
40
+ });
41
+ };
@@ -1,6 +1,8 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ 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) { _defineProperty(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; }
4
6
  import React from 'react';
5
7
  import uuid from 'uuid/v4';
6
8
  import { keyName } from 'w3c-keyname';
@@ -19,12 +21,14 @@ function buildExpandClassName(type, expanded) {
19
21
  return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
20
22
  }
21
23
  var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
22
- return ['div', {
24
+ return ['div', _objectSpread({
23
25
  // prettier-ignore
24
26
  'class': buildExpandClassName(node.type.name, __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
25
27
  'data-node-type': node.type.name,
26
28
  'data-title': node.attrs.title
27
- }, ['div', {
29
+ }, fg('platform_editor_adf_with_localid') && {
30
+ 'data-local-id': node.attrs.localId
31
+ }), ['div', {
28
32
  // prettier-ignore
29
33
  'class': expandClassNames.titleContainer,
30
34
  contenteditable: 'false',
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
2
  import { expandWithNestedExpand, nestedExpand } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { FORMAT_MENU_ITEM, FORMAT_EXPAND_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
4
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
6
  import { IconExpand } from '@atlaskit/editor-common/quick-insert';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
8
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
9
+ import { createExpandBlockMenuItem } from '../ui/ExpandBlockMenuItem';
7
10
  import { createExpandNode, insertExpand, insertExpandWithInputMethod, toggleExpandWithMatch as _toggleExpandWithMatch } from './commands';
8
11
  import { expandKeymap } from './pm-plugins/keymap';
9
12
  import { createPlugin } from './pm-plugins/main';
@@ -16,6 +19,19 @@ export var expandPlugin = function expandPlugin(_ref) {
16
19
  var _ref$config = _ref.config,
17
20
  options = _ref$config === void 0 ? {} : _ref$config,
18
21
  api = _ref.api;
22
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
23
+ var _api$blockMenu;
24
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
25
+ type: 'block-menu-item',
26
+ key: FORMAT_EXPAND_MENU_ITEM.key,
27
+ parent: {
28
+ type: 'block-menu-section',
29
+ key: FORMAT_MENU_ITEM.key,
30
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_EXPAND_MENU_ITEM.key]
31
+ },
32
+ component: createExpandBlockMenuItem(api)
33
+ }]);
34
+ }
19
35
  return {
20
36
  name: 'expand',
21
37
  nodes: function nodes() {
@@ -1,10 +1,13 @@
1
1
  import React from 'react';
2
2
  import { expandWithNestedExpand, expandWithNestedExpandLocalId, nestedExpand, nestedExpandWithLocalId } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { FORMAT_MENU_ITEM, FORMAT_EXPAND_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
4
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
6
  import { IconExpand } from '@atlaskit/editor-common/quick-insert';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
+ import { createExpandBlockMenuItem } from '../ui/ExpandBlockMenuItem';
8
11
  import { createExpandNode, insertExpand, insertExpandWithInputMethod, toggleExpandWithMatch as _toggleExpandWithMatch } from './commands';
9
12
  import { expandKeymap } from './pm-plugins/keymap';
10
13
  import { createPlugin } from './pm-plugins/main';
@@ -17,6 +20,19 @@ export var expandPlugin = function expandPlugin(_ref) {
17
20
  var _ref$config = _ref.config,
18
21
  options = _ref$config === void 0 ? {} : _ref$config,
19
22
  api = _ref.api;
23
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
24
+ var _api$blockMenu;
25
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
26
+ type: 'block-menu-item',
27
+ key: FORMAT_EXPAND_MENU_ITEM.key,
28
+ parent: {
29
+ type: 'block-menu-section',
30
+ key: FORMAT_MENU_ITEM.key,
31
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_EXPAND_MENU_ITEM.key]
32
+ },
33
+ component: createExpandBlockMenuItem(api)
34
+ }]);
35
+ }
20
36
  return {
21
37
  name: 'expand',
22
38
  nodes: function nodes() {
@@ -1,17 +1,23 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ 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) { _defineProperty(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; }
1
4
  import { expandedState } from '@atlaskit/editor-common/expand';
2
5
  import { expandClassNames } from '@atlaskit/editor-common/styles';
3
6
  import { expandMessages } from '@atlaskit/editor-common/ui';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
4
8
  export var buildExpandClassName = function buildExpandClassName(type, expanded) {
5
9
  return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
6
10
  };
7
11
  export var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
8
12
  var _expandedState$get;
9
- return ['div', {
13
+ return ['div', _objectSpread({
10
14
  // prettier-ignore
11
15
  'class': buildExpandClassName(node.type.name, (_expandedState$get = expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false),
12
16
  'data-node-type': node.type.name,
13
17
  'data-title': node.attrs.title
14
- }, ['div', {
18
+ }, fg('platform_editor_adf_with_localid') && {
19
+ 'data-local-id': node.attrs.localId
20
+ }), ['div', {
15
21
  // prettier-ignore
16
22
  'class': expandClassNames.titleContainer,
17
23
  contenteditable: 'false',
@@ -0,0 +1,41 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import ExpandElementIcon from '@atlaskit/icon-lab/core/expand-element';
8
+ var nodeName = 'expand';
9
+ var ExpandBlockMenuItem = function ExpandBlockMenuItem(_ref) {
10
+ var api = _ref.api;
11
+ var _useIntl = useIntl(),
12
+ formatMessage = _useIntl.formatMessage;
13
+ var selection = useSharedPluginStateSelector(api, 'selection.selection');
14
+ var isExpandSelected = useMemo(function () {
15
+ if (!selection) {
16
+ return false;
17
+ }
18
+ if (selection instanceof NodeSelection) {
19
+ return selection.node.type.name === nodeName;
20
+ }
21
+ return false;
22
+ }, [selection]);
23
+ var handleClick = function handleClick() {
24
+ var _api$blockMenu;
25
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode(nodeName));
26
+ };
27
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
28
+ onClick: handleClick,
29
+ isSelected: isExpandSelected,
30
+ elemBefore: /*#__PURE__*/React.createElement(ExpandElementIcon, {
31
+ label: ""
32
+ })
33
+ }, formatMessage(toolbarInsertBlockMessages.expand));
34
+ };
35
+ export var createExpandBlockMenuItem = function createExpandBlockMenuItem(api) {
36
+ return function () {
37
+ return /*#__PURE__*/React.createElement(ExpandBlockMenuItem, {
38
+ api: api
39
+ });
40
+ };
41
+ };
@@ -1,6 +1,7 @@
1
1
  import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorAppearance, EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
4
5
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
6
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
6
7
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
@@ -46,7 +47,8 @@ export type ExpandPluginDependencies = [
46
47
  OptionalPlugin<SelectionMarkerPlugin>,
47
48
  OptionalPlugin<EditorDisabledPlugin>,
48
49
  OptionalPlugin<FeatureFlagsPlugin>,
49
- OptionalPlugin<EditorViewModePlugin>
50
+ OptionalPlugin<EditorViewModePlugin>,
51
+ OptionalPlugin<BlockMenuPlugin>
50
52
  ];
51
53
  export type ExpandPlugin = NextEditorPlugin<'expand', {
52
54
  actions: {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ExpandPlugin } from '../types';
4
+ export declare const createExpandBlockMenuItem: (api: ExtractInjectionAPI<ExpandPlugin>) => () => React.JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { EditorAppearance, EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
4
5
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
6
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
6
7
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
@@ -46,7 +47,8 @@ export type ExpandPluginDependencies = [
46
47
  OptionalPlugin<SelectionMarkerPlugin>,
47
48
  OptionalPlugin<EditorDisabledPlugin>,
48
49
  OptionalPlugin<FeatureFlagsPlugin>,
49
- OptionalPlugin<EditorViewModePlugin>
50
+ OptionalPlugin<EditorViewModePlugin>,
51
+ OptionalPlugin<BlockMenuPlugin>
50
52
  ];
51
53
  export type ExpandPlugin = NextEditorPlugin<'expand', {
52
54
  actions: {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ExpandPlugin } from '../types';
4
+ export declare const createExpandBlockMenuItem: (api: ExtractInjectionAPI<ExpandPlugin>) => () => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "4.3.1",
3
+ "version": "5.0.1",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,18 +31,21 @@
31
31
  "dependencies": {
32
32
  "@atlaskit/adf-schema": "^50.2.3",
33
33
  "@atlaskit/button": "^23.4.0",
34
- "@atlaskit/editor-plugin-analytics": "^3.0.0",
35
- "@atlaskit/editor-plugin-decorations": "^3.1.0",
36
- "@atlaskit/editor-plugin-editor-disabled": "^3.0.0",
37
- "@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
38
- "@atlaskit/editor-plugin-selection": "^3.2.0",
39
- "@atlaskit/editor-plugin-selection-marker": "^3.0.0",
34
+ "@atlaskit/editor-plugin-analytics": "^4.0.0",
35
+ "@atlaskit/editor-plugin-block-menu": "^1.0.0",
36
+ "@atlaskit/editor-plugin-decorations": "^4.0.0",
37
+ "@atlaskit/editor-plugin-editor-disabled": "^4.0.0",
38
+ "@atlaskit/editor-plugin-editor-viewmode": "^6.0.0",
39
+ "@atlaskit/editor-plugin-selection": "^4.0.0",
40
+ "@atlaskit/editor-plugin-selection-marker": "^4.0.0",
40
41
  "@atlaskit/editor-prosemirror": "7.0.0",
41
42
  "@atlaskit/editor-shared-styles": "^3.6.0",
42
43
  "@atlaskit/editor-tables": "^2.9.0",
44
+ "@atlaskit/editor-toolbar": "^0.6.0",
43
45
  "@atlaskit/icon": "^28.1.0",
46
+ "@atlaskit/icon-lab": "^5.7.0",
44
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^11.9.0",
48
+ "@atlaskit/tmp-editor-statsig": "^12.0.0",
46
49
  "@atlaskit/tokens": "^6.1.0",
47
50
  "@atlaskit/tooltip": "^20.4.0",
48
51
  "@babel/runtime": "^7.0.0",
@@ -51,19 +54,19 @@
51
54
  "w3c-keyname": "^2.1.8"
52
55
  },
53
56
  "peerDependencies": {
54
- "@atlaskit/editor-common": "^107.33.0",
57
+ "@atlaskit/editor-common": "^108.0.0",
55
58
  "react": "^18.2.0",
56
59
  "react-dom": "^18.2.0",
57
60
  "react-intl-next": "npm:react-intl@^5.18.1"
58
61
  },
59
62
  "devDependencies": {
60
63
  "@atlaskit/analytics-next": "^11.1.0",
61
- "@atlaskit/editor-plugin-content-insertion": "^3.1.0",
62
- "@atlaskit/editor-plugin-guideline": "^3.0.0",
63
- "@atlaskit/editor-plugin-quick-insert": "^3.0.0",
64
- "@atlaskit/editor-plugin-table": "^12.3.0",
65
- "@atlaskit/editor-plugin-type-ahead": "^3.1.0",
66
- "@atlaskit/editor-plugin-width": "^4.0.0",
64
+ "@atlaskit/editor-plugin-content-insertion": "^4.0.0",
65
+ "@atlaskit/editor-plugin-guideline": "^4.0.0",
66
+ "@atlaskit/editor-plugin-quick-insert": "^4.0.0",
67
+ "@atlaskit/editor-plugin-table": "^13.0.0",
68
+ "@atlaskit/editor-plugin-type-ahead": "^4.0.0",
69
+ "@atlaskit/editor-plugin-width": "^5.0.0",
67
70
  "@testing-library/react": "^13.4.0",
68
71
  "react-test-renderer": "^18.2.0"
69
72
  },