UNPKG

@atlaskit/editor-plugin-block-menu

Version:

BlockMenu plugin for @atlaskit/editor-core

26 lines (25 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkIsFormatMenuHidden = void 0; var _utils = require("@atlaskit/editor-prosemirror/utils"); var getIsFormatMenuHidden = function getIsFormatMenuHidden(selection, schema) { var nodes = schema.nodes; if (!nodes) { return false; } var disabledOnNodes = [nodes.rule]; var disabledNode = (0, _utils.findSelectedNodeOfType)(disabledOnNodes)(selection); return !!disabledNode; }; var checkIsFormatMenuHidden = exports.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); };