3 Commits

Author SHA1 Message Date
Kendrick Bollens
8057870f8b Release v2.6.0 — updates.json (Auto-Update-Manifest)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XcAzPQhKgwS4HNzvXEFeN
2026-07-22 18:34:43 +02:00
Kendrick Bollens
2b6e2267c2 Vorlage beim Durchswitchen ersetzen statt stapeln (v2.6.0)
HTML-Vorlagen werden jetzt in <div id="hps-vorlage"> gewickelt und
direkt im Editor-DOM eingefügt. Vor dem Einfügen wird ein evtl. schon
vorhandener hps-vorlage-Block entfernt — so ersetzt Durchswitchen die
Vorlage statt sie oben draufzustapeln. insertText bleibt als Fallback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XcAzPQhKgwS4HNzvXEFeN
2026-07-22 18:34:26 +02:00
Kendrick Bollens
169fc68f18 Release v2.5.0 — updates.json (Auto-Update-Manifest)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015PZHd9vRsBiH8cKYdQo1Yv
2026-07-22 15:23:04 +02:00
4 changed files with 54 additions and 15 deletions

View File

@@ -276,31 +276,50 @@ async function handleInsertTemplate(msg) {
const newBody = msg.text + (old ? '\n' + old : '');
await browser.compose.setComposeDetails(tab.id, { plainTextBody: newBody });
} else {
// HTML mode: use insertText API to go through the editor's rendering pipeline
// HTML mode: wrap the template in a marker element (id=hps-vorlage) and
// replace any previously inserted one — so durchswitchen ersetzt statt stapelt.
const htmlContent = isHtmlTemplate ? msg.text : msg.text.replace(/\n/g, '<br>');
// Move cursor to beginning of body first via script injection
await browser.tabs.executeScript(tab.id, {
// Directly manipulate the editor DOM: remove the old template block (if any),
// then insert the new one at the top of the body. Returns true on success.
const injected = await browser.tabs.executeScript(tab.id, {
code: `
(function () {
const editor = document.getElementById('messageEditor');
const editorDoc = editor ? editor.contentDocument : document;
const body = editorDoc.body;
if (body) {
const body = editorDoc && editorDoc.body;
if (!body) return false;
// Remove a previously inserted template block, so switching replaces it
const prev = editorDoc.getElementById('hps-vorlage');
if (prev) prev.remove();
// Wrap the new template in a marker element with a stable id
const wrapper = editorDoc.createElement('div');
wrapper.id = 'hps-vorlage';
wrapper.innerHTML = ${JSON.stringify(htmlContent)};
// Insert at the very top of the body (above quote/signature/typed text)
body.insertBefore(wrapper, body.firstChild);
// Place the cursor right after the inserted block
const range = editorDoc.createRange();
range.setStart(body, 0);
range.setStartAfter(wrapper);
range.collapse(true);
const sel = editorDoc.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
return true;
})();
`
}).catch(() => {
// Fallback: some TB versions structure the editor differently
});
}).then(r => (Array.isArray(r) ? r[0] : r)).catch(() => false);
// Insert HTML at cursor position - this goes through the editor's render pipeline
if (!injected) {
// Fallback: editor DOM not reachable (TB version differences) — use the
// insertText pipeline. Note: this variant cannot replace, only prepend.
await browser.compose.insertText(tab.id, htmlContent + '<br>', { insertAsText: false });
}
}
} catch (e) {
console.error('background.js error:', e);

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "HPS Vorlagen & Signaturen",
"version": "2.5.0",
"version": "2.6.0",
"description": "Vorlagen- und Signaturverwaltung für Hotel Park Soltau mit Git-Sync",
"browser_specific_settings": {
"gecko": {

Binary file not shown.

View File

@@ -2,6 +2,26 @@
"addons": {
"it@hotel-park-soltau.de": {
"updates": [
{
"version": "2.6.0",
"update_link": "https://git.hotel-park-soltau.de/hps/hps-thunderbird-templates/releases/download/v2.6.0/templates-reply-hotel.xpi",
"update_hash": "sha256:563e65f7686db7be30712fbc2be934f51c9ce8f4d35bb37f07046d8da40b562d",
"applications": {
"gecko": {
"strict_min_version": "109.0"
}
}
},
{
"version": "2.5.0",
"update_link": "https://git.hotel-park-soltau.de/hps/hps-thunderbird-templates/releases/download/v2.5.0/templates-reply-hotel.xpi",
"update_hash": "sha256:97f9006a88d565e6ec524841687b851c4f2f8f02b313b2effd5b05b68e141599",
"applications": {
"gecko": {
"strict_min_version": "109.0"
}
}
},
{
"version": "2.3.6",
"update_link": "https://git.hotel-park-soltau.de/hps/hps-thunderbird-templates/releases/download/v2.3.6/templates-reply-hotel.xpi",