mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
add 200ms timeout to api.getTextEditor() and similar #4174
This commit is contained in:
parent
d93e00adce
commit
6c96cca3a5
@ -265,32 +265,39 @@ class NoteContext extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getTextEditor(callback) {
|
async getTextEditor(callback) {
|
||||||
return new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', {
|
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', {
|
||||||
callback,
|
callback,
|
||||||
resolve,
|
resolve,
|
||||||
ntxId: this.ntxId
|
ntxId: this.ntxId
|
||||||
}));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCodeEditor() {
|
async getCodeEditor() {
|
||||||
return new Promise(resolve => appContext.triggerCommand('executeWithCodeEditor', {
|
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithCodeEditor', {
|
||||||
resolve,
|
resolve,
|
||||||
ntxId: this.ntxId
|
ntxId: this.ntxId
|
||||||
}));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getContentElement() {
|
async getContentElement() {
|
||||||
return new Promise(resolve => appContext.triggerCommand('executeWithContentElement', {
|
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithContentElement', {
|
||||||
resolve,
|
resolve,
|
||||||
ntxId: this.ntxId
|
ntxId: this.ntxId
|
||||||
}));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTypeWidget() {
|
async getTypeWidget() {
|
||||||
return new Promise(resolve => appContext.triggerCommand('executeWithTypeWidget', {
|
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTypeWidget', {
|
||||||
resolve,
|
resolve,
|
||||||
ntxId: this.ntxId
|
ntxId: this.ntxId
|
||||||
}));
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
timeout(promise) {
|
||||||
|
return Promise.race([
|
||||||
|
promise,
|
||||||
|
new Promise(res => setTimeout(() => res(null), 200))
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetViewScope() {
|
resetViewScope() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user