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:
parent
7fe9b3ed4c
commit
f1db8e0601
Binary file not shown.
|
@ -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.
|
||||
|
|
12
text/text.go
12
text/text.go
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue