@atlaskit/editor-plugin-block-controls 7.10.2 → 7.11.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/blockControlsPlugin.js +5 -26
  3. package/dist/cjs/editor-commands/move-node-with-block-menu.js +1 -1
  4. package/dist/cjs/editor-commands/utils/move-node-utils.js +2 -2
  5. package/dist/cjs/pm-plugins/main.js +1 -2
  6. package/dist/cjs/pm-plugins/utils/getSelection.js +1 -1
  7. package/dist/cjs/ui/consts.js +2 -7
  8. package/dist/cjs/ui/drag-handle.js +17 -57
  9. package/dist/es2019/blockControlsPlugin.js +5 -27
  10. package/dist/es2019/editor-commands/move-node-with-block-menu.js +1 -1
  11. package/dist/es2019/editor-commands/utils/move-node-utils.js +2 -2
  12. package/dist/es2019/pm-plugins/main.js +1 -2
  13. package/dist/es2019/pm-plugins/utils/getSelection.js +1 -1
  14. package/dist/es2019/ui/consts.js +1 -6
  15. package/dist/es2019/ui/drag-handle.js +15 -55
  16. package/dist/esm/blockControlsPlugin.js +5 -26
  17. package/dist/esm/editor-commands/move-node-with-block-menu.js +1 -1
  18. package/dist/esm/editor-commands/utils/move-node-utils.js +2 -2
  19. package/dist/esm/pm-plugins/main.js +1 -2
  20. package/dist/esm/pm-plugins/utils/getSelection.js +1 -1
  21. package/dist/esm/ui/consts.js +1 -6
  22. package/dist/esm/ui/drag-handle.js +15 -55
  23. package/dist/types/ui/consts.d.ts +0 -2
  24. package/dist/types-ts4.5/ui/consts.d.ts +0 -2
  25. package/package.json +2 -2
  26. package/dist/cjs/ui/block-menu-items.js +0 -90
  27. package/dist/cjs/ui/block-menu.js +0 -110
  28. package/dist/es2019/ui/block-menu-items.js +0 -82
  29. package/dist/es2019/ui/block-menu.js +0 -108
  30. package/dist/esm/ui/block-menu-items.js +0 -82
  31. package/dist/esm/ui/block-menu.js +0 -102
  32. package/dist/types/ui/block-menu-items.d.ts +0 -15
  33. package/dist/types/ui/block-menu.d.ts +0 -16
  34. package/dist/types-ts4.5/ui/block-menu-items.d.ts +0 -15
  35. package/dist/types-ts4.5/ui/block-menu.d.ts +0 -16
@@ -1,82 +0,0 @@
1
- /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
-
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
- import { jsx } from '@emotion/react';
9
- import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, tooltip } from '@atlaskit/editor-common/keymaps';
10
- import { blockControlsMessages } from '@atlaskit/editor-common/messages';
11
- import { DIRECTION } from '@atlaskit/editor-common/types';
12
- import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
13
- import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
14
- import ArrowLeftIcon from '@atlaskit/icon/core/arrow-left';
15
- import ArrowRightnIcon from '@atlaskit/icon/core/arrow-right';
16
- import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
17
- import { moveNodeViaShortcut } from '../editor-commands/move-node';
18
- export var getBlockMenuItems = function getBlockMenuItems(formatMessage) {
19
- return [{
20
- items: [{
21
- content: formatMessage(blockControlsMessages.moveUp),
22
- elemBefore: jsx(ArrowUpIcon, {
23
- label: ""
24
- }),
25
- value: {
26
- name: 'moveUp'
27
- },
28
- key: 'move_up',
29
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
30
- elemAfter: jsx("div", {
31
- css: shortcutStyle
32
- }, tooltip(dragToMoveUp))
33
- }, {
34
- content: formatMessage(blockControlsMessages.moveDown),
35
- elemBefore: jsx(ArrowDownIcon, {
36
- label: ""
37
- }),
38
- value: {
39
- name: 'moveDown'
40
- },
41
- key: 'move_down',
42
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
43
- elemAfter: jsx("div", {
44
- css: shortcutStyle
45
- }, tooltip(dragToMoveDown))
46
- }, {
47
- content: formatMessage(blockControlsMessages.moveLeft),
48
- elemBefore: jsx(ArrowLeftIcon, {
49
- label: ""
50
- }),
51
- value: {
52
- name: 'moveLeft'
53
- },
54
- key: 'move_left',
55
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
56
- elemAfter: jsx("div", {
57
- css: shortcutStyle
58
- }, tooltip(dragToMoveLeft))
59
- }, {
60
- content: formatMessage(blockControlsMessages.moveRight),
61
- elemBefore: jsx(ArrowRightnIcon, {
62
- label: ""
63
- }),
64
- value: {
65
- name: 'moveRight'
66
- },
67
- key: 'move_right',
68
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
69
- elemAfter: jsx("div", {
70
- css: shortcutStyle
71
- }, tooltip(dragToMoveRight))
72
- }]
73
- }];
74
- };
75
- export var menuItemsCallback = {
76
- moveUp: function moveUp(api, formatMessage) {
77
- return moveNodeViaShortcut(api, DIRECTION.UP, formatMessage);
78
- },
79
- moveDown: function moveDown(api, formatMessage) {
80
- return moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage);
81
- }
82
- };
@@ -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;