BetterDiscordAddons
BetterDiscordAddons copied to clipboard
[Bug] BetterFormatting not doing anything
Which plugin/theme is this about? BetterFormattingRedux
Describe the Bug I type something in the chat, then try to format the message and nothing happens.
To Reproduce Type something in the chat, click on the formatting button and select any formatting.
Expected Behavior The plugin should format the message as expected.
Discord Version Fluent Discord 1.1.3 Stable 122087 (5c6d04c) BetterDiscord 1.5.2 Host 1.0.9004 Windows 10 64-Bit (10.0.19043)
I've tried turning off the theme. That changed nothing. Then I thought I could reinstall the plugin, also nothing.
Toolbar buttons ain't working anymore
the wrappers from the options still work (==
for varied text, frex), but the toolbar buttons no longer work.
same here
same issue here
I've tried everything, but nothing ever happens. Nearly embarrassed myself just now while trying to mock someone with varied text 😵
yup same not working
The plugin needs an update since Discord has made a lot of changes in the past week
Quick Fix for the buttons not working:
line: 511
Old:
async wrapSelection(leftWrapper, rightWrapper) {
if (!rightWrapper) rightWrapper = leftWrapper;
if (leftWrapper.startsWith("```")) leftWrapper = leftWrapper + "\n";
if (rightWrapper.startsWith("```")) rightWrapper = "\n" + rightWrapper;
const textarea = document.querySelector(DiscordSelectors.Textarea.textArea);
if (!textarea) return;
if (textarea.tagName === "TEXTAREA") return this.oldWrapSelection(textarea, leftWrapper, rightWrapper);
const slateEditor = Utilities.findInTree(ReactTools.getReactInstance(textarea), e => e && e.wrapText, { walkable: ["return", "stateNode", "editorRef"] });
if (!slateEditor) return;
return slateEditor.wrapText(leftWrapper, rightWrapper);
}
New:
async wrapSelection(leftWrapper, rightWrapper) {
if (!rightWrapper) rightWrapper = leftWrapper;
if (leftWrapper.startsWith("```")) leftWrapper = leftWrapper + "\n";
if (rightWrapper.startsWith("```")) rightWrapper = "\n" + rightWrapper;
const textarea = document.querySelector(DiscordSelectors.Textarea.textArea);
if (!textarea) return;
if (textarea.tagName === "TEXTAREA") return this.oldWrapSelection(textarea, leftWrapper, rightWrapper);
const { Transforms } = BdApi.findModuleByProps('Transforms');
const slate = ReactTools.getOwnerInstance(textarea).ref.current.getSlateEditor();
let selection = JSON.parse(JSON.stringify(slate.selection));
Transforms.insertText(slate,leftWrapper,{at:slate.selection.anchor});
Transforms.insertText(slate,rightWrapper,{at:slate.selection.focus});
selection.anchor.offset += 2;
selection.focus.offset += 2;
Transforms.select(slate,selection);
return 1; // promise mem leak prevention.
}
EDIT: I've updated the snippet to wrap the selection, if nothing is selected it will add the wrappers to the end of the text with the middle focused so you can just start typing after clicking the button.
That code snippet update has fixed it! However, it no longer places the symbols around text that I select and puts it on the beginning and the end of the message only. Is there anything that can be done for that?
Thank you for fixing the snippet, it works 100% now.
New code seems to work! Much appreciated!
It sucks, knowing that almost all plugins I'm using got abandoned.
Anyway the snippet works just fine, thanks.
Quick Fix for the buttons not working:
line: 511
Old:
async wrapSelection(leftWrapper, rightWrapper) { if (!rightWrapper) rightWrapper = leftWrapper; if (leftWrapper.startsWith("```")) leftWrapper = leftWrapper + "\n"; if (rightWrapper.startsWith("```")) rightWrapper = "\n" + rightWrapper; const textarea = document.querySelector(DiscordSelectors.Textarea.textArea); if (!textarea) return; if (textarea.tagName === "TEXTAREA") return this.oldWrapSelection(textarea, leftWrapper, rightWrapper); const slateEditor = Utilities.findInTree(ReactTools.getReactInstance(textarea), e => e && e.wrapText, { walkable: ["return", "stateNode", "editorRef"] }); if (!slateEditor) return; return slateEditor.wrapText(leftWrapper, rightWrapper); }
New:
async wrapSelection(leftWrapper, rightWrapper) { if (!rightWrapper) rightWrapper = leftWrapper; if (leftWrapper.startsWith("```")) leftWrapper = leftWrapper + "\n"; if (rightWrapper.startsWith("```")) rightWrapper = "\n" + rightWrapper; const textarea = document.querySelector(DiscordSelectors.Textarea.textArea); if (!textarea) return; if (textarea.tagName === "TEXTAREA") return this.oldWrapSelection(textarea, leftWrapper, rightWrapper); const { Transforms } = BdApi.findModuleByProps('Transforms'); const slate = ReactTools.getOwnerInstance(textarea).ref.current.getSlateEditor(); let selection = JSON.parse(JSON.stringify(slate.selection)); Transforms.insertText(slate,leftWrapper,{at:slate.selection.anchor}); Transforms.insertText(slate,rightWrapper,{at:slate.selection.focus}); selection.anchor.offset += 2; selection.focus.offset += 2; Transforms.select(slate,selection); return 1; // promise mem leak prevention. }
EDIT: I've updated the snippet to wrap the selection, if nothing is selected it will add the wrappers to the end of the text with the middle focused so you can just start typing after clicking the button.
I've tried to follow this, it didn't work for me, maybe I was doing it wrong, can someone tell me how to do it that would be very appreciated.
NVM, it somehow worked after BFDB got updated
Excellent! I was digging for a fix and this worked perfectly! Thank you
Thank you @BadScribbles I used yours as a reference and made some minor improvements on it!