From 84389a7b55510d5d95846f1011654df2b4579a3e Mon Sep 17 00:00:00 2001
From: Kerwin Bryant
Date: Mon, 3 Mar 2025 06:49:15 +0000
Subject: [PATCH 1/4] Refactor initPdfViewer using the new
registerGlobalInitFunc
---
templates/repo/settings/lfs_file.tmpl | 2 +-
templates/repo/view_file.tmpl | 2 +-
web_src/js/render/pdf.ts | 10 ++++------
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl
index f6fac05b69141..b889479e5b23f 100644
--- a/templates/repo/settings/lfs_file.tmpl
+++ b/templates/repo/settings/lfs_file.tmpl
@@ -31,7 +31,7 @@
{{ctx.Locale.Tr "repo.audio_not_supported_in_browser"}}
{{else if .IsPDFFile}}
-
+
{{else}}
{{ctx.Locale.Tr "repo.file_view_raw"}}
{{end}}
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl
index 4907d87301f57..9f1b2a5e8f402 100644
--- a/templates/repo/view_file.tmpl
+++ b/templates/repo/view_file.tmpl
@@ -108,7 +108,7 @@
{{ctx.Locale.Tr "repo.audio_not_supported_in_browser"}}
{{else if .IsPDFFile}}
-
+
{{else}}
{{ctx.Locale.Tr "repo.file_view_raw"}}
{{end}}
diff --git a/web_src/js/render/pdf.ts b/web_src/js/render/pdf.ts
index f31f161e6e8e2..283b4ed85c933 100644
--- a/web_src/js/render/pdf.ts
+++ b/web_src/js/render/pdf.ts
@@ -1,12 +1,10 @@
import {htmlEscape} from 'escape-goat';
+import {registerGlobalInitFunc} from '../modules/observer.ts';
export async function initPdfViewer() {
- const els = document.querySelectorAll('.pdf-content');
- if (!els.length) return;
+ registerGlobalInitFunc('initPdfViewer', async (el: HTMLInputElement) => {
+ const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
- const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
-
- for (const el of els) {
const src = el.getAttribute('data-src');
const fallbackText = el.getAttribute('data-fallback-button-text');
pdfobject.embed(src, el, {
@@ -15,5 +13,5 @@ export async function initPdfViewer() {
`,
});
el.classList.remove('is-loading');
- }
+ });
}
From c5fe61cd26f3c5ce116dac64bcf75630efdcb813 Mon Sep 17 00:00:00 2001
From: wxiaoguang
Date: Mon, 3 Mar 2025 17:09:41 +0800
Subject: [PATCH 2/4] refactor markup init
---
templates/org/home.tmpl | 2 +-
templates/projects/list.tmpl | 4 +-
templates/repo/issue/fields/markdown.tmpl | 2 +-
templates/repo/issue/milestone_issues.tmpl | 2 +-
templates/repo/issue/milestones.tmpl | 4 +-
templates/repo/release/list.tmpl | 2 +-
templates/repo/settings/lfs_file.tmpl | 2 +-
templates/repo/wiki/view.tmpl | 8 +-
templates/user/dashboard/feeds.tmpl | 2 +-
templates/user/dashboard/milestones.tmpl | 6 +-
templates/user/profile.tmpl | 2 +-
web_src/css/markup/content.css | 2 +-
web_src/css/shared/milestone.css | 2 +-
web_src/js/features/repo-editor.ts | 2 -
web_src/js/features/repo-issue-edit.ts | 3 -
web_src/js/features/repo-wiki.ts | 4 +-
web_src/js/index.ts | 3 +-
web_src/js/markup/asciicast.ts | 18 ++-
web_src/js/markup/codecopy.ts | 17 ++-
web_src/js/markup/content.ts | 25 ++--
web_src/js/markup/math.ts | 42 ++++---
web_src/js/markup/mermaid.ts | 126 ++++++++++-----------
web_src/js/markup/tasklist.ts | 124 ++++++++++----------
23 files changed, 190 insertions(+), 214 deletions(-)
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index 826642db42c93..cffdfabfaa9ab 100644
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -6,7 +6,7 @@
{{if .ProfileReadmeContent}}
-
{{.ProfileReadmeContent}}
+
{{.ProfileReadmeContent}}
{{end}}
{{template "shared/repo_search" .}}
{{template "explore/repo_list" .}}
diff --git a/templates/projects/list.tmpl b/templates/projects/list.tmpl
index 5d40653dc672c..48083811e762e 100644
--- a/templates/projects/list.tmpl
+++ b/templates/projects/list.tmpl
@@ -74,9 +74,7 @@
{{end}}
{{if .Description}}
-
- {{.RenderedContent}}
-
+
{{.RenderedContent}}
{{end}}
{{end}}
diff --git a/templates/repo/issue/fields/markdown.tmpl b/templates/repo/issue/fields/markdown.tmpl
index da8f5e6bdf7c1..dbf4b71ba8abd 100644
--- a/templates/repo/issue/fields/markdown.tmpl
+++ b/templates/repo/issue/fields/markdown.tmpl
@@ -1,3 +1,3 @@
diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl
index abb4e3290da24..ac5d7f16ddd8e 100644
--- a/templates/repo/issue/milestone_issues.tmpl
+++ b/templates/repo/issue/milestone_issues.tmpl
@@ -22,7 +22,7 @@
{{end}}
{{if .Milestone.RenderedContent}}
-
+
{{.Milestone.RenderedContent}}
{{end}}
diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl
index e7dfe08ee0592..5701c1faa60f0 100644
--- a/templates/repo/issue/milestones.tmpl
+++ b/templates/repo/issue/milestones.tmpl
@@ -81,9 +81,7 @@
{{end}}
{{if .Content}}
-
- {{.RenderedContent}}
-
+ {{.RenderedContent}}
{{end}}
{{end}}
diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl
index 041890ca9cd41..88bd85ef4db8e 100644
--- a/templates/repo/release/list.tmpl
+++ b/templates/repo/release/list.tmpl
@@ -64,7 +64,7 @@
| {{ctx.Locale.Tr "repo.release.ahead.commits" $release.NumCommitsBehind}} {{ctx.Locale.Tr "repo.release.ahead.target" $release.TargetBehind}}
{{end}}
-
+
{{$release.RenderedNote}}
diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl
index b889479e5b23f..9f72d764ae9d2 100644
--- a/templates/repo/settings/lfs_file.tmpl
+++ b/templates/repo/settings/lfs_file.tmpl
@@ -13,7 +13,7 @@
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
-
+
{{if .IsFileTooLarge}}
{{template "shared/filetoolarge" dict "RawFileLink" .RawFileLink}}
{{else if not .FileSize}}
diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl
index 843a977e3e57c..efb614280a567 100644
--- a/templates/repo/wiki/view.tmpl
+++ b/templates/repo/wiki/view.tmpl
@@ -63,18 +63,18 @@
{{if .sidebarTocContent}}
-