commit 9053327486f624509309cbc785707bdcff8f100d Author: Oliver Herb Date: Tue Nov 24 09:27:49 2026 +0100 Inline Comment 0.2.0 - initial public release Thunderbird/Betterbird add-on (Manifest V3): typing inside a quote splits the quote and inserts your own text with a marker such as [OH]:. - English and German user interface - Licensed under the Mozilla Public License 2.0 - English documentation, JSDoc lint gate, 87 tests (node:test + jsdom) diff --git a/.docs/architecture/overview.md b/.docs/architecture/overview.md new file mode 100644 index 0000000..194bcb4 --- /dev/null +++ b/.docs/architecture/overview.md @@ -0,0 +1,102 @@ +# Architecture – Overview + +## Building blocks + +```text +Thunderbird / Betterbird +├── Background script (src/background.js) event page, Manifest V3 +│ ├── registers the compose script (scripting.compose) +│ ├── keeps the on/off state per compose window (storage.session, else in memory) +│ ├── "Inline Comment" toolbar button (composeAction, badge "on"/"off") +│ └── delivers the configuration: settings + identity + on/off + plain text? +│ +├── Compose script (src/compose/compose.js) in the editor document of every compose window +│ ├── intercepts typed characters inside a quote (keydown, fallback: beforeinput) +│ ├── splits the quote (editor command insertParagraph, fallback: manual split) +│ └── inserts the comment with its marker (insertHTML or insertText) +│ +├── Options page (src/options/) settings in storage.local, localized texts +│ +├── Translations (src/_locales/{en,de}/messages.json) default locale: en +│ +└── Shared library (src/lib/) classic UMD scripts, testable under Node + ├── settings.js defaults, validation, profiles per identity, compose script file list + ├── marker.js placeholders, initials, comment as DOM node or plain text + ├── quote.js quote and gap detection, manual split, caret placement + └── i18n.js localizeDocument() for data-i18n attributes (options page) +``` + +The library files attach their functions to `globalThis.InlineComment` and also export them through +`module.exports`, so the same file runs in the add-on and in the Node tests. They are classic scripts +rather than ES modules because compose scripts cannot load modules. + +## What runs where + +| Context | Scripts, in load order | Defined in | +| -------------- | ------------------------------------------------------------------------ | ------------------------------------------- | +| Background | `lib/settings.js`, `lib/marker.js`, `background.js` | `manifest.json` → `background` | +| Compose window | `lib/settings.js`, `lib/marker.js`, `lib/quote.js`, `compose/compose.js` | `COMPOSE_SCRIPT_FILES` in `lib/settings.js` | +| Options page | `lib/settings.js`, `lib/marker.js`, `lib/i18n.js`, `options/options.js` | ` + + + + + diff --git a/src/options/options.js b/src/options/options.js new file mode 100644 index 0000000..3de9828 --- /dev/null +++ b/src/options/options.js @@ -0,0 +1,480 @@ +/* + * Copyright 2026 Oliver Herb + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +/* + * Options page script: edits the settings for all sender identities (the + * global profile) and optional own profiles per sender identity, shows a live + * preview of the comment and resets a profile to the defaults. There is no + * save button: changes are saved automatically 300 ms after the last edit. + * + * Runs on the options page only (manifest "options_ui", options.html). The + * Node tests (test/i18n.test.js) also run it in jsdom with a fake WebExtension + * API. It is not loaded in the background or in the compose editor. + * + * Needs these scripts loaded first (options.html does this): lib/settings.js, + * lib/marker.js and lib/i18n.js, which attach their functions to + * globalThis.InlineComment. Its