Plugin links pt 2: Link::InsertText (#6527)

This commit is contained in:
Mm2PL
2025-10-25 15:30:49 +02:00
committed by GitHub
parent 86217019da
commit 6e443cd767
7 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
- Minor: Badges now link to their home page like emotes in the context menu. (#6437)
- Minor: Fixed usercard resizing improperly without recent messages. (#6496)
- Minor: Added setting for character limit of deleted messages. (#6491)
- Minor: Added link support to plugin message API. (#6386)
- Minor: Added link support to plugin message API. (#6386, #6527)
- Minor: Added a description for the logging option under moderation tab. (#6514)
- Minor: Fixed "edit hotkey" dialog opening like a normal window. (#6540)
- Bugfix: Expose the "Extra extension IDs" setting on non-Windows systems too. (#6509)
+1
View File
@@ -255,6 +255,7 @@ declare namespace c2 {
JumpToChannel,
CopyToClipboard,
JumpToMessage,
InsertText,
}
enum MessageFlag {
+1
View File
@@ -354,6 +354,7 @@ c2.LinkType = {
JumpToChannel = {}, ---@type c2.LinkType.JumpToChannel
CopyToClipboard = {}, ---@type c2.LinkType.CopyToClipboard
JumpToMessage = {}, ---@type c2.LinkType.JumpToMessage
InsertText = {}, ---@type c2.LinkType.InsertText
}
-- Begin src/singletons/Fonts.hpp
+1
View File
@@ -621,6 +621,7 @@ This table describes links available to plugins.
| `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 |
| `InsertText` | Any text, command or emote | Insert text into split input | n/a |
### Input/Output API
+1 -1
View File
@@ -190,6 +190,7 @@ std::unique_ptr<MessageElement> elementFromTable(const sol::table &tbl)
break;
// these links should be safe to click as they don't have any immediate action associated with them
case Link::InsertText:
case Link::JumpToChannel:
case Link::JumpToMessage:
case Link::UserInfo:
@@ -201,7 +202,6 @@ std::unique_ptr<MessageElement> elementFromTable(const sol::table &tbl)
case Link::None:
case Link::AutoModAllow:
case Link::AutoModDeny:
case Link::InsertText:
case Link::OpenAccountsPage:
case Link::Reconnect:
throw std::runtime_error(
+1
View File
@@ -102,6 +102,7 @@ enum class ExposedLinkType : std::uint8_t {
JumpToChannel = Link::Type::JumpToChannel,
CopyToClipboard = Link::Type::CopyToClipboard,
JumpToMessage = Link::Type::JumpToMessage,
InsertText = Link::Type::InsertText,
};
/**
+9
View File
@@ -2423,6 +2423,15 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
if (link.type == Link::InsertText)
{
this->linkClicked.invoke(link);
if (this->context_ == Context::None)
{
auto *split = dynamic_cast<Split *>(this->parentWidget());
if (split)
{
split->insertTextToInput(link.value);
}
}
}
}
break;