feat: Add partial quoting
- If you select a portion of the comment, `Quote reply` will not only quote that portion and not copy paste the whole text as it previously did. This is achieved by using the `@github/quote-selection` package. - There's preprocessing to ensure Forgejo-flavored markdown syntax is preserved. - e2e test added. - Resolves #1342
This commit is contained in:
parent
8b7410f35c
commit
2c2ac80030
21 changed files with 303 additions and 68 deletions
|
@ -472,7 +472,7 @@ func createInlineCode(content string) *html.Node {
|
|||
return code
|
||||
}
|
||||
|
||||
func createEmoji(content, class, name string) *html.Node {
|
||||
func createEmoji(content, class, name, alias string) *html.Node {
|
||||
span := &html.Node{
|
||||
Type: html.ElementNode,
|
||||
Data: atom.Span.String(),
|
||||
|
@ -484,6 +484,9 @@ func createEmoji(content, class, name string) *html.Node {
|
|||
if name != "" {
|
||||
span.Attr = append(span.Attr, html.Attribute{Key: "aria-label", Val: name})
|
||||
}
|
||||
if alias != "" {
|
||||
span.Attr = append(span.Attr, html.Attribute{Key: "data-alias", Val: alias})
|
||||
}
|
||||
|
||||
text := &html.Node{
|
||||
Type: html.TextNode,
|
||||
|
@ -502,6 +505,7 @@ func createCustomEmoji(alias string) *html.Node {
|
|||
}
|
||||
span.Attr = append(span.Attr, html.Attribute{Key: "class", Val: "emoji"})
|
||||
span.Attr = append(span.Attr, html.Attribute{Key: "aria-label", Val: alias})
|
||||
span.Attr = append(span.Attr, html.Attribute{Key: "data-alias", Val: alias})
|
||||
|
||||
img := &html.Node{
|
||||
Type: html.ElementNode,
|
||||
|
@ -1147,7 +1151,7 @@ func emojiShortCodeProcessor(ctx *RenderContext, node *html.Node) {
|
|||
continue
|
||||
}
|
||||
|
||||
replaceContent(node, m[0], m[1], createEmoji(converted.Emoji, "emoji", converted.Description))
|
||||
replaceContent(node, m[0], m[1], createEmoji(converted.Emoji, "emoji", converted.Description, alias))
|
||||
node = node.NextSibling.NextSibling
|
||||
start = 0
|
||||
}
|
||||
|
@ -1169,7 +1173,7 @@ func emojiProcessor(ctx *RenderContext, node *html.Node) {
|
|||
start = m[1]
|
||||
val := emoji.FromCode(codepoint)
|
||||
if val != nil {
|
||||
replaceContent(node, m[0], m[1], createEmoji(codepoint, "emoji", val.Description))
|
||||
replaceContent(node, m[0], m[1], createEmoji(codepoint, "emoji", val.Description, val.Aliases[0]))
|
||||
node = node.NextSibling.NextSibling
|
||||
start = 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue