Merge pull request '[v7.0/forgejo] Remove EasyMDE from various areas' (#3331) from bp-v7.0/forgejo-089e370-703aee4-f5c7cca into v7.0/forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3331
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
0ko 2024-04-19 14:25:39 +00:00
commit 59cfbf2070
4 changed files with 31 additions and 1 deletions

View file

@ -57,6 +57,7 @@
"TextareaPlaceholder" (ctx.Locale.Tr "repo.release.message")
"TextareaAriaLabel" (ctx.Locale.Tr "repo.release.message")
"DropzoneParentContainer" "form"
"EasyMDE" true
)}}
</div>
{{range .attachments}}

View file

@ -29,6 +29,7 @@
"TextareaPlaceholder" (ctx.Locale.Tr "repo.wiki.page_content")
"TextareaAriaLabel" (ctx.Locale.Tr "repo.wiki.page_content")
"TextareaContent" $content
"EasyMDE" true
)}}
<div class="field tw-mt-4">

View file

@ -10,6 +10,7 @@ Template Attributes:
* TextareaAriaLabel: aria-label attribute for the textarea
* DropzoneParentContainer: container for file upload (leave it empty if no upload)
* DisableAutosize: whether to disable automatic height resizing
* EasyMDE: whether to display button for switching to legacy editor
*/}}
<div {{if .ContainerId}}id="{{.ContainerId}}"{{end}} class="combo-markdown-editor {{.ContainerClasses}}" data-dropzone-parent-container="{{.DropzoneParentContainer}}">
{{if .MarkdownPreviewUrl}}
@ -41,7 +42,9 @@ Template Attributes:
</div>
<div class="markdown-toolbar-group">
<button class="markdown-toolbar-button markdown-switch-monospace" role="switch" data-enable-text="{{ctx.Locale.Tr "editor.buttons.enable_monospace_font"}}" data-disable-text="{{ctx.Locale.Tr "editor.buttons.disable_monospace_font"}}">{{svg "octicon-typography"}}</button>
<button class="markdown-toolbar-button markdown-switch-easymde" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.switch_to_legacy.tooltip"}}">{{svg "octicon-arrow-switch"}}</button>
{{if .EasyMDE}}
<button class="markdown-toolbar-button markdown-switch-easymde" data-tooltip-content="{{ctx.Locale.Tr "editor.buttons.switch_to_legacy.tooltip"}}">{{svg "octicon-arrow-switch"}}</button>
{{end}}
</div>
</markdown-toolbar>
<text-expander keys=": @" suffix="">

View file

@ -0,0 +1,25 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
import (
"net/http"
"testing"
)
func TestEasyMDESwitch(t *testing.T) {
session := loginUser(t, "user2")
testEasyMDESwitch(t, session, "user2/glob/issues/1", false)
testEasyMDESwitch(t, session, "user2/glob/issues/new", false)
testEasyMDESwitch(t, session, "user2/glob/wiki?action=_new", true)
testEasyMDESwitch(t, session, "user2/glob/releases/new", true)
}
func testEasyMDESwitch(t *testing.T, session *TestSession, url string, expected bool) {
t.Helper()
req := NewRequest(t, "GET", url)
resp := session.MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
doc.AssertElement(t, ".combo-markdown-editor button.markdown-switch-easymde", expected)
}