From 5479a94a6cc33956b07ecc40c290ce1e0c78f0ac Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Tue, 7 Jun 2022 02:34:52 -0700 Subject: [PATCH 01/25] Added option to disable autocorrect feature by default. --- src/background/modules/AutocorrectHandler.js | 8 +++- .../modules/UnicodeTransformationHandler.js | 1 + src/common/modules/data/DefaultSettings.js | 1 + src/content_scripts/autocorrect.js | 13 +++++- src/options/modules/CustomOptionTriggers.js | 22 +++++++++- src/options/options.html | 44 ++++++++++++------- 6 files changed, 69 insertions(+), 20 deletions(-) diff --git a/src/background/modules/AutocorrectHandler.js b/src/background/modules/AutocorrectHandler.js index 4e32109..01a94b8 100644 --- a/src/background/modules/AutocorrectHandler.js +++ b/src/background/modules/AutocorrectHandler.js @@ -7,6 +7,7 @@ import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunic import * as symbols from "/common/modules/data/Symbols.js"; const settings = { + enabled: null, autocorrectEmojis: null, quotes: null, fracts: null, @@ -107,11 +108,14 @@ function onError(error) { * @returns {void} */ function setSettings(autocorrect) { + settings.enabled = autocorrect.enabled; settings.autocorrectSymbols = autocorrect.autocorrectSymbols; settings.quotes = autocorrect.autocorrectUnicodeQuotes; settings.fracts = autocorrect.autocorrectUnicodeFracts; - applySettings(); + if (settings.enabled) { + applySettings(); + } } /** @@ -129,6 +133,7 @@ function sendSettings(autocorrect) { browser.tabs.sendMessage( tab.id, { + "enabled": settings.enabled, "quotes": settings.quotes, "fracts": settings.fracts, "autocorrections": autocorrections, @@ -157,6 +162,7 @@ export async function init() { if (message.type === COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT) { const response = { "type": COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT, + "enabled": settings.enabled, "quotes": settings.quotes, "fracts": settings.fracts, "autocorrections": autocorrections, diff --git a/src/common/modules/UnicodeTransformationHandler.js b/src/common/modules/UnicodeTransformationHandler.js index 8f6c664..cb648a0 100644 --- a/src/common/modules/UnicodeTransformationHandler.js +++ b/src/common/modules/UnicodeTransformationHandler.js @@ -53,6 +53,7 @@ export function getTransformationType(transformationId) { 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 + // Intl.Segmenter is not yet supported by Firefox/Thunderbird: https://bugzilla.mozilla.org/show_bug.cgi?id=1423593 // \p{Alphabetic} return text.replace(/(?<=^|\P{Alpha})\p{Alpha}\S*/gu, ([h, ...t]) => h.toLocaleUpperCase() + t.join("")); } diff --git a/src/common/modules/data/DefaultSettings.js b/src/common/modules/data/DefaultSettings.js index b89a9f0..a81bbbf 100644 --- a/src/common/modules/data/DefaultSettings.js +++ b/src/common/modules/data/DefaultSettings.js @@ -16,6 +16,7 @@ const defaultSettings = { tips: {} }, autocorrect: { + enabled: false, autocorrectSymbols: true, autocorrectUnicodeQuotes: true, autocorrectUnicodeFracts: true, diff --git a/src/content_scripts/autocorrect.js b/src/content_scripts/autocorrect.js index 72d4471..c5f311a 100644 --- a/src/content_scripts/autocorrect.js +++ b/src/content_scripts/autocorrect.js @@ -35,6 +35,7 @@ let deletedText; // Last deleted text let lastTarget; // Last target let lastCaretPosition; // Last caret position +let enabled = false; let quotes = true; let fracts = true; @@ -132,6 +133,7 @@ function insertIntoPage(atext) { /** * Count Unicode characters. * Adapted from: https://blog.jonnew.com/posts/poo-dot-length-equals-two + * Intl.Segmenter is not yet supported by Firefox/Thunderbird: https://bugzilla.mozilla.org/show_bug.cgi?id=1423593 * * @param {string} str * @returns {number} @@ -387,6 +389,7 @@ function handleResponse(message, sender) { if (message.type !== AUTOCORRECT_CONTENT) { return; } + enabled = message.enabled; quotes = message.quotes; fracts = message.fracts; autocorrections = message.autocorrections; @@ -394,6 +397,14 @@ function handleResponse(message, sender) { symbolpatterns = IS_CHROME ? new RegExp(message.symbolpatterns) : message.symbolpatterns; antipatterns = IS_CHROME ? new RegExp(message.antipatterns) : message.antipatterns; // console.log(message); + + if (enabled) { + window.addEventListener("beforeinput", undoAutocorrect, true); + window.addEventListener("beforeinput", autocorrect, true); + } else { + window.removeEventListener("beforeinput", undoAutocorrect, true); + window.removeEventListener("beforeinput", autocorrect, true); + } } /** @@ -408,6 +419,4 @@ function handleError(error) { browser.runtime.sendMessage({ "type": AUTOCORRECT_CONTENT }).then(handleResponse, handleError); browser.runtime.onMessage.addListener(handleResponse); -window.addEventListener("beforeinput", undoAutocorrect, true); -window.addEventListener("beforeinput", autocorrect, true); console.log("Unicodify autocorrect module loaded."); diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 4934a67..88a38db 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -17,7 +17,24 @@ import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunic * @param {Object} [event] * @returns {Promise} */ -function applyAutocorrectPermissions(optionValue) { +function applyAutocorrectPermissions(optionValue, option, event) { + if (optionValue.enabled) { + if (option && event?.target?.name === "enabled") { + if (!confirm("Are you sure you want to enable this experimental feature?")) { + // Remove once https://github.com/TinyWebEx/AutomaticSettings/issues/21 is fixed + event.target.checked = !optionValue.enabled; + return Promise.reject(); + } + } + document.getElementById("autocorrectSymbols").disabled = false; + document.getElementById("autocorrectUnicodeQuotes").disabled = false; + document.getElementById("autocorrectUnicodeFracts").disabled = false; + } else { + document.getElementById("autocorrectSymbols").disabled = true; + document.getElementById("autocorrectUnicodeQuotes").disabled = true; + document.getElementById("autocorrectUnicodeFracts").disabled = true; + } + // trigger update for current session browser.runtime.sendMessage({ "type": COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_BACKGROUND, @@ -53,4 +70,7 @@ export function registerTrigger() { // update slider status AutomaticSettings.Trigger.registerSave("autocorrect", applyAutocorrectPermissions); AutomaticSettings.Trigger.registerSave("unicodeFont", applyUnicodeFontSettings); + + // handle loading of options correctly + AutomaticSettings.Trigger.registerAfterLoad(AutomaticSettings.Trigger.RUN_ALL_SAVE_TRIGGER); } diff --git a/src/options/options.html b/src/options/options.html index 868406d..2723434 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -65,27 +65,39 @@

Unicode autocorrection

From 98fab9e040e4a19f10516e02e2b98f19df8c113a Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sat, 23 Jul 2022 04:12:02 -0700 Subject: [PATCH 02/25] Added Thunderbird workaround. --- scripts/manifests/thunderbirdmanifest.json | 4 +- src/background/modules/AutocorrectHandler.js | 37 +++++++------ src/background/modules/ContextMenu.js | 58 +++++++++++++++++--- src/options/options.html | 10 ++-- 4 files changed, 76 insertions(+), 33 deletions(-) diff --git a/scripts/manifests/thunderbirdmanifest.json b/scripts/manifests/thunderbirdmanifest.json index 0478ce8..232ca83 100644 --- a/scripts/manifests/thunderbirdmanifest.json +++ b/scripts/manifests/thunderbirdmanifest.json @@ -39,7 +39,9 @@ "", "tabs", "compose", - "menus" + "menus", + "notifications", + "clipboardWrite" ], "applications": { diff --git a/src/background/modules/AutocorrectHandler.js b/src/background/modules/AutocorrectHandler.js index 01a94b8..3a8e272 100644 --- a/src/background/modules/AutocorrectHandler.js +++ b/src/background/modules/AutocorrectHandler.js @@ -133,6 +133,7 @@ function sendSettings(autocorrect) { browser.tabs.sendMessage( tab.id, { + "type": COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT, "enabled": settings.enabled, "quotes": settings.quotes, "fracts": settings.fracts, @@ -157,24 +158,6 @@ export async function init() { setSettings(autocorrect); - browser.runtime.onMessage.addListener((message) => { - // console.log(message); - if (message.type === COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT) { - const response = { - "type": COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT, - "enabled": settings.enabled, - "quotes": settings.quotes, - "fracts": settings.fracts, - "autocorrections": autocorrections, - "longest": longest, - "symbolpatterns": IS_CHROME ? symbolpatterns.source : symbolpatterns, - "antipatterns": IS_CHROME ? antipatterns.source : antipatterns, - }; - // console.log(response); - return Promise.resolve(response); - } - }); - // Thunderbird // Remove if part 3 of https://bugzilla.mozilla.org/show_bug.cgi?id=1630786#c4 is ever done if (typeof messenger !== "undefined") { @@ -192,3 +175,21 @@ BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_BACKGROU return sendSettings(request.optionValue); }); + +browser.runtime.onMessage.addListener((message) => { + // console.log(message); + if (message.type === COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT) { + const response = { + "type": COMMUNICATION_MESSAGE_TYPE.AUTOCORRECT_CONTENT, + "enabled": settings.enabled, + "quotes": settings.quotes, + "fracts": settings.fracts, + "autocorrections": autocorrections, + "longest": longest, + "symbolpatterns": IS_CHROME ? symbolpatterns.source : symbolpatterns, + "antipatterns": IS_CHROME ? antipatterns.source : antipatterns, + }; + // console.log(response); + return Promise.resolve(response); + } +}); diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index 910cef0..383ac86 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -1,7 +1,6 @@ import * as UnicodeTransformationHandler from "/common/modules/UnicodeTransformationHandler.js"; import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js"; import * as BrowserCommunication from "/common/modules/BrowserCommunication/BrowserCommunication.js"; -import { isMobile } from "/common/modules/MobileHelper.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; import { menuStructure, SEPARATOR_ID, TRANSFORMATION_TYPE } from "/common/modules/data/Fonts.js"; @@ -12,6 +11,38 @@ const PREVIEW_STRING_CUT_LENGTH = 100; // a setting that may improve performance let lastCachedUnicodeFontSettings = null; let menuIsShown = false; +let pasteSymbol = null; + +/** + * Create notification. + * + * @param {string} title + * @param {string} message + * @returns {void} + */ +function notification(title, message) { + console.log(title, message); + browser.notifications.create({ + "type": "basic", + "iconUrl": browser.runtime.getURL("icons/icon.svg"), + "title": title, + "message": message + }); +} + +/** + * Copy text to clipboard and show notification when unable to do transformation directly. + * Thunderbird workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1641575 + * + * @param {string} text + * @param {string} fieldId + * @returns {void} + */ +function fallback(text, fieldId) { + navigator.clipboard.writeText(text); + notification(`📋 Press ${pasteSymbol}-V`, `Add-ons in Thunderbird are currently unable to access the “${fieldId.startsWith("compose") ? fieldId.slice("compose".length) : fieldId}” field directly, so the transformed text has been copied to your clipboard.\nPlease press ${pasteSymbol}-V to do the transformation.`); +} + /** * Handle selection of a context menu item. * @@ -32,6 +63,12 @@ function handleMenuChoosen(info, tab) { text = text.normalize(); const output = UnicodeTransformationHandler.transformText(text, info.menuItemId); + // Thunderbird workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1641575 + if (info.fieldId) { + fallback(output, info.fieldId); + return; + } + browser.tabs.executeScript(tab.id, { code: `insertIntoPage("${output}");`, frameId: info.frameId @@ -197,8 +234,9 @@ BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UPDATE_CONTEXT_MENU, * @returns {void} */ export async function init() { + const platformInfo = await browser.runtime.getPlatformInfo(); // Remove once https://bugzilla.mozilla.org/show_bug.cgi?id=1595822 is fixed - if (await isMobile()) { + if (platformInfo.os === "android") { return; } @@ -213,11 +251,13 @@ export async function init() { } menus.onClicked.addListener(handleMenuChoosen); - BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UNICODE_FONT, async (request) => { - lastCachedUnicodeFontSettings = request.optionValue; - - await menus.removeAll(); - menuIsShown = false; - return buildMenu(request.optionValue); - }); + pasteSymbol = platformInfo.os === "mac" ? "\u2318" : "Ctrl"; } + +BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UNICODE_FONT, async (request) => { + lastCachedUnicodeFontSettings = request.optionValue; + + await menus.removeAll(); + menuIsShown = false; + return buildMenu(request.optionValue); +}); diff --git a/src/options/options.html b/src/options/options.html index 2723434..f623d06 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -20,35 +20,35 @@ - +
From f1e12800d460729910269762f5bfd002ee0a0b25 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sun, 24 Jul 2022 05:30:28 -0700 Subject: [PATCH 03/25] Incremented version to 0.5 and updated libraries. --- scripts/manifests/chromemanifest.json | 2 +- scripts/manifests/dev.json | 2 +- scripts/manifests/firefox.json | 2 +- scripts/manifests/thunderbirdmanifest.json | 2 +- src/common/modules/AutomaticSettings | 2 +- src/common/modules/MessageHandler | 2 +- src/manifest.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/manifests/chromemanifest.json b/scripts/manifests/chromemanifest.json index 3318d4a..b736b65 100644 --- a/scripts/manifests/chromemanifest.json +++ b/scripts/manifests/chromemanifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extensionName__", "short_name": "__MSG_extensionNameShort__", - "version": "0.1", + "version": "0.5", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", diff --git a/scripts/manifests/dev.json b/scripts/manifests/dev.json index 9223efd..4f63007 100644 --- a/scripts/manifests/dev.json +++ b/scripts/manifests/dev.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Unicodify DEV VERSION", "short_name": "__MSG_extensionNameShort__", - "version": "0.1", + "version": "0.5", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", diff --git a/scripts/manifests/firefox.json b/scripts/manifests/firefox.json index 0075adb..d6719f6 100644 --- a/scripts/manifests/firefox.json +++ b/scripts/manifests/firefox.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extensionName__", "short_name": "__MSG_extensionNameShort__", - "version": "0.1", + "version": "0.5", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", diff --git a/scripts/manifests/thunderbirdmanifest.json b/scripts/manifests/thunderbirdmanifest.json index 232ca83..8f78b50 100644 --- a/scripts/manifests/thunderbirdmanifest.json +++ b/scripts/manifests/thunderbirdmanifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extensionName__", "short_name": "__MSG_extensionNameShort__", - "version": "0.5", + "version": "0.5.1", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", diff --git a/src/common/modules/AutomaticSettings b/src/common/modules/AutomaticSettings index b3a4ff5..fce7d28 160000 --- a/src/common/modules/AutomaticSettings +++ b/src/common/modules/AutomaticSettings @@ -1 +1 @@ -Subproject commit b3a4ff575a0d1c3d742dbd6511cc0a6f0286a192 +Subproject commit fce7d28ce753354da18cad9cfe71c729ec46d424 diff --git a/src/common/modules/MessageHandler b/src/common/modules/MessageHandler index f639972..a2aa9f4 160000 --- a/src/common/modules/MessageHandler +++ b/src/common/modules/MessageHandler @@ -1 +1 @@ -Subproject commit f6399721e021cbbdfe2f258f50e7b907beab6b5f +Subproject commit a2aa9f477e4dfa9a12b97c7bb4088255e381a191 diff --git a/src/manifest.json b/src/manifest.json index 9223efd..4f63007 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Unicodify DEV VERSION", "short_name": "__MSG_extensionNameShort__", - "version": "0.1", + "version": "0.5", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", From a8b95bbea3b6030dd620d290e070900eff9ca67c Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sun, 24 Jul 2022 07:37:20 -0700 Subject: [PATCH 04/25] Updated AMO and ATN descriptions. --- assets/texts/en/amoDescription.html | 2 ++ assets/texts/en/atnDescription.html | 6 ++++-- src/options/modules/CustomOptionTriggers.js | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/assets/texts/en/amoDescription.html b/assets/texts/en/amoDescription.html index de1aafa..c403291 100644 --- a/assets/texts/en/amoDescription.html +++ b/assets/texts/en/amoDescription.html @@ -48,6 +48,8 @@
  • and much more…
  • +ℹ️ The Unicode autocorrection feature is experimental and must be enabled in the settings. + 📢 More Features 📢
      diff --git a/assets/texts/en/atnDescription.html b/assets/texts/en/atnDescription.html index f213b80..170a1d1 100644 --- a/assets/texts/en/atnDescription.html +++ b/assets/texts/en/atnDescription.html @@ -4,6 +4,8 @@ You can enable and disable any features in the options and adjust more settings regarding the behavior of the add-on. +⚠️ Note that context menu does NOT currently work in Thunderbird's compose body because of Bug 1716976. + Convert text to any style you want! Just select text, right-click and let Unicodify convert the text into styles like: @@ -28,8 +30,6 @@
    • Fullwidth
    -⚠️ Note that context menu does NOT currently work in Thunderbird's compose body because of Bug 1716976. - ✍️ Improve your typographic style! ✍️ @@ -48,6 +48,8 @@
  • and much more…
  • +ℹ️ The Unicode autocorrection feature is experimental and must be enabled in the settings. + More Features
      diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 88a38db..0658c50 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -7,6 +7,14 @@ import * as AutomaticSettings from "/common/modules/AutomaticSettings/AutomaticSettings.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; +// Thunderbird +// https://bugzilla.mozilla.org/show_bug.cgi?id=1641573 +const IS_THUNDERBIRD = typeof messenger !== "undefined"; + +// Chrome +// Adapted from: https://github.com/mozilla/webextension-polyfill/blob/master/src/browser-polyfill.js +const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype; + /** * Apply the new autocorrect settings. @@ -20,7 +28,8 @@ import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunic function applyAutocorrectPermissions(optionValue, option, event) { if (optionValue.enabled) { if (option && event?.target?.name === "enabled") { - if (!confirm("Are you sure you want to enable this experimental feature?")) { + // Remove IS_THUNDERBIRD once https://bugzilla.mozilla.org/show_bug.cgi?id=1780977 is fixed + if (!IS_THUNDERBIRD && !IS_CHROME && !confirm("Are you sure you want to enable this experimental feature?")) { // Remove once https://github.com/TinyWebEx/AutomaticSettings/issues/21 is fixed event.target.checked = !optionValue.enabled; return Promise.reject(); From bfc52910cce4dee8a22da7a10072d5b9781c9765 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Mon, 25 Jul 2022 08:11:41 -0700 Subject: [PATCH 05/25] Updated autocorrect to prevent nested events. --- src/content_scripts/autocorrect.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/content_scripts/autocorrect.js b/src/content_scripts/autocorrect.js index c5f311a..892cf8c 100644 --- a/src/content_scripts/autocorrect.js +++ b/src/content_scripts/autocorrect.js @@ -48,6 +48,8 @@ let symbolpatterns = null; // Exceptions, do not autocorrect for these patterns let antipatterns = null; +let running = false; + // Chrome // Adapted from: https://github.com/mozilla/webextension-polyfill/blob/master/src/browser-polyfill.js const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype; @@ -94,7 +96,7 @@ function getCaretPosition(target) { function insertAtCaret(target, atext) { // document.execCommand is deprecated, although there is not yet an alternative: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand // insertReplacementText - if(document.execCommand("insertText", false, atext)) { + if (document.execCommand("insertText", false, atext)) { return; } @@ -103,7 +105,7 @@ function insertAtCaret(target, atext) { const start = target.selectionStart; const end = target.selectionEnd; - if (start !== undefined && end !== undefined) { + if (start != null && end != null) { target.setRangeText(atext); target.selectionStart = target.selectionEnd = start + atext.length; @@ -271,6 +273,10 @@ function autocorrect(event) { if (!symbolpatterns) { throw new Error("Emoji autocorrect settings have not been received. Do not autocorrect."); } + if (running) { + return; + } + running = true; const target = event.target; const caretposition = getCaretPosition(target); if (caretposition) { @@ -332,6 +338,7 @@ function autocorrect(event) { const text = deletecount ? value.slice(caretposition - deletecount, caretposition) : ""; if (text) { + lastTarget = null; deleteCaret(target, text); } insertAtCaret(target, insert); @@ -344,6 +351,7 @@ function autocorrect(event) { lastCaretPosition = caretposition - deletecount + insert.length; } } + running = false; } /** @@ -358,6 +366,10 @@ function undoAutocorrect(event) { if (event.inputType !== "deleteContentBackward") { return; } + if (running) { + return; + } + running = true; const target = event.target; const caretposition = getCaretPosition(target); if (caretposition) { @@ -376,6 +388,7 @@ function undoAutocorrect(event) { lastTarget = null; } + running = false; } /** From 3347d67a5be700adfcb1b267a3a2a0c284af7de3 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Thu, 28 Jul 2022 02:33:00 -0700 Subject: [PATCH 06/25] Apply suggestions from code review Co-authored-by: rugk --- src/background/modules/AutocorrectHandler.js | 1 - src/background/modules/ContextMenu.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/background/modules/AutocorrectHandler.js b/src/background/modules/AutocorrectHandler.js index 3a8e272..d003d23 100644 --- a/src/background/modules/AutocorrectHandler.js +++ b/src/background/modules/AutocorrectHandler.js @@ -189,7 +189,6 @@ browser.runtime.onMessage.addListener((message) => { "symbolpatterns": IS_CHROME ? symbolpatterns.source : symbolpatterns, "antipatterns": IS_CHROME ? antipatterns.source : antipatterns, }; - // console.log(response); return Promise.resolve(response); } }); diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index 383ac86..f370173 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -21,7 +21,7 @@ let pasteSymbol = null; * @returns {void} */ function notification(title, message) { - console.log(title, message); + console.info("Showing notification:", title, message); browser.notifications.create({ "type": "basic", "iconUrl": browser.runtime.getURL("icons/icon.svg"), From 4d3d8a5c9be80d5a0089230ca3a2748ba62389fc Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Thu, 28 Jul 2022 02:39:37 -0700 Subject: [PATCH 07/25] Added notifications module. --- src/background/modules/ContextMenu.js | 21 +++------------- src/common/modules/Notifications.js | 28 +++++++++++++++++++++ src/options/modules/CustomOptionTriggers.js | 1 + 3 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 src/common/modules/Notifications.js diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index f370173..51241db 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -1,6 +1,7 @@ import * as UnicodeTransformationHandler from "/common/modules/UnicodeTransformationHandler.js"; import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js"; import * as BrowserCommunication from "/common/modules/BrowserCommunication/BrowserCommunication.js"; +import * as Notifications from "/common/modules/Notifications.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; import { menuStructure, SEPARATOR_ID, TRANSFORMATION_TYPE } from "/common/modules/data/Fonts.js"; @@ -13,23 +14,6 @@ let menuIsShown = false; let pasteSymbol = null; -/** - * Create notification. - * - * @param {string} title - * @param {string} message - * @returns {void} - */ -function notification(title, message) { - console.info("Showing notification:", title, message); - browser.notifications.create({ - "type": "basic", - "iconUrl": browser.runtime.getURL("icons/icon.svg"), - "title": title, - "message": message - }); -} - /** * Copy text to clipboard and show notification when unable to do transformation directly. * Thunderbird workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1641575 @@ -40,7 +24,8 @@ function notification(title, message) { */ function fallback(text, fieldId) { navigator.clipboard.writeText(text); - notification(`📋 Press ${pasteSymbol}-V`, `Add-ons in Thunderbird are currently unable to access the “${fieldId.startsWith("compose") ? fieldId.slice("compose".length) : fieldId}” field directly, so the transformed text has been copied to your clipboard.\nPlease press ${pasteSymbol}-V to do the transformation.`); + // This will need to be localized + Notifications.showNotification(`📋 Press ${pasteSymbol}-V`, `Add-ons in Thunderbird are currently unable to access the “${fieldId.startsWith("compose") ? fieldId.slice("compose".length) : fieldId}” field directly, so the transformed text has been copied to your clipboard.\nPlease press ${pasteSymbol}-V to do the transformation.`); } /** diff --git a/src/common/modules/Notifications.js b/src/common/modules/Notifications.js new file mode 100644 index 0000000..dab694a --- /dev/null +++ b/src/common/modules/Notifications.js @@ -0,0 +1,28 @@ +/** + * Show a notification. + * + * @module common/modules/Notifications + * @see {@link https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/user_interface/Notifications} + */ + +/** + * Show a notification. + * + * @public + * @param {string} title the title + * @param {string} content the message content + * @returns {Promise} + * @see {@link https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/notifications/create} + */ +export function showNotification(title, content) { + title = browser.i18n.getMessage(title) || title; + content = browser.i18n.getMessage(content) || content; + + console.info("Showing notification:", title, content); + browser.notifications.create({ + "type": "basic", + "iconUrl": browser.runtime.getURL("icons/icon.svg"), + "title": title, + "message": content + }); +} diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 0658c50..5de78a2 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -28,6 +28,7 @@ const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype; function applyAutocorrectPermissions(optionValue, option, event) { if (optionValue.enabled) { if (option && event?.target?.name === "enabled") { + // This will need to be localized // Remove IS_THUNDERBIRD once https://bugzilla.mozilla.org/show_bug.cgi?id=1780977 is fixed if (!IS_THUNDERBIRD && !IS_CHROME && !confirm("Are you sure you want to enable this experimental feature?")) { // Remove once https://github.com/TinyWebEx/AutomaticSettings/issues/21 is fixed From d629b8b4a7effcc841df56924a3a021d94ca04f0 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Fri, 29 Jul 2022 02:56:01 -0700 Subject: [PATCH 08/25] Revert isMobile removal. --- src/background/modules/ContextMenu.js | 5 +++-- src/options/modules/CustomOptionTriggers.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index 51241db..453d36a 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -1,6 +1,7 @@ import * as UnicodeTransformationHandler from "/common/modules/UnicodeTransformationHandler.js"; import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js"; import * as BrowserCommunication from "/common/modules/BrowserCommunication/BrowserCommunication.js"; +import { isMobile } from "/common/modules/MobileHelper.js"; import * as Notifications from "/common/modules/Notifications.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; @@ -24,7 +25,7 @@ let pasteSymbol = null; */ function fallback(text, fieldId) { navigator.clipboard.writeText(text); - // This will need to be localized + // TODO: This will need to be localized Notifications.showNotification(`📋 Press ${pasteSymbol}-V`, `Add-ons in Thunderbird are currently unable to access the “${fieldId.startsWith("compose") ? fieldId.slice("compose".length) : fieldId}” field directly, so the transformed text has been copied to your clipboard.\nPlease press ${pasteSymbol}-V to do the transformation.`); } @@ -221,7 +222,7 @@ BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UPDATE_CONTEXT_MENU, export async function init() { const platformInfo = await browser.runtime.getPlatformInfo(); // Remove once https://bugzilla.mozilla.org/show_bug.cgi?id=1595822 is fixed - if (platformInfo.os === "android") { + if (await isMobile()) { // platformInfo.os === "android" return; } diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 5de78a2..06b03c6 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -28,7 +28,7 @@ const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype; function applyAutocorrectPermissions(optionValue, option, event) { if (optionValue.enabled) { if (option && event?.target?.name === "enabled") { - // This will need to be localized + // TODO: This will need to be localized // Remove IS_THUNDERBIRD once https://bugzilla.mozilla.org/show_bug.cgi?id=1780977 is fixed if (!IS_THUNDERBIRD && !IS_CHROME && !confirm("Are you sure you want to enable this experimental feature?")) { // Remove once https://github.com/TinyWebEx/AutomaticSettings/issues/21 is fixed From 8917637a3431535c604ca10e802478b847a5970d Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sat, 30 Jul 2022 03:04:24 -0700 Subject: [PATCH 09/25] Incremented Thunderbird version. --- scripts/manifests/thunderbirdmanifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/manifests/thunderbirdmanifest.json b/scripts/manifests/thunderbirdmanifest.json index 8f78b50..6361e19 100644 --- a/scripts/manifests/thunderbirdmanifest.json +++ b/scripts/manifests/thunderbirdmanifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extensionName__", "short_name": "__MSG_extensionNameShort__", - "version": "0.5.1", + "version": "0.5.2", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", @@ -47,7 +47,7 @@ "applications": { "gecko": { "id": "unicodify@rugk.github.io", - "strict_min_version": "87.0" + "strict_min_version": "91.0" } } } From ea5c4ff382b82c66e7543252752ec54e2df24dbf Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 16:15:19 +0200 Subject: [PATCH 10/25] Properly use icon path from manifest --- src/common/modules/Notifications.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/modules/Notifications.js b/src/common/modules/Notifications.js index dab694a..7d921c3 100644 --- a/src/common/modules/Notifications.js +++ b/src/common/modules/Notifications.js @@ -5,6 +5,8 @@ * @see {@link https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/user_interface/Notifications} */ +const ICON = (browser.runtime.getManifest()).icons[32]; + /** * Show a notification. * @@ -21,7 +23,7 @@ export function showNotification(title, content) { console.info("Showing notification:", title, content); browser.notifications.create({ "type": "basic", - "iconUrl": browser.runtime.getURL("icons/icon.svg"), + "iconUrl": browser.runtime.getURL(ICON), "title": title, "message": content }); From 64e3a31bc32b1b8cb216ecd0359ac384bad5298a Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 16:39:08 +0200 Subject: [PATCH 11/25] Localise Thunderbird fallback message --- src/_locales/de/messages.json | 29 +++++++++++++++++++++++++++ src/_locales/en/messages.json | 29 +++++++++++++++++++++++++++ src/background/modules/ContextMenu.js | 14 +++++++++---- src/common/modules/Notifications.js | 7 ++++--- 4 files changed, 72 insertions(+), 7 deletions(-) diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index eadda6e..83ce593 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -77,6 +77,35 @@ } }, + "menuCtrlKey": { + "message": "Strg", + "description": "The short key name used for the Control modifier key on typical Windows(-like) keyboards. For mac OS devices it automatically uses the Unicode symbol ⌘ instead." + }, + "menuNotificationPressCtrlVTitle": { + "message": "📋 Drück $CTRL_KEY$+V", + "description": "The message title shown as a workaround to let users know to press Ctrl+V to insert the transformed text.", + "placeholders": { + "ctrl_key": { + "content": "$1", + "example": "Ctrl" + } + } + }, + "menuNotificationPressCtrlVContent": { + "message": "Add-ons in Thunderbird können aktuell nicht auf das ausgewählte Feld („$FIELD_NAME$”) zugreifen. Daher wurde der transformierte Text in diene Zwischenablage kopiert.\nBitte drück $CTRL_KEY$+V um die Transformation auszuführen.", + "description": "The message title shown as a workaround to let users know to press Ctrl+V to insert the transformed text.", + "placeholders": { + "ctrl_key": { + "content": "$1", + "example": "Ctrl" + }, + "field_name": { + "content": "$2", + "example": "compose" + } + } + }, + "menuCaseLowercase": { "message": "Kleinbuchstaben", "description": "An entry in the context menu. This is an entry for the case." diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 01385f4..2491c2a 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -89,6 +89,35 @@ } }, + "menuCtrlKey": { + "message": "Ctrl", + "description": "The short key name used for the Control modifier key on typical Windows(-like) keyboards. For mac OS devices it automatically uses the Unicode symbol ⌘ instead." + }, + "menuNotificationPressCtrlVTitle": { + "message": "📋 Press $CTRL_KEY$-V", + "description": "The message title shown as a workaround to let users know to press Ctrl+V to insert the transformed text.", + "placeholders": { + "ctrl_key": { + "content": "$1", + "example": "Ctrl" + } + } + }, + "menuNotificationPressCtrlVContent": { + "message": "Add-ons in Thunderbird are currently unable to access chosen field (“$FIELD_NAME$”) directly, so the transformed text has been copied to your clipboard.\nPlease press $CTRL_KEY$-V to do the transformation.", + "description": "The message title shown as a workaround to let users know to press Ctrl+V to insert the transformed text.", + "placeholders": { + "ctrl_key": { + "content": "$1", + "example": "Ctrl" + }, + "field_name": { + "content": "$2", + "example": "compose" + } + } + }, + "menuCaseLowercase": { "message": "Lowercase", "description": "An entry in the context menu. This is an entry for the case." diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index 453d36a..25d7a27 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -25,8 +25,14 @@ let pasteSymbol = null; */ function fallback(text, fieldId) { navigator.clipboard.writeText(text); - // TODO: This will need to be localized - Notifications.showNotification(`📋 Press ${pasteSymbol}-V`, `Add-ons in Thunderbird are currently unable to access the “${fieldId.startsWith("compose") ? fieldId.slice("compose".length) : fieldId}” field directly, so the transformed text has been copied to your clipboard.\nPlease press ${pasteSymbol}-V to do the transformation.`); + const fieldName = fieldId.startsWith("compose") ? fieldId.slice("compose".length) : fieldId; + Notifications.showNotification( + "menuNotificationPressCtrlVTitle", + "menuNotificationPressCtrlVContent", + [ + browser.i18n.getMessage("menuCtrlKey"), + fieldName + ]); } /** @@ -231,13 +237,13 @@ export async function init() { buildMenu(unicodeFontSettings); - // feature detection for this feature, as it is not compatible with CHrome/ium. + // feature detection for this feature, as it is not compatible with Chrome/ium. if (menus.onShown) { menus.onShown.addListener(handleMenuShown); } menus.onClicked.addListener(handleMenuChoosen); - pasteSymbol = platformInfo.os === "mac" ? "\u2318" : "Ctrl"; + pasteSymbol = platformInfo.os === "mac" ? "\u2318" : browser.i18n.getMessage("menuCtrlKey"); } BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UNICODE_FONT, async (request) => { diff --git a/src/common/modules/Notifications.js b/src/common/modules/Notifications.js index 7d921c3..8f3ed41 100644 --- a/src/common/modules/Notifications.js +++ b/src/common/modules/Notifications.js @@ -13,12 +13,13 @@ const ICON = (browser.runtime.getManifest()).icons[32]; * @public * @param {string} title the title * @param {string} content the message content + * @param {string[] | string} substitutions the message parameters to pass for i18n.getMessage * @returns {Promise} * @see {@link https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/notifications/create} */ -export function showNotification(title, content) { - title = browser.i18n.getMessage(title) || title; - content = browser.i18n.getMessage(content) || content; +export function showNotification(title, content, substitutions) { + title = browser.i18n.getMessage(title, substitutions) || title; + content = browser.i18n.getMessage(content, substitutions) || content; console.info("Showing notification:", title, content); browser.notifications.create({ From 9ff5f96b99e4896f796057ba19fb2b723d36c6d7 Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 16:40:38 +0200 Subject: [PATCH 12/25] Fix typo --- src/_locales/de/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index 83ce593..f58d10f 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -92,7 +92,7 @@ } }, "menuNotificationPressCtrlVContent": { - "message": "Add-ons in Thunderbird können aktuell nicht auf das ausgewählte Feld („$FIELD_NAME$”) zugreifen. Daher wurde der transformierte Text in diene Zwischenablage kopiert.\nBitte drück $CTRL_KEY$+V um die Transformation auszuführen.", + "message": "Add-ons in Thunderbird können aktuell nicht auf das ausgewählte Feld („$FIELD_NAME$”) zugreifen. Daher wurde der transformierte Text in deine Zwischenablage kopiert.\nBitte drück $CTRL_KEY$+V um die Transformation auszuführen.", "description": "The message title shown as a workaround to let users know to press Ctrl+V to insert the transformed text.", "placeholders": { "ctrl_key": { From 3b4a67f2c1de428887dcca9c623dd26a714ef4fb Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 17:34:26 +0200 Subject: [PATCH 13/25] Convert autocorrection warning to proper warning and localize it --- src/_locales/de/messages.json | 13 +++++++++++++ src/_locales/en/messages.json | 13 +++++++++++++ src/options/options.html | 13 ++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index f58d10f..234c3ee 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -225,11 +225,24 @@ "message": "Weitere Informationen", "description": "When a link to an explainer needs to be added, this is the link text." }, + "optionMoreInformation": { + "message": "Mehr Informationen", + "description": "When a link to an explainer needs to be added and it is more informative and not about learning something, this is the link text." + }, "optionsResetButton": { "message": "Setze alle Einstellungen auf Standardwerte zurück", "description": "The button to delete all current settings and load the defaults, shown in the add-on settings." }, + "optionWarningAutocorrectFeature": { + "message": "Die Unicode-Autokorrektur-Funktion ist experimentell und kann einige Webseiten beeinträchtigen.", + "description": "The warning used to mark the autocorrection feature as experimental. Try to keep it short." + }, + "optionWarningAutocorrectFeatureLink": { + "message": "https://github.com/rugk/unicodify/wiki/FAQ-(deutsch)#warum-ist-die-autokorrektur-funktion-experimentell", + "description": "The link for more information about the optionWarningAutocorrectFeature warning." + }, + "titleUnicodeAutocorrection": { "message": "Unicode-Autokorrektur", "description": "A title in the add-on settings." diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 2491c2a..3bced42 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -237,11 +237,24 @@ "message": "Learn more", "description": "When a link to an explainer needs to be added, this is the link text." }, + "optionMoreInformation": { + "message": "More information", + "description": "When a link to an explainer needs to be added and it is more informative and not about learning something, this is the link text." + }, "optionsResetButton": { "message": "Reset all settings to defaults", "description": "The button to delete all current settings and load the defaults, shown in the add-on settings." }, + "optionWarningAutocorrectFeature": { + "message": "The Unicode autocorrect feature is experimental and may negatively affect some web pages.", + "description": "The warning used to mark the autocorrection feature as experimental. Try to keep it short." + }, + "optionWarningAutocorrectFeatureLink": { + "message": "https://github.com/rugk/unicodify/wiki/FAQ#why-is-the-autocorrect-feature-experimental", + "description": "The link for more information about the optionWarningAutocorrectFeature warning." + }, + "titleUnicodeAutocorrection": { "message": "Unicode autocorrection", "description": "A title in the add-on settings." diff --git a/src/options/options.html b/src/options/options.html index f623d06..aaee349 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -54,6 +54,7 @@

      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. @@ -62,13 +63,23 @@

      Unicode autocorrection

      For Emoji autocorrection, including :colon: shortcodes and Emoticons, please also try out our 🤩 Awesome Emoji Picker add-on. + +
      +
      + The Unicode autocorrect feature is experimental and may negatively affect some web pages. + + + +
      +
      +
      • - Enable the experimental Unicode autocorrection feature. ⚠️ This is for testing only. + For example, this will replace -- with –, --> with ⟶ and 1/4 with ¼.
      • From 71fb1238dacfd0640943ab9ef78e31ef0cbc3063 Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 17:40:34 +0200 Subject: [PATCH 14/25] chore: use CommonCSS from TinyWebExt Fixes https://github.com/TinyWebEx/CommonCss/issues/1 --- .gitmodules | 3 + src/common/common.css | 258 +-------------------------- src/common/modules/AutomaticSettings | 2 +- src/common/modules/CommonCss | 1 + 4 files changed, 6 insertions(+), 258 deletions(-) create mode 160000 src/common/modules/CommonCss diff --git a/.gitmodules b/.gitmodules index abac9c3..7de49c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "src/common/modules/AutomaticSettings"] path = src/common/modules/AutomaticSettings url = https://github.com/TinyWebEx/AutomaticSettings +[submodule "src/common/modules/CommonCss"] + path = src/common/modules/CommonCss + url = https://github.com/TinyWebEx/CommonCss diff --git a/src/common/common.css b/src/common/common.css index f1fe89c..a466d63 100644 --- a/src/common/common.css +++ b/src/common/common.css @@ -1,257 +1 @@ -@import url("./variables.css"); - -body { - direction: __MSG_@@bidi_dir__; -} - -/* https://design.firefox.com/photon/components/links.html */ -a { - color: var(--blue-60); - text-decoration: none; -} - -a:focus { - border-radius: 4px; - box-shadow: 0 0 0 2px var(--blue-50), 0 0 0 6px var(--blue-50-a30); -} - -a:hover, a:active { - text-decoration: underline; -} - -a:active { - color: var(--blue-70); -} - -/* external link symbol */ -/* currently disabled, because it is not clear what an external link is, in our case */ -/*a:not([class])[href*="//"]::after { - background-image: url(/common/img/open-in-new.svg); - background-repeat: no-repeat; - background-size: 16px 16px; - content: ""; - display: inline-block; - height: 16px; - margin: -.3rem .15rem 0 .25rem; - vertical-align: middle; - width: 16px; -}*/ - -/* small classes in order to avoid inline CSS */ -.invisible { - display: none !important; -} - -.message-container { - position: relative; -} - -/* buttons https://design.firefox.com/photon/components/buttons.html */ -.micro-button { - min-height: 24px; - height: auto; - border-radius: 2px; - - padding-left: 8px; - padding-right: 8px; - - /* not documented, but looks ugly otherwise */ - padding-top: 2px; - padding-bottom: 2px; - - box-sizing: content-box; - - /* do not break over multiple lines */ - /* white-space: nowrap; */ - height: auto; /* currently, we rather prefer breaking until https://github.com/rugk/offline-qr-code/issues/12 is done */ -} - -/* use light color for dark backgrounds */ -.micro-button:hover.success, -.micro-button:active.success, -.micro-button:hover.warning, -.micro-button:active.warning, -.micro-button:hover.error, -.micro-button:active.error { - color: var(--white-100); -} - -.micro-button.info { - background-color: var(--grey-90-a10); -} -.micro-button:hover.info { - background-color: var(--grey-90-a20); -} -.micro-button:active.info { - background-color: var(--grey-90-a30); -} - -.micro-button.success { - background-color: var(--green-60); -} -.micro-button:hover.success { - background-color: var(--green-70); -} -.micro-button:active.success { - background-color: var(--green-80); -} - -.micro-button.warning { - background-color: var(--yellow-60); -} -.micro-button:hover.warning { - background-color: var(--yellow-70); -} -.micro-button:active.warning { - background-color: var(--yellow-80); -} - -.micro-button.error { - background-color: var(--red-70); - color: var(--white-100); -} -.micro-button:hover.error { - background-color: var(--red-80); -} -.micro-button:active.error { - background-color: var(--red-90); -} - -.micro-button:focus { - box-shadow: 0 0 0 1px #0a84ff inset, 0 0 0 1px #0a84ff, 0 0 0 4px rgba(10, 132, 255, 0.3) -} - -/* message box */ -/* follows https://design.firefox.com/photon/components/message-bars.html */ -.message-box { - padding: 4px; - - border-radius: 4px; - - /* use whole width */ - width: 100%; - min-height: 32px; - - /* make errors selectable, so users can copy them */ - -moz-user-select: text; - cursor: text; - - /* multiline */ - hypens: auto; - overflow-wrap: break-word; - - /* center-vertically */ - display: flex; - align-items: center; - - z-index: 2; - - /* fade-in transition */ - /* follow https://design.firefox.com/photon/motion/duration-and-easing.html */ - opacity: 1; - max-height: 100px; - - transition: opacity 150ms cubic-bezier(.07,.95,0,1), - max-height 200ms cubic-bezier(.07,.95,0,1); -} -.message-box.fade-hide { - max-height: 0px; - opacity: 0; - min-height: 0px; -} - -/* add margin when messages are stacked on each other */ -.message-box:not(.invisible) ~ .message-box:not(.invisible) { - margin-top: 8px; -} - -.error { - color: var(--white-100); - background-color: var(--red-60); -} - -.info { - color: var(--grey-90); - background-color: var(--grey-20); -} - -.success { - color: var(--green-90); - background-color: var(--green-50); -} - -.warning { - color: var(--yellow-90); - background-color: var(--yellow-50); -} - -/* message box action button */ -.message-action-button { - margin-left: 8px; - - /* center vertially */ - margin-top: auto; - margin-bottom: auto; - - /* some minimum margin to dismiss button or similar */ - margin-right: 4px; - - border: 0; - color: var(--grey-90); - - cursor: pointer; -} - -/* icons for the message boxes */ -.message-box::before { - display: inline-block; - - /* fixed size */ - background-size: 16px 16px; - width: 16px; - height: 16px; - min-width: 16px; - min-height: 16px; - - content: ""; - margin: 4px; -} - -.error::before { - background-image: url('/common/img/error-white.svg'); -} -.info::before { - background-image: url('/common/img/info-dark.svg'); -} -.success::before { - background-image: url('/common/img/check.svg'); -} -.warning::before { - background-image: url('/common/img/warning-dark.svg'); -} - -.icon-dismiss { - box-sizing: content-box; - padding: 2px; - - width: 24px; - height: 24px; - - margin-left: auto; - cursor: pointer; - - /* some animation on hover */ - transition: background-color 150ms cubic-bezier(.07,.95,0,1); -} -.icon-dismiss:hover { - background-color: var(--grey-90-a10); - border-radius: 2px; -} -.icon-dismiss:active { - background-color: var(--grey-90-a20); - border-radius: 2px; -} -.icon-dismiss:focus { - box-shadow: 0 0 0 1px var(--blue-50) inset, 0 0 0 1px var(--blue-50), 0 0 0 4px var(--blue-50-a30); - border-radius: 2px; -} +@import url("./modules/CommonCss/common.css"); diff --git a/src/common/modules/AutomaticSettings b/src/common/modules/AutomaticSettings index fce7d28..5d11d88 160000 --- a/src/common/modules/AutomaticSettings +++ b/src/common/modules/AutomaticSettings @@ -1 +1 @@ -Subproject commit fce7d28ce753354da18cad9cfe71c729ec46d424 +Subproject commit 5d11d88a8756c0be70fbf13499d1918f1931a058 diff --git a/src/common/modules/CommonCss b/src/common/modules/CommonCss new file mode 160000 index 0000000..bdd81cc --- /dev/null +++ b/src/common/modules/CommonCss @@ -0,0 +1 @@ +Subproject commit bdd81cc7d19caeb324c9ccbbde19c624bf8429e2 From 8d1ed437f2be85a32689eb5654e34d343da7d092 Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 20:09:08 +0200 Subject: [PATCH 15/25] chore: update CommonCss for proper message display --- src/common/modules/CommonCss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/modules/CommonCss b/src/common/modules/CommonCss index bdd81cc..57cd712 160000 --- a/src/common/modules/CommonCss +++ b/src/common/modules/CommonCss @@ -1 +1 @@ -Subproject commit bdd81cc7d19caeb324c9ccbbde19c624bf8429e2 +Subproject commit 57cd712256ae06a424b550521aabfbd855cfb4e3 From 9e68e4e5cf2a98fa5b5dbc32945f1ccb59b88dd6 Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 20:09:51 +0200 Subject: [PATCH 16/25] Remove the second warning for experimental features as confirm message --- src/options/modules/CustomOptionTriggers.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 06b03c6..64affff 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -27,15 +27,6 @@ const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype; */ function applyAutocorrectPermissions(optionValue, option, event) { if (optionValue.enabled) { - if (option && event?.target?.name === "enabled") { - // TODO: This will need to be localized - // Remove IS_THUNDERBIRD once https://bugzilla.mozilla.org/show_bug.cgi?id=1780977 is fixed - if (!IS_THUNDERBIRD && !IS_CHROME && !confirm("Are you sure you want to enable this experimental feature?")) { - // Remove once https://github.com/TinyWebEx/AutomaticSettings/issues/21 is fixed - event.target.checked = !optionValue.enabled; - return Promise.reject(); - } - } document.getElementById("autocorrectSymbols").disabled = false; document.getElementById("autocorrectUnicodeQuotes").disabled = false; document.getElementById("autocorrectUnicodeFracts").disabled = false; From 96ec140321cde3c98a3300f26e40fc401212b96b Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 20:18:09 +0200 Subject: [PATCH 17/25] chore: remove unused browser detection for now --- src/manifest.json | 17 ++++++++++------- src/options/modules/CustomOptionTriggers.js | 9 --------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index 4f63007..6361e19 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,8 +1,8 @@ { "manifest_version": 2, - "name": "Unicodify DEV VERSION", + "name": "__MSG_extensionName__", "short_name": "__MSG_extensionNameShort__", - "version": "0.5", + "version": "0.5.2", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", @@ -20,12 +20,12 @@ { "matches": [""], "all_frames": true, + "match_about_blank": true, "js": ["content_scripts/autocorrect.js"] } ], - // testing version allows loading unit test libraries from CDNs - "content_security_policy": "default-src 'self'; img-src data:; style-src 'self' https://unpkg.com; script-src 'self' https://unpkg.com", + "content_security_policy": "default-src 'self'", "icons": { "16": "icons/icon.svg", "32": "icons/icon.svg", @@ -37,14 +37,17 @@ "permissions": [ "storage", "", - "contextMenus", - "tabs" + "tabs", + "compose", + "menus", + "notifications", + "clipboardWrite" ], "applications": { "gecko": { "id": "unicodify@rugk.github.io", - "strict_min_version": "87.0" + "strict_min_version": "91.0" } } } diff --git a/src/options/modules/CustomOptionTriggers.js b/src/options/modules/CustomOptionTriggers.js index 64affff..f631da7 100644 --- a/src/options/modules/CustomOptionTriggers.js +++ b/src/options/modules/CustomOptionTriggers.js @@ -7,15 +7,6 @@ import * as AutomaticSettings from "/common/modules/AutomaticSettings/AutomaticSettings.js"; import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js"; -// Thunderbird -// https://bugzilla.mozilla.org/show_bug.cgi?id=1641573 -const IS_THUNDERBIRD = typeof messenger !== "undefined"; - -// Chrome -// Adapted from: https://github.com/mozilla/webextension-polyfill/blob/master/src/browser-polyfill.js -const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype; - - /** * Apply the new autocorrect settings. * From 4d7dc9bee4cc377ecceb0d2700c696a2ece7811d Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 22 Aug 2022 20:19:56 +0200 Subject: [PATCH 18/25] chore: uuups, revert to default dev manifest --- src/manifest.json | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index 6361e19..4f63007 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,8 +1,8 @@ { "manifest_version": 2, - "name": "__MSG_extensionName__", + "name": "Unicodify DEV VERSION", "short_name": "__MSG_extensionNameShort__", - "version": "0.5.2", + "version": "0.5", "author": "Teal Dulcet, rugk", "description": "__MSG_extensionDescription__", @@ -20,12 +20,12 @@ { "matches": [""], "all_frames": true, - "match_about_blank": true, "js": ["content_scripts/autocorrect.js"] } ], - "content_security_policy": "default-src 'self'", + // testing version allows loading unit test libraries from CDNs + "content_security_policy": "default-src 'self'; img-src data:; style-src 'self' https://unpkg.com; script-src 'self' https://unpkg.com", "icons": { "16": "icons/icon.svg", "32": "icons/icon.svg", @@ -37,17 +37,14 @@ "permissions": [ "storage", "", - "tabs", - "compose", - "menus", - "notifications", - "clipboardWrite" + "contextMenus", + "tabs" ], "applications": { "gecko": { "id": "unicodify@rugk.github.io", - "strict_min_version": "91.0" + "strict_min_version": "87.0" } } } From 5eb8cc6cbbffb2e39545653771a7a70a01ea9e44 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Tue, 6 Sep 2022 04:41:42 -0700 Subject: [PATCH 19/25] Fix issue with Unicode font conversion. --- src/background/modules/ContextMenu.js | 6 +++--- src/common/modules/data/Tips.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index 25d7a27..b725e5f 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -62,7 +62,7 @@ function handleMenuChoosen(info, tab) { } browser.tabs.executeScript(tab.id, { - code: `insertIntoPage("${output}");`, + code: `insertIntoPage(${JSON.stringify(output)});`, frameId: info.frameId }); } @@ -108,7 +108,7 @@ async function handleMenuShown(info) { text = null; } - await buildMenu(lastCachedUnicodeFontSettings, text, menuIsShown); + await buildMenu(lastCachedUnicodeFontSettings, text); menus.refresh(); } @@ -216,7 +216,7 @@ BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.UPDATE_CONTEXT_MENU, text = null; } - await buildMenu(lastCachedUnicodeFontSettings, text, true); + await buildMenu(lastCachedUnicodeFontSettings, text); }); /** diff --git a/src/common/modules/data/Tips.js b/src/common/modules/data/Tips.js index e0392eb..fc7f6e9 100644 --- a/src/common/modules/data/Tips.js +++ b/src/common/modules/data/Tips.js @@ -111,7 +111,7 @@ const tipArray = [ tipSpec.actionButton.action = await getBrowserValue({ firefox: "https://addons.mozilla.org/firefox/addon/unicodify-text-transformer/reviews/?utm_source=unicodify-addon&utm_medium=addon&utm_content=unicodify-addon-tips-tipYouLikeAddon&utm_campaign=unicodify-addon-tips", thunderbird: "https://addons.thunderbird.net/thunderbird/addon/unicodify-text-transformer/reviews/?utm_source=unicodify-addon&utm_medium=addon&utm_content=unicodify-addon-tips-awesomeIcons&utm_campaign=unicodify-addon-tips", - chrome: "https://chrome.google.com/webstore/detail/unicodify-text-transformer/#...", + chrome: "https://chrome.google.com/webstore/detail/unicodify-text-transformer/reviews", }); return null; } @@ -134,7 +134,7 @@ const tipArray = [ showTip: async (tipSpec) => { tipSpec.actionButton.action = await getBrowserValue({ firefox: "https://addons.mozilla.org/firefox/addon/awesome-emoji-picker/?utm_source=unicodify-addon&utm_medium=addon&utm_content=unicodify-addon-tips-awesomeIcons&utm_campaign=unicodify-addon-tips", - thunderbird: "https://addons.thunderbird.net/thunderbird/addon/awesome-emoji-picker/reviews/?utm_source=unicodify-addon&utm_medium=addon&utm_content=unicodify-addon-tips-awesomeIcons&utm_campaign=unicodify-addon-tips", + thunderbird: "https://addons.thunderbird.net/thunderbird/addon/awesome-emoji-picker/?utm_source=unicodify-addon&utm_medium=addon&utm_content=unicodify-addon-tips-awesomeIcons&utm_campaign=unicodify-addon-tips", chrome: "https://chrome.google.com/webstore/detail/awesome-emoji-picker/", }); return null; From ba40745475dc9a3a152502f4a0936b31c5fe2036 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Fri, 23 Sep 2022 04:33:52 -0700 Subject: [PATCH 20/25] Added new superscript characters. --- src/common/modules/data/Fonts.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index acce768..a5a19ac 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -1,6 +1,7 @@ "use strict"; // Adapted from: https://entropymine.wordpress.com/2018/05/26/the-curious-case-of-small-caps-in-unicode/ +// https://en.wikipedia.org/wiki/Small_caps#Unicode const smallCaps = "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘꞯʀꜱᴛᴜᴠᴡxʏᴢ"; /** @@ -87,6 +88,9 @@ export const menuStructure = Object.freeze({ /** * Unicode fonts * Some of the fonts have characters that are not yet implemented. + * https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols + * https://en.wikipedia.org/wiki/Enclosed_Alphanumerics + * https://en.wikipedia.org/wiki/Enclosed_Alphanumeric_Supplement * * @private * @const @@ -110,9 +114,11 @@ const fonts = Object.freeze({ [`${FONT_ID_PREFIX}CircledBlack`]: "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿❶❷❸❹❺❻❼❽❾", [`${FONT_ID_PREFIX}Squared`]: "!\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", [`${FONT_ID_PREFIX}SquaredBlack`]: "🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉", + // https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block) [`${FONT_ID_PREFIX}Fullwidth`]: "!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", // Adapted from: https://rupertshepherd.info/resource_pages/superscript-letters-in-unicode - [`${FONT_ID_PREFIX}Superscript`]: "ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾQᴿˢᵀᵁⱽᵂˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖqʳˢᵗᵘᵛʷˣʸᶻ⁰¹²³⁴⁵⁶⁷⁸⁹", + // https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts + [`${FONT_ID_PREFIX}Superscript`]: "!\"#$%&'⁽⁾*⁺,⁻./⁰¹²³⁴⁵⁶⁷⁸⁹:;<⁼>?@ᴬᴮꟲᴰᴱꟳᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾꟴᴿˢᵀᵁⱽᵂˣʸᶻ[\]^_`ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖ𐞥ʳˢᵗᵘᵛʷˣʸᶻ{|}~", [`${FONT_ID_PREFIX}SmallCaps`]: `ABCDEFGHIJKLMNOPQRSTUVWXYZ${smallCaps}`, [`${FONT_ID_PREFIX}AllSmallCaps`]: smallCaps, [`${FONT_ID_PREFIX}Unicase`]: `${smallCaps}abcdefghijklmnopqrstuvwxyz` From 074ce73b6136ae870e0724ad7f35a1348728fbe7 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Wed, 12 Oct 2022 05:30:06 -0700 Subject: [PATCH 21/25] Support Unicode font conversion of spaces. --- .../modules/UnicodeTransformationHandler.js | 18 +++++++++--------- src/common/modules/data/Fonts.js | 9 +++++---- src/content_scripts/autocorrect.js | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/common/modules/UnicodeTransformationHandler.js b/src/common/modules/UnicodeTransformationHandler.js index cb648a0..3d4cd83 100644 --- a/src/common/modules/UnicodeTransformationHandler.js +++ b/src/common/modules/UnicodeTransformationHandler.js @@ -76,23 +76,23 @@ function changeFont(text, 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)]; + const code = letter.codePointAt(0); + if (code >= 32 && code <= 127) { + if (font.length === 95) { + letter = font[code - " ".codePointAt(0)]; } else if (letter >= "A" && letter <= "Z") { - letter = font[code - "A".charCodeAt(0)]; + letter = font[code - "A".codePointAt(0)]; } else if (letter >= "a" && letter <= "z") { if (font.length === 26 || font.length === 26 + 10) { - letter = font[code - "a".charCodeAt(0)]; + letter = font[code - "a".codePointAt(0)]; } else if (font.length === 26 + 26 || font.length === 26 + 26 + 10) { - letter = font[code - "a".charCodeAt(0) + 26]; + letter = font[code - "a".codePointAt(0) + 26]; } } else if (letter >= "0" && letter <= "9") { if (font.length === 26 + 10) { - letter = font[code - "0".charCodeAt(0) + 26]; + letter = font[code - "0".codePointAt(0) + 26]; } else if (font.length === 26 + 26 + 10) { - letter = font[code - "0".charCodeAt(0) + 26 + 26]; + letter = font[code - "0".codePointAt(0) + 26 + 26]; } } } diff --git a/src/common/modules/data/Fonts.js b/src/common/modules/data/Fonts.js index a5a19ac..e8e51ef 100644 --- a/src/common/modules/data/Fonts.js +++ b/src/common/modules/data/Fonts.js @@ -110,15 +110,16 @@ const fonts = Object.freeze({ [`${FONT_ID_PREFIX}FrakturBold`]: "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟", [`${FONT_ID_PREFIX}Monospace`]: "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", [`${FONT_ID_PREFIX}DoubleStruck`]: "𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", - [`${FONT_ID_PREFIX}Circled`]: "!\"#$%&'()⊛⊕,⊖⊙⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[⦸]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~", + [`${FONT_ID_PREFIX}Circled`]: " !\"#$%&'()⊛⊕,⊖⊙⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[⦸]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~", [`${FONT_ID_PREFIX}CircledBlack`]: "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿❶❷❸❹❺❻❼❽❾", - [`${FONT_ID_PREFIX}Squared`]: "!\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", + [`${FONT_ID_PREFIX}Squared`]: " !\"#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[⧅]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{|}~", [`${FONT_ID_PREFIX}SquaredBlack`]: "🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉", // https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block) - [`${FONT_ID_PREFIX}Fullwidth`]: "!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", + [`${FONT_ID_PREFIX}Fullwidth`]: " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~", // Adapted from: https://rupertshepherd.info/resource_pages/superscript-letters-in-unicode // https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts - [`${FONT_ID_PREFIX}Superscript`]: "!\"#$%&'⁽⁾*⁺,⁻./⁰¹²³⁴⁵⁶⁷⁸⁹:;<⁼>?@ᴬᴮꟲᴰᴱꟳᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾꟴᴿˢᵀᵁⱽᵂˣʸᶻ[\]^_`ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖ𐞥ʳˢᵗᵘᵛʷˣʸᶻ{|}~", + [`${FONT_ID_PREFIX}Superscript`]: " !\"#$%&'⁽⁾*⁺,⁻./⁰¹²³⁴⁵⁶⁷⁸⁹:;<⁼>?@ᴬᴮꟲᴰᴱꟳᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾꟴᴿˢᵀᵁⱽᵂˣʸᶻ[\\]^_`ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖ𐞥ʳˢᵗᵘᵛʷˣʸᶻ{|}~", + [`${FONT_ID_PREFIX}Subscript`]: " !\"#$%&'₍₎*₊,₋./₀₁₂₃₄₅₆₇₈₉:;<₌>?@ₐBCDₑFGₕᵢⱼₖₗₘₙₒₚQᵣₛₜᵤᵥWₓYZ[\\]^_`ₐbcdₑfgₕᵢⱼₖₗₘₙₒₚqᵣₛₜᵤᵥwₓyz{|}~", [`${FONT_ID_PREFIX}SmallCaps`]: `ABCDEFGHIJKLMNOPQRSTUVWXYZ${smallCaps}`, [`${FONT_ID_PREFIX}AllSmallCaps`]: smallCaps, [`${FONT_ID_PREFIX}Unicase`]: `${smallCaps}abcdefghijklmnopqrstuvwxyz` diff --git a/src/content_scripts/autocorrect.js b/src/content_scripts/autocorrect.js index 892cf8c..30acb47 100644 --- a/src/content_scripts/autocorrect.js +++ b/src/content_scripts/autocorrect.js @@ -72,7 +72,7 @@ function getCaretPosition(target) { const temp = document.createTextNode("\0"); range.insertNode(temp); const caretposition = target.innerText.indexOf("\0"); - temp.parentNode.removeChild(temp); + temp.remove(); return caretposition; } // input and textarea fields From fb6ab8048abeafc46fad109d21dace9fc23fd0ac Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 19 Oct 2022 14:40:38 +0200 Subject: [PATCH 22/25] fix: use paste symbol to make it work on macOS Co-authored-by: Teal Dulcet --- src/background/modules/ContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background/modules/ContextMenu.js b/src/background/modules/ContextMenu.js index b725e5f..c484524 100644 --- a/src/background/modules/ContextMenu.js +++ b/src/background/modules/ContextMenu.js @@ -30,7 +30,7 @@ function fallback(text, fieldId) { "menuNotificationPressCtrlVTitle", "menuNotificationPressCtrlVContent", [ - browser.i18n.getMessage("menuCtrlKey"), + pasteSymbol, fieldName ]); } From 9c4c35da0275dab34147ff041697c52805e595a5 Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 19 Oct 2022 16:28:03 +0200 Subject: [PATCH 23/25] remove duplicate description --- src/options/options.html | 1 - 1 file changed, 1 deletion(-) diff --git a/src/options/options.html b/src/options/options.html index aaee349..4895c92 100644 --- a/src/options/options.html +++ b/src/options/options.html @@ -79,7 +79,6 @@

        Unicode autocorrection

        - For example, this will replace -- with –, --> with ⟶ and 1/4 with ¼.
      • From 9def52112c651eaa4fe7f3a4ffc88644ac6208e8 Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 19 Oct 2022 16:28:32 +0200 Subject: [PATCH 24/25] chore: update submodules --- src/common/modules/BrowserCommunication | 2 +- src/common/modules/Localizer | 2 +- src/common/modules/MessageHandler | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/modules/BrowserCommunication b/src/common/modules/BrowserCommunication index b0125e5..3c7c776 160000 --- a/src/common/modules/BrowserCommunication +++ b/src/common/modules/BrowserCommunication @@ -1 +1 @@ -Subproject commit b0125e55f3aa8631bf3224e9389a51879e0ace96 +Subproject commit 3c7c77631185b792a61fa1dcb4c30b2aa5fdd1ff diff --git a/src/common/modules/Localizer b/src/common/modules/Localizer index da1f4c3..dee08d4 160000 --- a/src/common/modules/Localizer +++ b/src/common/modules/Localizer @@ -1 +1 @@ -Subproject commit da1f4c3edc616655a360b2a79b79514d8c077b55 +Subproject commit dee08d49f0ddc9f4ae2f0d94b7c993f4bfe165e8 diff --git a/src/common/modules/MessageHandler b/src/common/modules/MessageHandler index a2aa9f4..5eb3a2e 160000 --- a/src/common/modules/MessageHandler +++ b/src/common/modules/MessageHandler @@ -1 +1 @@ -Subproject commit a2aa9f477e4dfa9a12b97c7bb4088255e381a191 +Subproject commit 5eb3a2e24cbff76af0281f6ff5a737a2a0b77e39 From e5d6cce778db108d842b26d54418e11aa9da499e Mon Sep 17 00:00:00 2001 From: rugk Date: Wed, 19 Oct 2022 16:30:02 +0200 Subject: [PATCH 25/25] chore: better example in message.json --- src/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 3bced42..68f08df 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -113,7 +113,7 @@ }, "field_name": { "content": "$2", - "example": "compose" + "example": "Subject" } } },