fixes
This commit is contained in:
parent
7e3df688b1
commit
b9e29942d9
|
@ -5162,8 +5162,6 @@ module.exports = (_ => {
|
|||
};
|
||||
|
||||
CustomComponents.Checkbox = reactInitialized && class BDFDB_Checkbox extends Internal.LibraryModules.React.Component {
|
||||
handleClick(e) {if (typeof this.props.onClick == "function") this.props.onClick(e, this);}
|
||||
handleContextMenu(e) {if (typeof this.props.onContextMenu == "function") this.props.onContextMenu(e, this);}
|
||||
handleMouseDown(e) {if (typeof this.props.onMouseDown == "function") this.props.onMouseDown(e, this);}
|
||||
handleMouseUp(e) {if (typeof this.props.onMouseUp == "function") this.props.onMouseUp(e, this);}
|
||||
handleMouseEnter(e) {if (typeof this.props.onMouseEnter == "function") this.props.onMouseEnter(e, this);}
|
||||
|
@ -5217,6 +5215,10 @@ module.exports = (_ => {
|
|||
type: "checkbox",
|
||||
onClick: this.props.disabled || this.props.readOnly ? (_ => {}) : this.handleChange.bind(this),
|
||||
onContextMenu: this.props.disabled || this.props.readOnly ? (_ => {}) : this.handleChange.bind(this),
|
||||
onMouseUp: !this.props.disabled && this.handleMouseDown.bind(this),
|
||||
onMouseDown: !this.props.disabled && this.handleMouseUp.bind(this),
|
||||
onMouseEnter: !this.props.disabled && this.handleMouseEnter.bind(this),
|
||||
onMouseLeave: !this.props.disabled && this.handleMouseLeave.bind(this),
|
||||
checked: this.props.value,
|
||||
style: {
|
||||
width: this.props.size,
|
||||
|
@ -7242,17 +7244,20 @@ module.exports = (_ => {
|
|||
},
|
||||
children: this.props.settings.map(setting => BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.checkboxcontainer,
|
||||
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.Checkbox, {
|
||||
disabled: props.disabled,
|
||||
cardId: props.key,
|
||||
settingId: setting,
|
||||
shape: Internal.LibraryComponents.Checkbox.Shapes && Internal.LibraryComponents.Checkbox.Shapes.ROUND,
|
||||
type: Internal.LibraryComponents.Checkbox.Types && Internal.LibraryComponents.Checkbox.Types.INVERTED,
|
||||
color: this.props.checkboxColor,
|
||||
getColor: this.props.getCheckboxColor,
|
||||
value: props[setting],
|
||||
getValue: this.props.getCheckboxValue,
|
||||
onChange: this.props.onCheckboxChange
|
||||
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.TooltipContainer, {
|
||||
text: setting,
|
||||
children: BDFDB.ReactUtils.createElement(Internal.LibraryComponents.Checkbox, {
|
||||
disabled: props.disabled,
|
||||
cardId: props.key,
|
||||
settingId: setting,
|
||||
shape: Internal.LibraryComponents.Checkbox.Shapes && Internal.LibraryComponents.Checkbox.Shapes.ROUND,
|
||||
type: Internal.LibraryComponents.Checkbox.Types && Internal.LibraryComponents.Checkbox.Types.INVERTED,
|
||||
color: this.props.checkboxColor,
|
||||
getColor: this.props.getCheckboxColor,
|
||||
value: props[setting],
|
||||
getValue: this.props.getCheckboxValue,
|
||||
onChange: this.props.onCheckboxChange
|
||||
})
|
||||
})
|
||||
})).flat(10).filter(n => n)
|
||||
})
|
||||
|
@ -7919,6 +7924,7 @@ module.exports = (_ => {
|
|||
return BDFDB.ReactUtils.createElement(Internal.LibraryComponents.PopoutContainer, BDFDB.ObjectUtils.exclude(Object.assign({}, this.props, {
|
||||
wrap: false,
|
||||
renderPopout: instance => BDFDB.ReactUtils.createElement(Internal.LibraryComponents.UserPopout, {
|
||||
user: Internal.LibraryModules.UserStore.getUser(this.props.userId),
|
||||
userId: this.props.userId,
|
||||
channelId: this.props.channelId,
|
||||
guildId: this.props.guildId
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name SpellCheck
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.5.9
|
||||
* @version 1.6.0
|
||||
* @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.9",
|
||||
"version": "1.6.0",
|
||||
"description": "Adds a Spell Check to all Message Inputs. Select a Word and Right Click it to add it to your Dictionary"
|
||||
}
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ module.exports = (_ => {
|
|||
|
||||
this.patchedModules = {
|
||||
after: {
|
||||
SlateChannelTextArea: ["componentDidMount", "componentDidUpdate"]
|
||||
ChannelEditorContainer: ["componentDidMount", "componentDidUpdate"]
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -221,14 +221,10 @@ module.exports = (_ => {
|
|||
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||
label: this.labels.context_spellcheck,
|
||||
id: BDFDB.ContextMenuUtils.createItemId(this.name, "add-to-spellcheck"),
|
||||
hint: _ => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
|
||||
hint: word
|
||||
});
|
||||
},
|
||||
action: _ => {
|
||||
this.addToOwnDictionary(word);
|
||||
}
|
||||
hint: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
|
||||
hint: word
|
||||
}),
|
||||
action: _ => this.addToOwnDictionary(word)
|
||||
}),
|
||||
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSeparator, {}),
|
||||
!similarWords.length ? BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||
|
@ -238,9 +234,7 @@ module.exports = (_ => {
|
|||
}) : similarWords.sort().map(suggestion => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||
label: suggestion,
|
||||
id: BDFDB.ContextMenuUtils.createItemId(this.name, "suggestion", suggestion),
|
||||
action: _ => {
|
||||
this.replaceWord(e.instance.props.editor, word, suggestion);
|
||||
}
|
||||
action: _ => this.replaceWord(e.instance.props.editor, word, suggestion)
|
||||
}))
|
||||
].flat(10).filter(n => n)
|
||||
})
|
||||
|
@ -248,8 +242,8 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
|
||||
processSlateChannelTextArea (e) {
|
||||
let newText = BDFDB.SlateUtils.toTextValue(e.instance.props.value);
|
||||
processChannelEditorContainer (e) {
|
||||
let newText = BDFDB.SlateUtils.toTextValue(e.instance.props.richValue);
|
||||
if (newText != currentText) {
|
||||
currentText = newText;
|
||||
BDFDB.DOMUtils.remove(e.node.parentElement.querySelectorAll(BDFDB.dotCN._spellcheckoverlay));
|
||||
|
@ -300,11 +294,10 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
replaceWord (editor, toBeReplaced, replacement) {
|
||||
let editorContainer = BDFDB.ReactUtils.findOwner(editor, {name: "ChannelEditorContainer", up: true});
|
||||
if (!editor || !editorContainer || !editorContainer.props || !editorContainer.props.textValue) return;
|
||||
if (!editor) return;
|
||||
toBeReplaced = toBeReplaced.toUpperCase();
|
||||
let newString = [];
|
||||
editorContainer.props.textValue.replace(/\n/g, "\n ").split(" ").forEach(word => {
|
||||
BDFDB.SlateUtils.toTextValue(editor.children).replace(/\n/g, "\n ").split(" ").forEach(word => {
|
||||
let hasNewline = word.endsWith("\n");
|
||||
word = word.replace(/\n/g, "");
|
||||
if (word.toUpperCase() == toBeReplaced) {
|
||||
|
@ -314,7 +307,14 @@ module.exports = (_ => {
|
|||
}
|
||||
else newString.push(word + (hasNewline ? "\n" : ""));
|
||||
});
|
||||
editor.setValue(BDFDB.SlateUtils.toRichValue(newString.join(" ").replace(/\n /g, "\n")));
|
||||
editor.history.stack.splice(editor.history.index + 1, 0, {
|
||||
type: "other",
|
||||
mergeable: false,
|
||||
createdAt: new Date().getTime(),
|
||||
value: BDFDB.SlateUtils.toRichValue(newString.join(" ").replace(/\n /g, "\n")),
|
||||
selection: editor.history.stack[editor.history.index].selection
|
||||
});
|
||||
editor.redo();
|
||||
}
|
||||
|
||||
addToOwnDictionary (word) {
|
||||
|
|
Loading…
Reference in New Issue