UNPKG

@atlaskit/editor-plugin-block-menu

Version:

BlockMenu plugin for @atlaskit/editor-core

20 lines 1.46 kB
import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils'; var getIsFormatMenuHidden = function getIsFormatMenuHidden(selection, schema) { var nodes = schema.nodes; if (!nodes) { return false; } var disabledOnNodes = [nodes.rule]; var disabledNode = findSelectedNodeOfType(disabledOnNodes)(selection); return !!disabledNode; }; export var checkIsFormatMenuHidden = function checkIsFormatMenuHidden(api) { var _api$selection, _api$core$sharedState, _api$blockControls; 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; var schema = api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.schema; var menuTriggerBy = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.menuTriggerBy; if (!selection || !schema || !menuTriggerBy) { return false; } return getIsFormatMenuHidden(selection, schema); };