diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go
--- a/appview/pages/funcmap.go
+++ b/appview/pages/funcmap.go
@@ -18,6 +18,7 @@
"reflect"
"strings"
"time"
+ "unicode/utf8"
"github.com/alecthomas/chroma/v2"
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
@@ -332,6 +333,12 @@
},
"nl2br": func(text string) template.HTML {
return template.HTML(strings.ReplaceAll(template.HTMLEscapeString(text), "\n", "
"))
+ },
+ "isLongBody": func(text string) bool {
+ return utf8.RuneCountInString(text) > 800 ||
+ len(strings.Split(text, "\n\n")) > 4 ||
+ strings.Contains(text, "```") ||
+ strings.Contains(text, "![")
},
"unwrapText": func(text string) string {
paragraphs := strings.Split(text, "\n\n")
diff --git a/appview/pages/templates/fragments/comment/commentBody.html b/appview/pages/templates/fragments/comment/commentBody.html
--- a/appview/pages/templates/fragments/comment/commentBody.html
+++ b/appview/pages/templates/fragments/comment/commentBody.html
@@ -6,7 +6,7 @@
(dict "Reactions" .Reactions
"UserReacted" .UserReacted
"ThreadAt" .Comment.FeedCommentAtUri
- "HideIfEmpty" true) }}
+ "ShowPicker" (isLongBody .Comment.Body.Text)) }}
{{ else }}
[deleted by author]
{{ end }}
diff --git a/appview/pages/templates/repo/fragments/reaction.html b/appview/pages/templates/repo/fragments/reaction.html
--- a/appview/pages/templates/repo/fragments/reaction.html
+++ b/appview/pages/templates/repo/fragments/reaction.html
@@ -1,6 +1,6 @@
{{ define "repo/fragments/reaction" }}