"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.wrapInBlockquote = wrapInBlockquote;

var _commands = require("../../../utils/commands");

var _prosemirrorCommands = require("prosemirror-commands");

function wrapInBlockquote(editor) {
  var state = editor.state;
  var schema = editor.state.schema;
  var $from = state.selection.$from;
  var parent = $from.node($from.depth - 1);

  if (parent.type === schema.nodes.blockquote) {
    (0, _commands.clearNodes)()(state, editor.view.dispatch);
    editor.view.focus();
    return;
  }

  (0, _commands.chainTransactions)((0, _commands.clearNodes)(), (0, _prosemirrorCommands.wrapIn)(schema.nodes.blockquote))(state, editor.view.dispatch);
  editor.view.focus();
  return;
}