UNPKG

@atlaskit/editor-plugin-highlight

Version:

Highlight plugin for @atlaskit/editor-core

29 lines (28 loc) 998 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDisabledState = void 0; var _mark = require("@atlaskit/editor-common/mark"); var _selection = require("@atlaskit/editor-common/selection"); var _state = require("@atlaskit/editor-prosemirror/state"); var getDisabledState = exports.getDisabledState = function getDisabledState(state) { var backgroundColor = state.schema.marks.backgroundColor; var _ref = state.selection, empty = _ref.empty, ranges = _ref.ranges, $cursor = _ref.$cursor; if (!backgroundColor) { return true; } if (state.selection instanceof _state.NodeSelection || state.selection instanceof _selection.GapCursorSelection) { return true; } if (empty && !$cursor || (0, _mark.isMarkAllowedInRange)(state.doc, ranges, backgroundColor) === false) { return true; } if ((0, _mark.isMarkExcluded)(backgroundColor, state.storedMarks || $cursor && $cursor.marks())) { return true; } return false; };