This commit is contained in:
Mirco Wittrien 2020-05-02 18:27:18 +02:00
parent 455196ec7e
commit 93f3efb8ac
3 changed files with 12 additions and 121 deletions

View File

@ -4,7 +4,7 @@ var CopyRawMessage = (_ => {
return class CopyRawMessage {
getName () {return "CopyRawMessage";}
getVersion () {return "1.0.4";}
getVersion () {return "1.0.5";}
getAuthor () {return "DevilBro";}
@ -12,8 +12,7 @@ var CopyRawMessage = (_ => {
constructor () {
this.changelog = {
"fixed":[["Message Update","Fixed the plugin for the new Message Update"]],
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
"improved":[["Raw Embed Text","Right clicking inside an embed which contains a description will add an extra option in the context menu to copy the raw contents of the embed description"]]
};
}
@ -62,6 +61,8 @@ var CopyRawMessage = (_ => {
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.message.content) {
let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target);
let embedIndex = embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [
@ -72,25 +73,15 @@ var CopyRawMessage = (_ => {
BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.content});
}
}),
embed && embed.querySelector(BDFDB.dotCN.embeddescription) && e.instance.props.message.embeds[embedIndex] && e.instance.props.message.embeds[embedIndex].rawDescription && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw Embed)",
action: _ => {
BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.embeds[embedIndex].rawDescription});
}
})
]
}));
}
}
onMessageOptionToolbar (e) {
if (!e.instance.props.hasMorePopout && e.instance.props.message && e.instance.props.channel) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {key: ["mark-unread"]});
children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.messagetoolbarbutton,
onClick: _ => {BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.content});},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.messagetoolbaricon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
})
})
].filter(n => n)
}));
}
}

View File

@ -211,43 +211,6 @@ var GoogleTranslateOption = (_ => {
}
}
onMessageOptionToolbar (e) {
if (!e.instance.props.hasMorePopout && e.instance.props.message && e.instance.props.channel) {
let translated = !!translatedMessages[e.instance.props.message.id];
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {key: ["pin", "unpin"]});
children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "translate",
text: translated ? this.labels.context_messageuntranslateoption_text : this.labels.context_messagetranslateoption_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.messagetoolbarbutton,
disabled: isTranslating,
onClick: event => {
this.translateMessage(e.instance.props.message, e.instance.props.channel);
let buttonIns = BDFDB.ReactUtils.getInstance(BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagetoolbarbutton, event.target));
if (buttonIns) {
let isTranslated = !!translatedMessages[e.instance.props.message.id];
let svgInstance = BDFDB.ReactUtils.findOwner(buttonIns, {props: "iconSVG"});
let tooltipInstance = BDFDB.ReactUtils.findOwner(buttonIns, {key: "translate", up:true});
if (svgInstance) {
svgInstance.props.iconSVG = isTranslated ? translateIconUntranslate : translateIcon;
BDFDB.ReactUtils.forceUpdate(svgInstance);
}
if (tooltipInstance) {
tooltipInstance.props.text = isTranslated ? this.labels.context_messageuntranslateoption_text : this.labels.context_messagetranslateoption_text;
BDFDB.ReactUtils.forceUpdate(tooltipInstance);
}
}
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.messagetoolbaricon,
nativeClass: true,
iconSVG: translated ? translateIconUntranslate : translateIcon
})
})
}));
}
}
onMessageOptionContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel) {
let translated = !!translatedMessages[e.instance.props.message.id];

View File

@ -124,69 +124,6 @@ var PersonalPins = (_ => {
}
}
onMessageOptionToolbar (e) {
if (!e.instance.props.hasMorePopout && e.instance.props.message && e.instance.props.channel) {
let note = this.getNoteData(e.instance.props.message, e.instance.props.channel);
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {key: ["pin", "unpin"]});
children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "add/remove note",
text: note ? this.labels.context_unpinoption_text : this.labels.context_pinoption_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.messagetoolbarbutton,
onClick: event => {
this.addMessageToNotes(e.instance.props.message, e.instance.props.channel);
let buttonIns = BDFDB.ReactUtils.getInstance(BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagetoolbarbutton, event.target));
if (buttonIns) {
let isNoted = !!this.getNoteData(e.instance.props.message, e.instance.props.channel);
let svgInstance = BDFDB.ReactUtils.findOwner(buttonIns, {props: "iconSVG"});
let tooltipInstance = BDFDB.ReactUtils.findOwner(buttonIns, {key: "add/remove note", up:true});
if (svgInstance) {
svgInstance.props.iconSVG = isNoted ? pinIconDelete : pinIcon;
BDFDB.ReactUtils.forceUpdate(svgInstance);
}
if (tooltipInstance) {
tooltipInstance.props.text = isNoted ? this.labels.context_unpinoption_text : this.labels.context_pinoption_text;
BDFDB.ReactUtils.forceUpdate(tooltipInstance);
}
if (!isNoted) {
tooltipInstance = BDFDB.ReactUtils.findOwner(buttonIns.return.return, {key: "update note"});
if (tooltipInstance) {
tooltipInstance.props.children = null;
BDFDB.ReactUtils.forceUpdate(tooltipInstance);
}
}
}
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.messagetoolbaricon,
nativeClass: true,
iconSVG: note ? pinIconDelete : pinIcon
})
})
}));
if (this.isNoteOutdated(note, e.instance.props.message)) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "update note",
text: this.labels.context_updateoption_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.messagetoolbarbutton,
onClick: event => {
this.updateNoteData(note, e.instance.props.message);
let tooltipInstance = BDFDB.ReactUtils.findOwner(event._targetInst, {key: "update note", up:true});
if (tooltipInstance) {
tooltipInstance.props.children = null;
BDFDB.ReactUtils.forceUpdate(tooltipInstance);
}
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.messagetoolbaricon,
nativeClass: true,
iconSVG: pinIconUpdate
})
})
}));
}
}
onMessageOptionContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel) {
let note = this.getNoteData(e.instance.props.message, e.instance.props.channel);