From 9ea02aacbfaf72739ed10f1581481a0ace4e9c62 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 28 Nov 2020 21:16:03 +0100 Subject: [PATCH 1/9] feat: localize options page * add English translation as template * add German translation --- src/_locales/de/messages.json | 153 +++++++++++++++++++++++++++++++++- src/_locales/en/messages.json | 151 +++++++++++++++++++++++++++++++++ src/options/options.html | 38 +++++---- 3 files changed, 324 insertions(+), 18 deletions(-) diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index ceef40a..dfdd3d4 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -49,7 +49,7 @@ "description": "The message, which appears, when settings are pre-defined (as managed options) by administrators." }, "optionIsDisabledBecauseManaged": { - "message": "Diese option ist deaktiviert, weil sie von deinem Systemadministrator festgelegt wurde.", + "message": "Diese Option ist deaktiviert, weil sie von deinem Systemadministrator festgelegt wurde.", "description": "The title (tooltip) shown, when hovering over a disabled, managed option." }, "optionLearnMore": { @@ -61,6 +61,157 @@ "description": "The button to delete all current settings and load the defaults, shown in the add-on settings." }, + "titleUnicodeAutocorrection": { + "message": "Unicode-Autokorrektur", + "description": "A title in the add-on settings." + }, + "titleContextMenu": { + "message": "Kontextmenü", + "description": "A title in the add-on settings." + }, + + "optionHelperTextAutocorrection": { + "message": "Du kannst die automatischen Korrekturen, welche bei Eingabe von Text ausgeführt werden, hier konfigurieren.$BR$Alle Autokorreturen werden ausgeführt, sobald du das ersten nicht-passenden Zeichen, gefolgt von einer Zeichensequenz wie einem Leerzeichen (␣), schreibst. Drück die Rücktaste (⌫) um eine Autokorrektur rückgängig zu machen. Nur das Ersetzen der Anführungszeichen wird sofort ausgeführt.", + "description": "Description for the section titleUnicodeAutocorrection explaining how the autocorrection works.", + "placeholders": { + "br": { + "content": "$1", + "example": "
" + } + } + }, + "optionHelperTextAutocorrectionEmoji": { + "message": "Um auch Emojis, inklusive $COLON$-Codes und Emoticons, automatisch zu korrigieren zu lassen, teste auch unser $LINK$ add-on.", + "description": "Description for the section titleUnicodeAutocorrection advertising the Awesome Emoji Picker add-on.", + "placeholders": { + "colon": { + "content": "$1", + "example": ":colon:" + }, + "link": { + "content": "$2", + "example": "🤩 Awesome Emoji Picker" + } + } + }, + "optionHelperTextAutocorrectionEmojiColonsCode": { + "message": ":Doppelpunkt:", + "description": "This is included in code-style in optionHelperTextAutocorrectionEmoji." + }, + "optionHelperTextAutocorrectionEmojiLink": { + "message": "https://addons.mozilla.org/firefox/addon/awesome-emoji-picker/", + "description": "The target for the link provided in optionHelperTextAutocorrectionEmoji. Usually should not be modified and link to the AMO page of the Awesome Emoji Picker. It does redirect to the correct language automatically." + }, + "optionHelperTextAutocorrectionEmojiLinkText": { + "message": "🤩\u00a0Awesome Emoji Picker", + "description": "The text for the link provided in optionHelperTextAutocorrectionEmoji. Should be the official name of the emoji picker add-on in your language." + }, + "optionHelperTextContextMenu": { + "message": "Schreibe Text, markiere diesen und wähle die passende Option im Kontextmenü aus, um schnell das den Zeichenstil oder die Groß-/Kleinschreibung. Dies ist nützlich bei Websieten, welche es nicht erlauben die Schriftart oder die Textformattierung anzupassen.", + "description": "Description for the section titleContextMenu explaining how the autocorrection works." + }, + + "optionAutocorrectSymbols": { + "message": "Korrigiere Unicode-Symbole", + "description": "This is an option shown in the add-on settings." + }, + "optionAutocorrectSymbolsDescr": { + "message": "Dies ersetzt bspw. $CODE_HYPHEN$ durch –, $CODE_ARROW$ durch ⟶ und $CODE_FRACTION$ mit ¼.", + "description": "This is an option shown in the add-on settings. It describes the optionAutocorrectSymbols setting.", + "placeholders": { + "code_hyphen": { + "content": "$1", + "example": "--" + }, + "code_arrow": { + "content": "$2", + "example": "-->" + }, + "code_fraction": { + "content": "$3", + "example": "1/4" + } + } + }, + "optionReplaceQuotes": { + "message": "Ersetze Anführungszeichen mit der typografischen Version", + "description": "This is an option shown in the add-on settings." + }, + "optionReplaceQuotesDescr": { + "message": "Dies ersetzt \"diese ('Ersatz-')Anführungszeichen\" mit den sogenannten “smart quotes” bzw. deren “etwas ‘kleinerer’ Variante”.", + "description": "This is an option shown in the add-on settings. It describes the optionReplaceQuotes setting." + }, + "optionConvertFractions": { + "message": "Konvertiere Brüche und andere mathematische Konstanten zu Unicode-Zeichen", + "description": "This is an option shown in the add-on settings." + }, + "optionConvertFractionsDescr": { + "message": "Dies wird bspw. $CODE_NUMBER$ mit 1234¼ ersetzen.", + "description": "This is an option shown in the add-on settings. It describes the optionConvertFractions setting.", + "placeholders": { + "code_number": { + "content": "$1", + "example": "1234.25" + } + } + }, + + "optionMenuUnicodeFont": { + "message": "Zeige Uncode-Schriftarten-Optionen", + "description": "This is an option shown in the add-on settings." + }, + "optionMenuUnicodeFontDescr": { + "message": "Wie bspw. ˢᵘᵖᵉʳˢᶜʳⁱᵖᵗ, ꜱᴍᴀʟʟ ᴄᴀᴘꜱ, 𝒮𝒸𝓇𝒾𝓅𝓉, 𝔉𝔯𝔞𝔨𝔱𝔲𝔯, 🅒🅘🅡🅒🅛🅔🅓 und 🆂🆀🆄🅰🆁🅴🅳.", + "description": "This is an option shown in the add-on settings. It describes the optionMenuUnicodeFont setting." + }, + "optionMenuCasing": { + "message": "Zeige Optionen zur Änderung der Groß-/Kleinschreibung", + "description": "This is an option shown in the add-on settings." + }, + "optionMenuCasingDescr": { + "message": "Zum Beispiel, “GROẞSCHREIBUNG”, “kleinschreibung”, “Schriebe Jedes Wort Groß” or “kEHRE gROẞSCHREIBUNG uM”.", + "description": "This is an option shown in the add-on settings. It describes the optionMenuCasing setting." + }, + + // option footer + "translatorCredit": { + "message": "Dieses Add-on wurde von $TRANSLATORS$ ins Deutsche übersetzt.", + "description": "The credit text for the translator. See https://github.com/TinyWebEx/common/blob/master/CONTRIBUTING.md#translator-credit-inside-of-add-on for how to translate this.", + "placeholders": { + "translators": { + "content": "$1", + "example": "@rugk" + } + } + }, + "translatorLink": { + "message": "https://github.com/rugk", + "description": "The link to the translator's GitHub profile." + }, + "translatorUsername": { + "message": "rugk", + "description": "The username that the translator wants to be referred to." + }, + + "contributorsThanks": { + "message": "Ebenfalls vielen Dank an $CONTRIBUTORS$.", + "description": "Text thanking all contributors and linking to the contributors file.", + "placeholders": { + "contributors": { + "content": "$1", + "example": "all other contributors" + } + } + }, + "contributorsThanksLink": { + "message": "https://github.com/rugk/awesome-emoji-picker/blob/master/CONTRIBUTORS.md", + "description": "The link to the CONTRIBUTORS file." + }, + "contributorsThanksLinkText": { + "message": "alle anderen Beitragenden", + "description": "The link text linking to the contributors file. See contributorsThanks." + }, + // ARIA labels/descriptions "dismissIconDescription": { "message": "Diese Nachricht schließen", diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index ee053d7..1af738c 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -61,6 +61,157 @@ "description": "The button to delete all current settings and load the defaults, shown in the add-on settings." }, + "titleUnicodeAutocorrection": { + "message": "Unicode autocorrection", + "description": "A title in the add-on settings." + }, + "titleContextMenu": { + "message": "Context menu", + "description": "A title in the add-on settings." + }, + + "optionHelperTextAutocorrection": { + "message": "You can configure the automatic corrections that are done when you are typing text here.$BR$All the autocorrections are done after typing the first nonmatching character following the character sequence, such as a space (␣). Press Backspace (⌫) to undo an autocorrection. Only the quotes replacement is done immediately.", + "description": "Description for the section titleUnicodeAutocorrection explaining how the autocorrection works.", + "placeholders": { + "br": { + "content": "$1", + "example": "
" + } + } + }, + "optionHelperTextAutocorrectionEmoji": { + "message": "For Emoji autocorrection, including $COLON$ shortcodes and Emoticons, please also try out our $LINK$ add-on.", + "description": "Description for the section titleUnicodeAutocorrection advertising the Awesome Emoji Picker add-on.", + "placeholders": { + "colon": { + "content": "$1", + "example": ":colon:" + }, + "link": { + "content": "$2", + "example": "🤩 Awesome Emoji Picker" + } + } + }, + "optionHelperTextAutocorrectionEmojiColonsCode": { + "message": ":colon:", + "description": "This is included in code-style in optionHelperTextAutocorrectionEmoji." + }, + "optionHelperTextAutocorrectionEmojiLink": { + "message": "https://addons.mozilla.org/firefox/addon/awesome-emoji-picker/", + "description": "The target for the link provided in optionHelperTextAutocorrectionEmoji. Usually should not be modified and link to the AMO page of the Awesome Emoji Picker. It does redirect to the correct language automatically." + }, + "optionHelperTextAutocorrectionEmojiLinkText": { + "message": "🤩\u00a0Awesome Emoji Picker", + "description": "The text for the link provided in optionHelperTextAutocorrectionEmoji. Should be the official name of the emoji picker add-on in your language." + }, + "optionHelperTextContextMenu": { + "message": "Write, select text and choose the corresponding option in the context menu to quickly change the character style or capitalization. This is useful on websites that do not support changing the font or text formatting.", + "description": "Description for the section titleContextMenu explaining how the autocorrection works." + }, + + "optionAutocorrectSymbols": { + "message": "Autocorrect Unicode symbols", + "description": "This is an option shown in the add-on settings." + }, + "optionAutocorrectSymbolsDescr": { + "message": "For example, this will replace $CODE_HYPHEN$ with –, $CODE_ARROW$ with ⟶ and $CODE_FRACTION$ with ¼.", + "description": "This is an option shown in the add-on settings. It describes the optionAutocorrectSymbols setting.", + "placeholders": { + "code_hyphen": { + "content": "$1", + "example": "--" + }, + "code_arrow": { + "content": "$2", + "example": "-->" + }, + "code_fraction": { + "content": "$3", + "example": "1/4" + } + } + }, + "optionReplaceQuotes": { + "message": "Replace quotes with typographical ones", + "description": "This is an option shown in the add-on settings." + }, + "optionReplaceQuotesDescr": { + "message": "This will replace \"these ('replacement') quotes\" with the so-called “smart quotes”, respectively their “somewhat ‘smaller’ variant”.", + "description": "This is an option shown in the add-on settings. It describes the optionReplaceQuotes setting." + }, + "optionConvertFractions": { + "message": "Convert fractions and mathematical constants to Unicode characters", + "description": "This is an option shown in the add-on settings." + }, + "optionConvertFractionsDescr": { + "message": "For example, this will replace $CODE_NUMBER$ with 1234¼.", + "description": "This is an option shown in the add-on settings. It describes the optionConvertFractions setting.", + "placeholders": { + "code_number": { + "content": "$1", + "example": "1234.25" + } + } + }, + + "optionMenuUnicodeFont": { + "message": "Show Unicode font options", + "description": "This is an option shown in the add-on settings." + }, + "optionMenuUnicodeFontDescr": { + "message": "For example, ˢᵘᵖᵉʳˢᶜʳⁱᵖᵗ, ꜱᴍᴀʟʟ ᴄᴀᴘꜱ, 𝒮𝒸𝓇𝒾𝓅𝓉, 𝔉𝔯𝔞𝔨𝔱𝔲𝔯, 🅒🅘🅡🅒🅛🅔🅓 and 🆂🆀🆄🅰🆁🅴🅳.", + "description": "This is an option shown in the add-on settings. It describes the optionMenuUnicodeFont setting." + }, + "optionMenuCasing": { + "message": "Show case changing options", + "description": "This is an option shown in the add-on settings." + }, + "optionMenuCasingDescr": { + "message": "For example, “UPPER CASE”, “lower case”, “Capitalize Each Word” or “tOGGLE cASE”.", + "description": "This is an option shown in the add-on settings. It describes the optionMenuCasing setting." + }, + + // option footer + "translatorCredit": { + "message": "This add-on has been translated into English by $TRANSLATORS$.", + "description": "The credit text for the translator. See https://github.com/TinyWebEx/common/blob/master/CONTRIBUTING.md#translator-credit-inside-of-add-on for how to translate this.", + "placeholders": { + "translators": { + "content": "$1", + "example": "@rugk" + } + } + }, + "translatorLink": { + "message": "https://github.com/rugk/unicodify/blob/main/CONTRIBUTORS.md#english", + "description": "The link to the translator's GitHub profile." + }, + "translatorUsername": { + "message": "Teal Dulcet and rugk", + "description": "The username that the translator wants to be referred to." + }, + + "contributorsThanks": { + "message": "Also thanks to $CONTRIBUTORS$.", + "description": "Text thanking all contributors and linking to the contributors file.", + "placeholders": { + "contributors": { + "content": "$1", + "example": "all other contributors" + } + } + }, + "contributorsThanksLink": { + "message": "https://github.com/rugk/awesome-emoji-picker/blob/master/CONTRIBUTORS.md", + "description": "The link to the CONTRIBUTORS file." + }, + "contributorsThanksLinkText": { + "message": "all other contributors", + "description": "The link text linking to the contributors file. See contributorsThanks." + }, + // ARIA labels/descriptions "dismissIconDescription": { "message": "Close this message", diff --git a/src/options/options.html b/src/options/options.html index be1c0da..3f3f760 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -54,59 +54,63 @@
    -

    Unicode autocorrection

    - +

    Unicode autocorrection

    + You can configure the automatic corrections that are done when you are typing text here.
    All the autocorrections are done after typing the first nonmatching character following the character sequence, such as a space (␣). Press Backspace (⌫) to undo an autocorrection. - Only the quotes replacement is done immediately.
    - For Emoji autocorrection, including :colon: shortcodes and Emoticons, please try our 🤩 Awesome Emoji Picker add-on.
    + Only the quotes replacement is done immediately. +

    + + For Emoji autocorrection, including :colon: shortcodes and Emoticons, please also try out our 🤩 Awesome Emoji Picker add-on. +
  • - +
    - For example, this will replace -- with –, --> with ⟶ and 1/4 with ¼. + For example, this will replace -- with –, --> with ⟶ and 1/4 with ¼.
  • - +
    - This will replace "these ('replacement') quotes" with the so-called “smart quotes”, respectively their ‘replacement version’”. + This will replace "these ('replacement') quotes" with the so-called “smart quotes”, respectively their “somewhat ‘smaller’ variant”.
  • - +
    - For example, this will replace 1234.25 with 1234¼. + For example, this will replace 1234.25 with 1234¼.
    -

    Context menu

    - Write, select text and select the corresponding option in the context menu to quickly change the character style or casing. - This is useful on websites that do not support changing the font and/or text formatting. +

    Context menu

    + Write, select text and choose the corresponding option in the context menu to quickly change the character style or capitalization. + This is useful on websites that do not support changing the font or text formatting.
  • - +
    - For example, ˢᵘᵖᵉʳˢᶜʳⁱᵖᵗ, ꜱᴍᴀʟʟ ᴄᴀᴘꜱ, 𝒮𝒸𝓇𝒾𝓅𝓉, 𝔉𝔯𝔞𝔨𝔱𝔲𝔯, 🅒🅘🅡🅒🅛🅔🅓 and 🆂🆀🆄🅰🆁🅴🅳. + For example, ˢᵘᵖᵉʳˢᶜʳⁱᵖᵗ, ꜱᴍᴀʟʟ ᴄᴀᴘꜱ, 𝒮𝒸𝓇𝒾𝓅𝓉, 𝔉𝔯𝔞𝔨𝔱𝔲𝔯, 🅒🅘🅡🅒🅛🅔🅓 and 🆂🆀🆄🅰🆁🅴🅳.
  • - +
    - For example, “UPPER CASE”, “lower case”, “Capitalize Each Word” or “tOGGLE cASE”. + For example, “UPPER CASE”, “lower case”, “Capitalize Each Word” or “tOGGLE cASE”.
From e09ba85821b6bf1c0263a22e6aaee081242ca757 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 28 Nov 2020 21:19:07 +0100 Subject: [PATCH 2/9] refactor: minor changes recommend by eslint --- src/common/modules/AutocorrectHandler.js | 2 +- src/options/modules/CustomOptionTriggers.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/modules/AutocorrectHandler.js b/src/common/modules/AutocorrectHandler.js index 4e28575..5a32002 100644 --- a/src/common/modules/AutocorrectHandler.js +++ b/src/common/modules/AutocorrectHandler.js @@ -157,7 +157,7 @@ export async function init() { setSettings(autocorrect); - browser.runtime.onMessage.addListener((message, sender) => { + browser.runtime.onMessage.addListener((message) => { // console.log(message); if (message.type === COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT) { const response = { diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 758f483..4934a67 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -5,7 +5,6 @@ */ import * as AutomaticSettings from "/common/modules/AutomaticSettings/AutomaticSettings.js"; - import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; @@ -18,7 +17,7 @@ import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunic * @param {Object} [event] * @returns {Promise} */ -function applyAutocorrectPermissions(optionValue, option, event) { +function applyAutocorrectPermissions(optionValue) { // trigger update for current session browser.runtime.sendMessage({ "type": COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_BACKGROUND, @@ -35,7 +34,7 @@ function applyAutocorrectPermissions(optionValue, option, event) { * @param {Object} [event] * @returns {Promise} */ -function applyUnicodeFontSettings(optionValue, option, event) { +function applyUnicodeFontSettings(optionValue) { // trigger update for current session browser.runtime.sendMessage({ "type": COMMUNICATION_MESSAGE_TYPE.UNICODE_FONT, From c1019899a819e828ae549ed30295477c96a2632c Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 2 Dec 2020 17:43:10 +0100 Subject: [PATCH 3/9] i18n: put menu strings into en.json --- src/_locales/en/messages.json | 111 +++++++++++++++++++++++ src/common/modules/UnicodeFontHandler.js | 10 +- src/common/modules/data/Fonts.js | 13 ++- 3 files changed, 127 insertions(+), 7 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 1af738c..7460b40 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -43,6 +43,117 @@ "description": "The message shown, when the options of the settings could not have been reset." }, + // context menu + "menuCaseLowercase": { + "message": "Lowercase", + "description": "An entry in the context menu. This is an entry for the case." + }, + "menuCaseUppercase": { + "message": "Uppercase", + "description": "An entry in the context menu. This is an entry for the case." + }, + "menuCaseCapitalizeEachWord": { + "message": "Capitalize Each Word", + "description": "An entry in the context menu. This is an entry for the case." + }, + "menuCaseToggleCase": { + "message": "Toggle Case", + "description": "An entry in the context menu. This is an entry for the case." + }, + + "menuFontSuperscript": { + "message": "Superscript", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSmallCaps": { + "message": "Small Caps", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontAllSmallCaps": { + "message": "All Small Caps", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontUnicase": { + "message": "Unicase", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSerifBold": { + "message": "Serif bold", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSerifItalic": { + "message": "Serif italic", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSerifBoldItalic": { + "message": "Serif bold italic", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSerifBoldItalic": { + "message": "Serif bold italic", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSansSerif": { + "message": "Sans-serif", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSansSerifBold": { + "message": "Sans-serif bold", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSansSerifItalic": { + "message": "Sans-serif italic", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSansSerifBoldItalic": { + "message": "Sans-serif bold italic", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontScript": { + "message": "Script", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontScriptBold": { + "message": "Script bold", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontScriptFraktur": { + "message": "Fraktur", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontFrakturBold": { + "message": "Fraktur bold", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontMonospace": { + "message": "Monospace", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontDoubleStruck": { + "message": "Double-struck", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontCircled": { + "message": "Circled", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontCircledBlack": { + "message": "Circled (black)", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSquared": { + "message": "Squared", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontSquaredBlack": { + "message": "Squared (black)", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + "menuFontFullwidth": { + "message": "Fullwidth", + "description": "An entry in the context menu. This is an entry for the Unicode font." + }, + // options "someSettingsAreManaged": { "message": "Some settings are managed by your system administrator and cannot be changed.", diff --git a/src/common/modules/UnicodeFontHandler.js b/src/common/modules/UnicodeFontHandler.js index cc5a763..e0163bd 100644 --- a/src/common/modules/UnicodeFontHandler.js +++ b/src/common/modules/UnicodeFontHandler.js @@ -5,7 +5,7 @@ import * as BrowserCommunication from "/common/modules/BrowserCommunication/Brow import { isMobile } from "./MobileHelper.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; -import { caseIds, fontIds, fonts } from "/common/modules/data/Fonts.js"; +import { caseIds, fontIds, fonts, SEPARATOR_ID } from "/common/modules/data/Fonts.js"; /** * Change Unicode font. @@ -161,7 +161,7 @@ function applySettings(unicodeFont) { if (unicodeFont.changeCase) { for (const id of caseIds) { // .replaceAll(" ", "-"); - const aid = id.toLowerCase().split(" ").join("-"); + const aid = browser.i18n.getMessage(id).toLowerCase().split(" ").join("-"); menus.create({ "id": aid, "title": changeCase[aid](id), @@ -172,7 +172,7 @@ function applySettings(unicodeFont) { if (unicodeFont.changeCase && unicodeFont.changeFont) { menus.create({ - id: "separator-2", + id: "separator-text-transforms", type: "separator", contexts: ["editable"] }); @@ -180,7 +180,7 @@ function applySettings(unicodeFont) { if (unicodeFont.changeFont) { for (const id of fontIds) { - if (id === "separator") { + if (id === SEPARATOR_ID) { menus.create({ // id: id, type: "separator", @@ -188,7 +188,7 @@ function applySettings(unicodeFont) { }); } else { // .replaceAll(" ", "-"); - const aid = id.toLowerCase().split(" ").join("-"); + const aid = browser.i18n.getMessage(id).toLowerCase().split(" ").join("-"); // console.log(id, aid, fonts[aid], changeFont(id, aid)); menus.create({ "id": aid, diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index 559dd39..aaecd19 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -3,6 +3,15 @@ // Adapted from: https://entropymine.wordpress.com/2018/05/26/the-curious-case-of-small-caps-in-unicode/ const smallCaps = "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘꞯʀꜱᴛᴜᴠᴡxʏᴢ"; +/** + * Separater symbol + * + * @public + * @const + * @type {Symbol} + */ +export const SEPARATOR_ID = Symbol("separator"); + /** * Case IDs * @@ -10,7 +19,7 @@ const smallCaps = "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘꞯʀꜱᴛᴜᴠ * @const * @type {Object.} */ -export const caseIds = Object.freeze(["Lowercase", "Uppercase", "Capitalize Each Word", "Toggle Case"]); +export const caseIds = Object.freeze(["menuCaseLowercase", "menuCaseUppercase", "menuCaseCapitalizeEachWord", "menuCaseToggleCase"]); /** * Font IDs * @@ -18,7 +27,7 @@ export const caseIds = Object.freeze(["Lowercase", "Uppercase", "Capitalize Each * @const * @type {Object.} */ -export const fontIds = Object.freeze(["Superscript", "Small Caps", "All Small Caps", "Unicase", "separator", "Serif bold", "Serif italic", "Serif bold italic", "Sans-serif", "Sans-serif bold", "Sans-serif italic", "Sans-serif bold italic", "Script", "Script bold", "Fraktur", "Fraktur bold", "Monospace", "Double-struck", "separator", "Circled", "Circled (black)", "Squared", "Squared (black)", "Fullwidth"]); +export const fontIds = Object.freeze(["menuFontSuperscript", "menuFontSmallCaps", "menuFontAllSmallCaps", "menuFontUnicase", SEPARATOR_ID, "menuFontSerifBold", "menuFontSerifItalic", "menuFontSerifBoldItalic", "menuFontSansSerif", "menuFontSansSerifBold", "menuFontSansSerifItalic", "menuFontSansSerifBoldItalic", "menuFontScript", "menuFontScriptBold", "menuFontScriptFraktur", "menuFontFrakturBold", "menuFontMonospace", "menuFontDoubleStruck", SEPARATOR_ID, "menuFontCircled", "menuFontCircledBlack", "menuFontSquared", "menuFontSquaredBlack", "menuFontFullwidth"]); /** * Unicode fonts From cb6c3ee50c1f58a6eba9caa9fd19207ff690b58d Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 2 Dec 2020 17:51:10 +0100 Subject: [PATCH 4/9] refactor: one line per item --- src/common/modules/data/Fonts.js | 35 ++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index aaecd19..4952a13 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -19,7 +19,13 @@ export const SEPARATOR_ID = Symbol("separator"); * @const * @type {Object.} */ -export const caseIds = Object.freeze(["menuCaseLowercase", "menuCaseUppercase", "menuCaseCapitalizeEachWord", "menuCaseToggleCase"]); +export const caseIds = Object.freeze([ + "menuCaseLowercase", + "menuCaseUppercase", + "menuCaseCapitalizeEachWord", + "menuCaseToggleCase" +]); + /** * Font IDs * @@ -27,7 +33,32 @@ export const caseIds = Object.freeze(["menuCaseLowercase", "menuCaseUppercase", * @const * @type {Object.} */ -export const fontIds = Object.freeze(["menuFontSuperscript", "menuFontSmallCaps", "menuFontAllSmallCaps", "menuFontUnicase", SEPARATOR_ID, "menuFontSerifBold", "menuFontSerifItalic", "menuFontSerifBoldItalic", "menuFontSansSerif", "menuFontSansSerifBold", "menuFontSansSerifItalic", "menuFontSansSerifBoldItalic", "menuFontScript", "menuFontScriptBold", "menuFontScriptFraktur", "menuFontFrakturBold", "menuFontMonospace", "menuFontDoubleStruck", SEPARATOR_ID, "menuFontCircled", "menuFontCircledBlack", "menuFontSquared", "menuFontSquaredBlack", "menuFontFullwidth"]); +export const fontIds = Object.freeze([ + "menuFontSuperscript", + "menuFontSmallCaps", + "menuFontAllSmallCaps", + "menuFontUnicase", + SEPARATOR_ID, + "menuFontSerifBold", + "menuFontSerifItalic", + "menuFontSerifBoldItalic", + "menuFontSansSerif", + "menuFontSansSerifBold", + "menuFontSansSerifItalic", + "menuFontSansSerifBoldItalic", + "menuFontScript", + "menuFontScriptBold", + "menuFontScriptFraktur", + "menuFontFrakturBold", + "menuFontMonospace", + "menuFontDoubleStruck", + SEPARATOR_ID, + "menuFontCircled", + "menuFontCircledBlack", + "menuFontSquared", + "menuFontSquaredBlack", + "menuFontFullwidth" +]); /** * Unicode fonts From b8307afebe48e8c3cfda376452852b5e1b5b92cc Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 2 Dec 2020 18:22:36 +0100 Subject: [PATCH 5/9] refactor: font character --- src/common/modules/UnicodeFontHandler.js | 20 +++++++++++--------- src/common/modules/data/Fonts.js | 23 ++++++++++++++++++----- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/common/modules/UnicodeFontHandler.js b/src/common/modules/UnicodeFontHandler.js index e0163bd..de9bada 100644 --- a/src/common/modules/UnicodeFontHandler.js +++ b/src/common/modules/UnicodeFontHandler.js @@ -5,18 +5,19 @@ import * as BrowserCommunication from "/common/modules/BrowserCommunication/Brow import { isMobile } from "./MobileHelper.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; -import { caseIds, fontIds, fonts, SEPARATOR_ID } from "/common/modules/data/Fonts.js"; +import { caseIds, fontIds, fontLetters, SEPARATOR_ID } from "/common/modules/data/Fonts.js"; /** - * Change Unicode font. + * Changes the Unicode font of the given text. + * * It replaces each ASCII character in the text with the corresponding character from the Unicode font. * * @param {string} text - * @param {string} afont + * @param {string} chosenFont * @returns {string} */ -function changeFont(text, afont) { - const font = fonts[afont]; +function changeFont(text, chosenFont) { + const font = fontLetters[chosenFont]; // console.log(afont, font); let output = ''; @@ -48,12 +49,13 @@ function changeFont(text, afont) { /** * Capitalize Each Word. * - * @param {string} atext + * @param {string} text * @returns {string} */ -function capitalizeEachWord(atext) { - // Regular expression Unicode property escapes and lookbehind assertions require Firefox/Thunderbird 78, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#bcd:javascript.builtins.RegExp - return atext.replace(/(?<=^|\P{Alpha})\p{Alpha}\S*/gu, ([h, ...t]) => h.toLocaleUpperCase() + t.join('')); +function capitalizeEachWord(text) { + // Regular expression Unicode property escapes and lookbehind assertions require Firefox/Thunderbird 78 + // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#bcd:javascript.builtins.RegExp + return text.replace(/(?<=^|\P{Alpha})\p{Alpha}\S*/gu, ([h, ...t]) => h.toLocaleUpperCase() + t.join('')); } /** diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index 4952a13..1626e1c 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -64,11 +64,11 @@ export const fontIds = Object.freeze([ * Unicode fonts * Some of the fonts have characters that are not yet implemented. * - * @public + * @private * @const * @type {Object.} */ -export const fonts = { +const fonts = { "serif-bold": "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", "serif-italic": "𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑊𝑋𝑌𝑍𝑎𝑏𝑐𝑑𝑒𝑓𝑔ℎ𝑖𝑗𝑘𝑙𝑚𝑛𝑜𝑝𝑞𝑟𝑠𝑡𝑢𝑣𝑤𝑥𝑦𝑧", "serif-bold-italic": "𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛", @@ -94,6 +94,19 @@ export const fonts = { "unicase": `${smallCaps}abcdefghijklmnopqrstuvwxyz` }; -Object.keys(fonts).map((key) => fonts[key] = Array.from(fonts[key])); - -Object.freeze(fonts); +/** + * All letters for each Unicode font + * + * Some of the fonts have characters that are not yet implemented. + * The most similar looking are choosen in such a case. + * + * @public + * @const + * @type {Object.} + */ +export const fontLetters = Object.freeze( + Object.fromEntries(Object.entries(fonts).map(([font, charString]) => { + // split-up the letter string an array with each character + return [font, Array.from(charString)]; + })) +); From 3ef07cff1520e376a3775c3e286255cc775d63c9 Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 2 Dec 2020 23:31:41 +0100 Subject: [PATCH 6/9] refactor: use ID as Symbol as a common key --- jsconfig.json | 13 ++ src/_locales/en/messages.json | 4 - src/common/modules/UnicodeFontHandler.js | 282 ++++++++++------------- src/common/modules/data/Fonts.js | 232 ++++++++++++++----- 4 files changed, 311 insertions(+), 220 deletions(-) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..ff02e18 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es2017", + "checkJs": true, + "baseUrl": "src", + "moduleResolution": "classic", + "paths": { + "/*": ["./*"] + } + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "**/node_modules/*"] +} diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 7460b40..06dabb3 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -89,10 +89,6 @@ "message": "Serif bold italic", "description": "An entry in the context menu. This is an entry for the Unicode font." }, - "menuFontSerifBoldItalic": { - "message": "Serif bold italic", - "description": "An entry in the context menu. This is an entry for the Unicode font." - }, "menuFontSansSerif": { "message": "Sans-serif", "description": "An entry in the context menu. This is an entry for the Unicode font." diff --git a/src/common/modules/UnicodeFontHandler.js b/src/common/modules/UnicodeFontHandler.js index de9bada..e6e8379 100644 --- a/src/common/modules/UnicodeFontHandler.js +++ b/src/common/modules/UnicodeFontHandler.js @@ -5,7 +5,7 @@ import * as BrowserCommunication from "/common/modules/BrowserCommunication/Brow import { isMobile } from "./MobileHelper.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; -import { caseIds, fontIds, fontLetters, SEPARATOR_ID } from "/common/modules/data/Fonts.js"; +import { CASE, FONT, SEPARATOR, contextMenuList, menuTranslation, fontMap, caseByString, fontByString } from "/common/modules/data/Fonts.js"; /** * Changes the Unicode font of the given text. @@ -13,37 +13,38 @@ import { caseIds, fontIds, fontLetters, SEPARATOR_ID } from "/common/modules/dat * It replaces each ASCII character in the text with the corresponding character from the Unicode font. * * @param {string} text - * @param {string} chosenFont + * @param {Symbol} chosenFont * @returns {string} */ function changeFont(text, chosenFont) { - const font = fontLetters[chosenFont]; - // console.log(afont, font); - let output = ''; - - for (let letter of text) { - const code = letter.charCodeAt(0); - if (code >= 33 && code <= 127) { - if (font.length == 94) - letter = font[code - '!'.charCodeAt(0)]; - else if (letter >= 'A' && letter <= 'Z') { - letter = font[code - 'A'.charCodeAt(0)]; - } else if (letter >= 'a' && letter <= 'z') { - if (font.length == 26 || font.length == 26 + 10) - letter = font[code - 'a'.charCodeAt(0)]; - else if (font.length == 26 + 26 || font.length == 26 + 26 + 10) - letter = font[code - 'a'.charCodeAt(0) + 26]; - } else if (letter >= '0' && letter <= '9') { - if (font.length == 26 + 10) - letter = font[code - '0'.charCodeAt(0) + 26]; - else if (font.length == 26 + 26 + 10) - letter = font[code - '0'.charCodeAt(0) + 26 + 26]; - } - } - output += letter; - } - - return output; + const font = fontMap[chosenFont]; + let output = ""; + + for (let letter of text) { + const code = letter.charCodeAt(0); + if (code >= 33 && code <= 127) { + if (font.length === 94) { + letter = font[code - "!".charCodeAt(0)]; + } else if (letter >= "A" && letter <= "Z") { + letter = font[code - "A".charCodeAt(0)]; + } else if (letter >= "a" && letter <= "z") { + if (font.length === 26 || font.length === 26 + 10) { + letter = font[code - "a".charCodeAt(0)]; + } else if (font.length === 26 + 26 || font.length === 26 + 26 + 10) { + letter = font[code - "a".charCodeAt(0) + 26]; + } + } else if (letter >= "0" && letter <= "9") { + if (font.length === 26 + 10) { + letter = font[code - "0".charCodeAt(0) + 26]; + } else if (font.length === 26 + 26 + 10) { + letter = font[code - "0".charCodeAt(0) + 26 + 26]; + } + } + } + output += letter; + } + + return output; } /** @@ -55,98 +56,84 @@ function changeFont(text, chosenFont) { function capitalizeEachWord(text) { // Regular expression Unicode property escapes and lookbehind assertions require Firefox/Thunderbird 78 // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#bcd:javascript.builtins.RegExp - return text.replace(/(?<=^|\P{Alpha})\p{Alpha}\S*/gu, ([h, ...t]) => h.toLocaleUpperCase() + t.join('')); + // return text.replace(/(?<=^|\P{Alpha})\p{Alpha}\S*/gu, ([h, ...t]) => h.toLocaleUpperCase() + t.join('')); } /** - * Toggle Case. + * Toggle case of text. * - * @param {string} atext + * @param {string} text * @returns {string} */ -function toggleCase(atext) { - let output = ''; - - for (let letter of atext) { - const upper = letter.toLocaleUpperCase(); - const lower = letter.toLocaleLowerCase(); - if (letter === lower && letter !== upper) - letter = upper; - else if (letter === upper && letter !== lower) - letter = lower; - output += letter; - } - - return output; +function toggleCase(text) { + let output = ""; + + for (let letter of text) { + const upper = letter.toLocaleUpperCase(); + const lower = letter.toLocaleLowerCase(); + if (letter === lower && letter !== upper) { + letter = upper; + } else if (letter === upper && letter !== lower) { + letter = lower; + } + output += letter; + } + + return output; } /** * Change Case * - * @public + * @private * @const * @type {Object.} */ const changeCase = Object.freeze({ - "lowercase": (str) => str.toLocaleLowerCase(), - "uppercase": (str) => str.toLocaleUpperCase(), - "capitalize-each-word": (str) => capitalizeEachWord(str.toLocaleLowerCase()), - "toggle-case": (str) => toggleCase(str) + [CASE.CAPITALIZE]: (text) => capitalizeEachWord(text.toLocaleLowerCase()), + [CASE.LOWERCASE]: (text) => text.toLocaleLowerCase(), + [CASE.TOGGLE]: (text) => toggleCase(text), + [CASE.UPPERCASE]: (text) => text.toLocaleUpperCase(), }); /** - * Handle context menu click. + * Handle context menu selection. * * @param {Object} info * @param {Object} tab * @returns {void} */ -function handle(info, tab) { - let text = info.selectionText; - - if (text) { - text = text.normalize(); - let output = ''; - - switch (info.menuItemId) { - case "lowercase": - case "uppercase": - case "capitalize-each-word": - case "toggle-case": - output = changeCase[info.menuItemId](text); - break; - case "superscript": - case "small-caps": - case "all-small-caps": - case "unicase": - case "serif-bold": - case "serif-italic": - case "serif-bold-italic": - case "sans-serif": - case "sans-serif-bold": - case "sans-serif-italic": - case "sans-serif-bold-italic": - case "script": - case "script-bold": - case "fraktur": - case "fraktur-bold": - case "monospace": - case "double-struck": - case "circled": - case "circled-(black)": - case "squared": - case "squared-(black)": - case "fullwidth": { - output = changeFont(text, info.menuItemId); - break; - } - } - - browser.tabs.executeScript(tab.id, { - code: `insertIntoPage("${output}");`, - frameId: info.frameId - }); - } +function handleMenuSelect(info, tab) { + let text = info.selectionText; + + // ignore, if no text is selected + if (!text) { + return; + } + + text = text.normalize(); + let output = ""; + + // convert string back to Symbol + const caseId = caseByString[info.menuItemId]; + const fontId = fontByString[info.menuItemId]; + if (caseId) { + output = changeCase[caseId](text); + } else if (fontId) { + output = changeFont(text, fontId); + } else { + throw new Error(`Unknown menu item selected. Expected FONT or CASE; but got ${info.menuItemId}`); + } + + if (!output) { + throw new Error(`Unknown conversion error occured for menu item ${info.menuItemId}`); + } + + // finally inject if everything is all right + browser.tabs.executeScript(tab.id, { + code: `insertIntoPage("${output}");`, + frameId: info.frameId + }); } /** @@ -156,75 +143,60 @@ function handle(info, tab) { * @returns {void} */ function applySettings(unicodeFont) { - const menus = browser.menus || browser.contextMenus; // fallback for Thunderbird - - menus.removeAll(); - - if (unicodeFont.changeCase) { - for (const id of caseIds) { - // .replaceAll(" ", "-"); - const aid = browser.i18n.getMessage(id).toLowerCase().split(" ").join("-"); - menus.create({ - "id": aid, - "title": changeCase[aid](id), - "contexts": ["editable"], - }); - } - } - - if (unicodeFont.changeCase && unicodeFont.changeFont) { - menus.create({ - id: "separator-text-transforms", - type: "separator", - contexts: ["editable"] - }); - } - - if (unicodeFont.changeFont) { - for (const id of fontIds) { - if (id === SEPARATOR_ID) { - menus.create({ - // id: id, - type: "separator", - contexts: ["editable"] - }); - } else { - // .replaceAll(" ", "-"); - const aid = browser.i18n.getMessage(id).toLowerCase().split(" ").join("-"); - // console.log(id, aid, fonts[aid], changeFont(id, aid)); - menus.create({ - "id": aid, - "title": changeFont(id, aid), - "contexts": ["editable"], - }); - } - } - } + const menus = browser.menus || browser.contextMenus; // fallback for Thunderbird + + menus.removeAll(); + + let menuItemsToShow = contextMenuList; + if (!unicodeFont.changeCase) { + const caseValues = Object.values(CASE); + menuItemsToShow = contextMenuList.filter((id) => !caseValues.includes(id) ); + } + if (!unicodeFont.changeFont) { + const fontValues = Object.values(FONT); + menuItemsToShow = contextMenuList.filter((id) => !fontValues.includes(id) ); + } + menuItemsToShow + .filter((id, index) => (index !== 0 || id !== SEPARATOR)) + .forEach((id) => { + if (id === SEPARATOR) { + menus.create({ + type: "separator", + contexts: ["editable"] + }); + } else { + menus.create({ + "id": id.toString(), + "title": browser.i18n.getMessage(menuTranslation[id]), + "contexts": ["editable"], + }); + } + }); } /** * Init Unicode font module. * * @public - * @returns {void} + * @returns {Promise} */ export async function init() { - if (await isMobile()) { - return; - } + if (await isMobile()) { + return; + } - const unicodeFont = await AddonSettings.get("unicodeFont"); + const unicodeFont = await AddonSettings.get("unicodeFont"); - applySettings(unicodeFont); + applySettings(unicodeFont); - const menus = browser.menus || browser.contextMenus; // fallback for Thunderbird + const menus = browser.menus || browser.contextMenus; // fallback for Thunderbird - menus.onClicked.addListener(handle); + menus.onClicked.addListener(handleMenuSelect); - BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UNICODE_FONT, (request) => { - // clear cache by reloading all options - // await AddonSettings.loadOptions(); + BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UNICODE_FONT, (request) => { + // clear cache by reloading all options + // await AddonSettings.loadOptions(); - return applySettings(request.optionValue); - }); + return applySettings(request.optionValue); + }); } diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index 1626e1c..d70534c 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -1,3 +1,4 @@ + "use strict"; // Adapted from: https://entropymine.wordpress.com/2018/05/26/the-curious-case-of-small-caps-in-unicode/ @@ -10,88 +11,197 @@ const smallCaps = "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘꞯʀꜱᴛᴜᴠ * @const * @type {Symbol} */ -export const SEPARATOR_ID = Symbol("separator"); +export const SEPARATOR = Symbol("separator"); /** * Case IDs * * @public * @const - * @type {Object.} + * @type {Object.} */ -export const caseIds = Object.freeze([ - "menuCaseLowercase", - "menuCaseUppercase", - "menuCaseCapitalizeEachWord", - "menuCaseToggleCase" -]); +export const CASE = Object.freeze({ + CAPITALIZE: Symbol("capitalize-each-word"), + LOWERCASE: Symbol("lowercase"), + TOGGLE: Symbol("toggle-case"), + UPPERCASE: Symbol("uppercase"), +}); + +/** + * Contains the "inversed" array of the casing options. + * + * It helps you to access ther {@see CASE} object with an Symbol.toString() value. + * + * @public + * @const + * @type {Object.} + */ +export const caseByString = Object.freeze( + Object.fromEntries(Object.entries(CASE).map(([key, symbol]) => { + return [symbol.toString(), symbol]; + })) +); /** * Font IDs * * @public * @const - * @type {Object.} + * @type {Object.} + */ +export const FONT = Object.freeze({ + ALL_SMALL_CAPS: Symbol("all-small-caps"), + CIRCLED_BLACK: Symbol("circledBlack"), + CIRCLED: Symbol("circled"), + DOUBLE_STRUCK: Symbol("double-struck"), + FRAKTUR_BOLD: Symbol("fraktur-bold"), + FULLWIDTH: Symbol("fullwidth"), + MONOSPACE: Symbol("monospace"), + SANS_SERIF_BOLD_ITALIC: Symbol("sans-serif-bold-italic"), + SANS_SERIF_BOLD: Symbol("sans-serif-bold"), + SANS_SERIF_ITALIC: Symbol("sans-serif-italic"), + SANS_SERIF: Symbol("sans-serif"), + SCRIPT_BOLD: Symbol("script-bold"), + SCRIPT_FRAKTUR: Symbol("script-fraktur"), + SCRIPT: Symbol("script"), + SERIF_BOLD_ITALIC: Symbol("serif-bold-italic"), + SERIF_BOLD: Symbol("serif-bold"), + SERIF_ITALIC: Symbol("serif-italic"), + SMALL_CAPS: Symbol("small-caps"), + SQUARD_BLACK: Symbol("squared-black"), + SQUARD: Symbol("squared"), + SUPERSCRIPT: Symbol("superscript"), + UNICASE: Symbol("unicase"), +}); + +/** + * Contains the "inversed" array of the font. + * + * It helps you to access ther {@see FONT} object with an Symbol.toString() value. + * + * @public + * @const + * @type {Object.} */ -export const fontIds = Object.freeze([ - "menuFontSuperscript", - "menuFontSmallCaps", - "menuFontAllSmallCaps", - "menuFontUnicase", - SEPARATOR_ID, - "menuFontSerifBold", - "menuFontSerifItalic", - "menuFontSerifBoldItalic", - "menuFontSansSerif", - "menuFontSansSerifBold", - "menuFontSansSerifItalic", - "menuFontSansSerifBoldItalic", - "menuFontScript", - "menuFontScriptBold", - "menuFontScriptFraktur", - "menuFontFrakturBold", - "menuFontMonospace", - "menuFontDoubleStruck", - SEPARATOR_ID, - "menuFontCircled", - "menuFontCircledBlack", - "menuFontSquared", - "menuFontSquaredBlack", - "menuFontFullwidth" +export const fontByString = Object.freeze( + Object.fromEntries(Object.entries(FONT).map(([key, symbol]) => { + return [symbol.toString(), symbol]; + })) +); + +/** + * The casing/font menu in it's order and it's translations. + * + * Includes {@link SEPARATOR} as a value for where separators are to be insterted. + * + * @public + * @const + * @type {Readonly>} + */ +export const contextMenuList = Object.freeze([ + CASE.LOWERCASE, + CASE.UPPERCASE, + CASE.CAPITALIZE, + CASE.TOGGLE, + SEPARATOR, + FONT.SUPERSCRIPT, + FONT.SMALL_CAPS, + FONT.ALL_SMALL_CAPS, + FONT.UNICASE, + SEPARATOR, + FONT.SERIF_BOLD, + FONT.SERIF_ITALIC, + FONT.SERIF_BOLD_ITALIC, + FONT.SANS_SERIF, + FONT.SANS_SERIF_BOLD, + FONT.SANS_SERIF_ITALIC, + FONT.SANS_SERIF_BOLD_ITALIC, + FONT.SCRIPT, + FONT.SCRIPT_BOLD, + FONT.SCRIPT_FRAKTUR, + FONT.FRAKTUR_BOLD, + FONT.MONOSPACE, + FONT.DOUBLE_STRUCK, + SEPARATOR, + FONT.CIRCLED, + FONT.CIRCLED_BLACK, + FONT.SQUARD, + FONT.SQUARD_BLACK, + FONT.FULLWIDTH ]); +const bla = new Map() +Object.freeze(bla) +bla.set(CASE.LOWERCASE, "asd") + +/** + * The casing/font menu in it's order and it's translations. + * + * @public + * @const + * @type {Object.} + */ +export const menuTranslation = Object.freeze({ + [CASE.LOWERCASE]: "menuCaseLowercase", + [CASE.UPPERCASE]: "menuCaseUppercase", + [CASE.CAPITALIZE]: "menuCaseCapitalizeEachWord", + [CASE.TOGGLE]: "menuCaseToggleCase", + [FONT.SUPERSCRIPT]: "menuFontSuperscript", + [FONT.SMALL_CAPS]: "menuFontSmallCaps", + [FONT.ALL_SMALL_CAPS]: "menuFontAllSmallCaps", + [FONT.UNICASE]: "menuFontUnicase", + [FONT.SERIF_BOLD]: "menuFontSerifBold", + [FONT.SERIF_ITALIC]: "menuFontSerifItalic", + [FONT.SERIF_BOLD_ITALIC]: "menuFontSerifBoldItalic", + [FONT.SANS_SERIF]: "menuFontSansSerif", + [FONT.SANS_SERIF_BOLD]: "menuFontSansSerifBold", + [FONT.SANS_SERIF_ITALIC]: "menuFontSansSerifItalic", + [FONT.SANS_SERIF_BOLD_ITALIC]: "menuFontSansSerifBoldItalic", + [FONT.SCRIPT]: "menuFontScript", + [FONT.SCRIPT_BOLD]: "menuFontScriptBold", + [FONT.SCRIPT_FRAKTUR]: "menuFontScriptFraktur", + [FONT.FRAKTUR_BOLD]: "menuFontFrakturBold", + [FONT.MONOSPACE]: "menuFontMonospace", + [FONT.DOUBLE_STRUCK]: "menuFontDoubleStruck", + [FONT.CIRCLED]: "menuFontCircled", + [FONT.CIRCLED_BLACK]: "menuFontCircledBlack", + [FONT.SQUARD]: "menuFontSquared", + [FONT.SQUARD_BLACK]: "menuFontSquaredBlack", + [FONT.FULLWIDTH]: "menuFontFullwidth" +}); + /** * Unicode fonts * Some of the fonts have characters that are not yet implemented. * * @private * @const - * @type {Object.} + * @type {Object.} */ const fonts = { - "serif-bold": "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", - "serif-italic": "𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑊𝑋𝑌𝑍𝑎𝑏𝑐𝑑𝑒𝑓𝑔ℎ𝑖𝑗𝑘𝑙𝑚𝑛𝑜𝑝𝑞𝑟𝑠𝑡𝑢𝑣𝑤𝑥𝑦𝑧", - "serif-bold-italic": "𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛", - "sans-serif": "𝖠𝖡𝖢𝖣𝖤𝖥𝖦𝖧𝖨𝖩𝖪𝖫𝖬𝖭𝖮𝖯𝖰𝖱𝖲𝖳𝖴𝖵𝖶𝖷𝖸𝖹𝖺𝖻𝖼𝖽𝖾𝖿𝗀𝗁𝗂𝗃𝗄𝗅𝗆𝗇𝗈𝗉𝗊𝗋𝗌𝗍𝗎𝗏𝗐𝗑𝗒𝗓𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", - "sans-serif-bold": "𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", - "sans-serif-italic": "𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻", - "sans-serif-bold-italic": "𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙒𝙓𝙔𝙕𝙖𝙗𝙘𝙙𝙚𝙛𝙜𝙝𝙞𝙟𝙠𝙡𝙢𝙣𝙤𝙥𝙦𝙧𝙨𝙩𝙪𝙫𝙬𝙭𝙮𝙯", - "script": "𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵𝒶𝒷𝒸𝒹ℯ𝒻ℊ𝒽𝒾𝒿𝓀𝓁𝓂𝓃ℴ𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏", - "script-bold": "𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃", - "fraktur": "𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷", - "fraktur-bold": "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟", - "monospace": "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", - "double-struck": "𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", - "circled": "!\"#$%&'()⊛⊕,⊖⊙⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[⦸]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~", - "circled-(black)": "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿❶❷❸❹❺❻❼❽❾", - "squared": "!\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", - "squared-(black)": "🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉", - "fullwidth": "!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", + [FONT.SERIF_BOLD]: "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", + [FONT.SERIF_ITALIC]: "𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑊𝑋𝑌𝑍𝑎𝑏𝑐𝑑𝑒𝑓𝑔ℎ𝑖𝑗𝑘𝑙𝑚𝑛𝑜𝑝𝑞𝑟𝑠𝑡𝑢𝑣𝑤𝑥𝑦𝑧", + [FONT.SERIF_BOLD_ITALIC]: "𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛", + [FONT.SANS_SERIF]: "𝖠𝖡𝖢𝖣𝖤𝖥𝖦𝖧𝖨𝖩𝖪𝖫𝖬𝖭𝖮𝖯𝖰𝖱𝖲𝖳𝖴𝖵𝖶𝖷𝖸𝖹𝖺𝖻𝖼𝖽𝖾𝖿𝗀𝗁𝗂𝗃𝗄𝗅𝗆𝗇𝗈𝗉𝗊𝗋𝗌𝗍𝗎𝗏𝗐𝗑𝗒𝗓𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", + [FONT.SANS_SERIF_BOLD]: "𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", + [FONT.SANS_SERIF_ITALIC]: "𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻", + [FONT.SANS_SERIF_BOLD_ITALIC]: "𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙒𝙓𝙔𝙕𝙖𝙗𝙘𝙙𝙚𝙛𝙜𝙝𝙞𝙟𝙠𝙡𝙢𝙣𝙤𝙥𝙦𝙧𝙨𝙩𝙪𝙫𝙬𝙭𝙮𝙯", + [FONT.SCRIPT]: "𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵𝒶𝒷𝒸𝒹ℯ𝒻ℊ𝒽𝒾𝒿𝓀𝓁𝓂𝓃ℴ𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏", + [FONT.SCRIPT_BOLD]: "𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃", + [FONT.SCRIPT_FRAKTUR]: "𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷", + [FONT.FRAKTUR_BOLD]: "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟", + [FONT.MONOSPACE]: "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", + [FONT.DOUBLE_STRUCK]: "𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", + [FONT.CIRCLED]: "!\"#$%&'()⊛⊕,⊖⊙⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[⦸]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~", + [FONT.CIRCLED_BLACK]: "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿❶❷❸❹❺❻❼❽❾", + [FONT.SQUARD]: "!\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", + [FONT.SQUARD_BLACK]: "🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉", + [FONT.FULLWIDTH]: "!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", // Adapted from: https://rupertshepherd.info/resource_pages/superscript-letters-in-unicode - "superscript": "ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖqʳˢᵗᵘᵛʷˣʸᶻ⁰¹²³⁴⁵⁶⁷⁸⁹", - "small-caps": `ABCDEFGHIJKLMNOPQRSTUVWXYZ${smallCaps}`, - "all-small-caps": smallCaps, - "unicase": `${smallCaps}abcdefghijklmnopqrstuvwxyz` + [FONT.SUPERSCRIPT]: "ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖqʳˢᵗᵘᵛʷˣʸᶻ⁰¹²³⁴⁵⁶⁷⁸⁹", + [FONT.SMALL_CAPS]: `ABCDEFGHIJKLMNOPQRSTUVWXYZ${smallCaps}`, + [FONT.ALL_SMALL_CAPS]: smallCaps, + [FONT.UNICASE]: `${smallCaps}abcdefghijklmnopqrstuvwxyz` }; /** @@ -102,11 +212,11 @@ const fonts = { * * @public * @const - * @type {Object.} + * @type {Object.} */ -export const fontLetters = Object.freeze( - Object.fromEntries(Object.entries(fonts).map(([font, charString]) => { +export const fontMap = Object.freeze( + Object.fromEntries(Object.getOwnPropertySymbols(fonts).map((font) => { // split-up the letter string an array with each character - return [font, Array.from(charString)]; + return [font, Array.from(fonts[font])]; })) ); From 9c9e497eed8827c6c2e4082720d5ffe2ec51bec3 Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 16 Dec 2020 12:23:37 +0100 Subject: [PATCH 7/9] minor style fixes --- src/common/modules/data/Fonts.js | 54 +++++++++++++++----------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index d70534c..97cf12b 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -130,10 +130,6 @@ export const contextMenuList = Object.freeze([ FONT.FULLWIDTH ]); -const bla = new Map() -Object.freeze(bla) -bla.set(CASE.LOWERCASE, "asd") - /** * The casing/font menu in it's order and it's translations. * @@ -176,33 +172,33 @@ export const menuTranslation = Object.freeze({ * * @private * @const - * @type {Object.} + * @type {Object.} */ -const fonts = { - [FONT.SERIF_BOLD]: "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", - [FONT.SERIF_ITALIC]: "𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑊𝑋𝑌𝑍𝑎𝑏𝑐𝑑𝑒𝑓𝑔ℎ𝑖𝑗𝑘𝑙𝑚𝑛𝑜𝑝𝑞𝑟𝑠𝑡𝑢𝑣𝑤𝑥𝑦𝑧", - [FONT.SERIF_BOLD_ITALIC]: "𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛", - [FONT.SANS_SERIF]: "𝖠𝖡𝖢𝖣𝖤𝖥𝖦𝖧𝖨𝖩𝖪𝖫𝖬𝖭𝖮𝖯𝖰𝖱𝖲𝖳𝖴𝖵𝖶𝖷𝖸𝖹𝖺𝖻𝖼𝖽𝖾𝖿𝗀𝗁𝗂𝗃𝗄𝗅𝗆𝗇𝗈𝗉𝗊𝗋𝗌𝗍𝗎𝗏𝗐𝗑𝗒𝗓𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", - [FONT.SANS_SERIF_BOLD]: "𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", - [FONT.SANS_SERIF_ITALIC]: "𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻", - [FONT.SANS_SERIF_BOLD_ITALIC]: "𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙒𝙓𝙔𝙕𝙖𝙗𝙘𝙙𝙚𝙛𝙜𝙝𝙞𝙟𝙠𝙡𝙢𝙣𝙤𝙥𝙦𝙧𝙨𝙩𝙪𝙫𝙬𝙭𝙮𝙯", - [FONT.SCRIPT]: "𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵𝒶𝒷𝒸𝒹ℯ𝒻ℊ𝒽𝒾𝒿𝓀𝓁𝓂𝓃ℴ𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏", - [FONT.SCRIPT_BOLD]: "𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃", - [FONT.SCRIPT_FRAKTUR]: "𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷", - [FONT.FRAKTUR_BOLD]: "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟", - [FONT.MONOSPACE]: "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", - [FONT.DOUBLE_STRUCK]: "𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", - [FONT.CIRCLED]: "!\"#$%&'()⊛⊕,⊖⊙⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[⦸]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~", - [FONT.CIRCLED_BLACK]: "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿❶❷❸❹❺❻❼❽❾", - [FONT.SQUARD]: "!\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", - [FONT.SQUARD_BLACK]: "🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉", - [FONT.FULLWIDTH]: "!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", +export const fonts = Object.freeze({ + "serif-bold": "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", + "serif-italic": "𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑊𝑋𝑌𝑍𝑎𝑏𝑐𝑑𝑒𝑓𝑔ℎ𝑖𝑗𝑘𝑙𝑚𝑛𝑜𝑝𝑞𝑟𝑠𝑡𝑢𝑣𝑤𝑥𝑦𝑧", + "serif-bold-italic": "𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛", + "sans-serif": "𝖠𝖡𝖢𝖣𝖤𝖥𝖦𝖧𝖨𝖩𝖪𝖫𝖬𝖭𝖮𝖯𝖰𝖱𝖲𝖳𝖴𝖵𝖶𝖷𝖸𝖹𝖺𝖻𝖼𝖽𝖾𝖿𝗀𝗁𝗂𝗃𝗄𝗅𝗆𝗇𝗈𝗉𝗊𝗋𝗌𝗍𝗎𝗏𝗐𝗑𝗒𝗓𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", + "sans-serif-bold": "𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", + "sans-serif-italic": "𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻", + "sans-serif-bold-italic": "𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙒𝙓𝙔𝙕𝙖𝙗𝙘𝙙𝙚𝙛𝙜𝙝𝙞𝙟𝙠𝙡𝙢𝙣𝙤𝙥𝙦𝙧𝙨𝙩𝙪𝙫𝙬𝙭𝙮𝙯", + "script": "𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵𝒶𝒷𝒸𝒹ℯ𝒻ℊ𝒽𝒾𝒿𝓀𝓁𝓂𝓃ℴ𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏", + "script-bold": "𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃", + "fraktur": "𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷", + "fraktur-bold": "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟", + "monospace": "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", + "double-struck": "𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", + "circled": "!\"#$%&'()⊛⊕,⊖⊙⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[⦸]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~", + "circled-(black)": "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿❶❷❸❹❺❻❼❽❾", + "squared": "!\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", + "squared-(black)": "🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉", + "fullwidth": "!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", // Adapted from: https://rupertshepherd.info/resource_pages/superscript-letters-in-unicode - [FONT.SUPERSCRIPT]: "ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖqʳˢᵗᵘᵛʷˣʸᶻ⁰¹²³⁴⁵⁶⁷⁸⁹", - [FONT.SMALL_CAPS]: `ABCDEFGHIJKLMNOPQRSTUVWXYZ${smallCaps}`, - [FONT.ALL_SMALL_CAPS]: smallCaps, - [FONT.UNICASE]: `${smallCaps}abcdefghijklmnopqrstuvwxyz` -}; + "superscript": "ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖqʳˢᵗᵘᵛʷˣʸᶻ⁰¹²³⁴⁵⁶⁷⁸⁹", + "small-caps": `ABCDEFGHIJKLMNOPQRSTUVWXYZ${smallCaps}`, + "all-small-caps": smallCaps, + "unicase": `${smallCaps}abcdefghijklmnopqrstuvwxyz` +}); /** * All letters for each Unicode font From 79d2cc338fd5bd51106647819d2abfad38cd9fbf Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 28 Feb 2021 15:39:48 +0100 Subject: [PATCH 8/9] implement font changing --- src/common/modules/UnicodeFontHandler.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/modules/UnicodeFontHandler.js b/src/common/modules/UnicodeFontHandler.js index e6e8379..380a081 100644 --- a/src/common/modules/UnicodeFontHandler.js +++ b/src/common/modules/UnicodeFontHandler.js @@ -13,11 +13,11 @@ import { CASE, FONT, SEPARATOR, contextMenuList, menuTranslation, fontMap, caseB * It replaces each ASCII character in the text with the corresponding character from the Unicode font. * * @param {string} text - * @param {Symbol} chosenFont + * @param {Symbol|string} chosenFont * @returns {string} */ function changeFont(text, chosenFont) { - const font = fontMap[chosenFont]; + const font = fontMap[chosenFont] || chosenFont; let output = ""; for (let letter of text) { @@ -167,7 +167,7 @@ function applySettings(unicodeFont) { } else { menus.create({ "id": id.toString(), - "title": browser.i18n.getMessage(menuTranslation[id]), + "title": changeFont(browser.i18n.getMessage(menuTranslation[id]), id), "contexts": ["editable"], }); } From 19c6c3fede8b4d0b9e2b295a8028fbe67247a255 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 28 Feb 2021 15:39:58 +0100 Subject: [PATCH 9/9] doc: coment fixes --- src/common/modules/data/Fonts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index 97cf12b..92a2b2e 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -30,7 +30,7 @@ export const CASE = Object.freeze({ /** * Contains the "inversed" array of the casing options. * - * It helps you to access ther {@see CASE} object with an Symbol.toString() value. + * It helps you to access the {@see CASE} object with an Symbol.toString() value. * * @public * @const