"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var shortcuts_exports = {};
__export(shortcuts_exports, {
  shortcuts: () => shortcuts
});
module.exports = __toCommonJS(shortcuts_exports);
var import_consts = require("./../ricos-content/consts.js");
var import_ricos_types = require("./../ricos-types/index.js");
var import_tiptap = require("./../tiptap/index.js");
var import_queries = require("./tiptap/commands/queries.js");
var import_table_query = require("./tiptap/table-query.js");
var import_find_table = require("./tiptap/utilities/find-table.js");
var import_is_selection_type = require("./tiptap/utilities/is-selection-type.js");
const shortcuts = [
  (0, import_ricos_types.createShortcut)({
    name: "MoveToNextCellTab",
    description: "ShortcutsSheet_Table_MoveToTheNextCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Tab",
      windows: "Tab"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "MoveToNextCellArrow",
    description: "ShortcutsSheet_Table_MoveToTheNextCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Arrow",
      windows: "Arrow"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "MoveToPreviousCellTab",
    description: "ShortcutsSheet_Table_MoveToThePreviousCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Shift+Tab",
      windows: "Shift+Tab"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "MoveToPreviousCellArrow",
    description: "ShortcutsSheet_Table_MoveToThePreviousCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Arrow",
      windows: "Arrow"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "EnterExitCell",
    description: "ShortcutsSheet_Table_EnterExitASelectedCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Enter",
      windows: "Enter"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "AddNewLineShift",
    description: "ShortcutsSheet_Table_AddANewLineWithinCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Shift+Enter",
      windows: "Shift+Enter"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "AddNewLineAlt",
    description: "ShortcutsSheet_Table_AddANewLineWithinCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Meta+Enter",
      windows: "Meta+Enter"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "SelectContentInCell",
    description: "ShortcutsSheet_Table_SelectingAllContentInsideCell",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Meta+A",
      windows: "Ctrl+A"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "SelectColumn",
    description: "ShortcutsSheet_Table_SelectColumn",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Alt+Space",
      windows: "Alt+Space"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "SelectRow",
    description: "ShortcutsSheet_Table_SelectRow",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Shift+Space",
      windows: "Shift+Space"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "SelectTable",
    description: "ShortcutsSheet_Table_SelectTable",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Meta+A",
      windows: "Ctrl+A"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "AddNewColumnRow",
    description: "ShortcutsSheet_Table_AddNewColumnRow",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Alt+Ctrl+=",
      windows: "Alt+Ctrl+="
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "DeleteColumnRow",
    description: "ShortcutsSheet_Table_DeleteSelectedColumnRow",
    group: "ShortcutsSheet_Section_Table",
    keys: {
      macOs: "Alt+Ctrl+-",
      windows: "Alt+Ctrl+-"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: () => "continue"
  }),
  (0, import_ricos_types.createShortcut)({
    name: "TableEscapeNavigation",
    group: "ShortcutsSheet_Section_Formatting",
    description: void 0,
    keys: {
      macOs: "Escape",
      windows: "Escape"
    },
    enabled: true,
    showInShortcutSheet: false,
    command: ({ editor, event }) => {
      const { state } = editor.view;
      const { selection } = state;
      if (!(0, import_queries.isInTable)(state)) {
        return "continue";
      }
      if ((0, import_is_selection_type.isRicosCellSelection)(selection)) {
        const table = import_table_query.TableQuery.of(selection);
        if (table && table.isTableSelected()) {
          return "continue";
        }
        editor.commands.selectWholeTable();
        event?.preventDefault();
        event?.stopImmediatePropagation();
        return "handled";
      }
      const tablePos = (0, import_find_table.findTable)(selection);
      if (!tablePos) {
        return "continue";
      }
      const cell = (0, import_tiptap.findParentNodeClosestToPos)(
        selection.$from,
        (node) => [import_consts.TIPTAP_TABLE_CELL_TYPE, import_consts.TIPTAP_TABLE_HEADER_CELL_TYPE].includes(node.type.name)
      );
      if (!cell) {
        return "continue";
      }
      editor.commands.setCellSelection(cell.pos);
      event?.preventDefault();
      event?.stopImmediatePropagation();
      return "handled";
    }
  })
];
//# sourceMappingURL=shortcuts.js.map
