mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 02:52:27 +08:00
Fix find_widget bugs
This commit is contained in:
parent
d63baa1503
commit
a0c6d695b0
@ -158,9 +158,11 @@ export default class FindWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
this.handler = await this.getHandler();
|
||||
|
||||
const isReadOnly = await this.noteContext.isReadOnly();
|
||||
|
||||
let selectedText = '';
|
||||
if (this.note.type === 'code'){
|
||||
if (this.note.type === 'code' && !isReadOnly){
|
||||
const codeEditor = await this.noteContext.getCodeEditor();
|
||||
selectedText = codeEditor.getSelection();
|
||||
}else{
|
||||
@ -168,7 +170,6 @@ export default class FindWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
this.$widget.show();
|
||||
this.$input.focus();
|
||||
const isReadOnly = await this.noteContext.isReadOnly();
|
||||
if (['text', 'code'].includes(this.note.type) && !isReadOnly) {
|
||||
this.$replaceWidgetBox.show();
|
||||
}else{
|
||||
|
@ -171,6 +171,10 @@ export default class FindInCode {
|
||||
codeEditor.focus();
|
||||
}
|
||||
async replace(replaceText) {
|
||||
// this.findResult may be undefined and null
|
||||
if (!this.findResult || this.findResult.length===0){
|
||||
return;
|
||||
}
|
||||
let currentFound = -1;
|
||||
this.findResult.forEach((marker, index) => {
|
||||
const pos = marker.find();
|
||||
@ -202,6 +206,9 @@ export default class FindInCode {
|
||||
}
|
||||
}
|
||||
async replaceAll(replaceText) {
|
||||
if (!this.findResult || this.findResult.length===0){
|
||||
return;
|
||||
}
|
||||
const codeEditor = await this.getCodeEditor();
|
||||
const doc = codeEditor.doc;
|
||||
codeEditor.operation(() => {
|
||||
|
@ -51,7 +51,7 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
|
||||
|
||||
await this.initialized;
|
||||
|
||||
resolve(this.$content);
|
||||
resolve(this.$editor);
|
||||
}
|
||||
|
||||
format(html) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user