"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _prosemirrorState = require("prosemirror-state");
var _prosemirrorTransform = require("prosemirror-transform");
var _prosemirrorView = require("prosemirror-view");
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class MarksClearCommand extends _licitDocAttrsStep.UICommand {
  constructor() {
    super(...arguments);
    _defineProperty(this, "isActive", state => {
      return false;
    });
    _defineProperty(this, "isEnabled", state => {
      const {
        selection
      } = state;
      return !selection.empty && (selection instanceof _prosemirrorState.TextSelection || selection instanceof _prosemirrorState.AllSelection);
    });
    _defineProperty(this, "execute", (state, dispatch, view) => {
      let tr = (0, _licitUiCommands.clearMarks)(state.tr.setSelection(state.selection), state.schema);
      // [FS] IRAD-948 2021-02-22

      // Clear Header formatting
      tr = (0, _licitUiCommands.clearHeading)(tr, state.schema);
      if (dispatch && tr.docChanged) {
        dispatch(tr);
        return true;
      }
      return false;
    });
  }
}
var _default = MarksClearCommand;
exports.default = _default;