This commit is contained in:
Mirco Wittrien 2020-05-22 20:47:25 +02:00
parent bf58dd0e04
commit 53635b8296
3 changed files with 13 additions and 13 deletions

View File

@ -6484,6 +6484,7 @@
`${string.length}${!this.props.max ? "" : "/" + this.props.max}${!select ? "" : " (" + select + ")"}`,
typeof this.props.renderSuffix == "function" && this.props.renderSuffix(string.length)
].filter(n => n);
if (typeof this.props.onChange == "function") this.props.onChange(this);
return children.length == 1 ? children[0] : BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
align: InternalComponents.LibraryComponents.Flex.Align.CENTER,
children: children
@ -6497,7 +6498,6 @@
forceUpdateCounter() {
if (!this.refElement) return;
this.props.children = this.getCounterString();
if (typeof this.props.onChange == "function") this.props.onChange(this);
BDFDB.ReactUtils.forceUpdate(this);
}
handleSelection() {

File diff suppressed because one or more lines are too long

View File

@ -13,18 +13,13 @@ var CharCounter = (_ => {
return class CharCounter {
getName () {return "CharCounter";}
getVersion () {return "1.4.6";}
getVersion () {return "1.4.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a charcounter in the chat.";}
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"]]
};
this.patchedModules = {
after: {
ChannelTextAreaContainer: "render",
@ -36,9 +31,6 @@ var CharCounter = (_ => {
initConstructor () {
this.css = `
${BDFDB.dotCNS.typing + BDFDB.dotCN.typingcooldownwrapper} {
margin-right: 64px;
}
${BDFDB.dotCN._charcountercounteradded} {
position: relative !important;
}
@ -151,12 +143,20 @@ var CharCounter = (_ => {
injectCounter (parent, children, type, refClass, parsing) {
if (!children) return;
parent.props.className = ((parent.props.className || "") + " " + BDFDB.disCN._charcountercounteradded).trim();
parent.props.className = BDFDB.DOMUtils.formatClassName(parent.props.className, BDFDB.disCN._charcountercounteradded);
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CharCounter, {
className: `${BDFDB.disCN._charcountercounter} ${type}`,
refClass: refClass,
parsing: parsing,
max: maxLenghts[type]
max: maxLenghts[type],
onChange: instance => {
let node = BDFDB.ReactUtils.findDOMNode(instance);
let form = node && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, node);
if (form) {
let typing = form.querySelector(BDFDB.dotCN.typing);
if (typing) typing.style.setProperty("margin-right", `${BDFDB.DOMUtils.getWidth(node) + 10}px`);
}
}
}));
}
}