"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
class EventProxy {
  constructor(_editor) {
    (0, _defineProperty2.default)(this, "onKeyDown", event => {
      const editor = this.editor;
      if (editor.onHotKeyDown) {
        const isHandled = editor.onHotKeyDown(event);
        if (isHandled) return;
      }

      // Disable the default 'save page'
      if ((0, _isHotkey.default)('mod+s', event)) {
        event.preventDefault();
        const {
          onSave
        } = this.editor;
        onSave && onSave();
      }

      // Disable default 'tab' behavior
      if ((0, _isHotkey.default)('tab', event)) {
        if (editor.hasMovedSelection) event.stopPropagation();
        event.preventDefault();
      }
    });
    (0, _defineProperty2.default)(this, "onCopy", event => {
      const editor = this.editor;
      if (editor.onCopy) {
        const isHandled = editor.onCopy(event);
        if (isHandled) return true;
      }
      return false;
    });
    this.editor = _editor;
  }
}
var _default = exports.default = EventProxy;