fixes
This commit is contained in:
parent
fc2ef62398
commit
036693d6fa
|
@ -24,17 +24,17 @@
|
||||||
BDFDB.LogUtils.log = function (string, name) {
|
BDFDB.LogUtils.log = function (string, name) {
|
||||||
if (typeof string != "string") string = "";
|
if (typeof string != "string") string = "";
|
||||||
if (typeof name != "string" || name == "$BDFDB") name = "BDFDB";
|
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) {
|
BDFDB.LogUtils.warn = function (string, name) {
|
||||||
if (typeof string != "string") string = "";
|
if (typeof string != "string") string = "";
|
||||||
if (typeof name != "string" || name == "$BDFDB") name = "BDFDB";
|
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) {
|
BDFDB.LogUtils.error = function (string, name) {
|
||||||
if (typeof string != "string") string = "";
|
if (typeof string != "string") string = "";
|
||||||
if (typeof name != "string" || name == "$BDFDB") name = "BDFDB";
|
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.");
|
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;
|
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;
|
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>`) {
|
BDFDB.StringUtils.highlight = function (string, searchstring, prefix = `<span class="${BDFDB.disCN.highlight}">`, suffix = `</span>`) {
|
||||||
if (typeof string != "string" || !searchstring || searchstring.length < 1) return string;
|
if (typeof string != "string" || !searchstring || searchstring.length < 1) return string;
|
||||||
var offset = 0, original = string;
|
var offset = 0, original = string;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
||||||
class WriteUpperCase {
|
class WriteUpperCase {
|
||||||
getName () {return "WriteUpperCase";}
|
getName () {return "WriteUpperCase";}
|
||||||
|
|
||||||
getVersion () {return "1.2.2";}
|
getVersion () {return "1.2.3";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,12 +11,13 @@ class WriteUpperCase {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
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"]]
|
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.patchedModules = {
|
||||||
after: {
|
before: {
|
||||||
ChannelTextArea: "componentDidMount"
|
ChannelTextArea: "render"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -66,30 +67,18 @@ class WriteUpperCase {
|
||||||
// begin of own functions
|
// begin of own functions
|
||||||
|
|
||||||
processChannelTextArea (e) {
|
processChannelTextArea (e) {
|
||||||
if (e.instance.props.type) {
|
if (e.instance.props.type && e.instance.props.textValue && e.instance.state.focused) {
|
||||||
var textarea = e.node.querySelector("textarea");
|
let string = e.instance.props.textValue;
|
||||||
if (!textarea) return;
|
if (string.length > 0) {
|
||||||
BDFDB.ListenerUtils.add(this, textarea, "keyup", () => {
|
let newstring = string;
|
||||||
BDFDB.TimeUtils.clear(textarea.WriteUpperCaseTimeout);
|
let first = string.charAt(0);
|
||||||
textarea.WriteUpperCaseTimeout = BDFDB.TimeUtils.timeout(() => {
|
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) newstring = string.charAt(0).toLowerCase() + string.slice(1);
|
||||||
let string = textarea.value;
|
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.length > 0) {
|
if (string != newstring) {
|
||||||
let newstring = string;
|
e.instance.props.textValue = newstring;
|
||||||
let first = string.charAt(0);
|
if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.StringUtils.copyRichValue(newstring, e.instance.props.richValue);
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue