File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -866,7 +866,15 @@ document.addEventListener("DOMContentLoaded", function () {
866866
867867 // PERF-012: Inlined default template to eliminate network request, FOUC, and layout shifts
868868 const defaultMarkdownTemplate = document . getElementById ( 'default-markdown' ) ;
869- const sampleMarkdown = defaultMarkdownTemplate ? defaultMarkdownTemplate . textContent . trim ( ) : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...' ;
869+ let templateText = '' ;
870+ if ( defaultMarkdownTemplate ) {
871+ if ( defaultMarkdownTemplate . content && typeof defaultMarkdownTemplate . content . textContent === 'string' ) {
872+ templateText = defaultMarkdownTemplate . content . textContent . trim ( ) ;
873+ } else {
874+ templateText = defaultMarkdownTemplate . textContent ? defaultMarkdownTemplate . textContent . trim ( ) : '' ;
875+ }
876+ }
877+ const sampleMarkdown = templateText || '# Welcome to Markdown Viewer\n\nStart typing your markdown here...' ;
870878
871879 if ( ! markdownEditor . value ) {
872880 markdownEditor . value = sampleMarkdown ;
Original file line number Diff line number Diff line change @@ -866,7 +866,15 @@ document.addEventListener("DOMContentLoaded", function () {
866866
867867 // PERF-012: Inlined default template to eliminate network request, FOUC, and layout shifts
868868 const defaultMarkdownTemplate = document . getElementById ( 'default-markdown' ) ;
869- const sampleMarkdown = defaultMarkdownTemplate ? defaultMarkdownTemplate . textContent . trim ( ) : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...' ;
869+ let templateText = '' ;
870+ if ( defaultMarkdownTemplate ) {
871+ if ( defaultMarkdownTemplate . content && typeof defaultMarkdownTemplate . content . textContent === 'string' ) {
872+ templateText = defaultMarkdownTemplate . content . textContent . trim ( ) ;
873+ } else {
874+ templateText = defaultMarkdownTemplate . textContent ? defaultMarkdownTemplate . textContent . trim ( ) : '' ;
875+ }
876+ }
877+ const sampleMarkdown = templateText || '# Welcome to Markdown Viewer\n\nStart typing your markdown here...' ;
870878
871879 if ( ! markdownEditor . value ) {
872880 markdownEditor . value = sampleMarkdown ;
You can’t perform that action at this time.
0 commit comments