@atlaskit/editor-plugin-layout 3.2.2 → 4.0.0

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,13 @@
1
1
  # @atlaskit/editor-plugin-layout
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e882e86092666`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e882e86092666) -
8
+ [ux] Register expand, layout and code block itmes in block menu. Update panel item.
9
+ - Updated dependencies
10
+
3
11
  ## 3.2.2
4
12
 
5
13
  ### Patch Changes
@@ -9,17 +9,20 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _schema = require("@atlaskit/adf-schema/schema");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
12
13
  var _messages = require("@atlaskit/editor-common/messages");
13
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
14
15
  var _state = require("@atlaskit/editor-prosemirror/state");
15
16
  var _utils = require("@atlaskit/editor-prosemirror/utils");
16
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
17
19
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
20
  var _actions = require("./pm-plugins/actions");
19
21
  var _main = _interopRequireDefault(require("./pm-plugins/main"));
20
22
  var _pluginKey = require("./pm-plugins/plugin-key");
21
23
  var _resizing = _interopRequireDefault(require("./pm-plugins/resizing"));
22
24
  var _globalStyles = require("./ui/global-styles");
25
+ var _LayoutBlockMenuItem = require("./ui/LayoutBlockMenuItem");
23
26
  var _toolbar = require("./ui/toolbar");
24
27
  /**
25
28
  * This function is used to set the selection into
@@ -56,6 +59,19 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
56
59
  var allowAdvancedSingleColumnLayout = (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _experiments.editorExperiment)('single_column_layouts', true, {
57
60
  exposure: true
58
61
  });
62
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
63
+ var _api$blockMenu;
64
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
65
+ type: 'block-menu-item',
66
+ key: _blockMenu.FORMAT_LAYOUT_MENU_ITEM.key,
67
+ parent: {
68
+ type: 'block-menu-section',
69
+ key: _blockMenu.FORMAT_MENU_ITEM.key,
70
+ rank: _blockMenu.FORMAT_NESTED_MENU_RANK[_blockMenu.FORMAT_LAYOUT_MENU_ITEM.key]
71
+ },
72
+ component: (0, _LayoutBlockMenuItem.createLayoutBlockMenuItem)(api)
73
+ }]);
74
+ }
59
75
  return {
60
76
  name: 'layout',
61
77
  nodes: function nodes() {
@@ -0,0 +1,49 @@
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.createLayoutBlockMenuItem = 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 _layoutTwoColumns = _interopRequireDefault(require("@atlaskit/icon/core/layout-two-columns"));
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 LayoutBlockMenuItem = function LayoutBlockMenuItem(_ref) {
18
+ var api = _ref.api;
19
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
20
+ formatMessage = _useIntl.formatMessage;
21
+ var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
22
+ var isLayoutSelected = (0, _react.useMemo)(function () {
23
+ if (!selection) {
24
+ return false;
25
+ }
26
+ if (selection instanceof _state.NodeSelection) {
27
+ return selection.node.type.name === 'layoutSection';
28
+ }
29
+ return false;
30
+ }, [selection]);
31
+ var handleClick = function handleClick() {
32
+ var _api$blockMenu;
33
+ 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('layout'));
34
+ };
35
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
36
+ onClick: handleClick,
37
+ isSelected: isLayoutSelected,
38
+ elemBefore: /*#__PURE__*/_react.default.createElement(_layoutTwoColumns.default, {
39
+ label: ""
40
+ })
41
+ }, formatMessage(_messages.blockMenuMessages.layout));
42
+ };
43
+ var createLayoutBlockMenuItem = exports.createLayoutBlockMenuItem = function createLayoutBlockMenuItem(api) {
44
+ return function () {
45
+ return /*#__PURE__*/_react.default.createElement(LayoutBlockMenuItem, {
46
+ api: api
47
+ });
48
+ };
49
+ };
@@ -2,17 +2,20 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection, layoutColumnWithLocalId, layoutSectionWithLocalId } from '@atlaskit/adf-schema';
3
3
  import { layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from '@atlaskit/adf-schema/schema';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { FORMAT_MENU_ITEM, FORMAT_LAYOUT_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
5
6
  import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
7
  import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
7
8
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
13
  import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
12
14
  import { default as createLayoutPlugin } from './pm-plugins/main';
13
15
  import { pluginKey } from './pm-plugins/plugin-key';
14
16
  import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
15
17
  import { GlobalStylesWrapper } from './ui/global-styles';
18
+ import { createLayoutBlockMenuItem } from './ui/LayoutBlockMenuItem';
16
19
  import { buildToolbar } from './ui/toolbar';
17
20
 
18
21
  /**
@@ -49,6 +52,19 @@ export const layoutPlugin = ({
49
52
  const allowAdvancedSingleColumnLayout = editorExperiment('advanced_layouts', true) && editorExperiment('single_column_layouts', true, {
50
53
  exposure: true
51
54
  });
55
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
56
+ var _api$blockMenu;
57
+ api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents([{
58
+ type: 'block-menu-item',
59
+ key: FORMAT_LAYOUT_MENU_ITEM.key,
60
+ parent: {
61
+ type: 'block-menu-section',
62
+ key: FORMAT_MENU_ITEM.key,
63
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_LAYOUT_MENU_ITEM.key]
64
+ },
65
+ component: createLayoutBlockMenuItem(api)
66
+ }]);
67
+ }
52
68
  return {
53
69
  name: 'layout',
54
70
  nodes() {
@@ -0,0 +1,40 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { blockMenuMessages } 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 LayoutTwoColumnsIcon from '@atlaskit/icon/core/layout-two-columns';
8
+ const LayoutBlockMenuItem = ({
9
+ api
10
+ }) => {
11
+ const {
12
+ formatMessage
13
+ } = useIntl();
14
+ const selection = useSharedPluginStateSelector(api, 'selection.selection');
15
+ const isLayoutSelected = useMemo(() => {
16
+ if (!selection) {
17
+ return false;
18
+ }
19
+ if (selection instanceof NodeSelection) {
20
+ return selection.node.type.name === 'layoutSection';
21
+ }
22
+ return false;
23
+ }, [selection]);
24
+ const handleClick = () => {
25
+ var _api$blockMenu;
26
+ 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('layout'));
27
+ };
28
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
29
+ onClick: handleClick,
30
+ isSelected: isLayoutSelected,
31
+ elemBefore: /*#__PURE__*/React.createElement(LayoutTwoColumnsIcon, {
32
+ label: ""
33
+ })
34
+ }, formatMessage(blockMenuMessages.layout));
35
+ };
36
+ export const createLayoutBlockMenuItem = api => {
37
+ return () => /*#__PURE__*/React.createElement(LayoutBlockMenuItem, {
38
+ api: api
39
+ });
40
+ };
@@ -2,17 +2,20 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection, layoutColumnWithLocalId, layoutSectionWithLocalId } from '@atlaskit/adf-schema';
3
3
  import { layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from '@atlaskit/adf-schema/schema';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { FORMAT_MENU_ITEM, FORMAT_LAYOUT_MENU_ITEM, FORMAT_NESTED_MENU_RANK } from '@atlaskit/editor-common/block-menu';
5
6
  import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
7
  import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
7
8
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
13
  import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
12
14
  import { default as createLayoutPlugin } from './pm-plugins/main';
13
15
  import { pluginKey } from './pm-plugins/plugin-key';
14
16
  import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
15
17
  import { GlobalStylesWrapper } from './ui/global-styles';
18
+ import { createLayoutBlockMenuItem } from './ui/LayoutBlockMenuItem';
16
19
  import { buildToolbar } from './ui/toolbar';
17
20
 
18
21
  /**
@@ -50,6 +53,19 @@ export var layoutPlugin = function layoutPlugin(_ref) {
50
53
  var allowAdvancedSingleColumnLayout = editorExperiment('advanced_layouts', true) && editorExperiment('single_column_layouts', true, {
51
54
  exposure: true
52
55
  });
56
+ if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
57
+ var _api$blockMenu;
58
+ api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
59
+ type: 'block-menu-item',
60
+ key: FORMAT_LAYOUT_MENU_ITEM.key,
61
+ parent: {
62
+ type: 'block-menu-section',
63
+ key: FORMAT_MENU_ITEM.key,
64
+ rank: FORMAT_NESTED_MENU_RANK[FORMAT_LAYOUT_MENU_ITEM.key]
65
+ },
66
+ component: createLayoutBlockMenuItem(api)
67
+ }]);
68
+ }
53
69
  return {
54
70
  name: 'layout',
55
71
  nodes: function nodes() {
@@ -0,0 +1,40 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { blockMenuMessages } 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 LayoutTwoColumnsIcon from '@atlaskit/icon/core/layout-two-columns';
8
+ var LayoutBlockMenuItem = function LayoutBlockMenuItem(_ref) {
9
+ var api = _ref.api;
10
+ var _useIntl = useIntl(),
11
+ formatMessage = _useIntl.formatMessage;
12
+ var selection = useSharedPluginStateSelector(api, 'selection.selection');
13
+ var isLayoutSelected = useMemo(function () {
14
+ if (!selection) {
15
+ return false;
16
+ }
17
+ if (selection instanceof NodeSelection) {
18
+ return selection.node.type.name === 'layoutSection';
19
+ }
20
+ return false;
21
+ }, [selection]);
22
+ var handleClick = function handleClick() {
23
+ var _api$blockMenu;
24
+ 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('layout'));
25
+ };
26
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
27
+ onClick: handleClick,
28
+ isSelected: isLayoutSelected,
29
+ elemBefore: /*#__PURE__*/React.createElement(LayoutTwoColumnsIcon, {
30
+ label: ""
31
+ })
32
+ }, formatMessage(blockMenuMessages.layout));
33
+ };
34
+ export var createLayoutBlockMenuItem = function createLayoutBlockMenuItem(api) {
35
+ return function () {
36
+ return /*#__PURE__*/React.createElement(LayoutBlockMenuItem, {
37
+ api: api
38
+ });
39
+ };
40
+ };
@@ -1,5 +1,6 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
3
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
5
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
6
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
@@ -15,7 +16,8 @@ export type LayoutPluginDependencies = [
15
16
  OptionalPlugin<WidthPlugin>,
16
17
  OptionalPlugin<EditorDisabledPlugin>,
17
18
  OptionalPlugin<GuidelinePlugin>,
18
- OptionalPlugin<InteractionPlugin>
19
+ OptionalPlugin<InteractionPlugin>,
20
+ OptionalPlugin<BlockMenuPlugin>
19
21
  ];
20
22
  export type LayoutPlugin = NextEditorPlugin<'layout', {
21
23
  actions: {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { LayoutPlugin } from '../layoutPluginType';
4
+ export declare const createLayoutBlockMenuItem: (api: ExtractInjectionAPI<LayoutPlugin>) => () => React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
3
4
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
5
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
6
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
@@ -15,7 +16,8 @@ export type LayoutPluginDependencies = [
15
16
  OptionalPlugin<WidthPlugin>,
16
17
  OptionalPlugin<EditorDisabledPlugin>,
17
18
  OptionalPlugin<GuidelinePlugin>,
18
- OptionalPlugin<InteractionPlugin>
19
+ OptionalPlugin<InteractionPlugin>,
20
+ OptionalPlugin<BlockMenuPlugin>
19
21
  ];
20
22
  export type LayoutPlugin = NextEditorPlugin<'layout', {
21
23
  actions: {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { LayoutPlugin } from '../layoutPluginType';
4
+ export declare const createLayoutBlockMenuItem: (api: ExtractInjectionAPI<LayoutPlugin>) => () => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-layout",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "description": "Layout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,25 +30,27 @@
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
32
  "@atlaskit/adf-schema": "^50.2.3",
33
- "@atlaskit/editor-plugin-analytics": "^3.0.0",
34
- "@atlaskit/editor-plugin-decorations": "^3.1.0",
35
- "@atlaskit/editor-plugin-editor-disabled": "^3.0.0",
36
- "@atlaskit/editor-plugin-guideline": "^3.0.0",
37
- "@atlaskit/editor-plugin-interaction": "^5.0.0",
38
- "@atlaskit/editor-plugin-selection": "^3.2.0",
39
- "@atlaskit/editor-plugin-width": "^4.0.0",
33
+ "@atlaskit/editor-plugin-analytics": "^4.0.0",
34
+ "@atlaskit/editor-plugin-block-menu": "^1.0.0",
35
+ "@atlaskit/editor-plugin-decorations": "^4.0.0",
36
+ "@atlaskit/editor-plugin-editor-disabled": "^4.0.0",
37
+ "@atlaskit/editor-plugin-guideline": "^4.0.0",
38
+ "@atlaskit/editor-plugin-interaction": "^6.0.0",
39
+ "@atlaskit/editor-plugin-selection": "^4.0.0",
40
+ "@atlaskit/editor-plugin-width": "^5.0.0",
40
41
  "@atlaskit/editor-prosemirror": "7.0.0",
41
42
  "@atlaskit/editor-shared-styles": "^3.6.0",
43
+ "@atlaskit/editor-toolbar": "^0.6.0",
42
44
  "@atlaskit/icon": "^28.1.0",
43
45
  "@atlaskit/icon-lab": "^5.7.0",
44
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^11.9.0",
47
+ "@atlaskit/tmp-editor-statsig": "^12.0.0",
46
48
  "@atlaskit/tokens": "^6.1.0",
47
49
  "@babel/runtime": "^7.0.0",
48
50
  "@emotion/react": "^11.7.1"
49
51
  },
50
52
  "peerDependencies": {
51
- "@atlaskit/editor-common": "^107.33.0",
53
+ "@atlaskit/editor-common": "^108.0.0",
52
54
  "react": "^18.2.0",
53
55
  "react-intl-next": "npm:react-intl@^5.18.1"
54
56
  },