Skip to content

Commit

Permalink
fix for comment keymap on spanish keyboards
Browse files Browse the repository at this point in the history
  • Loading branch information
tmhglnd committed Jan 9, 2025
1 parent e04d28d commit c5f0e03
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/web/src/components/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import React, { useEffect, useState } from "react";
import { yCollab } from "y-codemirror.next";
import { UndoManager } from "yjs";
import themes from "@/lib/themes";
import { toggleLineComment } from "@codemirror/commands";

const defaultLanguage = "javascript";
const langByTarget = langByTargetUntyped as { [lang: string]: string };
Expand Down Expand Up @@ -68,6 +69,16 @@ const panicKeymap = (
: [];
};

const extraKeymap = ( doc: Document ) => {
return keymap.of([
// fixes the Cmd/Alt-/ issue for Spanish keyboards
{ key: 'Shift-Cmd-7', run: toggleLineComment },
{ key: 'Shift-Alt-7', run: toggleLineComment },
{ key: 'Alt-/', run: toggleLineComment },
{ key: 'Ctrl-/', run: toggleLineComment },
])
};

interface FlokSetupOptions {
readOnly?: boolean;
}
Expand All @@ -88,6 +99,7 @@ const flokSetup = (
remoteEvalFlash(doc),
Prec.high(evalKeymap(doc, { defaultMode, web })),
panicKeymap(doc),
extraKeymap(doc),
yCollab(text, doc.session.awareness, {
undoManager,
hideCaret: readOnly,
Expand Down

0 comments on commit c5f0e03

Please sign in to comment.