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