Files
inline-comment/.docs/architecture/overview.md
T
Oliver_Herb 9053327486 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)
2026-11-24 12:07:09 +01:00

5.6 KiB
Raw Blame History

Architecture – Overview

Building blocks

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 <script> tags in options.html

Data flow

Options page ──storage.local──▶ Background ──configuration──▶ Compose script
                                  ▲  │                              │
       Button (on/off) ───────────┘  └── tabs.sendMessage on ───────┘
                                         change (settings,
                                         identity, button)

The compose script asks for its configuration when it loads and whenever its window gets the focus (runtime.sendMessage({type: "ic:getConfig"})) and keeps it locally, because the decision "intercept or not" has to be made immediately on every key press.

User interface texts

All texts the user sees come from src/_locales/<locale>/messages.json (English and German, default en):

  • manifest.json: name, description and button title as __MSG_key__.
  • Background script: badge text and button tooltip via i18n.getMessage().
  • Options page: static texts via data-i18n attributes and localizeDocument(), dynamic texts via i18n.getMessage().

The compose script shows no texts of its own; the marker comes from the user's template. Details: ../components/i18n.md.

DOM and markup

No file writes markup into a DOM sink (innerHTML, outerHTML =, insertAdjacentHTML, document.write). Elements are built with createElement, textContent and setAttribute. The editor still receives the HTML comment through execCommand("insertHTML"), with the HTML serialized from such a DOM node. See decision 0005.

Permissions

Permission Used for
compose read compose windows (identity, plain text), run the compose script
scripting register the compose script and inject it into open windows
storage settings (local), on/off state per window (session)
accountsRead name and address of the sender identity for the marker and for profiles

Packaging

npm run build checks formatting and runs the tests, then scripts/build.sh zips the contents of src/ into dist/inline-comment-<version>.xpi and adds LICENSE to the root of the XPI. The version in package.json, src/manifest.json and CHANGELOG.md must match (checked by test/manifest.test.js).

Further reading