import { TextSelection } from "./../../pm/state.js";
import { getMarkRange } from "../helpers/get-mark-range.js";
import { getMarkType } from "../helpers/get-mark-type.js";
const extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
  const type = getMarkType(typeOrName, state.schema);
  const { doc, selection } = tr;
  const { $from, from, to } = selection;
  if (dispatch) {
    const range = getMarkRange($from, type, attributes);
    if (range && range.from <= from && range.to >= to) {
      const newSelection = TextSelection.create(doc, range.from, range.to);
      tr.setSelection(newSelection);
    }
  }
  return true;
};
export {
  extendMarkRange
};
//# sourceMappingURL=extend-mark-range.js.map
