BetterDiscordAddons/Plugins/MessageUtilities/MessageUtilities.plugin.js

432 lines
19 KiB
JavaScript
Raw Normal View History

2020-10-20 23:25:34 +02:00
/**
* @name MessageUtilities
* @authorId 278543574059057154
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
* @patreon https://www.patreon.com/MircoWittrien
* @website https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/MessageUtilities
* @source https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/MessageUtilities/MessageUtilities.plugin.js
2020-11-12 17:30:48 +01:00
* @updateUrl https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/MessageUtilities/MessageUtilities.plugin.js
2020-10-20 23:25:34 +02:00
*/
2018-10-11 10:21:26 +02:00
2020-09-19 20:49:33 +02:00
module.exports = (_ => {
2020-10-09 21:09:35 +02:00
const config = {
2020-09-19 20:49:33 +02:00
"info": {
"name": "MessageUtilities",
"author": "DevilBro",
2020-11-23 17:55:46 +01:00
"version": "1.8.1",
2020-10-16 10:25:30 +02:00
"description": "Offer a number of useful message options. Remap the keybindings in the settings"
2020-09-23 09:29:56 +02:00
},
"changeLog": {
2020-11-23 17:55:46 +01:00
"added": {
"Replies": "Added option for replies",
2020-11-23 18:13:26 +01:00
"Quotes": "Now requires CustomQuoter plugin since Discord replaces Quotes with Replies"
2020-11-23 17:55:46 +01:00
},
2020-09-23 09:29:56 +02:00
"fixed": {
2020-11-23 17:55:46 +01:00
"Settings": "Fixed Settings"
2020-09-23 09:29:56 +02:00
}
2020-02-04 08:20:40 +01:00
}
2020-09-19 20:49:33 +02:00
};
2020-11-20 10:30:29 +01:00
2020-10-09 21:09:35 +02:00
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
2020-09-19 20:49:33 +02:00
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
2020-10-09 21:09:35 +02:00
load() {
2020-11-19 16:51:14 +01:00
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
2020-09-19 20:49:33 +02:00
if (!window.BDFDB_Global.downloadModal) {
window.BDFDB_Global.downloadModal = true;
BdApi.showConfirmationModal("Library Missing", `The library plugin needed for ${config.info.name} is missing. Please click "Download Now" to install it.`, {
confirmText: "Download Now",
cancelText: "Cancel",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
2020-09-20 08:15:13 +02:00
onConfirm: _ => {
delete window.BDFDB_Global.downloadModal;
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
2020-10-20 23:25:34 +02:00
if (!e && b && b.indexOf(`* @name BDFDB`) > -1) require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => {});
2020-09-20 08:15:13 +02:00
else BdApi.alert("Error", "Could not download BDFDB library plugin, try again some time later.");
});
}
2020-09-19 20:49:33 +02:00
});
2018-10-11 10:21:26 +02:00
}
2020-09-19 20:49:33 +02:00
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
2020-10-09 21:09:35 +02:00
}
start() {this.load();}
stop() {}
} : (([Plugin, BDFDB]) => {
2020-09-19 20:49:33 +02:00
const clickMap = ["CLICK", "DBLCLICK"];
2020-11-20 10:30:29 +01:00
var firedEvents = [], clickTimeout;
2020-09-19 20:49:33 +02:00
var settings = {}, bindings = {}, enabledBindings = {}, toasts = {};
2020-10-09 21:09:35 +02:00
return class MessageUtilities extends Plugin {
2020-09-19 20:49:33 +02:00
onLoad() {
this.defaults = {
settings: {
2020-11-19 16:51:14 +01:00
"addHints": {value: true, description: "Add keycombo hints to contextmenus: "},
"clearOnEscape": {value: true, description: "Clear chat input when Escape is pressed: "}
2020-09-19 20:49:33 +02:00
},
toasts: {},
bindings: {
2020-11-23 17:55:46 +01:00
"Edit_Message": {name: "Edit Message", func: this.doEdit, value: {click: 1, keycombo: []} },
"Delete_Message": {name: "Delete Message", func: this.doDelete, value: {click: 0, keycombo: [46]} },
"Pin/Unpin_Message": {name: "Pin/Unpin Message", func: this.doPinUnPin, value: {click: 0, keycombo: [17]} },
"Reply_to_Message": {name: "Reply to Message", func: this.doReply, value: {click: 0, keycombo: [17,84]} },
"React_to_Message": {name: "Open React Menu", func: this.doOpenReact, value: {click: 0, keycombo: [17,83]} },
"Copy_Raw": {name: "Copy raw Message", func: this.doCopyRaw, value: {click: 0, keycombo: [17,68]} },
"Copy_Link": {name: "Copy Message Link", func: this.doCopyLink, value: {click: 0, keycombo: [17,81]} },
"__Quote_Message": {name: "Quote Message", func: this.doQuote, value: {click: 0, keycombo: [17,87]}, plugin: "CustomQuoter"},
"__Note_Message": {name: "Note Message", func: this.doNote, value: {click: 0, keycombo: [16]}, plugin: "PersonalPins"},
"__Translate_Message": {name: "Translate Message", func: this.doTranslate, value: {click: 0, keycombo: [20]}, plugin: "GoogleTranslateOption"},
"__Reveal_Spoilers": {name: "Reveal All Spoilers", func: this.doReveal, value: {click: 0, keycombo: [17,74]}, plugin: "RevealAllSpoilersOption"}
2020-09-19 20:49:33 +02:00
}
};
this.patchedModules = {
before: {
Menu: "default"
}
};
for (let type in this.defaults.bindings) {
let nativeAction = type.indexOf("__") != 0;
this.defaults.settings[type] = {value: nativeAction};
2020-11-19 16:51:14 +01:00
if (nativeAction) this.defaults.toasts[type] = {value: type != "Edit_Message" && type != "React_to_Message" && type != "Quote_Message"};
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2020-09-19 20:49:33 +02:00
onStart() {
2020-08-05 21:52:24 +02:00
BDFDB.ListenerUtils.add(this, document, "click", BDFDB.dotCNC.message + BDFDB.dotCN.searchresultsgroupcozy, e => {
2020-09-23 09:29:56 +02:00
if (!BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagetoolbarbutton, e.target)) this.onClick(e, 0, "onSglClick");
2020-02-04 08:20:40 +01:00
});
2020-08-05 21:52:24 +02:00
BDFDB.ListenerUtils.add(this, document, "dblclick", BDFDB.dotCNC.message + BDFDB.dotCN.searchresultsgroupcozy, e => {
2020-09-23 09:29:56 +02:00
if (!BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagetoolbarbutton, e.target)) this.onClick(e, 1, "onDblClick");
2020-02-04 08:20:40 +01:00
});
BDFDB.ListenerUtils.add(this, document, "keydown", e => {
if (BDFDB.DOMUtils.getParent(BDFDB.dotCN.textareawrapchat, document.activeElement)) this.onKeyDown(document.activeElement, e.which, "onKeyDown");
});
2020-06-08 19:08:43 +02:00
2020-09-19 20:49:33 +02:00
this.forceUpdateAll();
2019-11-15 21:48:30 +01:00
}
2020-09-19 20:49:33 +02:00
onStop() {
this.forceUpdateAll();
2020-02-04 08:20:40 +01:00
}
2018-10-11 10:21:26 +02:00
2020-09-19 20:49:33 +02:00
getSettingsPanel (collapseStates = {}) {
2020-11-23 17:55:46 +01:00
let settingsPanel;
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
collapseStates: collapseStates,
children: _ => {
let settingsItems = [];
for (let key in settings) if (this.defaults.settings[key].description) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let action in bindings) if (!this.defaults.bindings[action].plugin || BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings[action].plugin)) {
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCN.marginbottom8,
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
label: this.defaults.bindings[action].name + (this.defaults.bindings[action].plugin ? ` (${this.defaults.bindings[action].plugin})` : "")
}),
toasts[action] != undefined ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
mini: true,
plugin: this,
keys: ["toasts", action],
grow: 0,
label: "Toast:",
value: toasts[action]
}) : null
].filter(n => n)
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
2020-09-19 20:49:33 +02:00
type: "Switch",
2020-11-23 17:55:46 +01:00
dividerBottom: true,
2020-09-19 20:49:33 +02:00
mini: true,
plugin: this,
2020-11-23 17:55:46 +01:00
keys: ["settings", action],
value: settings[action],
labelchildren: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.KeybindRecorder, {
defaultValue: bindings[action].keycombo.filter(n => n),
reset: true,
onChange: keycombo => {
bindings[action].keycombo = keycombo;
BDFDB.DataUtils.save(bindings, this, "bindings");
this.SettingsUpdated = true;
}
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
value: bindings[action].click,
options: clickMap.map((label, i) => {return {value: i, label: label}}),
onChange: choice => {
bindings[action].click = choice.value;
BDFDB.DataUtils.save(bindings, this, "bindings");
this.SettingsUpdated = true;
}
})
]
2020-09-19 20:49:33 +02:00
})
2020-11-23 17:55:46 +01:00
}));
}
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Reset all Key Bindings",
onClick: (e, instance) => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset all Key Bindings?", _ => {
BDFDB.DataUtils.remove(this, "bindings");
settingsPanel.parentElement.appendChild(this.getSettingsPanel());
settingsPanel.remove();
this.SettingsUpdated = true;
});
},
children: BDFDB.LanguageUtils.LanguageStrings.RESET
}));
return settingsItems;
}
});
2020-09-19 20:49:33 +02:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
bindings = BDFDB.DataUtils.get(this, "bindings");
enabledBindings = BDFDB.ObjectUtils.filter(bindings, action => settings[action], true);
toasts = BDFDB.DataUtils.get(this, "toasts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
2020-02-04 08:20:40 +01:00
2020-09-19 20:49:33 +02:00
processMenu (e) {
let contextMenu = BDFDB.ReactUtils.findChild(e.instance, {props: "navId"});
if (contextMenu && BDFDB.ArrayUtils.is(contextMenu.props.children)) for (let group of contextMenu.props.children) {
if (group && group.type == BDFDB.LibraryComponents.MenuItems.MenuGroup && BDFDB.ArrayUtils.is(group.props.children)) for (let item of group.props.children) {
if (item && item.props && item.props.id && !item.props.hint && !item.props.children) {
let hint, action;
if (item.props.id == "mark-unread") hint = settings.addHints && `${BDFDB.LibraryModules.KeyCodeUtils.getString(18)}+${clickMap[0]}`;
else {
switch (item.props.id) {
case "copy-link":
action = "Copy_Link";
break;
case "edit":
action = "Edit_Message";
break;
case "pin":
case "unpin":
action = "Pin/Unpin_Message";
break;
case "delete":
action = "Delete_Message";
break;
case "quote":
action = "Quote_Message";
break;
}
if (action) hint = this.getActiveShortcutString(action);
2020-05-23 15:21:57 +02:00
}
2020-09-19 20:49:33 +02:00
if (hint) item.props.hint = _ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
});
};
2020-05-23 15:21:57 +02:00
}
2019-09-28 10:27:59 +02:00
}
}
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
onClick (e, click, name) {
if (!firedEvents.includes(name)) {
firedEvents.push(name);
let priorityAction = null;
for (let action in enabledBindings) {
let binding = enabledBindings[action];
let priorityBinding = enabledBindings[priorityAction];
if (this.checkIfBindingIsValid(binding, click) && (!enabledBindings[priorityAction] || binding.click > priorityBinding.click || binding.keycombo.length > priorityBinding.keycombo.length)) priorityAction = action;
}
if (priorityAction) {
let {messageDiv, message} = this.getMessageData(e.currentTarget);
if (messageDiv && message) {
BDFDB.ListenerUtils.stopEvent(e);
2020-11-20 10:30:29 +01:00
BDFDB.TimeUtils.clear(clickTimeout);
2020-09-19 20:49:33 +02:00
if (!this.hasDoubleClickOverwrite(enabledBindings[priorityAction])) {
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
}
2020-11-20 10:30:29 +01:00
else clickTimeout = BDFDB.TimeUtils.timeout(_ => {
2020-09-19 20:49:33 +02:00
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
}, 500);
2020-02-04 08:20:40 +01:00
}
2019-09-28 10:27:59 +02:00
}
2020-09-19 20:49:33 +02:00
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, name, true)});
2018-10-11 10:21:26 +02:00
}
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
checkIfBindingIsValid (binding, doneclick) {
if (binding.click != doneclick) return false;
for (let key of binding.keycombo) if (!BDFDB.ListenerUtils.isPressed(key)) return false;
return true;
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
hasDoubleClickOverwrite (binding) {
if (binding.click == 1) return false;
let dblBindings = BDFDB.ObjectUtils.filter(enabledBindings, bndg => {return bndg.click == 1});
for (let dblAction in dblBindings) {
let dblBinding = dblBindings[dblAction];
let overwrite = true;
if (BDFDB.equals(binding.keycombo, dblBinding.keycombo)) return true;
}
return false;
2020-02-04 08:20:40 +01:00
}
2019-09-28 10:27:59 +02:00
2020-09-19 20:49:33 +02:00
doDelete ({messageDiv, message}, action) {
let deleteLink = messageDiv.parentElement.querySelector(BDFDB.dotCNS.messagelocalbotoperations + BDFDB.dotCN.anchor);
if (deleteLink) deleteLink.click();
else {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if ((channel && BDFDB.UserUtils.can("MANAGE_MESSAGES")) || message.author.id == BDFDB.UserUtils.me.id && message.type != 1 && message.type != 2 && message.type != 3) {
BDFDB.LibraryModules.MessageUtils.deleteMessage(message.channel_id, message.id, message.state != "SENT");
2020-11-20 10:30:29 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been deleted", {type: "success"});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2019-03-01 21:25:48 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
doEdit ({messageDiv, message}, action) {
if (message.author.id == BDFDB.UserUtils.me.id && !messageDiv.querySelector("textarea")) {
BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content);
2020-11-19 16:51:14 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Started editing.", {type: "success"});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
doOpenReact ({messageDiv, message}, action) {
let reactButton = messageDiv.querySelector(`${BDFDB.dotCN.messagetoolbarbutton}[aria-label="${BDFDB.LanguageUtils.LanguageStrings.ADD_REACTION}"]`);
if (reactButton) {
reactButton.click();
2020-11-20 10:30:29 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Reaction popout has been opened", {type: "success"});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
doPinUnPin ({messageDiv, message}, action) {
if (message.state == "SENT") {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && (channel.type == 1 || channel.type == 3 || BDFDB.UserUtils.can("MANAGE_MESSAGES")) && message.type == 0) {
if (message.pinned) {
BDFDB.LibraryModules.MessagePinUtils.unpinMessage(channel, message.id);
2020-11-20 10:30:29 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been unpinned", {type: "error"});
2020-09-19 20:49:33 +02:00
}
else {
BDFDB.LibraryModules.MessagePinUtils.pinMessage(channel, message.id);
2020-11-20 10:30:29 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been pinned", {type: "success"});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2019-09-26 20:09:46 +02:00
}
2019-03-01 21:25:48 +01:00
}
2020-11-23 17:55:46 +01:00
doReply ({messageDiv, message}, action) {
if (message.state == "SENT") {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && BDFDB.UserUtils.can("SEND_MESSAGES") && message.type == 0) {
BDFDB.LibraryModules.MessageManageUtils.replyToMessage(channel, message);
if (toasts[action]) BDFDB.NotificationUtils.toast("Added reply to message", {type: "success"});
}
}
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
doCopyRaw ({messageDiv, message}, action) {
if (message.content) {
2020-11-19 16:51:14 +01:00
BDFDB.LibraryRequires.electron.clipboard.write({text: message.content});
2020-11-20 10:30:29 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Raw message content has been copied", {type: "success"});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2019-09-26 16:18:55 +02:00
2020-09-19 20:49:33 +02:00
doCopyLink ({messageDiv, message}, action) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) {
BDFDB.LibraryModules.MessageManageUtils.copyLink(channel, message);
2020-11-20 10:30:29 +01:00
if (toasts[action]) BDFDB.NotificationUtils.toast("Messagelink has been copied", {type: "success"});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2019-09-26 16:18:55 +02:00
2020-09-19 20:49:33 +02:00
doQuote ({messageDiv, message}, action) {
2020-11-23 17:55:46 +01:00
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Quote_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Quote_Message.plugin).quote(channel, message);
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2020-01-07 11:09:56 +01:00
2020-09-19 20:49:33 +02:00
doNote ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, channel);
}
2020-02-04 08:20:40 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
doTranslate ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, channel);
}
2020-02-04 08:20:40 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
doReveal ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messageDiv);
}
2020-02-04 08:20:40 +01:00
}
2019-02-01 12:34:20 +01:00
2020-09-19 20:49:33 +02:00
onKeyDown (target, key, name) {
if (!firedEvents.includes(name)) {
firedEvents.push(name);
if (key == 27 && settings.clearOnEscape) {
let chatform = BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, target);
if (chatform) {
2020-11-19 16:51:14 +01:00
let instance = BDFDB.ReactUtils.findOwner(chatform, {name: "ChannelTextAreaForm"}) || BDFDB.ReactUtils.findOwner(chatform, {name: "ChannelTextAreaForm", up: true});
if (instance) instance.setState({textValue: "", richValue: BDFDB.LibraryModules.SlateUtils.deserialize("")});
2020-09-19 20:49:33 +02:00
}
2020-02-04 08:20:40 +01:00
}
2020-09-19 20:49:33 +02:00
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, name, true)});
2019-12-27 11:43:25 +01:00
}
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
getActiveShortcutString (action) {
if (!action) return null;
let str = [];
if (settings.addHints && settings[action] && enabledBindings[action]) {
if (enabledBindings[action].keycombo.length) str.push(BDFDB.LibraryModules.KeyCodeUtils.getString(enabledBindings[action].keycombo));
str.push(clickMap[enabledBindings[action].click]);
}
return str.join("+").replace(/ /g, "");
2018-12-29 11:32:07 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
getMessageData (target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCNC.message + BDFDB.dotCN.searchresultsgroupcozy, target);
if (messageDiv && messageDiv.querySelector(BDFDB.dotCN.textarea)) return {messageDiv: null, message: null};
let instance = BDFDB.ReactUtils.getInstance(messageDiv);
2020-11-20 10:30:29 +01:00
let message = instance && (BDFDB.ReactUtils.findValue(instance, "baseMessage") || BDFDB.ReactUtils.findValue(instance, "message"));
2020-09-19 20:49:33 +02:00
return {messageDiv, message};
}
};
2020-10-09 21:09:35 +02:00
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
2020-09-21 07:09:21 +02:00
})();