@atlaskit/editor-plugin-block-controls 7.10.2 → 7.11.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 +11 -0
- package/dist/cjs/blockControlsPlugin.js +5 -26
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/ui/consts.js +2 -7
- package/dist/cjs/ui/drag-handle.js +17 -57
- package/dist/es2019/blockControlsPlugin.js +5 -27
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/ui/consts.js +1 -6
- package/dist/es2019/ui/drag-handle.js +15 -55
- package/dist/esm/blockControlsPlugin.js +5 -26
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/ui/consts.js +1 -6
- package/dist/esm/ui/drag-handle.js +15 -55
- package/dist/types/ui/consts.d.ts +0 -2
- package/dist/types-ts4.5/ui/consts.d.ts +0 -2
- package/package.json +2 -2
- package/dist/cjs/ui/block-menu-items.js +0 -90
- package/dist/cjs/ui/block-menu.js +0 -110
- package/dist/es2019/ui/block-menu-items.js +0 -82
- package/dist/es2019/ui/block-menu.js +0 -108
- package/dist/esm/ui/block-menu-items.js +0 -82
- package/dist/esm/ui/block-menu.js +0 -102
- package/dist/types/ui/block-menu-items.d.ts +0 -15
- package/dist/types/ui/block-menu.d.ts +0 -16
- package/dist/types-ts4.5/ui/block-menu-items.d.ts +0 -15
- package/dist/types-ts4.5/ui/block-menu.d.ts +0 -16
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { injectIntl } from 'react-intl-next';
|
|
3
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
-
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
import { getBlockMenuItems, menuItemsCallback } from './block-menu-items';
|
|
8
|
-
import { BLOCK_MENU_WIDTH } from './consts';
|
|
9
|
-
import { getAnchorAttrName } from './utils/dom-attr-name';
|
|
10
|
-
var BlockMenuContent = function BlockMenuContent(_ref) {
|
|
11
|
-
var editorView = _ref.editorView,
|
|
12
|
-
mountPoint = _ref.mountPoint,
|
|
13
|
-
boundariesElement = _ref.boundariesElement,
|
|
14
|
-
scrollableElement = _ref.scrollableElement,
|
|
15
|
-
api = _ref.api,
|
|
16
|
-
menuTriggerBy = _ref.menuTriggerBy,
|
|
17
|
-
formatMessage = _ref.formatMessage;
|
|
18
|
-
var activeNodeSelector = "[".concat(getAnchorAttrName(), "=").concat(menuTriggerBy, "]");
|
|
19
|
-
var targetHandleRef = document.querySelector(activeNodeSelector);
|
|
20
|
-
var items = getBlockMenuItems(formatMessage);
|
|
21
|
-
var handleOpenChange = useCallback(function (payload) {
|
|
22
|
-
if (!(payload !== null && payload !== void 0 && payload.isOpen)) {
|
|
23
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
24
|
-
closeMenu: true
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
}, [api === null || api === void 0 ? void 0 : api.core.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands]);
|
|
28
|
-
var onMenuItemActivated = useCallback(function (_ref2) {
|
|
29
|
-
var item = _ref2.item;
|
|
30
|
-
if (editorView) {
|
|
31
|
-
var _menuItemsCallback, _menuItemsCallback$ca;
|
|
32
|
-
(_menuItemsCallback = menuItemsCallback[item.value.name]) === null || _menuItemsCallback === void 0 || (_menuItemsCallback$ca = _menuItemsCallback.call(menuItemsCallback, api, formatMessage)) === null || _menuItemsCallback$ca === void 0 || _menuItemsCallback$ca(editorView.state, editorView.dispatch, editorView);
|
|
33
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
34
|
-
closeMenu: true
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
}, [api, editorView, formatMessage]);
|
|
38
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
|
39
|
-
alignX: 'left',
|
|
40
|
-
alignY: 'start'
|
|
41
|
-
// Ignored via go/ees005
|
|
42
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
43
|
-
,
|
|
44
|
-
target: targetHandleRef,
|
|
45
|
-
mountTo: undefined,
|
|
46
|
-
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
47
|
-
forcePlacement: true,
|
|
48
|
-
stick: true,
|
|
49
|
-
offset: [-6, 8]
|
|
50
|
-
}, /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
51
|
-
mountTo: mountPoint,
|
|
52
|
-
boundariesElement: boundariesElement,
|
|
53
|
-
scrollableElement: scrollableElement
|
|
54
|
-
//This needs be removed when the a11y is completely handled
|
|
55
|
-
//Disabling key navigation now as it works only partially
|
|
56
|
-
,
|
|
57
|
-
arrowKeyNavigationProviderOptions: {
|
|
58
|
-
type: ArrowKeyNavigationType.MENU
|
|
59
|
-
},
|
|
60
|
-
items: items,
|
|
61
|
-
isOpen: true,
|
|
62
|
-
fitWidth: BLOCK_MENU_WIDTH,
|
|
63
|
-
section: {
|
|
64
|
-
hasSeparator: true
|
|
65
|
-
},
|
|
66
|
-
onOpenChange: handleOpenChange,
|
|
67
|
-
onItemActivated: onMenuItemActivated
|
|
68
|
-
}));
|
|
69
|
-
};
|
|
70
|
-
var BlockMenu = function BlockMenu(_ref3) {
|
|
71
|
-
var editorView = _ref3.editorView,
|
|
72
|
-
mountPoint = _ref3.mountPoint,
|
|
73
|
-
boundariesElement = _ref3.boundariesElement,
|
|
74
|
-
scrollableElement = _ref3.scrollableElement,
|
|
75
|
-
api = _ref3.api,
|
|
76
|
-
formatMessage = _ref3.intl.formatMessage;
|
|
77
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
78
|
-
var _states$blockControls, _states$blockControls2;
|
|
79
|
-
return {
|
|
80
|
-
isMenuOpen: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isMenuOpen,
|
|
81
|
-
menuTriggerBy: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.menuTriggerBy
|
|
82
|
-
};
|
|
83
|
-
}),
|
|
84
|
-
isMenuOpen = _useSharedPluginState.isMenuOpen,
|
|
85
|
-
menuTriggerBy = _useSharedPluginState.menuTriggerBy;
|
|
86
|
-
if (isMenuOpen) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
if (!menuTriggerBy) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return /*#__PURE__*/React.createElement(BlockMenuContent, {
|
|
93
|
-
editorView: editorView,
|
|
94
|
-
mountPoint: mountPoint,
|
|
95
|
-
boundariesElement: boundariesElement,
|
|
96
|
-
scrollableElement: scrollableElement,
|
|
97
|
-
api: api,
|
|
98
|
-
menuTriggerBy: menuTriggerBy,
|
|
99
|
-
formatMessage: formatMessage
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
export default injectIntl(BlockMenu);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import type { IntlShape } from 'react-intl-next';
|
|
6
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
-
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
8
|
-
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
9
|
-
export declare const getBlockMenuItems: (formatMessage: IntlShape["formatMessage"]) => {
|
|
10
|
-
items: MenuItem[];
|
|
11
|
-
}[];
|
|
12
|
-
export declare const menuItemsCallback: {
|
|
13
|
-
moveUp: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape["formatMessage"]) => import("@atlaskit/editor-common/types").Command;
|
|
14
|
-
moveDown: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape["formatMessage"]) => import("@atlaskit/editor-common/types").Command;
|
|
15
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
|
-
type BlockMenuProps = {
|
|
7
|
-
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
8
|
-
boundariesElement?: HTMLElement;
|
|
9
|
-
editorView: EditorView | undefined;
|
|
10
|
-
mountPoint?: HTMLElement;
|
|
11
|
-
scrollableElement?: HTMLElement;
|
|
12
|
-
};
|
|
13
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<BlockMenuProps & WrappedComponentProps>> & {
|
|
14
|
-
WrappedComponent: React.ComponentType<BlockMenuProps & WrappedComponentProps>;
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import type { IntlShape } from 'react-intl-next';
|
|
6
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
-
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
8
|
-
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
9
|
-
export declare const getBlockMenuItems: (formatMessage: IntlShape["formatMessage"]) => {
|
|
10
|
-
items: MenuItem[];
|
|
11
|
-
}[];
|
|
12
|
-
export declare const menuItemsCallback: {
|
|
13
|
-
moveUp: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape["formatMessage"]) => import("@atlaskit/editor-common/types").Command;
|
|
14
|
-
moveDown: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape["formatMessage"]) => import("@atlaskit/editor-common/types").Command;
|
|
15
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
|
-
type BlockMenuProps = {
|
|
7
|
-
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
8
|
-
boundariesElement?: HTMLElement;
|
|
9
|
-
editorView: EditorView | undefined;
|
|
10
|
-
mountPoint?: HTMLElement;
|
|
11
|
-
scrollableElement?: HTMLElement;
|
|
12
|
-
};
|
|
13
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<BlockMenuProps & WrappedComponentProps>> & {
|
|
14
|
-
WrappedComponent: React.ComponentType<BlockMenuProps & WrappedComponentProps>;
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|