aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-12-04 17:26:54 +0800
committerGitHub <noreply@github.com>2024-12-04 09:26:54 +0000
commit838653d1dfa0fbc6313b0bba682075baba385a5e (patch)
tree0da92e8ff2ad447ed4a386dc5cbe61c47b8e8841 /templates/repo
parente45ffc530f482a46de25d28f18b039f296750414 (diff)
downloadgitea-838653d1dfa0fbc6313b0bba682075baba385a5e.tar.gz
gitea-838653d1dfa0fbc6313b0bba682075baba385a5e.zip
Fix file editor & preview (#32706)
Fix a regression caused by jQuery removal (`renderPreviewPanelContent`) And simplify the file editor, it doesn't need to be that complex. And remove jQuery code.
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/editor/edit.tmpl28
-rw-r--r--templates/repo/editor/patch.tmpl25
2 files changed, 9 insertions, 44 deletions
diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl
index c556826827..204a426970 100644
--- a/templates/repo/editor/edit.tmpl
+++ b/templates/repo/editor/edit.tmpl
@@ -3,7 +3,10 @@
{{template "repo/header" .}}
<div class="ui container">
{{template "base/alert" .}}
- <form class="ui edit form" method="post">
+ <form class="ui edit form" method="post"
+ data-text-empty-confirm-header="{{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}"
+ data-text-empty-confirm-content="{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}"
+ >
{{.CsrfTokenHtml}}
<input type="hidden" name="last_commit" value="{{.last_commit}}">
<input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}">
@@ -29,7 +32,7 @@
<div class="ui top attached header">
<div class="ui compact small menu small-menu-items repo-editor-menu">
<a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a>
- <a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-markup-mode="file">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
+ <a class="item" data-tab="preview" data-preview-url="{{.Repository.Link}}/markup" data-preview-context-ref="{{.RepoLink}}/src/{{.BranchNameSubURL}}">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
{{if not .IsNewFile}}
<a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a>
{{end}}
@@ -38,8 +41,6 @@
<div class="ui bottom attached segment tw-p-0">
<div class="ui active tab tw-rounded-b" data-tab="write">
<textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-{{.TreePath}}"
- data-url="{{.Repository.Link}}/markup"
- data-context="{{.RepoLink}}"
data-previewable-extensions="{{.PreviewableExtensions}}"
data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea>
<div class="editor-loading is-loading"></div>
@@ -55,24 +56,5 @@
{{template "repo/editor/commit_form" .}}
</form>
</div>
- <div class="ui g-modal-confirm modal" id="edit-empty-content-modal">
- <div class="header">
- {{svg "octicon-file"}}
- {{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}
- </div>
- <div class="center content">
- <p>{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}</p>
- </div>
- <div class="actions">
- <button class="ui cancel button">
- {{svg "octicon-x"}}
- {{ctx.Locale.Tr "repo.editor.cancel"}}
- </button>
- <button class="ui primary ok button">
- {{svg "fontawesome-save"}}
- {{ctx.Locale.Tr "repo.editor.commit_changes"}}
- </button>
- </div>
- </div>
</div>
{{template "base/footer" .}}
diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl
index a29021fa47..33a7c2a89d 100644
--- a/templates/repo/editor/patch.tmpl
+++ b/templates/repo/editor/patch.tmpl
@@ -3,7 +3,10 @@
{{template "repo/header" .}}
<div class="ui container">
{{template "base/alert" .}}
- <form class="ui edit form" method="post" action="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}">
+ <form class="ui edit form" method="post" action="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}"
+ data-text-empty-confirm-header="{{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}"
+ data-text-empty-confirm-content="{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}"
+ >
{{.CsrfTokenHtml}}
<input type="hidden" name="last_commit" value="{{.last_commit}}">
<input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}">
@@ -33,25 +36,5 @@
{{template "repo/editor/commit_form" .}}
</form>
</div>
-
- <div class="ui g-modal-confirm modal" id="edit-empty-content-modal">
- <div class="header">
- {{svg "octicon-file"}}
- {{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}}
- </div>
- <div class="center content">
- <p>{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}</p>
- </div>
- <div class="actions">
- <button class="ui cancel button">
- {{svg "octicon-x"}}
- {{ctx.Locale.Tr "repo.editor.cancel"}}
- </button>
- <button class="ui primary ok button">
- {{svg "fontawesome-save"}}
- {{ctx.Locale.Tr "repo.editor.commit_changes"}}
- </button>
- </div>
- </div>
</div>
{{template "base/footer" .}}