diff --git a/resources/tester/helper_218_1_loupe.cjs b/resources/tester/helper_218_1_loupe.cjs index e09756ba8..32e247990 100644 --- a/resources/tester/helper_218_1_loupe.cjs +++ b/resources/tester/helper_218_1_loupe.cjs @@ -4,14 +4,22 @@ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); -const file = path.join(__dirname, "..", "..", "ui_template", "ui_template_loupe.ts"); -const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { - compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, -}).outputText; -const box = { exports: {} }; -const req = (p) => (p.endsWith(".css") ? {} : require(p)); -new Function("exports", "module", "require", js)(box.exports, box, req); -const m = box.exports; +const ROOT = path.join(__dirname, "..", ".."); +function load(file) { + const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { + compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, + }).outputText; + const box = { exports: {} }; + const req = (p) => + p.endsWith(".css") + ? {} + : p.endsWith("key_shortcut") // 공용 키 판정(214-2)도 그 자리에서 트랜스파일 + ? load(path.join(ROOT, "A00_Common", "key_shortcut.ts")) + : require(p); + new Function("exports", "module", "require", js)(box.exports, box, req); + return box.exports; +} +const m = load(path.join(ROOT, "ui_template", "ui_template_loupe.ts")); // ---- 가짜 시계 · 가짜 창 ---- function fakeWindow(doc) { diff --git a/ui_template/ui_template_loupe.ts b/ui_template/ui_template_loupe.ts index 46a82b369..e4c40b572 100644 --- a/ui_template/ui_template_loupe.ts +++ b/ui_template/ui_template_loupe.ts @@ -10,6 +10,7 @@ * ========================================================================== */ import "./ui_template_loupe.css"; +import { keyLetter } from "../A00_Common/key_shortcut"; /** 원 지름(px) */ export const LOUPE_DIAMETER = 240; @@ -51,11 +52,12 @@ const KEEP_INSIDE = new Set([ "CAPTION", ]); -/** Z 키 판정 — 글자(`key`)가 아니라 자판 자리(`code`) · 한글 자판(「ㅋ」)도 같음(CAD `input-shortcut` 과 같은 원리) · Ctrl/Alt/Meta 조합은 아님 */ +/** Z 키 판정 — 공용 `keyLetter`(214-2 · 한글 자판 「ㅋ」 = 자판 자리 KeyZ) · Ctrl/Alt/Meta 조합은 아님 */ export function isLoupeKey( - evt: Pick, + evt: Pick & + Partial>, ): boolean { - return evt.code === "KeyZ" && !evt.ctrlKey && !evt.altKey && !evt.metaKey; + return keyLetter(evt) === "z" && !evt.ctrlKey && !evt.altKey && !evt.metaKey; } /** 글을 치는 자리 — 글 칸 · 고르기 칸 · contenteditable */ @@ -159,7 +161,7 @@ export function initLoupe( update(); }); on("keyup", (e) => { - if (e.code !== "KeyZ" || !key) return; + if (keyLetter(e) !== "z" || !key) return; key = false; update(); });