Skip to content

Commit

Permalink
Merge branch 'main' into 317-py5
Browse files Browse the repository at this point in the history
  • Loading branch information
taconi committed Jan 13, 2025
2 parents a936966 + c0008e1 commit f8b71ab
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/web/src/components/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import React, { useEffect, useState } from "react";
import { yCollab } from "y-codemirror.next";
import { UndoManager } from "yjs";
import themes from "@/lib/themes";
import { insertNewline } from "@codemirror/commands";
import { toggleLineComment, insertNewline } from "@codemirror/commands";

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

// extra keymaps
const extraKeymap = () => {
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 },
]);
};

// overwrites the default insertNewlineAndIndent command on Enter
const autoIndentKeymap = (doc: Document) => {
// if any of the targets is part of the noAutoIndent setting in settings.json
Expand Down Expand Up @@ -100,6 +111,7 @@ const flokSetup = (
remoteEvalFlash(doc),
Prec.high(evalKeymap(doc, { defaultMode, web })),
panicKeymap(doc),
extraKeymap(),
autoIndentKeymap(doc),
yCollab(text, doc.session.awareness, {
undoManager,
Expand Down

0 comments on commit f8b71ab

Please sign in to comment.