mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-18 09:26:28 +08:00
fix(find): readonly code getSelection
This commit is contained in:
parent
cffdaf46f6
commit
3dd13ca321
@ -197,14 +197,9 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
const isReadOnly = await this.noteContext?.isReadOnly();
|
const isReadOnly = await this.noteContext?.isReadOnly();
|
||||||
|
|
||||||
let selectedText = "";
|
let selectedText = "";
|
||||||
if (this.note?.type === "code" && this.noteContext) {
|
if (this.note?.type === "code" && this.noteContext && !isReadOnly) {
|
||||||
if (isReadOnly){
|
const codeEditor = await this.noteContext.getCodeEditor();
|
||||||
const $content = await this.noteContext.getContentElement();
|
selectedText = codeEditor.getSelectedText();
|
||||||
selectedText = $content.find('.cm-matchhighlight').first().text();
|
|
||||||
} else {
|
|
||||||
const codeEditor = await this.noteContext.getCodeEditor();
|
|
||||||
selectedText = codeEditor.getSelectedText();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
selectedText = window.getSelection()?.toString() || "";
|
selectedText = window.getSelection()?.toString() || "";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user