"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "PassiveTransaction", {
  enumerable: true,
  get: function get() {
    return _PassiveTransaction.PassiveTransaction;
  }
});
exports.editorCommandToPMCommand = editorCommandToPMCommand;
var _PassiveTransaction = require("./PassiveTransaction");
/**
* Convert a EditorCommand to a standard Prosemirror Command.
* The preferred approach to dispatching a `EditorCommand` is via the
* `core.actions.execute` on `pluginInjectionAPI`. In some cases
* the type may require a Command until we refactor this out and this
* function is suitable for those cases.
*
* @param command A plugin command (a function that modifies and returns a `Transaction`)
* @returns Command
*/
function editorCommandToPMCommand(command) {
  return function (_ref, dispatch) {
    var tr = _ref.tr;
    var newTr = command === null || command === void 0 ? void 0 : command({
      tr: tr
    });
    if (!newTr) {
      return false;
    }
    if (newTr instanceof _PassiveTransaction.PassiveTransaction) {
      return true;
    }
    dispatch === null || dispatch === void 0 || dispatch(newTr);
    return true;
  };
}
// eslint-disable-next-line @atlaskit/editor/no-re-export