This commit is contained in:
Mirco Wittrien 2019-11-07 13:45:41 +01:00
parent c003d5934b
commit 86d59b5645
3 changed files with 121 additions and 69 deletions

View File

@ -735,7 +735,12 @@ var BDFDB = {
};
BDFDB.ObjectUtils.extract = function (obj, ...keys) {
let newobj = {};
if (BDFDB.ObjectUtils.is(obj)) for (let key of keys.flat()) if (obj[key]) newobj = obj[key];
if (BDFDB.ObjectUtils.is(obj)) for (let key of keys.flat()) if (obj[key]) newobj[key] = obj[key];
return newobj;
};
BDFDB.ObjectUtils.exclude = function (obj, ...keys) {
let newobj = Object.assign({}, obj);
BDFDB.ObjectUtils.delete(newobj, ...keys)
return newobj;
};
BDFDB.ObjectUtils.delete = function (obj, ...keys) {
@ -2744,7 +2749,7 @@ var BDFDB = {
}
};
BDFDB.DOMUtils.formatClassName = function (...classes) {
return BDFDB.ArrayUtils.removeCopies(classes.flat().filter(n => n).join(" ").split(" ")).join(" ");
return BDFDB.ArrayUtils.removeCopies(classes.flat().filter(n => n).join(" ").split(" ")).join(" ").trim();
};
BDFDB.DOMUtils.removeClassFromDOM = function (...classes) {
for (let c of classes.flat()) if (typeof c == "string") for (let a of c.split(",")) if (a && (a = a.replace(/\.|\s/g, ""))) BDFDB.DOMUtils.removeClass(document.querySelectorAll("." + a), a);
@ -3485,7 +3490,7 @@ var BDFDB = {
return BDFDB.ReactUtils.createElement(class BDFDBModal extends LibraryModules.React.Component {
render () {
return BDFDB.ReactUtils.createElement(LibraryComponents.ModalComponents.ModalRoot, {
className: BDFDB.DOMUtils.formatClassName(`BDFDB-modal`, name ? `${name}-modal` : null, config.selector ? config.selector : null),
className: BDFDB.DOMUtils.formatClassName(`BDFDB-modal`, name && `${name}-modal`, config.selector),
size: size || LibraryComponents.ModalComponents.ModalSize.SMALL,
transitionState: props.transitionState,
children: [
@ -5415,12 +5420,14 @@ var BDFDB = {
textareaattachbuttonplus: ["ChannelTextArea", "attachButtonPlus"],
textareabutton: ["ChannelTextAreaButton", "button"],
textareabuttonactive: ["ChannelTextAreaButton", "active"],
textareabuttonpulse: ["ChannelTextAreaButton", "pulseButton"],
textareabuttonwrapper: ["ChannelTextAreaButton", "buttonWrapper"],
textareadisabled: ["ChannelTextArea", "textAreaDisabled"],
textareaedit: ["ChannelTextArea", "textAreaEdit"],
textareaenabled: ["ChannelTextArea", "textAreaEnabled"],
textareaenablednoattach: ["ChannelTextArea", "textAreaEnabledNoAttach"],
textareaicon: ["ChannelTextAreaButton", "icon"],
textareaiconpulse: ["ChannelTextAreaButton", "pulseIcon"],
textareainner: ["ChannelTextArea", "inner"],
textareainnerautocomplete: ["ChannelTextArea", "innerAutocomplete"],
textareainnerdisabled: ["ChannelTextArea", "innerDisabled"],
@ -6056,18 +6063,57 @@ var BDFDB = {
} : LibraryComponents.BotTag;
LibraryComponents.Button = reactInitialized ? class BDFDB_Button extends LibraryModules.React.Component {
handleClick(e) {
if (typeof this.props.onClick == "function") this.props.onClick(e, this);
}
handleClick(e) {if (typeof this.props.onClick == "function") this.props.onClick(e, this);}
handleContextMenu(e) {if (typeof this.props.onContextMenu == "function") this.props.onContextMenu(e, this);}
handleMouseDown(e) {if (typeof this.props.onMouseDown == "function") this.props.onMouseDown(e, this);}
handleMouseUp(e) {if (typeof this.props.onMouseUp == "function") this.props.onMouseUp(e, this);}
handleMouseEnter(e) {if (typeof this.props.onMouseEnter == "function") this.props.onMouseEnter(e, this);}
handleMouseLeave(e) {if (typeof this.props.onMouseLeave == "function") this.props.onMouseLeave(e, this);}
render() {
return BDFDB.ReactUtils.createElement(NativeSubComponents.Button, Object.assign({}, this.props, {onClick: this.handleClick.bind(this)}));
let processingAndListening = (this.props.disabled || this.props.submitting) && (null != this.props.onMouseEnter || null != this.props.onMouseLeave);
let props = BDFDB.ObjectUtils.exclude(this.props, "look", "color", "hover", "size", "fullWidth", "grow", "disabled", "submitting", "type", "style", "wrapperClassName", "className", "innerClassName", "onClick", "onContextMenu", "onMouseDown", "onMouseUp", "onMouseEnter", "onMouseLeave", "children", "rel");
let button = BDFDB.ReactUtils.createElement("button", Object.assign({}, !this.props.disabled && !this.props.submitting && props, {
className: BDFDB.DOMUtils.formatClassName(this.props.className, BDFDB.disCN.button, this.props.look != null ? this.props.look : LibraryComponents.Button.Looks.FILLED, this.props.color != null ? this.props.color : LibraryComponents.Button.Colors.BRAND, this.props.hover, this.props.size != null ? this.props.size : LibraryComponents.Button.Sizes.MEDIUM, processingAndListening && this.props.wrapperClassName, this.props.fullWidth && BDFDB.disCN.buttonfullwidth, this.props.grow && BDFDB.disCN.buttongrow, this.props.hover && this.props.hover !== LibraryComponents.Button.Hovers.DEFAULT && BDFDB.disCN.buttonhashover, this.props.submitting && BDFDB.disCN.buttonsubmitting, this.props.disabled && BDFDB.disCN.buttondisabled),
onClick: (this.props.disabled || this.props.submitting) ? e => {return e.preventDefault();} : this.handleClick.bind(this),
onContextMenu: (this.props.disabled || this.props.submitting) ? e => {return e.preventDefault();} : this.handleContextMenu.bind(this),
onMouseUp: !this.props.disabled && this.handleMouseDown.bind(this),
onMouseDown: !this.props.disabled && this.handleMouseUp.bind(this),
onMouseEnter: this.handleMouseEnter.bind(this),
onMouseLeave: this.handleMouseLeave.bind(this),
type: this.props.type,
disabled: this.props.disabled,
style: this.props.style,
rel: this.props.rel,
children: [
this.props.submitting && !this.props.disabled ? BDFDB.ReactUtils.createElement(LibraryComponents.Spinner, {
type: LibraryComponents.Spinner.Type.PULSING_ELLIPSIS,
className: BDFDB.disCN.buttonspinner,
itemClassName: BDFDB.disCN.buttonspinneritem
}) : null,
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.buttoncontents, this.props.innerClassName),
children: this.props.children
})
]
}));
return !processingAndListening ? button : BDFDB.ReactUtils.createElement("span", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.buttondisabledwrapper, this.props.wrapperClassName, this.props.size != null ? this.props.size : LibraryComponents.Button.Sizes.MEDIUM, this.props.fullWidth && BDFDB.disCN.buttonfullwidth, this.props.grow && BDFDB.disCN.buttongrow),
children: [
button,
BDFDB.ReactUtils.createElement("span", {
onMouseEnter: this.handleMouseEnter.bind(this),
onMouseLeave: this.handleMouseLeave.bind(this),
className: BDFDB.disCN.buttondisabledoverlay
})
]
});
}
} : LibraryComponents.Button;
LibraryComponents.Card = reactInitialized ? class BDFDB_Card extends LibraryModules.React.Component {
render() {
return BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.hovercardwrapper, this.props.backdrop || this.props.backdrop === undefined ? BDFDB.disCN.hovercard : null, this.props.className),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.hovercardwrapper, (this.props.backdrop || this.props.backdrop === undefined) && BDFDB.disCN.hovercard, this.props.className),
direction: this.props.direction,
justify: this.props.justify,
align: this.props.align,
@ -6091,7 +6137,27 @@ var BDFDB = {
LibraryComponents.CardRemoveButton = BDFDB.ModuleUtils.findByName("RemoveButton");
LibraryComponents.ChannelTextAreaButton = BDFDB.ModuleUtils.findByName("ChannelTextAreaButton");
LibraryComponents.ChannelTextAreaButton = reactInitialized ? class BDFDB_ChannelTextAreaButton extends LibraryModules.React.Component {
render() {
return BDFDB.ReactUtils.createElement(LibraryComponents.Button, {
look: LibraryComponents.Button.Looks.BLANK,
size: LibraryComponents.Button.Sizes.NONE,
"aria-label": this.props.label,
tabIndex: this.props.tabIndex,
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.textareabuttonwrapper, this.props.isActive && BDFDB.disCN.textareabuttonactive),
innerClassName: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.textareabutton, this.props.className, this.props.pulse && BDFDB.disCN.textareaattachbuttonplus),
onClick: this.props.onClick,
onContextMenu: this.props.onContextMenu,
onMouseEnter: this.props.onMouseEnter,
onMouseLeave: this.props.onMouseLeave,
children: BDFDB.ReactUtils.createElement(LibraryComponents.SvgIcon, {
name: this.props.iconName,
iconSVG: this.props.iconSVG,
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.textareaicon, this.props.iconClassName, this.props.pulse && BDFDB.disCN.textareaiconpulse)
})
});
}
} : LibraryComponents.ChannelTextAreaButton;
LibraryComponents.CharCounter = reactInitialized ? class BDFDB_CharCounter extends LibraryModules.React.Component {
getCounterString() {
@ -6230,7 +6296,7 @@ var BDFDB = {
let usewhite = !BDFDB.ColorUtils.isBright(this.props.color);
return BDFDB.ReactUtils.createElement("button", {
type: "button",
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.colorpickerswatch, this.props.isDisabled ? BDFDB.disCN.colorpickerswatchdisabled : null, this.props.isSelected ? BDFDB.disCN.colorpickerswatchselected : null, this.props.isCustom ? BDFDB.disCN.colorpickerswatchcustom : null, this.props.isSingle ? BDFDB.disCN.colorpickerswatchsingle : null, this.props.color == null ? BDFDB.disCN.colorpickerswatchnocolor : null),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.colorpickerswatch, this.props.isDisabled && BDFDB.disCN.colorpickerswatchdisabled, this.props.isSelected && BDFDB.disCN.colorpickerswatchselected, this.props.isCustom && BDFDB.disCN.colorpickerswatchcustom, this.props.isSingle && BDFDB.disCN.colorpickerswatchsingle, this.props.color == null && BDFDB.disCN.colorpickerswatchnocolor),
disabled: this.props.isDisabled,
onClick: _ => {
if (!this.props.isSelected) {
@ -6289,7 +6355,7 @@ var BDFDB = {
}
render() {
return BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.colorpickerswatches, this.state.disabled ? BDFDB.disCN.colorpickerswatchesdisabled : null),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.colorpickerswatches, this.state.disabled && BDFDB.disCN.colorpickerswatchesdisabled),
number: this.props.number != null ? this.props.number : 0,
children: [
BDFDB.ReactUtils.createElement(LibraryComponents.Flex.Child, {
@ -6329,7 +6395,7 @@ var BDFDB = {
LibraryComponents.ContextMenuItem = reactInitialized ? class BDFDB_ContextMenuItem extends LibraryModules.React.Component {
render() {
return BDFDB.ReactUtils.createElement(LibraryComponents.Clickable, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.contextmenuitem, !this.props.disabled ? BDFDB.disCN.contextmenuitemclickable : null, this.props.danger ? BDFDB.disCN.contextmenuitemdanger : null, this.props.disabled ? BDFDB.disCN.contextmenuitemdisabled : null, this.props.brand ? BDFDB.disCN.contextmenuitembrand : null, this.props.className),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.contextmenuitem, !this.props.disabled && BDFDB.disCN.contextmenuitemclickable, this.props.danger && BDFDB.disCN.contextmenuitemdanger, this.props.disabled && BDFDB.disCN.contextmenuitemdisabled, this.props.brand && BDFDB.disCN.contextmenuitembrand, this.props.className),
style: this.props.style,
role: "menuitem",
onClick: this.props.disabled || typeof this.props.action != "function" ? null : this.props.action,
@ -6426,7 +6492,6 @@ var BDFDB = {
LibraryComponents.GuildComponents.Guild = reactInitialized ? class BDFDB_Guild extends LibraryModules.React.Component {
constructor(props) {
super(props);
this.state = {hovered: false};
}
handleMouseEnter(e) {
@ -6526,7 +6591,7 @@ var BDFDB = {
let childprops = Object.assign({}, this.props);
BDFDB.ObjectUtils.delete(childprops, "open");
return BDFDB.ReactUtils.createElement(LibraryComponents.Flex, Object.assign({tab:"unnamed"}, childprops, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.modaltabcontent, this.props.open ? BDFDB.disCN.modaltabcontentopen : null, this.props.className),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.modaltabcontent, this.props.open && BDFDB.disCN.modaltabcontentopen, this.props.className),
direction: LibraryComponents.Flex.Direction.VERTICAL,
align: LibraryComponents.Flex.Align.STRETCH,
style: Object.assign({}, childprops.style, {
@ -6548,7 +6613,7 @@ var BDFDB = {
let position = pos && DiscordClasses["popout" + pos] ? BDFDB.disCN["popout" + pos] : BDFDB.disCN.popouttop;
let arrow = !this.props.arrow ? BDFDB.disCN.popoutnoarrow : (pos && pos.indexOf("top") > -1 && pos != "top" ? BDFDB.disCN.popoutarrowalignmenttop : BDFDB.disCN.popoutarrowalignmentmiddle);
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.popout, position, this.props.invert && pos && pos != "bottom" ? BDFDB.disCN.popoutinvert : null, arrow, !this.props.shadow ? BDFDB.disCN.popoutnoshadow : null, this.props.className),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.popout, position, this.props.invert && pos && pos != "bottom" && BDFDB.disCN.popoutinvert, arrow, !this.props.shadow && BDFDB.disCN.popoutnoshadow, this.props.className),
id: this.props.id,
style: Object.assign({}, this.props.style, {
position: this.props.isChild ? "relative" : "absolute"
@ -6591,28 +6656,31 @@ var BDFDB = {
this.domElementRef = basepopout.domElementRef;
}
render() {
if (typeof this.props.children != "function") {
let children = this.props.children;
this.props.children = _ => {return children || BDFDB.ReactUtils.createElement("div", {style: {height: "100%", width: "100%"}});};
}
return BDFDB.ReactUtils.createElement(LibraryComponents.Clickable, {
className: this.props.className,
style: this.props.style,
onClick: e => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target)) {
if ((this.props.openOnClick || this.props.openOnClick === undefined) && typeof this.handleClick == "function") this.handleClick();
if (typeof this.props.onClick == "function") this.props.onClick(e, this);
}
else e.stopPropagation();
},
onContextMenu: e => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target)) {
if (this.props.openOnContextMenu && typeof this.handleClick == "function") this.handleClick();
if (typeof this.props.onContextMenu == "function") this.props.onContextMenu(e, this);
}
else e.stopPropagation();
},
let child = (BDFDB.ArrayUtils.is(this.props.children) ? this.props.children[0] : this.props.children) || BDFDB.ReactUtils.createElement("div", {
height: "100%",
width: "100%"
});
child.props.className = BDFDB.DOMUtils.formatClassName(child.props.className, this.props.className);
let childClick = child.props.onClick, childContextMenu = child.props.onContextMenu;
child.props.onClick = (e, childthis) => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target)) {
if ((this.props.openOnClick || this.props.openOnClick === undefined) && typeof this.handleClick == "function") this.handleClick();
if (typeof this.props.onClick == "function") this.props.onClick(e, this);
if (typeof childClick == "function") childClick(e, childthis);
}
else e.stopPropagation();
};
child.props.onContextMenu = (e, childthis) => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target)) {
if (this.props.openOnContextMenu && typeof this.handleClick == "function") this.handleClick();
if (typeof this.props.onContextMenu == "function") this.props.onContextMenu(e, this);
if (typeof childContextMenu == "function") childContextMenu(e, childthis);
}
else e.stopPropagation();
};
return BDFDB.ReactUtils.createElement(LibraryModules.React.Fragment, {
children: BDFDB.ReactUtils.createElement(NativeSubComponents.PopoutContainer, Object.assign({}, this.props, {
children: _ => {return child;},
renderPopout: this.handleRender.bind(this)
}))
});
@ -6738,7 +6806,7 @@ var BDFDB = {
});
BDFDB.ObjectUtils.delete(childprops, "id", "basis", "dividerbottom", "dividertop", "label", "labelchildren", "mini", "note", "childClassName", "childType");
return BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
className: BDFDB.DOMUtils.formatClassName(this.props.className, this.props.disabled ? BDFDB.disCN.disabled : null),
className: BDFDB.DOMUtils.formatClassName(this.props.className, this.props.disabled && BDFDB.disCN.disabled),
id: this.props.id,
direction: LibraryComponents.Flex.Direction.VERTICAL,
align: LibraryComponents.Flex.Align.STRETCH,
@ -6828,6 +6896,8 @@ var BDFDB = {
}
} : LibraryComponents.SettingsSwitch;
LibraryComponents.Spinner = BDFDB.ModuleUtils.findByName("Spinner");
LibraryComponents.SvgIcon = BDFDB.ModuleUtils.findByProperties("Gradients", "Names");
LibraryComponents.Switch = reactInitialized ? class BDFDB_Switch extends LibraryModules.React.Component {
@ -6922,7 +6992,7 @@ var BDFDB = {
}
render() {
let childprops = Object.assign({}, this.props, {
className: BDFDB.DOMUtils.formatClassName(this.props.size && LibraryComponents.TextInput.Sizes[this.props.size.toUpperCase()] && BDFDB.disCN["input" + this.props.size.toLowerCase()] || BDFDB.disCN.inputdefault, this.props.inputClassName, this.props.focused ? BDFDB.disCN.inputfocused : null, this.props.error || this.props.errorMessage ? BDFDB.disCN.inputerror : (this.props.success ? BDFDB.disCN.inputsuccess : null), this.props.disabled ? BDFDB.disCN.inputdisabled : null, this.props.editable ? BDFDB.disCN.inputeditable : null),
className: BDFDB.DOMUtils.formatClassName(this.props.size && LibraryComponents.TextInput.Sizes[this.props.size.toUpperCase()] && BDFDB.disCN["input" + this.props.size.toLowerCase()] || BDFDB.disCN.inputdefault, this.props.inputClassName, this.props.focused && BDFDB.disCN.inputfocused, this.props.error || this.props.errorMessage ? BDFDB.disCN.inputerror : (this.props.success && BDFDB.disCN.inputsuccess), this.props.disabled && BDFDB.disCN.inputdisabled, this.props.editable && BDFDB.disCN.inputeditable),
disabled: this.props.disabled,
onKeyDown: this.handleKeyDown.bind(this),
onChange: this.handleChange.bind(this),
@ -6935,7 +7005,7 @@ var BDFDB = {
});
BDFDB.ObjectUtils.delete(childprops, "errorMessage", "focused", "error", "success", "inputClassName", "inputPrefix", "size", "editable", "inputRef", "style");
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.inputwrapper, this.props.type == "number" ? (this.props.size && LibraryComponents.TextInput.Sizes[this.props.size.toUpperCase()] && BDFDB.disCN["inputnumberwrapper" + this.props.size.toLowerCase()] || BDFDB.disCN.inputnumberwrapperdefault) : null, this.props.className),
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.inputwrapper, this.props.type == "number" && (this.props.size && LibraryComponents.TextInput.Sizes[this.props.size.toUpperCase()] && BDFDB.disCN["inputnumberwrapper" + this.props.size.toLowerCase()] || BDFDB.disCN.inputnumberwrapperdefault), this.props.className),
style: this.props.style,
children: [
this.props.inputPrefix ? BDFDB.ReactUtils.createElement("span", {

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";}
getVersion () {return "1.7.6";}
getVersion () {return "1.7.7";}
getAuthor () {return "DevilBro";}
@ -11,7 +11,7 @@ class GoogleTranslateOption {
constructor () {
this.changelog = {
"improved":[["Embeds","Translating a message now also translates the embed descriptions (usually the maintext of embeds)"]]
"improved":[["Right Click","Fixed issue where right click would not quick enable/disable translating"]]
};
this.patchModules = {
@ -54,18 +54,11 @@ class GoogleTranslateOption {
color: #F04747 !important;
}
.reverse-button {
opacity: 0.5;
margin-right: 5px;
opacity: 0.2;
transition: all 200ms ease;
}
${BDFDB.dotCN.themedark} .reverse-button {
fill: #fff;
}
${BDFDB.dotCN.themelight} .reverse-button {
fill: #4f545c;
}
.reverse-button:hover {
cursor: pointer;
opacity: 1;
}
${BDFDB.dotCN.messagegroup} .GTO-translated-message ${BDFDB.dotCNS.messagebody + BDFDB.dotCN.messagemarkup},
@ -267,17 +260,6 @@ class GoogleTranslateOption {
}
}
processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) {
let optionPopoutButton = BDFDB.DOMUtils.create(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);
optionPopoutButton.addEventListener("click", () => {BDFDB.createMessageOptionPopout(optionPopoutButton);});
buttonwrap.appendChild(optionPopoutButton);
}
}
}
processMessageContent (instance, wrapper, returnvalue) {
if (instance.props && instance.props.message && instance.props.channel) {
let messagediv = BDFDB.DOMUtils.getParent(".GTO-translated-message", wrapper);
@ -295,10 +277,10 @@ class GoogleTranslateOption {
createTranslateButton () {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.PopoutContainer, {
className: BDFDB.disCN.textareapickerbuttoncontainer,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ChannelTextAreaButton, {
className: ["translate-button", this.translating ? "translating-active" : null, BDFDB.disCN.textareapickerbutton].filter(n => n).join(" "),
iconSVG: `<svg x="0" y="0" class="${BDFDB.disCN.textareaicon}" aria-hidden="false" width="22" height="22" viewBox="0 0 22 22" fill="currentColor"><path d="M 19.794, 3.299 H 9.765 L 8.797, 0 h -6.598 C 0.99, 0, 0, 0.99, 0, 2.199 V 16.495 c 0, 1.21, 0.99, 2.199, 2.199, 2.199 H 9.897 l 1.1, 3.299 H 19.794 c 1.21, 0, 2.199 -0.99, 2.199 -2.199 V 5.498 C 21.993, 4.289, 21.003, 3.299, 19.794, 3.299 z M 5.68, 13.839 c -2.48, 0 -4.492 -2.018 -4.492 -4.492 s 2.018 -4.492, 4.492 -4.492 c 1.144, 0, 2.183, 0.407, 3.008, 1.171 l 0.071, 0.071 l -1.342, 1.298 l -0.066 -0.06 c -0.313 -0.297 -0.858 -0.643 -1.671 -0.643 c -1.441, 0 -2.612, 1.193 -2.612, 2.661 c 0, 1.468, 1.171, 2.661, 2.612, 2.661 c 1.507, 0, 2.161 -0.962, 2.337 -1.606 h -2.43 v -1.704 h 4.344 l 0.016, 0.077 c 0.044, 0.231, 0.06, 0.434, 0.06, 0.665 C 10.001, 12.036, 8.225, 13.839, 5.68, 13.839 z M 11.739, 9.979 h 4.393 c 0, 0 -0.374, 1.446 -1.715, 3.008 c -0.588 -0.676 -0.995 -1.336 -1.254 -1.864 h -1.089 L 11.739, 9.979 z M 13.625, 13.839 l -0.588, 0.583 l -0.72 -2.452 C 12.685, 12.63, 13.13, 13.262, 13.625, 13.839 z M 20.893, 19.794 c 0, 0.605 -0.495, 1.1 -1.1, 1.1 H 12.096 l 2.199 -2.199 l -0.896 -3.041 l 1.012 -1.012 l 2.953, 2.953 l 0.803 -0.803 l -2.975 -2.953 c 0.99 -1.138, 1.759 -2.474, 2.106 -3.854 h 1.397 V 8.841 H 14.697 v -1.144 h -1.144 v 1.144 H 11.398 l -1.309 -4.443 H 19.794 c 0.605, 0, 1.1, 0.495, 1.1, 1.1 V 19.794 z"/></svg>`
className: BDFDB.DOMUtils.formatClassName("translate-button", this.translating && "translating-active", BDFDB.disCN.textareapickerbutton),
iconClassName: BDFDB.disCN.textareaicon,
iconSVG: `<svg x="0" y="0" aria-hidden="false" width="22" height="22" viewBox="0 0 22 22" fill="currentColor"><path d="M 19.794, 3.299 H 9.765 L 8.797, 0 h -6.598 C 0.99, 0, 0, 0.99, 0, 2.199 V 16.495 c 0, 1.21, 0.99, 2.199, 2.199, 2.199 H 9.897 l 1.1, 3.299 H 19.794 c 1.21, 0, 2.199 -0.99, 2.199 -2.199 V 5.498 C 21.993, 4.289, 21.003, 3.299, 19.794, 3.299 z M 5.68, 13.839 c -2.48, 0 -4.492 -2.018 -4.492 -4.492 s 2.018 -4.492, 4.492 -4.492 c 1.144, 0, 2.183, 0.407, 3.008, 1.171 l 0.071, 0.071 l -1.342, 1.298 l -0.066 -0.06 c -0.313 -0.297 -0.858 -0.643 -1.671 -0.643 c -1.441, 0 -2.612, 1.193 -2.612, 2.661 c 0, 1.468, 1.171, 2.661, 2.612, 2.661 c 1.507, 0, 2.161 -0.962, 2.337 -1.606 h -2.43 v -1.704 h 4.344 l 0.016, 0.077 c 0.044, 0.231, 0.06, 0.434, 0.06, 0.665 C 10.001, 12.036, 8.225, 13.839, 5.68, 13.839 z M 11.739, 9.979 h 4.393 c 0, 0 -0.374, 1.446 -1.715, 3.008 c -0.588 -0.676 -0.995 -1.336 -1.254 -1.864 h -1.089 L 11.739, 9.979 z M 13.625, 13.839 l -0.588, 0.583 l -0.72 -2.452 C 12.685, 12.63, 13.13, 13.262, 13.625, 13.839 z M 20.893, 19.794 c 0, 0.605 -0.495, 1.1 -1.1, 1.1 H 12.096 l 2.199 -2.199 l -0.896 -3.041 l 1.012 -1.012 l 2.953, 2.953 l 0.803 -0.803 l -2.975 -2.953 c 0.99 -1.138, 1.759 -2.474, 2.106 -3.854 h 1.397 V 8.841 H 14.697 v -1.144 h -1.144 v 1.144 H 11.398 l -1.309 -4.443 H 19.794 c 0.605, 0, 1.1, 0.495, 1.1, 1.1 V 19.794 z"/></svg>`
}),
width: 400,
padding: 10,
@ -306,23 +288,23 @@ class GoogleTranslateOption {
position: BDFDB.LibraryComponents.PopoutContainer.Positions.TOP,
align: BDFDB.LibraryComponents.PopoutContainer.Align.RIGHT,
onClose: instance => {
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"ChannelTextAreaButton"});
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_ChannelTextAreaButton"});
if (channelTextareaButtonIns) {
channelTextareaButtonIns.props.isActive = false;
BDFDB.ReactUtils.forceUpdate(channelTextareaButtonIns);
}
},
onContextMenu: instance => {
onContextMenu: (e, instance) => {
this.translating = !this.translating;
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"ChannelTextAreaButton"});
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_ChannelTextAreaButton"});
if (channelTextareaButtonIns) {
channelTextareaButtonIns.props.className = ["translate-button", this.translating ? "translating-active" : null, BDFDB.disCN.textareapickerbutton].filter(n => n).join(" ");
channelTextareaButtonIns.props.className = BDFDB.DOMUtils.formatClassName("translate-button", this.translating && "translating-active", BDFDB.disCN.textareapickerbutton);
BDFDB.ReactUtils.forceUpdate(channelTextareaButtonIns);
instance.close();
}
},
renderPopout: instance => {
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"ChannelTextAreaButton"});
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_ChannelTextAreaButton"});
if (channelTextareaButtonIns) {
channelTextareaButtonIns.props.isActive = true;
BDFDB.ReactUtils.forceUpdate(channelTextareaButtonIns);