Fix lag and random no reason package change
This commit is contained in:
parent
25decd0514
commit
6948335ea7
|
@ -16,12 +16,17 @@ export default new class AutoComplete {
|
|||
this.initialized = true;
|
||||
}
|
||||
|
||||
get latestComponent() {
|
||||
return this._latestComponent;
|
||||
}
|
||||
|
||||
channelTextAreaAfterRender(component, args, retVal) {
|
||||
const inner = Utils.findInReactTree(retVal, filter => filter && filter.className && filter.className.includes('inner'));
|
||||
|
||||
if (!inner || !inner.children) return;
|
||||
inner.children.splice(0, 0, VueInjector.createReactElement(AutocompleteComponent, {
|
||||
controller: this,
|
||||
component
|
||||
_insertText: component.insertText.bind(component)
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
<script>
|
||||
import { WebpackModules, DiscordApi, Events } from 'modules';
|
||||
let wtf = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -44,18 +45,23 @@
|
|||
textArea: null
|
||||
}
|
||||
},
|
||||
props: ['prefix', 'controller', 'component'],
|
||||
props: ['prefix', 'controller', '_insertText', '_ref'],
|
||||
computed: {
|
||||
},
|
||||
created() {
|
||||
this.attachListeners();
|
||||
},
|
||||
destroyed() {
|
||||
console.log('AUTOCOMPLET EDESTROYED');
|
||||
},
|
||||
methods: {
|
||||
attachListeners() {
|
||||
if (this._isDestroyed) return;
|
||||
if (!this.component._ref || !this.component._ref._textArea) return setTimeout(this.attachListeners, 10);
|
||||
this.component._ref._textArea.addEventListener('keydown', this.keyDown);
|
||||
this.component._ref._textArea.addEventListener('keyup', this.keyUp);
|
||||
const ta = document.querySelector('.da-textAreaEdit') || document.querySelector('.da-textArea');
|
||||
if (!ta) return setTimeout(this.attachListeners, 10);
|
||||
this.ta = ta;
|
||||
ta.addEventListener('keydown', this.keyDown);
|
||||
ta.addEventListener('keyup', this.keyUp);
|
||||
},
|
||||
keyDown(e) {
|
||||
if (!this.open) return;
|
||||
|
@ -108,12 +114,13 @@
|
|||
}
|
||||
},
|
||||
insertText(startIndex, text) {
|
||||
this.component._ref._textArea.selectionStart = startIndex;
|
||||
this.component.insertText(text);
|
||||
console.log(this._insertText);
|
||||
this.ta.selectionStart = startIndex;
|
||||
this._insertText(text);
|
||||
},
|
||||
inject() {
|
||||
if (!this.component || !this.component._ref || !this.component._ref._textArea) return;
|
||||
this.insertText(this.component._ref._textArea.selectionStart - this.fsterm.length, this.search.items[this.selectedIndex].value.replaceWith);
|
||||
if (!this.ta) return;
|
||||
this.insertText(this.ta.selectionStart - this.fsterm.length, this.search.items[this.selectedIndex].value.replaceWith);
|
||||
this.open = false;
|
||||
this.search = { type: null, items: [] };
|
||||
}
|
||||
|
|
|
@ -87,6 +87,6 @@
|
|||
"package_release": "node scripts/package-release.js",
|
||||
"release": "npm run lint && npm run build_release && gulp release && npm run package_release",
|
||||
"update_release": "npm run build_release && gulp build-release",
|
||||
"inject": "node scripts/inject.js"
|
||||
"inject": "node scripts/inject.js"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue