fixes
This commit is contained in:
parent
fc2ef62398
commit
036693d6fa
|
@ -24,17 +24,17 @@
|
|||
BDFDB.LogUtils.log = function (string, name) {
|
||||
if (typeof string != "string") string = "";
|
||||
if (typeof name != "string" || name == "$BDFDB") name = "BDFDB";
|
||||
console.log(`%c[${name}]%c`, "color: #3a71c1; font-weight: 700;", "", string.trim());
|
||||
console.log(`%c[${name}]`, "color: #3a71c1; font-weight: 700;", string.trim());
|
||||
};
|
||||
BDFDB.LogUtils.warn = function (string, name) {
|
||||
if (typeof string != "string") string = "";
|
||||
if (typeof name != "string" || name == "$BDFDB") name = "BDFDB";
|
||||
console.warn(`%c[${name}]%c`, "color: #3a71c1; font-weight: 700;", "", string.trim());
|
||||
console.warn(`%c[${name}]`, "color: #3a71c1; font-weight: 700;", string.trim());
|
||||
};
|
||||
BDFDB.LogUtils.error = function (string, name) {
|
||||
if (typeof string != "string") string = "";
|
||||
if (typeof name != "string" || name == "$BDFDB") name = "BDFDB";
|
||||
console.error(`%c[${name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: " + string.trim());
|
||||
console.error(`%c[${name}]`, "color: #3a71c1; font-weight: 700;", "Fatal Error: " + string.trim());
|
||||
};
|
||||
|
||||
BDFDB.LogUtils.log("Loading library.");
|
||||
|
@ -3890,6 +3890,16 @@
|
|||
var length = (!channel || string.indexOf("/") == 0 || string.indexOf("s/") == 0 || string.indexOf("+:") == 0) ? string.length : LibraryModules.MessageCreationUtils.parse(channel, string).content.length;
|
||||
return length > string.length ? length : string.length;
|
||||
};
|
||||
BDFDB.StringUtils.copyRichValue = function (string, richValue) {
|
||||
let newRichValue = LibraryModules.SlateUtils.deserialize(string);
|
||||
if (richValue && richValue._map && richValue._map._root && BDFDB.ArrayUtils.is(richValue._map._root.entries)) {
|
||||
for (let i in richValue._map._root.entries) if (richValue._map._root.entries[i][0] == "selection") {
|
||||
newRichValue._map._root.entries[i] = richValue._map._root.entries[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return newRichValue;
|
||||
};
|
||||
BDFDB.StringUtils.highlight = function (string, searchstring, prefix = `<span class="${BDFDB.disCN.highlight}">`, suffix = `</span>`) {
|
||||
if (typeof string != "string" || !searchstring || searchstring.length < 1) return string;
|
||||
var offset = 0, original = string;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
|||
class WriteUpperCase {
|
||||
getName () {return "WriteUpperCase";}
|
||||
|
||||
getVersion () {return "1.2.2";}
|
||||
getVersion () {return "1.2.3";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,12 +11,13 @@ class WriteUpperCase {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"fixed":[["New WYSIWYG Textarea","Fixed for the new WYSIWYG Textarea that is hidden by experiments"]],
|
||||
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
after: {
|
||||
ChannelTextArea: "componentDidMount"
|
||||
before: {
|
||||
ChannelTextArea: "render"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -66,30 +67,18 @@ class WriteUpperCase {
|
|||
// begin of own functions
|
||||
|
||||
processChannelTextArea (e) {
|
||||
if (e.instance.props.type) {
|
||||
var textarea = e.node.querySelector("textarea");
|
||||
if (!textarea) return;
|
||||
BDFDB.ListenerUtils.add(this, textarea, "keyup", () => {
|
||||
BDFDB.TimeUtils.clear(textarea.WriteUpperCaseTimeout);
|
||||
textarea.WriteUpperCaseTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
let string = textarea.value;
|
||||
if (string.length > 0) {
|
||||
let newstring = string;
|
||||
let first = string.charAt(0);
|
||||
let position = textarea.selectionStart;
|
||||
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) newstring = string.charAt(0).toLowerCase() + string.slice(1);
|
||||
else if (first === first.toLowerCase() && first !== first.toUpperCase() && string.toLowerCase().indexOf("http") != 0 && string.toLowerCase().indexOf("s/") != 0) newstring = string.charAt(0).toUpperCase() + string.slice(1);
|
||||
if (string != newstring) {
|
||||
textarea.focus();
|
||||
textarea.selectionStart = 0;
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
document.execCommand("insertText", false, newstring);
|
||||
textarea.selectionStart = position;
|
||||
textarea.selectionEnd = position;
|
||||
}
|
||||
}
|
||||
},1);
|
||||
});
|
||||
if (e.instance.props.type && e.instance.props.textValue && e.instance.state.focused) {
|
||||
let string = e.instance.props.textValue;
|
||||
if (string.length > 0) {
|
||||
let newstring = string;
|
||||
let first = string.charAt(0);
|
||||
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) newstring = string.charAt(0).toLowerCase() + string.slice(1);
|
||||
else if (first === first.toLowerCase() && first !== first.toUpperCase() && string.toLowerCase().indexOf("http") != 0 && string.toLowerCase().indexOf("s/") != 0) newstring = string.charAt(0).toUpperCase() + string.slice(1);
|
||||
if (string != newstring) {
|
||||
e.instance.props.textValue = newstring;
|
||||
if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.StringUtils.copyRichValue(newstring, e.instance.props.richValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue