From 64adc527a6117e34e9b9bb42769eb49a1295336a Mon Sep 17 00:00:00 2001 From: Baivab Sarkar Date: Sun, 31 May 2026 23:55:02 +0530 Subject: [PATCH 1/3] fix: resolve welcome template first-run missing and new tab button duplication --- desktop-app/resources/js/script.js | 27 +++++++++++++++------------ script.js | 27 +++++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/desktop-app/resources/js/script.js b/desktop-app/resources/js/script.js index 3ef4f3db..16512ef1 100644 --- a/desktop-app/resources/js/script.js +++ b/desktop-app/resources/js/script.js @@ -1139,18 +1139,21 @@ document.addEventListener("DOMContentLoaded", function () { }; // "+ Create" button at end of tab list (placed outside tabList to prevent ARIA child violation) - const newBtn = document.createElement('button'); - newBtn.className = 'tab-new-btn'; - newBtn.title = 'New Tab (Ctrl+T)'; - newBtn.setAttribute('aria-label', 'Open new tab'); - newBtn.innerHTML = ''; - newBtn.addEventListener('click', function() { newTab(); }); - - const resetBtn = document.getElementById('tab-reset-btn'); - if (resetBtn) { - tabList.parentElement.insertBefore(newBtn, resetBtn); - } else { - tabList.parentElement.appendChild(newBtn); + let newBtn = tabList.parentElement.querySelector('.tab-new-btn'); + if (!newBtn) { + newBtn = document.createElement('button'); + newBtn.className = 'tab-new-btn'; + newBtn.title = 'New Tab (Ctrl+T)'; + newBtn.setAttribute('aria-label', 'Open new tab'); + newBtn.innerHTML = ''; + newBtn.addEventListener('click', function() { newTab(); }); + + const resetBtn = document.getElementById('tab-reset-btn'); + if (resetBtn) { + tabList.parentElement.insertBefore(newBtn, resetBtn); + } else { + tabList.parentElement.appendChild(newBtn); + } } // Auto-scroll active tab into view (paint-aligned to prevent forced reflows) diff --git a/script.js b/script.js index 3ef4f3db..16512ef1 100644 --- a/script.js +++ b/script.js @@ -1139,18 +1139,21 @@ document.addEventListener("DOMContentLoaded", function () { }; // "+ Create" button at end of tab list (placed outside tabList to prevent ARIA child violation) - const newBtn = document.createElement('button'); - newBtn.className = 'tab-new-btn'; - newBtn.title = 'New Tab (Ctrl+T)'; - newBtn.setAttribute('aria-label', 'Open new tab'); - newBtn.innerHTML = ''; - newBtn.addEventListener('click', function() { newTab(); }); - - const resetBtn = document.getElementById('tab-reset-btn'); - if (resetBtn) { - tabList.parentElement.insertBefore(newBtn, resetBtn); - } else { - tabList.parentElement.appendChild(newBtn); + let newBtn = tabList.parentElement.querySelector('.tab-new-btn'); + if (!newBtn) { + newBtn = document.createElement('button'); + newBtn.className = 'tab-new-btn'; + newBtn.title = 'New Tab (Ctrl+T)'; + newBtn.setAttribute('aria-label', 'Open new tab'); + newBtn.innerHTML = ''; + newBtn.addEventListener('click', function() { newTab(); }); + + const resetBtn = document.getElementById('tab-reset-btn'); + if (resetBtn) { + tabList.parentElement.insertBefore(newBtn, resetBtn); + } else { + tabList.parentElement.appendChild(newBtn); + } } // Auto-scroll active tab into view (paint-aligned to prevent forced reflows) From fb90e50442c00214f0b9a1d184969af65856a567 Mon Sep 17 00:00:00 2001 From: Baivab Sarkar Date: Mon, 1 Jun 2026 00:05:06 +0530 Subject: [PATCH 2/3] fix: resolve empty welcome template issue via template content textContent access --- desktop-app/resources/js/script.js | 2 +- script.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop-app/resources/js/script.js b/desktop-app/resources/js/script.js index 16512ef1..9fa51660 100644 --- a/desktop-app/resources/js/script.js +++ b/desktop-app/resources/js/script.js @@ -866,7 +866,7 @@ document.addEventListener("DOMContentLoaded", function () { // PERF-012: Inlined default template to eliminate network request, FOUC, and layout shifts const defaultMarkdownTemplate = document.getElementById('default-markdown'); - const sampleMarkdown = defaultMarkdownTemplate ? defaultMarkdownTemplate.textContent.trim() : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; + const sampleMarkdown = defaultMarkdownTemplate && defaultMarkdownTemplate.content ? defaultMarkdownTemplate.content.textContent.trim() : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; if (!markdownEditor.value) { markdownEditor.value = sampleMarkdown; diff --git a/script.js b/script.js index 16512ef1..9fa51660 100644 --- a/script.js +++ b/script.js @@ -866,7 +866,7 @@ document.addEventListener("DOMContentLoaded", function () { // PERF-012: Inlined default template to eliminate network request, FOUC, and layout shifts const defaultMarkdownTemplate = document.getElementById('default-markdown'); - const sampleMarkdown = defaultMarkdownTemplate ? defaultMarkdownTemplate.textContent.trim() : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; + const sampleMarkdown = defaultMarkdownTemplate && defaultMarkdownTemplate.content ? defaultMarkdownTemplate.content.textContent.trim() : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; if (!markdownEditor.value) { markdownEditor.value = sampleMarkdown; From fca498fd49acc133ea38da76051967c0f9633608 Mon Sep 17 00:00:00 2001 From: Baivab Sarkar Date: Mon, 1 Jun 2026 00:20:38 +0530 Subject: [PATCH 3/3] fix: use script text/markdown tag to preserve raw HTML tags inside default markdown content --- desktop-app/resources/index.html | 4 ++-- desktop-app/resources/js/script.js | 2 +- index.html | 4 ++-- script.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/desktop-app/resources/index.html b/desktop-app/resources/index.html index e2d2ee0a..b02882ed 100644 --- a/desktop-app/resources/index.html +++ b/desktop-app/resources/index.html @@ -854,7 +854,7 @@ -