lib
This commit is contained in:
parent
dfe8d32262
commit
a932afa628
|
@ -5489,14 +5489,13 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
||||||
LibraryComponents.ChannelTextAreaButton = BDFDB.ModuleUtils.findByName("ChannelTextAreaButton");
|
LibraryComponents.ChannelTextAreaButton = BDFDB.ModuleUtils.findByName("ChannelTextAreaButton");
|
||||||
|
|
||||||
LibraryComponents.CharCounter = reactInitialized ? class BDFDB_CharCounter extends LibraryModules.React.Component {
|
LibraryComponents.CharCounter = reactInitialized ? class BDFDB_CharCounter extends LibraryModules.React.Component {
|
||||||
updateCounter(e) {
|
updateCounter(e = {string:"", start:0, end:0}) {
|
||||||
clearTimeout(this.updateTimeout);
|
clearTimeout(this.updateTimeout);
|
||||||
this.updateTimeout = setTimeout(() => {
|
this.updateTimeout = setTimeout(() => {
|
||||||
delete this.updateTimeout;
|
delete this.updateTimeout;
|
||||||
let string = e.string || "", start = e.start || 0, end = e.end || 0;
|
let length = this.props.parsing ? BDFDB.StringUtils.getParsedLength(e.string) : e.string.length;
|
||||||
let length = this.props.parsing ? BDFDB.StringUtils.getParsedLength(string) : string.length;
|
let select = e.end - e.start == 0 ? 0 : (this.props.parsing ? BDFDB.StringUtils.getParsedLength(e.string.slice(e.start, e.end)) : (e.end - e.start));
|
||||||
let select = end - start == 0 ? 0 : (this.props.parsing ? BDFDB.StringUtils.getParsedLength(string.slice(start, end)) : (end - start));
|
select = !select ? 0 : (select > length ? length - (length - e.end - e.start) : select);
|
||||||
select = !select ? 0 : (select > length ? length - (length - end - start) : select);
|
|
||||||
this.props.children = `${length}${!this.props.max ? "" : "/" + this.props.max}${!select ? "" : " (" + select + ")"}`;
|
this.props.children = `${length}${!this.props.max ? "" : "/" + this.props.max}${!select ? "" : " (" + select + ")"}`;
|
||||||
BDFDB.ReactUtils.forceUpdate(this);
|
BDFDB.ReactUtils.forceUpdate(this);
|
||||||
}, 100);
|
}, 100);
|
||||||
|
@ -5512,7 +5511,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
|
||||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.charcounter, this.props.className),
|
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.charcounter, this.props.className),
|
||||||
color: LibraryComponents.TextElement.Colors.PRIMARY
|
color: LibraryComponents.TextElement.Colors.PRIMARY
|
||||||
});
|
});
|
||||||
BDFDB.ObjectUtils.delete(props, "parsing", "start", "end", "string", "max");
|
BDFDB.ObjectUtils.delete(props, "parsing", "max");
|
||||||
return BDFDB.ReactUtils.createElement(LibraryComponents.TextElement, props);
|
return BDFDB.ReactUtils.createElement(LibraryComponents.TextElement, props);
|
||||||
}
|
}
|
||||||
}: LibraryComponents.CharCounter;
|
}: LibraryComponents.CharCounter;
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue