import { createShortcut } from "./../../ricos-types/index.js";
import { AllSelection } from "./../../tiptap/pm/state.js";
import { resolveIncrementalSelection } from "./resolve-incremental-selection.js";
import { ShortcutsDialog } from "./shortcuts-dialog.js";
const defaultCommand = ({ event }) => {
  event?.preventDefault();
  return "continue";
};
const generalShortcuts = [
  createShortcut({
    name: "OpenShortcutsSheet",
    description: "ShortcutsSheet_General_OpenKeyboardShortcutsSheet",
    group: "ShortcutsSheet_Section_General",
    keys: {
      macOs: "Meta+/",
      windows: "Ctrl+/"
    },
    enabled: true,
    showInShortcutSheet: false,
    command: ({ modalService, editor }) => {
      modalService.openModal({
        id: "shortcuts-help",
        Component: ShortcutsDialog,
        componentProps: {},
        dragHandleSelector: "[data-drag-handler]",
        enableDrag: true,
        layout: "floating",
        positioning: {
          referenceElement: editor.view.dom,
          placement: "right-start"
        }
      });
      return "continue";
    }
  }),
  createShortcut({
    name: "AddHorizontalTabulation",
    description: "ShortcutsSheet_General_AddHorizontalTabulation",
    group: "ShortcutsSheet_Section_General",
    keys: {
      macOs: "Tab",
      windows: "Tab"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: ({ publicCommands, event }) => {
      const selection = publicCommands.getSelection();
      if (selection.isFocused) {
        event?.preventDefault();
      }
      return "continue";
    }
  }),
  createShortcut({
    name: "MoveSelectionThroughElements",
    description: "ShortcutsSheet_General_MoveSelectionThroughAllElements",
    group: "ShortcutsSheet_Section_General",
    keys: {
      macOs: "Arrow",
      windows: "Arrow"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  }),
  createShortcut({
    name: "SelectAll",
    description: "ShortcutsSheet_General_SelectAll",
    group: "ShortcutsSheet_Section_General",
    keys: {
      macOs: "Meta+A",
      windows: "Ctrl+A"
    },
    enabled: true,
    showInShortcutSheet: true,
    command: ({ editor, event }) => {
      event?.preventDefault();
      event?.stopPropagation();
      const nextSelection = resolveIncrementalSelection(editor);
      if (nextSelection) {
        let success;
        if (nextSelection.type === "all") {
          const { state, view } = editor;
          view.dispatch(state.tr.setSelection(new AllSelection(state.doc)));
          success = true;
        } else if (nextSelection.type === "node") {
          success = editor.commands.setNodeSelection(nextSelection.from);
        } else {
          success = editor.commands.setTextSelection(nextSelection);
        }
        return success ? "handled" : "continue";
      }
      return "handled";
    }
  }),
  createShortcut({
    name: "SelectTextBlocks",
    description: "ShortcutsSheet_General_SelectTextBlocks",
    group: "ShortcutsSheet_Section_General",
    keys: {
      macOs: "Shift+Arrow",
      windows: "Shift+Arrow"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  }),
  createShortcut({
    name: "PasteWithoutFormatting",
    description: "ShortcutsSheet_Formatting_PasteWithoutFormatting",
    group: "ShortcutsSheet_Section_Formatting",
    keys: {
      macOs: "Meta+Shift+V",
      windows: "Ctrl+Shift+V"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  })
];
const navigationShortcuts = [
  createShortcut({
    name: "MoveSelectionToNextOption",
    description: "ShortcutsSheet_ToolbarNavigation_MoveSelectionToTheNextOption",
    group: "ShortcutsSheet_Section_ToolbarNavigation",
    keys: {
      macOs: "ArrowRight",
      windows: "ArrowRight"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  }),
  createShortcut({
    name: "MoveSelectionToPreviousOption",
    description: "ShortcutsSheet_ToolbarNavigation_MoveSelectionToThePreviousOption",
    group: "ShortcutsSheet_Section_ToolbarNavigation",
    keys: {
      macOs: "ArrowLeft",
      windows: "ArrowLeft"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  }),
  createShortcut({
    name: "ApplySelection",
    description: "ShortcutsSheet_ToolbarNavigation_ApplyASelection",
    group: "ShortcutsSheet_Section_ToolbarNavigation",
    keys: {
      macOs: "Enter",
      windows: "Enter"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  }),
  createShortcut({
    name: "ExitToolbar",
    description: "ShortcutsSheet_ToolbarNavigation_ExitToolbar",
    group: "ShortcutsSheet_Section_ToolbarNavigation",
    keys: {
      macOs: "Escape",
      windows: "Escape"
    },
    enabled: false,
    showInShortcutSheet: true,
    command: defaultCommand
  })
];
export {
  generalShortcuts,
  navigationShortcuts
};
//# sourceMappingURL=shortcut-definitions.js.map
