From 07258ecc35c1a05aa1581a54c9f47a40ce3d76c9 Mon Sep 17 00:00:00 2001 From: StefanVukovic99 Date: Sun, 21 Apr 2024 17:15:08 +0200 Subject: rework text processors (#793) * rework text processors * rename text-preprocessors file * Fix search header left margins on small screens (#839) * Refocuses search input on backspace (#840) Fixes #775. Note that this behavior gets overridden if backspace is set as a shortcut action. * Change hotkey triggering condition to account for IME usage (#837) _isKeyCharacterInput only worked when not using an IME, as inside of an IME when a keydown event is fired, the key is reported as "Process", which does not have a key.length equal to 1. This resulted in hotkeys being triggered while typing, which this commit fixes. --------- Co-authored-by: James Maa Co-authored-by: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Co-authored-by: Andrew Thomas Sartor --- ext/js/language/text-preprocessors.js | 49 ----------------------------------- 1 file changed, 49 deletions(-) delete mode 100755 ext/js/language/text-preprocessors.js (limited to 'ext/js/language/text-preprocessors.js') diff --git a/ext/js/language/text-preprocessors.js b/ext/js/language/text-preprocessors.js deleted file mode 100755 index e33fccda..00000000 --- a/ext/js/language/text-preprocessors.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2024 Yomitan Authors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** @type {import('language').TextPreprocessorOptions} */ -export const basicTextPreprocessorOptions = [false, true]; - -/** @type {import('language').TextPreprocessor} */ -export const decapitalize = { - name: 'Decapitalize text', - description: 'CAPITALIZED TEXT → capitalized text', - options: basicTextPreprocessorOptions, - process: (str, setting) => (setting ? str.toLowerCase() : str) -}; - -/** @type {import('language').TextPreprocessor} */ -export const capitalizeFirstLetter = { - name: 'Capitalize first letter', - description: 'lowercase text → Lowercase text', - options: basicTextPreprocessorOptions, - process: (str, setting) => (setting ? str.charAt(0).toUpperCase() + str.slice(1) : str) -}; - -/** - * WARNING: This should NOT be used with languages that use Han characters, - * as it can result in undesirable normalization: - * - '\u9038'.normalize('NFD') => '\u9038' (逸) - * - '\ufa67'.normalize('NFD') => '\u9038' (逸 => 逸) - * @type {import('language').TextPreprocessor} - */ -export const removeAlphabeticDiacritics = { - name: 'Remove Alphabetic Diacritics', - description: 'ἄήé -> αηe', - options: basicTextPreprocessorOptions, - process: (str, setting) => (setting ? str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : str) -}; -- cgit v1.2.3