This commit is contained in:
Mirco Wittrien 2019-12-11 08:51:09 +01:00
parent f7f705612a
commit 53800532be
2 changed files with 55 additions and 54 deletions

View File

@ -3,7 +3,7 @@
class ChatAliases { class ChatAliases {
getName () {return "ChatAliases";} getName () {return "ChatAliases";}
getVersion () {return "2.0.1";} getVersion () {return "2.0.2";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -11,12 +11,12 @@ class ChatAliases {
constructor () { constructor () {
this.changelog = { this.changelog = {
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]] "fixed":[["Little Fix","Sendings works again, but some stuff is still broken"]]
}; };
this.patchedModules = { this.patchedModules = {
after: { after: {
ChannelTextArea: "componentDidMount" ChannelTextArea: ["render", "componentDidMount"]
} }
}; };
} }
@ -329,28 +329,28 @@ class ChatAliases {
processChannelTextArea (e) { processChannelTextArea (e) {
if (e.instance.props.channel && e.instance.props.type) { if (e.instance.props.channel && e.instance.props.type) {
var textarea = e.node.querySelector("textarea"); if (e.returnvalue) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSubmit")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSubmit", {before: e2 => {
let messageData = this.formatText(e2.methodArguments[0]);
if (messageData) {
if (messageData.text != null) {
e2.methodArguments[0] = messageData.text;
if (!messageData.text) {
e.instance.props.textValue = "";
if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.StringUtils.copyRichValue("", e.instance.props.richValue);
BDFDB.ReactUtils.forceUpdate(e.instance);
}
}
if (messageData.files.length > 0 && (e.instance.props.channel.type == 1 || BDFDB.UserUtils.can("ATTACH_FILES"))) {
BDFDB.LibraryModules.UploadUtils.instantBatchUpload(e.instance.props.channel.id, messageData.files);
}
}
}}, true);
}
if (e.node) {
let textarea = e.node.querySelector("textarea");
if (!textarea) return; if (!textarea) return;
let settings = BDFDB.DataUtils.get(this, "settings"); let settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.ListenerUtils.add(this, textarea, "input", () => {
if (this.format) {
this.format = false;
textarea.focus();
textarea.selectionStart = 0;
textarea.selectionEnd = textarea.value.length;
if (document.activeElement == textarea) {
var messageInput = this.formatText(textarea.value);
if (messageInput) {
if (messageInput.text != null) {
document.execCommand("insertText", false, messageInput.text ? messageInput.text + " " : "");
}
if (messageInput.files.length > 0 && (e.instance.props.channel.type == 1 || BDFDB.UserUtils.can("ATTACH_FILES"))) {
BDFDB.LibraryModules.UploadUtils.instantBatchUpload(e.instance.props.channel.id, messageInput.files);
}
}
}
}
});
BDFDB.ListenerUtils.add(this, textarea, "keydown", event => { BDFDB.ListenerUtils.add(this, textarea, "keydown", event => {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete); let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete);
if (autocompletemenu && (event.which == 9 || event.which == 13)) { if (autocompletemenu && (event.which == 9 || event.which == 13)) {
@ -386,6 +386,7 @@ class ChatAliases {
}); });
} }
} }
}
addAutoCompleteMenu (textarea) { addAutoCompleteMenu (textarea) {
if (!textarea.value || textarea.parentElement.querySelector(".autocompleteAliasesRow")) return; if (!textarea.value || textarea.parentElement.querySelector(".autocompleteAliasesRow")) return;

View File

@ -3,7 +3,7 @@
class GoogleTranslateOption { class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";} getName () {return "GoogleTranslateOption";}
getVersion () {return "1.8.3";} getVersion () {return "1.8.4";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -244,7 +244,7 @@ class GoogleTranslateOption {
}); });
} }
else e2.callOriginalMethod(); else e2.callOriginalMethod();
}}); }}, true);
} }
} }