This commit is contained in:
Mirco Wittrien 2019-12-10 13:59:44 +01:00
parent 8e94b8d8fa
commit 5761460e31
7 changed files with 119 additions and 130 deletions

View File

@ -16,8 +16,7 @@ class ChatAliases {
this.patchedModules = { this.patchedModules = {
after: { after: {
"ChannelTextArea":"componentDidMount", ChannelTextArea: "componentDidMount"
"StandardSidebarView":"componentWillUnmount"
} }
}; };
} }
@ -293,46 +292,44 @@ class ChatAliases {
BDFDB.DataUtils.save(BDFDB.DOMUtils.isHidden(ele.nextElementSibling), this, "hideInfo", "hideInfo"); BDFDB.DataUtils.save(BDFDB.DOMUtils.isHidden(ele.nextElementSibling), this, "hideInfo", "hideInfo");
} }
onNativeContextMenu (instance, menu, returnvalue) { onSettingsClosed () {
if (instance.props.value && instance.props.value.trim()) {
if ((instance.props.type == "NATIVE_TEXT" || instance.props.type == "CHANNEL_TEXT_AREA") && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(menu, returnvalue, instance.props.value.trim());
}
}
onMessageContextMenu (instance, menu, returnvalue) {
if (instance.props.message && instance.props.channel && instance.props.target) {
let text = document.getSelection().toString().trim();
if (text && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(menu, returnvalue, text);
}
}
appendItem (menu, returnvalue, text) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: "Add to ChatAliases",
action: _ => {
BDFDB.ContextMenuUtils.close(menu);
this.openAddModal(text);
}
})
]
});
if (index > -1) children.splice(index, 0, itemgroup);
else children.push(itemgroup);
}
processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.ModuleUtils.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
processChannelTextArea (instance, wrapper, returnvalue) { onNativeContextMenu (e) {
if (instance.props.channel && instance.props.type) { if (e.instance.props.value && e.instance.props.value.trim()) {
var textarea = wrapper.querySelector("textarea"); if ((e.instance.props.type == "NATIVE_TEXT" || e.instance.props.type == "CHANNEL_TEXT_AREA") && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(e, e.instance.props.value.trim());
}
}
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel && e.instance.props.target) {
let text = document.getSelection().toString().trim();
if (text && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(e, text);
}
}
appendItem (e, text) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: "Add to ChatAliases",
action: _ => {
BDFDB.ContextMenuUtils.close(e.instance);
this.openAddModal(text);
}
})
]
}));
}
processChannelTextArea (e) {
if (e.instance.props.channel && e.instance.props.type) {
var textarea = e.node.querySelector("textarea");
if (!textarea) return; if (!textarea) return;
let settings = BDFDB.DataUtils.get(this, "settings"); let settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.ListenerUtils.add(this, textarea, "input", () => { BDFDB.ListenerUtils.add(this, textarea, "input", () => {
@ -347,44 +344,44 @@ class ChatAliases {
if (messageInput.text != null) { if (messageInput.text != null) {
document.execCommand("insertText", false, messageInput.text ? messageInput.text + " " : ""); document.execCommand("insertText", false, messageInput.text ? messageInput.text + " " : "");
} }
if (messageInput.files.length > 0 && (instance.props.channel.type == 1 || BDFDB.UserUtils.can("ATTACH_FILES"))) { if (messageInput.files.length > 0 && (e.instance.props.channel.type == 1 || BDFDB.UserUtils.can("ATTACH_FILES"))) {
BDFDB.LibraryModules.UploadUtils.instantBatchUpload(instance.props.channel.id, messageInput.files); BDFDB.LibraryModules.UploadUtils.instantBatchUpload(e.instance.props.channel.id, messageInput.files);
} }
} }
} }
} }
}); });
BDFDB.ListenerUtils.add(this, textarea, "keydown", e => { BDFDB.ListenerUtils.add(this, textarea, "keydown", event => {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete); let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete);
if (autocompletemenu && (e.which == 9 || e.which == 13)) { if (autocompletemenu && (event.which == 9 || event.which == 13)) {
if (BDFDB.DOMUtils.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteAliasesRow")) { if (BDFDB.DOMUtils.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteAliasesRow")) {
BDFDB.ListenerUtils.stopEvent(e); BDFDB.ListenerUtils.stopEvent(event);
this.swapWordWithAlias(textarea); this.swapWordWithAlias(textarea);
} }
} }
else if (autocompletemenu && (e.which == 38 || e.which == 40)) { else if (autocompletemenu && (event.which == 38 || event.which == 40)) {
let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteAliasesSelector)"); let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteAliasesSelector)");
let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected); let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected);
if (BDFDB.DOMUtils.containsClass(selected, "autocompleteAliasesSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) { if (BDFDB.DOMUtils.containsClass(selected, "autocompleteAliasesSelector") || autocompleteitems[event.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) {
BDFDB.ListenerUtils.stopEvent(e); BDFDB.ListenerUtils.stopEvent(event);
let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true); let next = this.getNextSelection(autocompletemenu, null, event.which == 38 ? false : true);
BDFDB.DOMUtils.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.DOMUtils.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.DOMUtils.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.DOMUtils.addClass(selected, BDFDB.disCN.autocompleteselector);
BDFDB.DOMUtils.addClass(next, BDFDB.disCN.autocompleteselected); BDFDB.DOMUtils.addClass(next, BDFDB.disCN.autocompleteselected);
} }
} }
else if (textarea.value && !e.shiftKey && e.which == 13 && !autocompletemenu && textarea.value.indexOf("s/") != 0) { else if (textarea.value && !event.shiftKey && event.which == 13 && !autocompletemenu && textarea.value.indexOf("s/") != 0) {
this.format = true; this.format = true;
textarea.dispatchEvent(new Event("input")); textarea.dispatchEvent(new Event("input"));
} }
else if (!e.ctrlKey && e.which != 16 && settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) { else if (!event.ctrlKey && event.which != 16 && settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) {
BDFDB.TimeUtils.clear(textarea.ChatAliasAutocompleteTimeout); BDFDB.TimeUtils.clear(textarea.ChatAliasAutocompleteTimeout);
textarea.ChatAliasAutocompleteTimeout = BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea);},100); textarea.ChatAliasAutocompleteTimeout = BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea);},100);
} }
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.DOMUtils.remove(".autocompleteAliases", ".autocompleteAliasesRow"); if (!event.ctrlKey && event.which != 38 && event.which != 40 && !(event.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.DOMUtils.remove(".autocompleteAliases", ".autocompleteAliasesRow");
}); });
BDFDB.ListenerUtils.add(this, textarea, "click", e => { BDFDB.ListenerUtils.add(this, textarea, "click", _ => {
if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea);}); if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) BDFDB.TimeUtils.timeout(() => {this.addAutoCompleteMenu(textarea);});
}); });
} }
@ -430,17 +427,17 @@ class ChatAliases {
} }
let autocompleterowheader = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCN.autocompleteselector} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.autocompletecontenttitle + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.weightsemibold}">Aliases: <strong class="lastword">${BDFDB.StringUtils.htmlEscape(lastword)}</strong></div></div></div>`); let autocompleterowheader = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCN.autocompleteselector} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.autocompletecontenttitle + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.weightsemibold}">Aliases: <strong class="lastword">${BDFDB.StringUtils.htmlEscape(lastword)}</strong></div></div></div>`);
autocompletemenu.appendChild(autocompleterowheader); autocompletemenu.appendChild(autocompleterowheader);
BDFDB.ListenerUtils.add(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => { BDFDB.ListenerUtils.add(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, event => {
var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected); var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected);
BDFDB.DOMUtils.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.DOMUtils.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.DOMUtils.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.DOMUtils.addClass(selected, BDFDB.disCN.autocompleteselector);
BDFDB.DOMUtils.addClass(e.currentTarget, BDFDB.disCN.autocompleteselected); BDFDB.DOMUtils.addClass(event.currentTarget, BDFDB.disCN.autocompleteselected);
}); });
for (let word in matchedaliases) { for (let word in matchedaliases) {
if (amount-- < 1) break; if (amount-- < 1) break;
let autocompleterow = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCNS.autocompleteselector + BDFDB.disCN.autocompleteselectable} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletecontent}" style="flex: 1 1 auto;"><div class="${BDFDB.disCN.flexchild} aliasword" style="flex: 1 1 auto;">${BDFDB.StringUtils.htmlEscape(word)}</div><div class="${BDFDB.disCNS.autocompletedescription + BDFDB.disCN.flexchild}">${BDFDB.StringUtils.htmlEscape(matchedaliases[word].replace)}</div></div></div></div>`); let autocompleterow = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCNS.autocompleteselector + BDFDB.disCN.autocompleteselectable} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletecontent}" style="flex: 1 1 auto;"><div class="${BDFDB.disCN.flexchild} aliasword" style="flex: 1 1 auto;">${BDFDB.StringUtils.htmlEscape(word)}</div><div class="${BDFDB.disCNS.autocompletedescription + BDFDB.disCN.flexchild}">${BDFDB.StringUtils.htmlEscape(matchedaliases[word].replace)}</div></div></div></div>`);
autocompleterow.querySelector(BDFDB.dotCN.autocompleteselectable).addEventListener("click", () => {this.swapWordWithAlias(textarea);}); autocompleterow.querySelector(BDFDB.dotCN.autocompleteselectable).addEventListener("click", _ => {this.swapWordWithAlias(textarea);});
autocompletemenu.appendChild(autocompleterow); autocompletemenu.appendChild(autocompleterow);
} }
if (!autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected)) { if (!autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected)) {

View File

@ -285,41 +285,7 @@ class ChatFilter {
BDFDB.DataUtils.save(BDFDB.DOMUtils.isHidden(ele.nextElementSibling), this, "hideInfo", "hideInfo"); BDFDB.DataUtils.save(BDFDB.DOMUtils.isHidden(ele.nextElementSibling), this, "hideInfo", "hideInfo");
} }
onNativeContextMenu (instance, menu, returnvalue) { onSettingsClosed () {
if (instance.props.value && instance.props.value.trim()) {
if ((instance.props.type == "NATIVE_TEXT" || instance.props.type == "CHANNEL_TEXT_AREA") && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(menu, returnvalue, instance.props.value.trim());
}
}
onMessageContextMenu (instance, menu, returnvalue) {
if (instance.props.message && instance.props.channel && instance.props.target) {
let text = document.getSelection().toString().trim();
if (text && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(menu, returnvalue, text);
}
}
appendItem (menu, returnvalue, text) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: "Add to ChatFilter",
action: _ => {
BDFDB.ContextMenuUtils.close(menu);
this.openAddModal(text);
}
})
]
});
if (index > -1) children.splice(index, 0, itemgroup);
else children.push(itemgroup);
}
processMessage (instance, wrapper, returnvalue) {
wrapper.querySelectorAll(`${BDFDB.dotCNC.messagemarkup + BDFDB.dotCN.messageaccessory}`).forEach(message => {this.hideMessage(message);});
}
processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);}); document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);});
@ -327,6 +293,38 @@ class ChatFilter {
} }
} }
onNativeContextMenu (e) {
if (e.instance.props.value && e.instance.props.value.trim()) {
if ((e.instance.props.type == "NATIVE_TEXT" || e.instance.props.type == "CHANNEL_TEXT_AREA") && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(e, e.instance.props.value.trim());
}
}
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel && e.instance.props.target) {
let text = document.getSelection().toString().trim();
if (text && BDFDB.DataUtils.get(this, "settings", "addContextMenu")) this.appendItem(e, text);
}
}
appendItem (e, text) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: "Add to ChatFilter",
action: _ => {
BDFDB.ContextMenuUtils.close(e.instance);
this.openAddModal(text);
}
})
]
}));
}
processMessage (e) {
e.node.querySelectorAll(`${BDFDB.dotCNC.messagemarkup + BDFDB.dotCN.messageaccessory}`).forEach(message => {this.hideMessage(message);});
}
hideMessage (message) { hideMessage (message) {
if (message.tagName && !BDFDB.DOMUtils.containsClass(message, "blocked", "censored", false)) { if (message.tagName && !BDFDB.DOMUtils.containsClass(message, "blocked", "censored", false)) {
var orightml = message.innerHTML; var orightml = message.innerHTML;

View File

@ -143,9 +143,9 @@ class EditChannels {
// begin of own functions // begin of own functions
onChannelContextMenu (instance, menu, returnvalue) { onChannelContextMenu (e) {
if (instance.props.channel && !BDFDB.DOMUtils.getParent(".container-hidden", instance.props.target) && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { if (e.instance.props.channel && !BDFDB.DOMUtils.getParent(".container-hidden", e.instance.props.target)) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, { children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [ children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, {
@ -155,16 +155,16 @@ class EditChannels {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: this.labels.submenu_channelsettings_text, label: this.labels.submenu_channelsettings_text,
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(menu); BDFDB.ContextMenuUtils.close(e.instance);
this.showChannelSettings(instance.props.channel); this.showChannelSettings(e.instance.props.channel);
} }
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: this.labels.submenu_resetsettings_text, label: this.labels.submenu_resetsettings_text,
disabled: !BDFDB.DataUtils.load(this, "channels", instance.props.channel.id), disabled: !BDFDB.DataUtils.load(this, "channels", e.instance.props.channel.id),
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(menu); BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.DataUtils.remove(this, "channels", instance.props.channel.id); BDFDB.DataUtils.remove(this, "channels", e.instance.props.channel.id);
this.forceUpdateAll(); this.forceUpdateAll();
} }
}) })

View File

@ -190,10 +190,10 @@ class EditUsers {
// begin of own functions // begin of own functions
onUserContextMenu (instance, menu, returnvalue) { onUserContextMenu (e) {
if (instance.props.user && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { if (e.instance.props.user) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, { children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: [ children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, {
label: this.labels.context_localusersettings_text, label: this.labels.context_localusersettings_text,
@ -202,16 +202,16 @@ class EditUsers {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: this.labels.submenu_usersettings_text, label: this.labels.submenu_usersettings_text,
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(menu); BDFDB.ContextMenuUtils.close(e.instance);
this.showUserSettings(instance.props.user); this.showUserSettings(e.instance.props.user);
} }
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: this.labels.submenu_resetsettings_text, label: this.labels.submenu_resetsettings_text,
disabled: !BDFDB.DataUtils.load(this, "users", instance.props.user.id), disabled: !BDFDB.DataUtils.load(this, "users", e.instance.props.user.id),
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(menu); BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.DataUtils.remove(this, "users", instance.props.user.id); BDFDB.DataUtils.remove(this, "users", e.instance.props.user.id);
this.forceUpdateAll(); this.forceUpdateAll();
} }
}) })
@ -219,9 +219,7 @@ class EditUsers {
})] })]
}) })
] ]
}); }));
if (index > -1) children.splice(index, 0, itemgroup);
else children.push(itemgroup);
} }
} }

View File

@ -339,16 +339,15 @@ class PluginRepo {
// begin of own functions // begin of own functions
onUserSettingsCogContextMenu (instance, menu, returnvalue) { onUserSettingsCogContextMenu (e) {
BDFDB.TimeUtils.timeout(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) { BDFDB.TimeUtils.timeout(_ => {for (let child of e.returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
const repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { child.props.render.push(repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: "Plugin Repo", label: "Plugin Repo",
action: _ => { action: _ => {
if (!this.loading.is) BDFDB.ContextMenuUtils.close(menu); if (!this.loading.is) BDFDB.ContextMenuUtils.close(e.instance);
this.openPluginRepoModal(); this.openPluginRepoModal();
} }
}); }));
child.props.render.push(repoItem);
break; break;
}}); }});
} }

View File

@ -144,11 +144,11 @@ class SpellCheck {
// begin of own functions // begin of own functions
onNativeContextMenu (instance, menu, returnvalue) { onNativeContextMenu (e) {
if (instance.props.target && instance.props.target.tagName == "TEXTAREA") { if (e.instance.props.target && e.instance.props.target.tagName == "TEXTAREA") {
let [SCparent, SCindex] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["NativeSpellcheckGroup", "FluxContainer(NativeSpellcheckGroup)"]}); let [SCparent, SCindex] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["NativeSpellcheckGroup", "FluxContainer(NativeSpellcheckGroup)"]});
if (SCindex > -1) { if (SCindex > -1) {
if (BDFDB.ReactUtils.findValue(instance._reactInternalFiber, "spellcheckEnabled") == true) { if (BDFDB.ReactUtils.findValue(e.instance._reactInternalFiber, "spellcheckEnabled") == true) {
BDFDB.TimeUtils.clear(this.disableSpellcheckTimeout); BDFDB.TimeUtils.clear(this.disableSpellcheckTimeout);
this.disableSpellcheckTimeout = BDFDB.TimeUtils.timeout(() => { this.disableSpellcheckTimeout = BDFDB.TimeUtils.timeout(() => {
BDFDB.LibraryModules.SpellCheckUtils.toggleSpellcheck(); BDFDB.LibraryModules.SpellCheckUtils.toggleSpellcheck();
@ -157,7 +157,7 @@ class SpellCheck {
} }
SCparent.splice(SCindex, 1); SCparent.splice(SCindex, 1);
} }
let textarea = instance.props.target, word = null, length = 0; let textarea = e.instance.props.target, word = null, length = 0;
if (textarea.value && (textarea.selectionStart || textarea.selectionEnd)) for (let splitword of textarea.value.split(/\s/g)) { if (textarea.value && (textarea.selectionStart || textarea.selectionEnd)) for (let splitword of textarea.value.split(/\s/g)) {
length += splitword.length + 1; length += splitword.length + 1;
if (length > textarea.selectionStart) { if (length > textarea.selectionStart) {
@ -173,7 +173,7 @@ class SpellCheck {
} }
} }
if (word && this.isWordNotInDictionary(word)) { if (word && this.isWordNotInDictionary(word)) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
let items = []; let items = [];
let similarWords = this.getSimilarWords(word.toLowerCase().trim()); let similarWords = this.getSimilarWords(word.toLowerCase().trim());
for (let suggestion of similarWords.sort()) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { for (let suggestion of similarWords.sort()) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
@ -187,7 +187,7 @@ class SpellCheck {
label: this.labels.similarwordssubmenu_none_text, label: this.labels.similarwordssubmenu_none_text,
disabled: true disabled: true
})); }));
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, { children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, {
label: BDFDB.LanguageUtils.LanguageStrings.SPELLCHECK, label: BDFDB.LanguageUtils.LanguageStrings.SPELLCHECK,
render: [ render: [
@ -195,7 +195,7 @@ class SpellCheck {
label: this.labels.context_spellcheck_text, label: this.labels.context_spellcheck_text,
hint: word, hint: word,
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(menu); BDFDB.ContextMenuUtils.close(e.instance);
this.addToOwnDictionary(word); this.addToOwnDictionary(word);
} }
}), }),
@ -205,9 +205,7 @@ class SpellCheck {
}) })
] ]
}) })
}); }));
if (index > -1) children.splice(index, 0, itemgroup);
else children.push(itemgroup);
} }
} }
} }

View File

@ -399,16 +399,15 @@ class ThemeRepo {
// begin of own functions // begin of own functions
onUserSettingsCogContextMenu (instance, menu, returnvalue) { onUserSettingsCogContextMenu (e) {
BDFDB.TimeUtils.timeout(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) { BDFDB.TimeUtils.timeout(_ => {for (let child of e.returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
const repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { child.props.render.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: "Theme Repo", label: "Theme Repo",
action: _ => { action: _ => {
if (!this.loading.is) BDFDB.ContextMenuUtils.close(menu); if (!this.loading.is) BDFDB.ContextMenuUtils.close(e.instance);
this.openThemeRepoModal(); this.openThemeRepoModal();
} }
}); }));
child.props.render.push(repoItem);
break; break;
}}); }});
} }