1
0
Fork 0
mirror of https://github.com/diamondburned/cchat.git synced 2024-10-31 20:04:33 +00:00

Added MessageReferencer for text.Rich

This commit added MessageReferencer for the text.Rich segments, which
allows a message to highlight a URL or text as a reference to other
messages. This could be used for replies as well as links that are
supposed to go to other messages.

The frontend gets to decide how exactly to represent the message when it
is clicked. However, as of right now, there is no API to fetch a single
message individually, so this API is limited to just within the message
buffer.
This commit is contained in:
diamondburned 2020-12-17 17:12:27 -08:00
parent 7fe9b3ed4c
commit f1db8e0601
3 changed files with 29 additions and 0 deletions

Binary file not shown.

View file

@ -114,6 +114,23 @@ var Main = Packages{
AsserterMethod{ChildType: "Codeblocker"},
AsserterMethod{ChildType: "Quoteblocker"},
},
}, {
Comment: Comment{`
MessageReferencer is similar to Linker, except it references a
message instead of an arbitrary URL. As such, its appearance may
be formatted similarly to a link, but this is up to the frontend
to decide. When clicked, the frontend should scroll to the
message with the ID returned by MessageID() and highlight it,
though this is also for appearance, so the frontend may decide
in detail how to display it.
`},
Name: "MessageReferencer",
Methods: []Method{
GetterMethod{
method: method{Name: "MessageID"},
Returns: []NamedType{{Type: "cchat.ID"}},
},
},
}, {
Comment: Comment{`
Linker is a hyperlink format that a segment could implement.

View file

@ -11,6 +11,8 @@
// shouldn't be.
package text
import cchat "cchat"
// Attribute is the type for basic rich text markup attributes.
type Attribute uint32
@ -138,6 +140,16 @@ type Mentioner interface {
MentionInfo() Rich
}
// MessageReferencer is similar to Linker, except it references a message
// instead of an arbitrary URL. As such, its appearance may be formatted
// similarly to a link, but this is up to the frontend to decide. When clicked,
// the frontend should scroll to the message with the ID returned by MessageID()
// and highlight it, though this is also for appearance, so the frontend may
// decide in detail how to display it.
type MessageReferencer interface {
MessageID() cchat.ID
}
// Quoteblocker represents a quoteblock that behaves similarly to the blockquote
// HTML tag. The quoteblock may be represented typically by an actaul quoteblock
// or with green arrows prepended to each line.