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();
|
this.handler = await this.getHandler();
|
||||||
|
|
||||||
|
const isReadOnly = await this.noteContext.isReadOnly();
|
||||||
|
|
||||||
let selectedText = '';
|
let selectedText = '';
|
||||||
if (this.note.type === 'code'){
|
if (this.note.type === 'code' && !isReadOnly){
|
||||||
const codeEditor = await this.noteContext.getCodeEditor();
|
const codeEditor = await this.noteContext.getCodeEditor();
|
||||||
selectedText = codeEditor.getSelection();
|
selectedText = codeEditor.getSelection();
|
||||||
}else{
|
}else{
|
||||||
@ -168,7 +170,6 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
this.$widget.show();
|
this.$widget.show();
|
||||||
this.$input.focus();
|
this.$input.focus();
|
||||||
const isReadOnly = await this.noteContext.isReadOnly();
|
|
||||||
if (['text', 'code'].includes(this.note.type) && !isReadOnly) {
|
if (['text', 'code'].includes(this.note.type) && !isReadOnly) {
|
||||||
this.$replaceWidgetBox.show();
|
this.$replaceWidgetBox.show();
|
||||||
}else{
|
}else{
|
||||||
|
@ -171,6 +171,10 @@ export default class FindInCode {
|
|||||||
codeEditor.focus();
|
codeEditor.focus();
|
||||||
}
|
}
|
||||||
async replace(replaceText) {
|
async replace(replaceText) {
|
||||||
|
// this.findResult may be undefined and null
|
||||||
|
if (!this.findResult || this.findResult.length===0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
let currentFound = -1;
|
let currentFound = -1;
|
||||||
this.findResult.forEach((marker, index) => {
|
this.findResult.forEach((marker, index) => {
|
||||||
const pos = marker.find();
|
const pos = marker.find();
|
||||||
@ -202,6 +206,9 @@ export default class FindInCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async replaceAll(replaceText) {
|
async replaceAll(replaceText) {
|
||||||
|
if (!this.findResult || this.findResult.length===0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
const codeEditor = await this.getCodeEditor();
|
const codeEditor = await this.getCodeEditor();
|
||||||
const doc = codeEditor.doc;
|
const doc = codeEditor.doc;
|
||||||
codeEditor.operation(() => {
|
codeEditor.operation(() => {
|
||||||
|
@ -51,7 +51,7 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
|
|||||||
|
|
||||||
await this.initialized;
|
await this.initialized;
|
||||||
|
|
||||||
resolve(this.$content);
|
resolve(this.$editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
format(html) {
|
format(html) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user