Add support for plugin links (#6386)
Co-authored-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
Vendored
+15
@@ -187,6 +187,7 @@ declare namespace c2 {
|
||||
interface MessageElementInitBase {
|
||||
tooltip?: string;
|
||||
trailing_space?: boolean;
|
||||
link?: Link;
|
||||
}
|
||||
|
||||
type MessageColor = "text" | "link" | "system" | string;
|
||||
@@ -242,6 +243,20 @@ declare namespace c2 {
|
||||
type: "reply-curve";
|
||||
}
|
||||
|
||||
interface Link {
|
||||
type: LinkType;
|
||||
value: string;
|
||||
}
|
||||
|
||||
enum LinkType {
|
||||
Url,
|
||||
UserInfo,
|
||||
UserAction,
|
||||
JumpToChannel,
|
||||
CopyToClipboard,
|
||||
JumpToMessage,
|
||||
}
|
||||
|
||||
enum MessageFlag {
|
||||
None = 0,
|
||||
System = 0,
|
||||
|
||||
@@ -292,6 +292,7 @@ c2.Message = {}
|
||||
---@class MessageElementInitBase
|
||||
---@field tooltip? string Tooltip text
|
||||
---@field trailing_space? boolean Whether to add a trailing space after the element (default: true)
|
||||
---@field link? c2.Link An action when clicking on this element. Mention and Link elements don't support this. They manage the link themselves.
|
||||
|
||||
---@alias MessageColor "text"|"link"|"system"|string A color for a text element - "text", "link", and "system" are special values that take the current theme into account
|
||||
|
||||
@@ -344,6 +345,17 @@ c2.Message = {}
|
||||
---@param init MessageInit The message initialization table
|
||||
---@return c2.Message msg The new message
|
||||
function c2.Message.new(init) end
|
||||
---@alias c2.Link { type: c2.LinkType, value: string } A link on a message element.
|
||||
---@enum c2.LinkType
|
||||
c2.LinkType = {
|
||||
Url = {}, ---@type c2.LinkType.Url
|
||||
UserInfo = {}, ---@type c2.LinkType.UserInfo
|
||||
UserAction = {}, ---@type c2.LinkType.UserAction
|
||||
JumpToChannel = {}, ---@type c2.LinkType.JumpToChannel
|
||||
CopyToClipboard = {}, ---@type c2.LinkType.CopyToClipboard
|
||||
JumpToMessage = {}, ---@type c2.LinkType.JumpToMessage
|
||||
}
|
||||
|
||||
-- Begin src/singletons/Fonts.hpp
|
||||
|
||||
---@enum c2.FontStyle
|
||||
|
||||
@@ -609,6 +609,19 @@ end)
|
||||
|
||||
The full range of options can be found in the typing files ([LuaLS](./plugin-meta.lua), [TypeScript](./chatterino.d.ts)).
|
||||
|
||||
#### `LinkType` enum
|
||||
|
||||
This table describes links available to plugins.
|
||||
|
||||
| `LinkType` | `c2.Link.value` content | Action on click | Example |
|
||||
| ----------------- | ---------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------- |
|
||||
| `Url` | Any URI that makes sense to open | Open Link in browser | `https://example.org` |
|
||||
| `UserInfo` | A Twitch username or `id:TwitchID` | Open a usercard | `mm2pl`, `id:117691339` |
|
||||
| `UserAction` | Command to run or message to send | Send command/message | `/timeout mm2pl 1s test`, `!spoilers` |
|
||||
| `JumpToChannel` | [Channel name](#channelget_name) | Go to already open split with given channel | `#pajlada` |
|
||||
| `CopyToClipboard` | Any Unicode text | Copy value to clipboard | n/a |
|
||||
| `JumpToMessage` | ID of the message | Highlight the message with given ID in current split, do nothing if it was not found | n/a |
|
||||
|
||||
### Input/Output API
|
||||
|
||||
These functions are wrappers for Lua's I/O library. Functions on file pointer
|
||||
|
||||
Reference in New Issue
Block a user