From c1d906d62f2424e6b26e664bec05cb5ee8b60c72 Mon Sep 17 00:00:00 2001 From: Arno Gourdol Date: Wed, 15 Nov 2023 18:24:32 -0800 Subject: [PATCH] lint --- src/core-atoms/latex.ts | 4 +- src/editor-mathfield/keyboard-input.ts | 4 +- src/editor/keybindings.ts | 3 +- src/editor/keyboard-layout.ts | 282 ++++++++++++------------- test/smoke/index.html | 184 ++++++++-------- 5 files changed, 236 insertions(+), 241 deletions(-) diff --git a/src/core-atoms/latex.ts b/src/core-atoms/latex.ts index b5ded2fe9..c61d4bd99 100644 --- a/src/core-atoms/latex.ts +++ b/src/core-atoms/latex.ts @@ -40,8 +40,8 @@ export class LatexAtom extends Atom { classes: this.isSuggestion ? 'ML__suggestion' : this.isError - ? 'ML__error' - : '', + ? 'ML__error' + : '', type: 'latex', maxFontSize: 1.0, }); diff --git a/src/editor-mathfield/keyboard-input.ts b/src/editor-mathfield/keyboard-input.ts index f9da271de..ba4a5a8bd 100644 --- a/src/editor-mathfield/keyboard-input.ts +++ b/src/editor-mathfield/keyboard-input.ts @@ -650,8 +650,8 @@ function insertMathModeChar( mathfield.adoptStyle === 'left' ? atom : atom.parent - ? atom.rightSibling - : null; + ? atom.rightSibling + : null; if ( sibling?.type === 'mord' && /[a-zA-Z0-9]/.test(sibling.value) && diff --git a/src/editor/keybindings.ts b/src/editor/keybindings.ts index ff011d4b6..689eb3407 100644 --- a/src/editor/keybindings.ts +++ b/src/editor/keybindings.ts @@ -269,9 +269,8 @@ function normalizeKeybinding( // Convert it to a key code. const code = getCodeForKey(modifiers.key, layout); // if (!code) throw new Error('Invalid keybinding key "' + keybinding.key + '"'); - if (!code) { + if (!code) return { ...keybinding, key: keystrokeModifiersToString(modifiers) }; - } if ((code.shift && modifiers.shift) || (code.alt && modifiers.alt)) { throw new Error( diff --git a/src/editor/keyboard-layout.ts b/src/editor/keyboard-layout.ts index 06e87edfc..b8b78c28c 100644 --- a/src/editor/keyboard-layout.ts +++ b/src/editor/keyboard-layout.ts @@ -293,147 +293,147 @@ export const DEFAULT_KEYBOARD_LAYOUT: KeyboardLayout = }, } : platform() === 'windows' - ? { - id: 'windows.en-intl', - displayName: 'English (international)', - platform: 'windows', - virtualLayout: 'qwerty', - locale: 'en', - score: 0, - mapping: { - KeyA: ['a', 'A', 'á', 'Á'], - KeyB: ['b', 'B', '', ''], - KeyC: ['c', 'C', '©', '¢'], - KeyD: ['d', 'D', 'ð', 'Ð'], - KeyE: ['e', 'E', 'é', 'É'], - KeyF: ['f', 'F', '', ''], - KeyG: ['g', 'G', '', ''], - KeyH: ['h', 'H', '', ''], - KeyI: ['i', 'I', 'í', 'Í'], - KeyJ: ['j', 'J', '', ''], - KeyK: ['k', 'K', '', ''], - KeyL: ['l', 'L', 'ø', 'Ø'], - KeyM: ['m', 'M', 'µ', ''], - KeyN: ['n', 'N', 'ñ', 'Ñ'], - KeyO: ['o', 'O', 'ó', 'Ó'], - KeyP: ['p', 'P', 'ö', 'Ö'], - KeyQ: ['q', 'Q', 'ä', 'Ä'], - KeyR: ['r', 'R', '®', ''], - KeyS: ['s', 'S', 'ß', '§'], - KeyT: ['t', 'T', 'þ', 'Þ'], - KeyU: ['u', 'U', 'ú', 'Ú'], - KeyV: ['v', 'V', '', ''], - KeyW: ['w', 'W', 'å', 'Å'], - KeyX: ['x', 'X', '', ''], - KeyY: ['y', 'Y', 'ü', 'Ü'], - KeyZ: ['z', 'Z', 'æ', 'Æ'], - Digit1: ['1', '!', '¡', '¹'], - Digit2: ['2', '@', '²', ''], - Digit3: ['3', '#', '³', ''], - Digit4: ['4', '$', '¤', '£'], - Digit5: ['5', '%', '€', ''], - Digit6: ['6', '^', '¼', ''], - Digit7: ['7', '&', '½', ''], - Digit8: ['8', '*', '¾', ''], - Digit9: ['9', '(', '‘', ''], - Digit0: ['0', ')', '’', ''], - Space: [' ', ' ', '', ''], - Minus: ['-', '_', '¥', ''], - Equal: ['=', '+', '×', '÷'], - BracketLeft: ['[', '{', '«', ''], - BracketRight: [']', '}', '»', ''], - Backslash: ['\\', '|', '¬', '¦'], - Semicolon: [';', ':', '¶', '°'], - Quote: ["'", '"', '´', '¨'], - Backquote: ['`', '~', '', ''], - Comma: [',', '<', 'ç', 'Ç'], - Period: ['.', '>', '', ''], - Slash: ['/', '?', '¿', ''], - NumpadDivide: ['/', '/', '', ''], - NumpadMultiply: ['*', '*', '', ''], - NumpadSubtract: ['-', '-', '', ''], - NumpadAdd: ['+', '+', '', ''], - IntlBackslash: ['\\', '|', '', ''], - }, - } - : { - id: 'linux.en', - displayName: 'English', - platform: 'linux', - virtualLayout: 'qwerty', - locale: 'en', - score: 0, - mapping: { - KeyA: ['a', 'A', 'a', 'A'], - KeyB: ['b', 'B', 'b', 'B'], - KeyC: ['c', 'C', 'c', 'C'], - KeyD: ['d', 'D', 'd', 'D'], - KeyE: ['e', 'E', 'e', 'E'], - KeyF: ['f', 'F', 'f', 'F'], - KeyG: ['g', 'G', 'g', 'G'], - KeyH: ['h', 'H', 'h', 'H'], - KeyI: ['i', 'I', 'i', 'I'], - KeyJ: ['j', 'J', 'j', 'J'], - KeyK: ['k', 'K', 'k', 'K'], - KeyL: ['l', 'L', 'l', 'L'], - KeyM: ['m', 'M', 'm', 'M'], - KeyN: ['n', 'N', 'n', 'N'], - KeyO: ['o', 'O', 'o', 'O'], - KeyP: ['p', 'P', 'p', 'P'], - KeyQ: ['q', 'Q', 'q', 'Q'], - KeyR: ['r', 'R', 'r', 'R'], - KeyS: ['s', 'S', 's', 'S'], - KeyT: ['t', 'T', 't', 'T'], - KeyU: ['u', 'U', 'u', 'U'], - KeyV: ['v', 'V', 'v', 'V'], - KeyW: ['w', 'W', 'w', 'W'], - KeyX: ['x', 'X', 'x', 'X'], - KeyY: ['y', 'Y', 'y', 'Y'], - KeyZ: ['z', 'Z', 'z', 'Z'], - Digit1: ['1', '!', '1', '!'], - Digit2: ['2', '@', '2', '@'], - Digit3: ['3', '#', '3', '#'], - Digit4: ['4', '$', '4', '$'], - Digit5: ['5', '%', '5', '%'], - Digit6: ['6', '^', '6', '^'], - Digit7: ['7', '&', '7', '&'], - Digit8: ['8', '*', '8', '*'], - Digit9: ['9', '(', '9', '('], - Digit0: ['0', ')', '0', ')'], - Space: [' ', ' ', ' ', ' '], - Minus: ['-', '_', '-', '_'], - Equal: ['=', '+', '=', '+'], - BracketLeft: ['[', '{', '[', '{'], - BracketRight: [']', '}', ']', '}'], - Backslash: ['\\', '|', '\\', '|'], - Semicolon: [';', ':', ';', ':'], - Quote: ["'", '"', "'", '"'], - Backquote: ['`', '~', '`', '~'], - Comma: [',', '<', ',', '<'], - Period: ['.', '>', '.', '>'], - Slash: ['/', '?', '/', '?'], - NumpadDivide: ['/', '/', '/', '/'], - NumpadMultiply: ['*', '*', '*', '*'], - NumpadSubtract: ['-', '-', '-', '-'], - NumpadAdd: ['+', '+', '+', '+'], - Numpad1: ['1', '1', '1', '1'], - Numpad2: ['2', '2', '2', '2'], - Numpad3: ['3', '3', '3', '3'], - Numpad4: ['4', '4', '4', '4'], - Numpad5: ['5', '5', '5', '5'], - Numpad6: ['6', '6', '6', '6'], - Numpad7: ['7', '7', '7', '7'], - Numpad8: ['8', '8', '8', '8'], - Numpad9: ['9', '9', '9', '9'], - Numpad0: ['0', '0', '0', '0'], - NumpadDecimal: ['', '.', '', '.'], - IntlBackslash: ['<', '>', '|', '¦'], - NumpadEqual: ['=', '=', '=', '='], - NumpadComma: ['.', '.', '.', '.'], - NumpadParenLeft: ['(', '(', '(', '('], - NumpadParenRight: [')', ')', ')', ')'], - }, - }; + ? { + id: 'windows.en-intl', + displayName: 'English (international)', + platform: 'windows', + virtualLayout: 'qwerty', + locale: 'en', + score: 0, + mapping: { + KeyA: ['a', 'A', 'á', 'Á'], + KeyB: ['b', 'B', '', ''], + KeyC: ['c', 'C', '©', '¢'], + KeyD: ['d', 'D', 'ð', 'Ð'], + KeyE: ['e', 'E', 'é', 'É'], + KeyF: ['f', 'F', '', ''], + KeyG: ['g', 'G', '', ''], + KeyH: ['h', 'H', '', ''], + KeyI: ['i', 'I', 'í', 'Í'], + KeyJ: ['j', 'J', '', ''], + KeyK: ['k', 'K', '', ''], + KeyL: ['l', 'L', 'ø', 'Ø'], + KeyM: ['m', 'M', 'µ', ''], + KeyN: ['n', 'N', 'ñ', 'Ñ'], + KeyO: ['o', 'O', 'ó', 'Ó'], + KeyP: ['p', 'P', 'ö', 'Ö'], + KeyQ: ['q', 'Q', 'ä', 'Ä'], + KeyR: ['r', 'R', '®', ''], + KeyS: ['s', 'S', 'ß', '§'], + KeyT: ['t', 'T', 'þ', 'Þ'], + KeyU: ['u', 'U', 'ú', 'Ú'], + KeyV: ['v', 'V', '', ''], + KeyW: ['w', 'W', 'å', 'Å'], + KeyX: ['x', 'X', '', ''], + KeyY: ['y', 'Y', 'ü', 'Ü'], + KeyZ: ['z', 'Z', 'æ', 'Æ'], + Digit1: ['1', '!', '¡', '¹'], + Digit2: ['2', '@', '²', ''], + Digit3: ['3', '#', '³', ''], + Digit4: ['4', '$', '¤', '£'], + Digit5: ['5', '%', '€', ''], + Digit6: ['6', '^', '¼', ''], + Digit7: ['7', '&', '½', ''], + Digit8: ['8', '*', '¾', ''], + Digit9: ['9', '(', '‘', ''], + Digit0: ['0', ')', '’', ''], + Space: [' ', ' ', '', ''], + Minus: ['-', '_', '¥', ''], + Equal: ['=', '+', '×', '÷'], + BracketLeft: ['[', '{', '«', ''], + BracketRight: [']', '}', '»', ''], + Backslash: ['\\', '|', '¬', '¦'], + Semicolon: [';', ':', '¶', '°'], + Quote: ["'", '"', '´', '¨'], + Backquote: ['`', '~', '', ''], + Comma: [',', '<', 'ç', 'Ç'], + Period: ['.', '>', '', ''], + Slash: ['/', '?', '¿', ''], + NumpadDivide: ['/', '/', '', ''], + NumpadMultiply: ['*', '*', '', ''], + NumpadSubtract: ['-', '-', '', ''], + NumpadAdd: ['+', '+', '', ''], + IntlBackslash: ['\\', '|', '', ''], + }, + } + : { + id: 'linux.en', + displayName: 'English', + platform: 'linux', + virtualLayout: 'qwerty', + locale: 'en', + score: 0, + mapping: { + KeyA: ['a', 'A', 'a', 'A'], + KeyB: ['b', 'B', 'b', 'B'], + KeyC: ['c', 'C', 'c', 'C'], + KeyD: ['d', 'D', 'd', 'D'], + KeyE: ['e', 'E', 'e', 'E'], + KeyF: ['f', 'F', 'f', 'F'], + KeyG: ['g', 'G', 'g', 'G'], + KeyH: ['h', 'H', 'h', 'H'], + KeyI: ['i', 'I', 'i', 'I'], + KeyJ: ['j', 'J', 'j', 'J'], + KeyK: ['k', 'K', 'k', 'K'], + KeyL: ['l', 'L', 'l', 'L'], + KeyM: ['m', 'M', 'm', 'M'], + KeyN: ['n', 'N', 'n', 'N'], + KeyO: ['o', 'O', 'o', 'O'], + KeyP: ['p', 'P', 'p', 'P'], + KeyQ: ['q', 'Q', 'q', 'Q'], + KeyR: ['r', 'R', 'r', 'R'], + KeyS: ['s', 'S', 's', 'S'], + KeyT: ['t', 'T', 't', 'T'], + KeyU: ['u', 'U', 'u', 'U'], + KeyV: ['v', 'V', 'v', 'V'], + KeyW: ['w', 'W', 'w', 'W'], + KeyX: ['x', 'X', 'x', 'X'], + KeyY: ['y', 'Y', 'y', 'Y'], + KeyZ: ['z', 'Z', 'z', 'Z'], + Digit1: ['1', '!', '1', '!'], + Digit2: ['2', '@', '2', '@'], + Digit3: ['3', '#', '3', '#'], + Digit4: ['4', '$', '4', '$'], + Digit5: ['5', '%', '5', '%'], + Digit6: ['6', '^', '6', '^'], + Digit7: ['7', '&', '7', '&'], + Digit8: ['8', '*', '8', '*'], + Digit9: ['9', '(', '9', '('], + Digit0: ['0', ')', '0', ')'], + Space: [' ', ' ', ' ', ' '], + Minus: ['-', '_', '-', '_'], + Equal: ['=', '+', '=', '+'], + BracketLeft: ['[', '{', '[', '{'], + BracketRight: [']', '}', ']', '}'], + Backslash: ['\\', '|', '\\', '|'], + Semicolon: [';', ':', ';', ':'], + Quote: ["'", '"', "'", '"'], + Backquote: ['`', '~', '`', '~'], + Comma: [',', '<', ',', '<'], + Period: ['.', '>', '.', '>'], + Slash: ['/', '?', '/', '?'], + NumpadDivide: ['/', '/', '/', '/'], + NumpadMultiply: ['*', '*', '*', '*'], + NumpadSubtract: ['-', '-', '-', '-'], + NumpadAdd: ['+', '+', '+', '+'], + Numpad1: ['1', '1', '1', '1'], + Numpad2: ['2', '2', '2', '2'], + Numpad3: ['3', '3', '3', '3'], + Numpad4: ['4', '4', '4', '4'], + Numpad5: ['5', '5', '5', '5'], + Numpad6: ['6', '6', '6', '6'], + Numpad7: ['7', '7', '7', '7'], + Numpad8: ['8', '8', '8', '8'], + Numpad9: ['9', '9', '9', '9'], + Numpad0: ['0', '0', '0', '0'], + NumpadDecimal: ['', '.', '', '.'], + IntlBackslash: ['<', '>', '|', '¦'], + NumpadEqual: ['=', '=', '=', '='], + NumpadComma: ['.', '.', '.', '.'], + NumpadParenLeft: ['(', '(', '(', '('], + NumpadParenRight: [')', ')', ')', ')'], + }, + }; /* prettier-ignore */ const BASE_LAYOUT_MAPPING = { diff --git a/test/smoke/index.html b/test/smoke/index.html index bcaf84820..4b7b2ea83 100644 --- a/test/smoke/index.html +++ b/test/smoke/index.html @@ -56,9 +56,10 @@

Smoke Test

- \frac{\frac12}{\frac34} -
+ \left(\frac{5}{3}+1\right)+1