Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: paste-as-text shortcut on non-Latin layouts #13411

ClosedValeraZSD(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/13411/headopened View on GitHub

Showing 2 changed files with 17 additions and 2 deletions.

x
0 of 2 viewed, 2 left
7 additions and 0 deletionspackages/client-runtime/src/textPaste.test.tsModified
View file
@@ -78,6 +78,13 @@
).toBe(true);
});
​
+ it("accepts the V key on non-Latin layouts but follows the letter on Latin ones", () => {
+ const chord = { metaKey: false, ctrlKey: true, shiftKey: true, altKey: false };
+ expect(isPasteAsTextShortcut({ ...chord, key: "М", code: "KeyV" }, false)).toBe(true);
+ expect(isPasteAsTextShortcut({ ...chord, key: "k", code: "KeyV" }, false)).toBe(false);
+ expect(isPasteAsTextShortcut({ ...chord, key: "V", code: "Period" }, false)).toBe(true);
+ });
+​
it("does not claim ordinary or alternate paste chords", () => {
expect(
isPasteAsTextShortcut(
10 additions and 2 deletionspackages/client-runtime/src/textPaste.tsModified
View file
@@ -4,12 +4,20 @@
​
export type PastedTextDisposition = "attachment" | "inline";
​
+/** Non-Latin layouts (Cyrillic, Greek) report the typed letter; fall back to the physical key. */
+function isVKey(event: { readonly key: string; readonly code?: string }): boolean {
+ const key = event.key.toLowerCase();
+ return /^[a-z]$/.test(key) ? key === "v" : event.code === "KeyV";
+}
+​
export function isPasteAsTextShortcut(
- event: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">,