Merge pull request #1933 from TriliumNext/codemirror_find

fix(find): readonly code getSelection
This commit is contained in:
Elian Doran 2025-05-14 12:56:55 +03:00 committed by GitHub
commit 5c8d3f9c51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -198,13 +198,8 @@ export default class FindWidget extends NoteContextAwareWidget {
let selectedText = ""; let selectedText = "";
if (this.note?.type === "code" && this.noteContext) { if (this.note?.type === "code" && this.noteContext) {
if (isReadOnly){
const $content = await this.noteContext.getContentElement();
selectedText = $content.find('.cm-matchhighlight').first().text();
} else {
const codeEditor = await this.noteContext.getCodeEditor(); const codeEditor = await this.noteContext.getCodeEditor();
selectedText = codeEditor.getSelectedText(); selectedText = codeEditor.getSelectedText();
}
} else { } else {
selectedText = window.getSelection()?.toString() || ""; selectedText = window.getSelection()?.toString() || "";
} }