@atlaskit/editor-plugin-block-menu 4.0.10 → 4.0.12

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-block-menu
2
2
 
3
+ ## 4.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1f3aae72424a3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f3aae72424a3) -
8
+ ED-29742 Set focus at drag handle when drag handle is clicked and don't refocus on editor to fix
9
+ arrow key setting new selection instead of keyboard nav
10
+
11
+ ## 4.0.11
12
+
13
+ ### Patch Changes
14
+
15
+ - [`7011f9be6a430`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7011f9be6a430) -
16
+ [ux] EDITOR-1653 add create synced block item to the block menu
17
+ - Updated dependencies
18
+
3
19
  ## 4.0.10
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AddBlocksSection = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
10
+ var AddBlocksSection = exports.AddBlocksSection = function AddBlocksSection(_ref) {
11
+ var _api$selection;
12
+ var api = _ref.api,
13
+ children = _ref.children;
14
+ var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
15
+ if (!(selection !== null && selection !== void 0 && selection.empty)) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
19
+ hasSeparator: true
20
+ }, children);
21
+ };
@@ -9,6 +9,8 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _blockMenu = require("@atlaskit/editor-common/block-menu");
11
11
  var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
+ var _addBlocksSection = require("./add-blocks-section");
12
14
  var _copyBlock = _interopRequireDefault(require("./copy-block"));
13
15
  var _copyLink = require("./copy-link");
14
16
  var _copySection = require("./copy-section");
@@ -95,12 +97,22 @@ var getFormatMenuComponents = function getFormatMenuComponents(api) {
95
97
  var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockMenuComponents(_ref4) {
96
98
  var api = _ref4.api,
97
99
  config = _ref4.config;
98
- return [].concat((0, _toConsumableArray2.default)(getFormatMenuComponents(api)), [{
100
+ return [].concat((0, _toConsumableArray2.default)(getFormatMenuComponents(api)), (0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) ? [{
99
101
  type: 'block-menu-section',
100
- key: _blockMenu.COPY_MENU_SECTION.key,
101
- rank: _blockMenu.BLOCK_MENU_SECTION_RANK[_blockMenu.COPY_MENU_SECTION.key],
102
+ key: _blockMenu.ADD_BLOCKS_MENU_SECTION.key,
103
+ rank: _blockMenu.BLOCK_MENU_SECTION_RANK[_blockMenu.ADD_BLOCKS_MENU_SECTION.key],
102
104
  component: function component(_ref5) {
103
105
  var children = _ref5.children;
106
+ return /*#__PURE__*/_react.default.createElement(_addBlocksSection.AddBlocksSection, {
107
+ api: api
108
+ }, " ", children, " ");
109
+ }
110
+ }] : []), [{
111
+ type: 'block-menu-section',
112
+ key: _blockMenu.COPY_MENU_SECTION.key,
113
+ rank: _blockMenu.BLOCK_MENU_SECTION_RANK[_blockMenu.COPY_MENU_SECTION.key],
114
+ component: function component(_ref6) {
115
+ var children = _ref6.children;
104
116
  return /*#__PURE__*/_react.default.createElement(_copySection.CopySection, {
105
117
  api: api
106
118
  }, children);
@@ -136,8 +148,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
136
148
  type: 'block-menu-section',
137
149
  key: _blockMenu.MOVE_UP_DOWN_MENU_SECTION.key,
138
150
  rank: _blockMenu.BLOCK_MENU_SECTION_RANK[_blockMenu.MOVE_UP_DOWN_MENU_SECTION.key],
139
- component: function component(_ref6) {
140
- var children = _ref6.children;
151
+ component: function component(_ref7) {
152
+ var children = _ref7.children;
141
153
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
142
154
  hasSeparator: true
143
155
  }, children);
@@ -146,8 +158,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
146
158
  type: 'block-menu-section',
147
159
  key: _blockMenu.DELETE_MENU_SECTION.key,
148
160
  rank: _blockMenu.BLOCK_MENU_SECTION_RANK[_blockMenu.DELETE_MENU_SECTION.key],
149
- component: function component(_ref7) {
150
- var children = _ref7.children;
161
+ component: function component(_ref8) {
162
+ var children = _ref8.children;
151
163
  return /*#__PURE__*/_react.default.createElement(_deleteSection.DeleteSection, {
152
164
  api: api
153
165
  }, children);
@@ -153,7 +153,9 @@ var BlockMenu = function BlockMenu(_ref2) {
153
153
  stick: true,
154
154
  focusTrap: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? openedViaKeyboard ? {
155
155
  initialFocus: undefined
156
- } : true : undefined,
156
+ } : {
157
+ initialFocus: targetHandleRef
158
+ } : undefined,
157
159
  offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
158
160
  }, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
159
161
  api: api
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ export const AddBlocksSection = ({
4
+ api,
5
+ children
6
+ }) => {
7
+ var _api$selection, _api$selection$shared, _api$selection$shared2;
8
+ const selection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$shared = _api$selection.sharedState) === null || _api$selection$shared === void 0 ? void 0 : (_api$selection$shared2 = _api$selection$shared.currentState()) === null || _api$selection$shared2 === void 0 ? void 0 : _api$selection$shared2.selection;
9
+ if (!(selection !== null && selection !== void 0 && selection.empty)) {
10
+ return null;
11
+ }
12
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
13
+ hasSeparator: true
14
+ }, children);
15
+ };
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
- import { MOVE_UP_MENU_ITEM, MOVE_UP_DOWN_MENU_SECTION, MOVE_DOWN_MENU_ITEM, MOVE_BLOCK_SECTION_RANK, PRIMARY_MENU_SECTION, BLOCK_MENU_SECTION_RANK, COPY_MENU_SECTION, COPY_BLOCK_MENU_ITEM, COPY_MENU_SECTION_RANK, COPY_LINK_MENU_ITEM, DELETE_MENU_SECTION, DELETE_MENU_ITEM, DELETE_SECTION_RANK, NESTED_FORMAT_MENU_SECTION, NESTED_FORMAT_MENU } from '@atlaskit/editor-common/block-menu';
2
+ import { ADD_BLOCKS_MENU_SECTION, MOVE_UP_MENU_ITEM, MOVE_UP_DOWN_MENU_SECTION, MOVE_DOWN_MENU_ITEM, MOVE_BLOCK_SECTION_RANK, PRIMARY_MENU_SECTION, BLOCK_MENU_SECTION_RANK, COPY_MENU_SECTION, COPY_BLOCK_MENU_ITEM, COPY_MENU_SECTION_RANK, COPY_LINK_MENU_ITEM, DELETE_MENU_SECTION, DELETE_MENU_ITEM, DELETE_SECTION_RANK, NESTED_FORMAT_MENU_SECTION, NESTED_FORMAT_MENU } from '@atlaskit/editor-common/block-menu';
3
3
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { AddBlocksSection } from './add-blocks-section';
4
6
  import CopyBlockMenuItem from './copy-block';
5
7
  import { CopyLinkDropdownItem } from './copy-link';
6
8
  import { CopySection } from './copy-section';
@@ -85,7 +87,16 @@ export const getBlockMenuComponents = ({
85
87
  api,
86
88
  config
87
89
  }) => {
88
- return [...getFormatMenuComponents(api), {
90
+ return [...getFormatMenuComponents(api), ...(expValEquals('platform_synced_block', 'isEnabled', true) ? [{
91
+ type: 'block-menu-section',
92
+ key: ADD_BLOCKS_MENU_SECTION.key,
93
+ rank: BLOCK_MENU_SECTION_RANK[ADD_BLOCKS_MENU_SECTION.key],
94
+ component: ({
95
+ children
96
+ }) => /*#__PURE__*/React.createElement(AddBlocksSection, {
97
+ api: api
98
+ }, " ", children, " ")
99
+ }] : []), {
89
100
  type: 'block-menu-section',
90
101
  key: COPY_MENU_SECTION.key,
91
102
  rank: BLOCK_MENU_SECTION_RANK[COPY_MENU_SECTION.key],
@@ -144,7 +144,9 @@ const BlockMenu = ({
144
144
  stick: true,
145
145
  focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? openedViaKeyboard ? {
146
146
  initialFocus: undefined
147
- } : true : undefined,
147
+ } : {
148
+ initialFocus: targetHandleRef
149
+ } : undefined,
148
150
  offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
149
151
  }, /*#__PURE__*/React.createElement(BlockMenuContent, {
150
152
  api: api
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ export var AddBlocksSection = function AddBlocksSection(_ref) {
4
+ var _api$selection;
5
+ var api = _ref.api,
6
+ children = _ref.children;
7
+ var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
8
+ if (!(selection !== null && selection !== void 0 && selection.empty)) {
9
+ return null;
10
+ }
11
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
12
+ hasSeparator: true
13
+ }, children);
14
+ };
@@ -1,7 +1,9 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import React from 'react';
3
- import { MOVE_UP_MENU_ITEM, MOVE_UP_DOWN_MENU_SECTION, MOVE_DOWN_MENU_ITEM, MOVE_BLOCK_SECTION_RANK, PRIMARY_MENU_SECTION, BLOCK_MENU_SECTION_RANK, COPY_MENU_SECTION, COPY_BLOCK_MENU_ITEM, COPY_MENU_SECTION_RANK, COPY_LINK_MENU_ITEM, DELETE_MENU_SECTION, DELETE_MENU_ITEM, DELETE_SECTION_RANK, NESTED_FORMAT_MENU_SECTION, NESTED_FORMAT_MENU } from '@atlaskit/editor-common/block-menu';
3
+ import { ADD_BLOCKS_MENU_SECTION, MOVE_UP_MENU_ITEM, MOVE_UP_DOWN_MENU_SECTION, MOVE_DOWN_MENU_ITEM, MOVE_BLOCK_SECTION_RANK, PRIMARY_MENU_SECTION, BLOCK_MENU_SECTION_RANK, COPY_MENU_SECTION, COPY_BLOCK_MENU_ITEM, COPY_MENU_SECTION_RANK, COPY_LINK_MENU_ITEM, DELETE_MENU_SECTION, DELETE_MENU_ITEM, DELETE_SECTION_RANK, NESTED_FORMAT_MENU_SECTION, NESTED_FORMAT_MENU } from '@atlaskit/editor-common/block-menu';
4
4
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
+ import { AddBlocksSection } from './add-blocks-section';
5
7
  import CopyBlockMenuItem from './copy-block';
6
8
  import { CopyLinkDropdownItem } from './copy-link';
7
9
  import { CopySection } from './copy-section';
@@ -88,12 +90,22 @@ var getFormatMenuComponents = function getFormatMenuComponents(api) {
88
90
  export var getBlockMenuComponents = function getBlockMenuComponents(_ref4) {
89
91
  var api = _ref4.api,
90
92
  config = _ref4.config;
91
- return [].concat(_toConsumableArray(getFormatMenuComponents(api)), [{
93
+ return [].concat(_toConsumableArray(getFormatMenuComponents(api)), _toConsumableArray(expValEquals('platform_synced_block', 'isEnabled', true) ? [{
92
94
  type: 'block-menu-section',
93
- key: COPY_MENU_SECTION.key,
94
- rank: BLOCK_MENU_SECTION_RANK[COPY_MENU_SECTION.key],
95
+ key: ADD_BLOCKS_MENU_SECTION.key,
96
+ rank: BLOCK_MENU_SECTION_RANK[ADD_BLOCKS_MENU_SECTION.key],
95
97
  component: function component(_ref5) {
96
98
  var children = _ref5.children;
99
+ return /*#__PURE__*/React.createElement(AddBlocksSection, {
100
+ api: api
101
+ }, " ", children, " ");
102
+ }
103
+ }] : []), [{
104
+ type: 'block-menu-section',
105
+ key: COPY_MENU_SECTION.key,
106
+ rank: BLOCK_MENU_SECTION_RANK[COPY_MENU_SECTION.key],
107
+ component: function component(_ref6) {
108
+ var children = _ref6.children;
97
109
  return /*#__PURE__*/React.createElement(CopySection, {
98
110
  api: api
99
111
  }, children);
@@ -129,8 +141,8 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref4) {
129
141
  type: 'block-menu-section',
130
142
  key: MOVE_UP_DOWN_MENU_SECTION.key,
131
143
  rank: BLOCK_MENU_SECTION_RANK[MOVE_UP_DOWN_MENU_SECTION.key],
132
- component: function component(_ref6) {
133
- var children = _ref6.children;
144
+ component: function component(_ref7) {
145
+ var children = _ref7.children;
134
146
  return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
135
147
  hasSeparator: true
136
148
  }, children);
@@ -139,8 +151,8 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref4) {
139
151
  type: 'block-menu-section',
140
152
  key: DELETE_MENU_SECTION.key,
141
153
  rank: BLOCK_MENU_SECTION_RANK[DELETE_MENU_SECTION.key],
142
- component: function component(_ref7) {
143
- var children = _ref7.children;
154
+ component: function component(_ref8) {
155
+ var children = _ref8.children;
144
156
  return /*#__PURE__*/React.createElement(DeleteSection, {
145
157
  api: api
146
158
  }, children);
@@ -145,7 +145,9 @@ var BlockMenu = function BlockMenu(_ref2) {
145
145
  stick: true,
146
146
  focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? openedViaKeyboard ? {
147
147
  initialFocus: undefined
148
- } : true : undefined,
148
+ } : {
149
+ initialFocus: targetHandleRef
150
+ } : undefined,
149
151
  offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
150
152
  }, /*#__PURE__*/React.createElement(BlockMenuContent, {
151
153
  api: api
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
+ export declare const AddBlocksSection: ({ api, children, }: {
5
+ api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
6
+ children: React.ReactNode;
7
+ }) => React.JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
+ export declare const AddBlocksSection: ({ api, children, }: {
5
+ api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
6
+ children: React.ReactNode;
7
+ }) => React.JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,12 +38,12 @@
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
39
  "@atlaskit/editor-shared-styles": "^3.6.0",
40
40
  "@atlaskit/editor-tables": "^2.9.0",
41
- "@atlaskit/editor-toolbar": "^0.12.0",
42
- "@atlaskit/icon": "^28.3.0",
43
- "@atlaskit/icon-lab": "^5.8.0",
41
+ "@atlaskit/editor-toolbar": "^0.13.0",
42
+ "@atlaskit/icon": "^28.4.0",
43
+ "@atlaskit/icon-lab": "^5.9.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/primitives": "^14.15.0",
46
- "@atlaskit/tmp-editor-statsig": "^13.1.0",
46
+ "@atlaskit/tmp-editor-statsig": "^13.2.0",
47
47
  "@atlaskit/tokens": "^6.4.0",
48
48
  "@babel/runtime": "^7.0.0"
49
49
  },