UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

26 lines • 1.47 kB
import React from 'react'; import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context'; import { BLOCK_CONTROLS_DRAG_HANDLE, BLOCK_CONTROLS_LEFT_GROUP } from '@atlaskit/editor-common/block-controls/surface-keys'; import { BlockControlsSurfaceDragHandle } from './block-controls-surface-drag-handle'; export const getBlockControlsSurfaceDragHandleComponents = ({ api }) => [{ component: ({ surfaceContext }) => /*#__PURE__*/React.createElement(BlockControlsSurfaceDragHandle, { api: api, surfaceContext: surfaceContext }), isHidden: ({ surfaceContext } = {}) => { var _api$editorViewMode, _api$editorViewMode$s; const context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT); return (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view' || !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos || context.activeControlKey !== undefined && context.activeControlKey !== BLOCK_CONTROLS_DRAG_HANDLE.key; }, ...BLOCK_CONTROLS_DRAG_HANDLE, parents: [{ ...BLOCK_CONTROLS_LEFT_GROUP, rank: 200 }] }];