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)
This commit is contained in:
Oliver_Herb committed 2026-11-24 12:07:09 +01:00
commit 9053327486
57 files changed
+9849

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
# 0001 – Manifest V3 with scripting.compose
**Date:** 2026-11-24 · **Status:** accepted
## Context
Thunderbird supports MailExtensions with Manifest V2 and V3. Thunderbird 128 is the first ESR release
with full Manifest V3 support; in Manifest V3, compose scripts are registered through
`scripting.compose`. The add-on is developed and tested with Betterbird 153, which is considerably
newer.
## Decision
Manifest V3 with a minimum version of 128 (`strict_min_version`). Compose scripts are registered with
`scripting.compose.registerScripts` (replaces `composeScripts` from V2), and the background script is
an event page.
## Consequences
- The background script can be stopped at any time: state lives in `storage.session` (an in-memory
map only as a fallback when `storage.session` is missing), listeners are registered at the top
level.
- Registered scripts only apply to new compose windows; windows that are already open get the
script through `scripting.executeScript` after install or update.
- No execution of JavaScript strings, only files.
- Thunderbird versions before 128 are not supported.
@@ -0,0 +1,27 @@
# 0002 – Let the editor split the quote, manual split only as fallback
**Date:** 2026-11-24 · **Status:** accepted, to be confirmed by the manual test
## Context
The original concept was to split the `<blockquote>` directly in the DOM. Direct DOM changes bypass
the editor: Ctrl+Z then does not work reliably, and nested quotes have to be handled by hand. The
Thunderbird mail editor, however, already splits quotes itself when Enter is pressed inside a quote,
right up to the outermost quote.
## Decision
Default (`splitMode = "native"`): trigger `execCommand("insertParagraph")`, which is the same action
as Enter. If the caret is outside every quote afterwards, the comment is inserted with `insertHTML`
(HTML messages) or `insertText` (plain-text messages). Both steps end up in the undo history.
If the editor does not split the quote, `insertParagraph` is reverted with `undo` and the manual
split (`splitCiteAtRange`) is used instead. The manual split can also be selected permanently in the
settings ("Advanced" → "Split the quote" → "by the add-on").
## Consequences
- Ctrl+Z may need two steps (comment, then split).
- Whether `insertParagraph` via `execCommand` splits the quote exactly like the Enter key can only be
verified in the real editor. The automatic fallback keeps the add-on working if it does not.
- The manual split is not part of the editor's undo history.
@@ -0,0 +1,24 @@
# 0003 – keydown as trigger, beforeinput as fallback
**Date:** 2026-11-24 · **Status:** accepted
## Context
The quote should only be split on actual text input, not on clicking or selecting. Candidates are
`keydown` and `beforeinput`. During `beforeinput` an editor action is already running; further
`execCommand` calls inside it are not reliable in Gecko.
## Decision
- `keydown`: printable keys without Ctrl/Alt/Cmd (AltGr allowed, so that `@`, `€`, `{` work).
Intercept, then split and insert immediately.
- `beforeinput` with `inputType = "insertText"`: only for input without a matching key press
(on-screen keyboard, emoji picker). Intercept and insert in the next task; characters arriving in
between are collected in `pendingText`.
## Consequences
- Shortcuts such as Ctrl+C and Ctrl+A, named keys such as the arrow keys, Delete, Backspace and
Enter, and clicks never start a comment; the editor handles them as usual.
- Dead keys (`^`, `´`) deliver the finished character with the second key press; IME input
(`compositionstart`) is not handled.
+59
View File
@@ -0,0 +1,59 @@
# 0004 – Licence: Mozilla Public License 2.0
**Date:** 2026-11-24 · **Status:** accepted
## Context
The repository is published publicly, and the add-on is meant to be listed on addons.thunderbird.net
(ATN). The licence should:
- keep the author's attribution in copies, forks and reused files,
- make sure that improvements to the add-on's own files stay open, without restricting what the
add-on may be combined with,
- be easy to select on ATN and familiar to Thunderbird reviewers and contributors.
## Decision
All source files are licensed under the Mozilla Public License 2.0 (MPL-2.0).
- **Attribution through per-file notices.** Every source file starts with a notice: copyright line,
`SPDX-License-Identifier: MPL-2.0` and the text of MPL Exhibit A. Under §3.4 of the MPL, recipients
may not remove or alter the substance of licence notices, including copyright notices, in the
Source Code Form. Because the notice sits in each file, the attribution travels with every file,
even when single files are copied into another project.
- **File-level copyleft.** Modified versions of covered files must stay under MPL-2.0, and their
source must be available when they are distributed, also as part of an executable form such as an
XPI (§3.1, §3.2). New files in a larger work may use any licence (§3.3), so the add-on can be
combined with code under other licences.
- **Built-in licence on ATN.** MPL-2.0 is one of the licences offered by the ATN listing form, so no
custom licence text has to be maintained there.
- **Common for Thunderbird add-ons.** Thunderbird itself is licensed under MPL-2.0, and many add-ons
use it; reviewers and contributors know its terms.
- In addition, MPL-2.0 contains an explicit patent licence from contributors (§2.1) and, without
Exhibit B in the headers, stays compatible with the GPL and LGPL as "Secondary Licenses" (§3.3).
## Alternatives considered
- **MIT:** short, very permissive and widely known. But there is no copyleft, so modified versions may
be distributed without source, and the attribution lives in a single licence text that is easily
lost when individual files are copied.
- **Apache-2.0:** permissive, with an explicit patent licence and a NOTICE file for attribution. But
there is no copyleft either, and the NOTICE and change-notice handling adds process without keeping
changes to the add-on's own files open.
- **CPAL-1.0:** strong attribution, since the attribution notice has to be shown in the user
interface. But it is rarely used and less familiar to reviewers, it is not a built-in choice on
ATN, it is incompatible with the GPL, and the user interface attribution clause is awkward for an
add-on that lives in the compose window.
## Consequences
- `LICENSE` with the full MPL-2.0 text lies in the repository root and in the root of every XPI
(`scripts/build.sh`).
- Every `.js` and `.css` file starts with the licence header as a block comment (after a shebang, if
any); HTML and SVG files carry it as `<!-- … -->` (HTML directly after `<!doctype html>`), shell
scripts as `# ` lines. JSON files have no header, because JSON has no comments.
- `package.json` declares `"license": "MPL-2.0"`.
- `test/license.test.js` checks the licence text, the header in every source, test and script file,
the package metadata and that `scripts/build.sh` adds `LICENSE` to the XPI.
- New files get the same header. Third-party code may only be added if its licence is compatible, and
it keeps its own notices.
+53
View File
@@ -0,0 +1,53 @@
# 0005 – No markup sinks: build DOM with DOM APIs
**Date:** 2026-11-24 · **Status:** accepted
## Context
Version 0.1.0 assembled the comment block as an HTML string with hand-written escaping and wrote it
into the DOM with `innerHTML` for the manual split and the options page preview. Reviewers on
addons.thunderbird.net (ATN) reject add-ons that create DOM nodes from HTML strings that may contain
unsanitized data, i.e. code that writes markup into DOM sinks: assignments to `innerHTML` or
`outerHTML`, `insertAdjacentHTML` and `document.write`. Such sinks are also the usual way for
untrusted text to turn into markup; here the marker template, the identity name and translated
messages all end up in the page.
At the same time, the comment must reach the mail editor through `execCommand("insertHTML")`: only
editor commands end up in the undo history, so Ctrl+Z keeps working (see
[decision 0002](./0002-split-quote-via-editor.md)).
## Decision
- **DOM APIs only.** Elements are built with `createElement`, `createTextNode`, `textContent`,
`setAttribute`, `append`, `replaceChildren` and `new Option()`. User data and messages are always
set as text, never parsed as markup.
- **Comment block:** `createCommentNode()` in `src/lib/marker.js` builds the `<div>` with the marker
`<span>` and the first text as a DOM node. The options page preview and the manual split insert
this node directly.
- **`insertHTML` stays for undo.** In the editor, the compose script serializes the same node with
`outerHTML` (reading only) and passes the string to `execCommand("insertHTML", …)`. The HTML is
therefore generated from DOM nodes, never assembled by hand, and text such as `<b>` in a marker
template arrives as escaped text.
- **Translations** are applied with `textContent` and `setAttribute` (`localizeDocument()`). Because
`textContent` replaces the whole content, elements with `data-i18n` must contain text only.
- **Guarded by a test:** `test/dom-sinks.test.js` scans every file in `src/` and fails on
`innerHTML`, `outerHTML` assignments, `insertAdjacentHTML` and `document.write`. Reading
`outerHTML` is allowed.
## Alternatives considered
- **Insert the node with DOM methods (such as `insertBefore()`) in the editor as well:** no markup
string at all, but the change bypasses the editor and Ctrl+Z no longer undoes it. Kept only for
the manual split.
- **`execCommand("insertText")` plus formatting commands:** no undo problem, but colours, bold and
data attributes would need several commands and are hard to control. Used only for plain-text
messages.
- **Keep escaping HTML strings by hand (as in 0.1.0) or sanitize them:** still writes into a markup
sink and would not pass the review rule; every new string is another chance to forget the escaping.
## Consequences
- New UI code must use DOM APIs; `npm test` fails otherwise.
- Elements with `data-i18n` must not contain child elements (checked by `test/i18n.test.js`).
- The preview in the options page and the comment in the editor are built by the same function and
look the same.