From f0f1737d4d533e06f482a63ff995ae79cc1c89dc Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Tue, 4 Mar 2025 03:49:15 +0800 Subject: [PATCH] Refactor markup and pdf-viewer to use new init framework (#33772) 1. Add some "render-content" classes to "markup" elements when the content is rendered 2. Use correct "markup" wrapper for "preview" (but not set that class on the tab) 3. Remove incorrect "markup" class from LFS file view, because there is no markup content * "edit-diff" is also removed because it does nothing 5. Use "initPdfViewer" for PDF viewer 6. Remove incorrect "content" class from milestone markup 7. Init all ".markup" elements by new init framework --------- Co-authored-by: wxiaoguang --- templates/org/home.tmpl | 2 +- templates/projects/list.tmpl | 4 +- templates/repo/editor/edit.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 | 4 +- templates/repo/view_file.tmpl | 2 +- templates/repo/wiki/view.tmpl | 8 +- templates/shared/combomarkdowneditor.tmpl | 2 +- templates/user/dashboard/feeds.tmpl | 2 +- templates/user/dashboard/milestones.tmpl | 6 +- templates/user/profile.tmpl | 2 +- web_src/css/editor/fileeditor.css | 9 -- web_src/css/markup/content.css | 2 +- web_src/css/shared/milestone.css | 2 +- web_src/js/features/repo-editor.ts | 4 +- 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 | 108 +++++++++--------- web_src/js/markup/tasklist.ts | 126 ++++++++++----------- web_src/js/modules/observer.ts | 3 + web_src/js/render/pdf.ts | 10 +- 29 files changed, 195 insertions(+), 227 deletions(-) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 826642db42c..cffdfabfaa9 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 5d40653dc67..48083811e76 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/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 577a2be9ad3..ae8a60c20c1 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -45,10 +45,10 @@ data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}
-
+
{{ctx.Locale.Tr "loading"}}
-
+
diff --git a/templates/repo/issue/fields/markdown.tmpl b/templates/repo/issue/fields/markdown.tmpl index da8f5e6bdf7..dbf4b71ba8a 100644 --- a/templates/repo/issue/fields/markdown.tmpl +++ b/templates/repo/issue/fields/markdown.tmpl @@ -1,3 +1,3 @@
-
{{ctx.RenderUtils.MarkdownToHtml .item.Attributes.value}}
+
{{ctx.RenderUtils.MarkdownToHtml .item.Attributes.value}}
diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index abb4e3290da..ac5d7f16ddd 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 e7dfe08ee05..5701c1faa60 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 041890ca9cd..88bd85ef4db 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 f6fac05b691..9f72d764ae9 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}} @@ -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 4907d87301f..9f1b2a5e8f4 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/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl index 843a977e3e5..efb614280a5 100644 --- a/templates/repo/wiki/view.tmpl +++ b/templates/repo/wiki/view.tmpl @@ -63,18 +63,18 @@
{{if .sidebarTocContent}} -