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) {
|
||||
return new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', {
|
||||
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', {
|
||||
callback,
|
||||
resolve,
|
||||
ntxId: this.ntxId
|
||||
}));
|
||||
})));
|
||||
}
|
||||
|
||||
async getCodeEditor() {
|
||||
return new Promise(resolve => appContext.triggerCommand('executeWithCodeEditor', {
|
||||
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithCodeEditor', {
|
||||
resolve,
|
||||
ntxId: this.ntxId
|
||||
}));
|
||||
})));
|
||||
}
|
||||
|
||||
async getContentElement() {
|
||||
return new Promise(resolve => appContext.triggerCommand('executeWithContentElement', {
|
||||
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithContentElement', {
|
||||
resolve,
|
||||
ntxId: this.ntxId
|
||||
}));
|
||||
})));
|
||||
}
|
||||
|
||||
async getTypeWidget() {
|
||||
return new Promise(resolve => appContext.triggerCommand('executeWithTypeWidget', {
|
||||
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTypeWidget', {
|
||||
resolve,
|
||||
ntxId: this.ntxId
|
||||
}));
|
||||
})));
|
||||
}
|
||||
|
||||
timeout(promise) {
|
||||
return Promise.race([
|
||||
promise,
|
||||
new Promise(res => setTimeout(() => res(null), 200))
|
||||
]);
|
||||
}
|
||||
|
||||
resetViewScope() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user