diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index 425cc2c87..81104a70d 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -57,6 +57,7 @@ "TextareaPlaceholder" (ctx.Locale.Tr "repo.release.message") "TextareaAriaLabel" (ctx.Locale.Tr "repo.release.message") "DropzoneParentContainer" "form" + "EasyMDE" true )}} {{range .attachments}} diff --git a/templates/repo/wiki/new.tmpl b/templates/repo/wiki/new.tmpl index 2f51a5fe2..81433db00 100644 --- a/templates/repo/wiki/new.tmpl +++ b/templates/repo/wiki/new.tmpl @@ -29,6 +29,7 @@ "TextareaPlaceholder" (ctx.Locale.Tr "repo.wiki.page_content") "TextareaAriaLabel" (ctx.Locale.Tr "repo.wiki.page_content") "TextareaContent" $content + "EasyMDE" true )}}
diff --git a/templates/shared/combomarkdowneditor.tmpl b/templates/shared/combomarkdowneditor.tmpl index f4d51f510..fb11a75be 100644 --- a/templates/shared/combomarkdowneditor.tmpl +++ b/templates/shared/combomarkdowneditor.tmpl @@ -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 */}}
{{if .MarkdownPreviewUrl}} @@ -41,7 +42,9 @@ Template Attributes:
- + {{if .EasyMDE}} + + {{end}}
diff --git a/tests/integration/easymde_test.go b/tests/integration/easymde_test.go new file mode 100644 index 000000000..c8203d36b --- /dev/null +++ b/tests/integration/easymde_test.go @@ -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) +}