This commit is contained in:
Mirco Wittrien 2020-07-29 00:32:40 +02:00
parent b040180a76
commit dcfcbe21a6
2 changed files with 15 additions and 12 deletions

View File

@ -39,7 +39,7 @@ var CustomQuoter = (_ => {
return class CustomQuoter { return class CustomQuoter {
getName () {return "CustomQuoter";} getName () {return "CustomQuoter";}
getVersion () {return "1.1.1";} getVersion () {return "1.1.2";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -47,8 +47,8 @@ var CustomQuoter = (_ => {
constructor () { constructor () {
this.changelog = { this.changelog = {
"added":[["More Choices","You can now add more formats, which you can choose from in the context submenu (clicking the main item will use first 'standard' format"],["Clipboard","You can now quote in channels that you got no writting permissions in, meaning quoting a message in such a channel will copy the quote to the clipboard instead of the channel textarea"]], "fixed":[["Quote in DMs","Fixed an issue that would break quoting in DMs in some cases"]],
"improved":[["Quote selected text","Works more smoothly with formating symbols like (~, _, `, etc.)"]] "improved":[["Copy to clipboard","Holding Shift and clicking quote now copies the quote to the clipboard"]]
}; };
} }
@ -270,9 +270,9 @@ var CustomQuoter = (_ => {
onMessageContextMenu (e) { onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel) { if (e.instance.props.message && e.instance.props.channel) {
let item = null, action = choice => { let item = null, action = (choice, copy) => {
format = choice; format = choice;
if (!BDFDB.LibraryModules.QuoteUtils.canQuote(e.instance.props.message, e.instance.props.channel)) { if (copy || !BDFDB.LibraryModules.QuoteUtils.canQuote(e.instance.props.message, e.instance.props.channel)) {
BDFDB.LibraryRequires.electron.clipboard.write({text:this.parseQuote(e.instance.props.message, e.instance.props.channel)}); BDFDB.LibraryRequires.electron.clipboard.write({text:this.parseQuote(e.instance.props.message, e.instance.props.channel)});
BDFDB.NotificationUtils.toast("Quote has been copied to clipboard.", {type:"success"}); BDFDB.NotificationUtils.toast("Quote has been copied to clipboard.", {type:"success"});
} }
@ -280,12 +280,15 @@ var CustomQuoter = (_ => {
format = null; format = null;
}; };
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "quote"}); let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "quote"});
if (index > -1) item = children[index]; if (index > -1) {
item = children[index];
item.props.action = event => {action(null, event.shiftKey);};
}
else { else {
item = BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { item = BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.QUOTE, label: BDFDB.LanguageUtils.LanguageStrings.QUOTE,
id: "quote", id: "quote",
action: _ => {action(null);} action: _ => {action(null, event.shiftKey);}
}); });
let [unreadChildren, unreadIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-unread"}); let [unreadChildren, unreadIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-unread"});
unreadChildren.splice(unreadIndex > -1 ? unreadIndex - 1 : unreadChildren.length, 0, item); unreadChildren.splice(unreadIndex > -1 ? unreadIndex - 1 : unreadChildren.length, 0, item);
@ -295,7 +298,7 @@ var CustomQuoter = (_ => {
children: Object.keys(addedFormats).map(key => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { children: Object.keys(addedFormats).map(key => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: key, label: key,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "added-quote", key), id: BDFDB.ContextMenuUtils.createItemId(this.name, "added-quote", key),
action: _ => {action(key);} action: event => {action(key, event.shiftKey);}
})) }))
}); });
} }
@ -327,10 +330,10 @@ var CustomQuoter = (_ => {
quotedLines = quotedLines.replace(/<@[!&]{0,1}([0-9]{10,})>/g, (string, match) => { quotedLines = quotedLines.replace(/<@[!&]{0,1}([0-9]{10,})>/g, (string, match) => {
let user = BDFDB.LibraryModules.UserStore.getUser(match); let user = BDFDB.LibraryModules.UserStore.getUser(match);
if (user) { if (user) {
let userMember = guild && BDFDB.LibraryModules.MemberStore.getMember(guild.id, match); let userMember = channel.guild_id && BDFDB.LibraryModules.MemberStore.getMember(guild.id, match);
return `\`@${userMember && userMember.nick || user.username}\``; return `\`@${userMember && userMember.nick || user.username}\``;
} }
else if (guild && guild.roles[match] && guild.roles[match].name) return `\`${guild.roles[match].name.indexOf("@") == 0 ? "" : "@"}${guild.roles[match].name}\``; else if (channel.guild_id && guild.roles[match] && guild.roles[match].name) return `\`${guild.roles[match].name.indexOf("@") == 0 ? "" : "@"}${guild.roles[match].name}\``;
return string; return string;
}); });
} }

View File

@ -380,7 +380,7 @@ var PluginRepo = (_ => {
settings: { settings: {
useChromium: {value:false, description:"Use an inbuilt browser window instead of opening your default browser"}, useChromium: {value:false, description:"Use an inbuilt browser window instead of opening your default browser"},
notifyOutdated: {value:true, description:"Notifies you when one of your Plugins is outdated"}, notifyOutdated: {value:true, description:"Notifies you when one of your Plugins is outdated"},
notifyNewentries: {value:true, description:"Notifies you when there are new entries in the Repo"} notifyNewEntries: {value:true, description:"Notifies you when there are new entries in the Repo"}
}, },
modalSettings: { modalSettings: {
updated: {value:true, modify:true, description:"Show updated Plugins",}, updated: {value:true, modify:true, description:"Show updated Plugins",},
@ -697,7 +697,7 @@ var PluginRepo = (_ => {
}); });
} }
if ((settings.notifyNewentries || settings.notifyNewentries == undefined) && newentries > 0) { if ((settings.notifyNewEntries || settings.notifyNewEntries == undefined) && newentries > 0) {
let oldbarbutton = document.querySelector(".pluginrepo-newentries-notice " + BDFDB.dotCN.noticedismiss); let oldbarbutton = document.querySelector(".pluginrepo-newentries-notice " + BDFDB.dotCN.noticedismiss);
if (oldbarbutton) oldbarbutton.click(); if (oldbarbutton) oldbarbutton.click();
let single = newentries == 1; let single = newentries == 1;