From 09194d6545cea3a330169289d0b728d9d395cb42 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien <23700969+mwittrien@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:52:01 +0200 Subject: [PATCH] stuff --- Library/0BDFDB.plugin.js | 26 ++++++------------- Library/_res/0BDFDB.data.json | 4 ++- Plugins/ChatAliases/ChatAliases.plugin.js | 13 +++------- .../MessageUtilities.plugin.js | 6 ++--- Plugins/SpellCheck/SpellCheck.plugin.js | 8 +++--- .../WriteUpperCase/WriteUpperCase.plugin.js | 21 ++++++++------- Themes/DiscordRecolor/DiscordRecolor.css | 1 + 7 files changed, 35 insertions(+), 44 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 4e4e4281fd..18436a1e44 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -2,7 +2,7 @@ * @name BDFDB * @author DevilBro * @authorId 278543574059057154 - * @version 2.2.4 + * @version 2.2.5 * @description Required Library for DevilBro's Plugins * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -19,14 +19,8 @@ module.exports = (_ => { "info": { "name": "BDFDB", "author": "DevilBro", - "version": "2.2.4", + "version": "2.2.5", "description": "Required Library for DevilBro's Plugins" - }, - "rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`, - "changeLog": { - "improved": { - "Toast Performance": "Increased Performance, by switching to css animation instead of discord internal animations" - } } }; @@ -4233,17 +4227,13 @@ module.exports = (_ => { BDFDB.SlateUtils = {}; BDFDB.SlateUtils.isRichValue = function (richValue) { - return BDFDB.ObjectUtils.is(richValue) && Internal.LibraryModules.SlateUtils.deserialize("").constructor.prototype.isPrototypeOf(richValue); + return richValue && typeof richValue == "object" && BDFDB.SlateUtils.toRichValue("").constructor.prototype.isPrototypeOf(richValue); }; - BDFDB.SlateUtils.copyRichValue = function (string, richValue) { - let newRichValue = Internal.LibraryModules.SlateUtils.deserialize(string); - if (BDFDB.SlateUtils.isRichValue(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.SlateUtils.toTextValue = function (richValue) { + return BDFDB.SlateUtils.isRichValue(richValue) ? Internal.LibraryModules.SlateTextUtils.toTextValue(richValue) : ""; + }; + BDFDB.SlateUtils.toRichValue = function (string) { + return typeof string == "string" ? Internal.LibraryModules.SlateRichUtils.toRichValue(string) : null; }; BDFDB.NumberUtils = {}; diff --git a/Library/_res/0BDFDB.data.json b/Library/_res/0BDFDB.data.json index 8f08825d63..8343aa8cf7 100644 --- a/Library/_res/0BDFDB.data.json +++ b/Library/_res/0BDFDB.data.json @@ -115,7 +115,9 @@ "SettingsUtilsOld": {"props": ["updateLocalSettings", "updateRemoteSettings"]}, "SimpleMarkdownComponents": {"strings": ["customEmoji", "emojiTooltipPosition", "timestampTooltip"]}, "SimpleMarkdownParser": {"props": ["parseBlock", "parseInline", "defaultOutput"]}, - "SlateUtils": {"props": ["serialize", "deserialize"], "nonProps": ["getFlag"]}, + "SlateDraftUtils": {"props": ["getRecentlyEditedDrafts", "getDraft"]}, + "SlateRichUtils": {"props": ["toRichValue", "createEmptyState"]}, + "SlateTextUtils": {"props": ["toTextValue", "serializeDescendant"]}, "SlateSelectionUtils": {"props": ["serialize", "serializeSelection"]}, "SlowmodeUtils": {"props": ["getSlowmodeCooldownGuess"]}, "SoundParser": {"strings": ["discodo", "ddr-down", "mute"]}, diff --git a/Plugins/ChatAliases/ChatAliases.plugin.js b/Plugins/ChatAliases/ChatAliases.plugin.js index 9315e6f1ea..7101930b31 100644 --- a/Plugins/ChatAliases/ChatAliases.plugin.js +++ b/Plugins/ChatAliases/ChatAliases.plugin.js @@ -2,7 +2,7 @@ * @name ChatAliases * @author DevilBro * @authorId 278543574059057154 - * @version 2.3.3 + * @version 2.3.4 * @description Allows you to configure your own Aliases/Commands * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,13 +17,8 @@ module.exports = (_ => { "info": { "name": "ChatAliases", "author": "DevilBro", - "version": "2.3.3", + "version": "2.3.4", "description": "Allows you to configure your own Aliases/Commands" - }, - "changeLog": { - "improved": { - "Threads": "Works flawlessly with Threads now" - } } }; @@ -406,10 +401,10 @@ module.exports = (_ => { if (messageData.text != null && e2.methodArguments[textIndex] != messageData.text) { e2.methodArguments[textIndex] = messageData.text; e.instance.props.textValue = ""; - if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.SlateUtils.copyRichValue("", e.instance.props.richValue); + if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.SlateUtils.toRichValue(""); if (e.instance.state) { e.instance.state.textValue = ""; - if (e.instance.state.richValue) e.instance.state.richValue = BDFDB.SlateUtils.copyRichValue("", e.instance.state.richValue); + if (e.instance.state.richValue) e.instance.state.richValue = BDFDB.SlateUtils.toRichValue(""); } BDFDB.ReactUtils.forceUpdate(e.instance); } diff --git a/Plugins/MessageUtilities/MessageUtilities.plugin.js b/Plugins/MessageUtilities/MessageUtilities.plugin.js index 14b0732cf3..3efb7cd721 100644 --- a/Plugins/MessageUtilities/MessageUtilities.plugin.js +++ b/Plugins/MessageUtilities/MessageUtilities.plugin.js @@ -2,7 +2,7 @@ * @name MessageUtilities * @author DevilBro * @authorId 278543574059057154 - * @version 1.9.2 + * @version 1.9.3 * @description Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.) * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,7 +17,7 @@ module.exports = (_ => { "info": { "name": "MessageUtilities", "author": "DevilBro", - "version": "1.9.2", + "version": "1.9.3", "description": "Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.)" } }; @@ -335,7 +335,7 @@ module.exports = (_ => { let type = event.type; if (!firedEvents.includes(type)) { if (event.which == 27 && settings.clearOnEscape && ChannelTextAreaForm) { - ChannelTextAreaForm.setState({textValue: "", richValue: BDFDB.LibraryModules.SlateUtils.deserialize("")}); + ChannelTextAreaForm.setState({textValue: "", richValue: BDFDB.SlateUtils.toRichValue("")}); } BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, type, true)}); } diff --git a/Plugins/SpellCheck/SpellCheck.plugin.js b/Plugins/SpellCheck/SpellCheck.plugin.js index 0e185cd458..c7a0fc4b7f 100644 --- a/Plugins/SpellCheck/SpellCheck.plugin.js +++ b/Plugins/SpellCheck/SpellCheck.plugin.js @@ -2,7 +2,7 @@ * @name SpellCheck * @author DevilBro * @authorId 278543574059057154 - * @version 1.5.8 + * @version 1.5.9 * @description Adds a Spell Check to all Message Inputs. Select a Word and Right Click it to add it to your Dictionary * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,7 +17,7 @@ module.exports = (_ => { "info": { "name": "SpellCheck", "author": "DevilBro", - "version": "1.5.8", + "version": "1.5.9", "description": "Adds a Spell Check to all Message Inputs. Select a Word and Right Click it to add it to your Dictionary" } }; @@ -249,7 +249,7 @@ module.exports = (_ => { } processSlateChannelTextArea (e) { - let newText = BDFDB.LibraryModules.SlateUtils.serialize(e.instance.props.value); + let newText = BDFDB.SlateUtils.toTextValue(e.instance.props.value); if (newText != currentText) { currentText = newText; BDFDB.DOMUtils.remove(e.node.parentElement.querySelectorAll(BDFDB.dotCN._spellcheckoverlay)); @@ -314,7 +314,7 @@ module.exports = (_ => { } else newString.push(word + (hasNewline ? "\n" : "")); }); - editor.setValue(BDFDB.SlateUtils.copyRichValue(newString.join(" ").replace(/\n /g, "\n"), editor.props.value)); + editor.setValue(BDFDB.SlateUtils.toRichValue(newString.join(" ").replace(/\n /g, "\n"))); } addToOwnDictionary (word) { diff --git a/Plugins/WriteUpperCase/WriteUpperCase.plugin.js b/Plugins/WriteUpperCase/WriteUpperCase.plugin.js index dac542feef..8f4c779d75 100644 --- a/Plugins/WriteUpperCase/WriteUpperCase.plugin.js +++ b/Plugins/WriteUpperCase/WriteUpperCase.plugin.js @@ -2,7 +2,7 @@ * @name WriteUpperCase * @author DevilBro * @authorId 278543574059057154 - * @version 1.3.4 + * @version 1.3.5 * @description Changes the first Letter of each Sentence in Message Inputs to Uppercase * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,13 +17,8 @@ module.exports = (_ => { "info": { "name": "WriteUpperCase", "author": "DevilBro", - "version": "1.3.4", + "version": "1.3.5", "description": "Changes the first Letter of each Sentence in Message Inputs to Uppercase" - }, - "changeLog": { - "added": { - "QuickMessage": "Now also works for the quick message input in the user popout" - } } }; @@ -178,8 +173,16 @@ module.exports = (_ => { let string = e.instance.props.textValue; let newString = this.parse(string); if (string != newString) { - e.instance.props.textValue = newString; - if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.SlateUtils.copyRichValue(newString, e.instance.props.richValue); + let selection = document.getSelection(); + let container = selection.anchorNode && BDFDB.DOMUtils.getParent("[contenteditable]", selection.anchorNode.parentElement); + if (container && Array.from(container.children).findIndex(n => n && n.contains(selection.anchorNode)) == (container.childElementCount - 1)) { + selection.modify("extend", "backward", "paragraphboundary"); + if (selection.toString().length == selection.anchorNode.textContent.length) { + e.instance.props.textValue = newString; + if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.SlateUtils.toRichValue(newString); + } + selection.collapseToEnd(); + } } } } diff --git a/Themes/DiscordRecolor/DiscordRecolor.css b/Themes/DiscordRecolor/DiscordRecolor.css index 0ed7d4e621..0322032e32 100644 --- a/Themes/DiscordRecolor/DiscordRecolor.css +++ b/Themes/DiscordRecolor/DiscordRecolor.css @@ -87,6 +87,7 @@ --focus-primary: rgb(var(--linkcolor)); --guild-header-text-shadow: 0 1px 1px rgba(var(--backgroundfloating),.5); --channeltextarea-background: rgba(var(--backgroundaccent),.8); + --input-background: rgba(0,0,0,.1); --activity-card-background: rgb(var(--backgroundtertiary)); --textbox-markdown-syntax: rgb(var(--textdark)); --deprecated-card-bg: rgba(var(--backgroundtertiary),.6);