Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 3dd13ca

Browse files
committed
fix(find): readonly code getSelection
1 parent cffdaf4 commit 3dd13ca

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

apps/client/src/widgets/find.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,9 @@ export default class FindWidget extends NoteContextAwareWidget {
197197
const isReadOnly = await this.noteContext?.isReadOnly();
198198

199199
let selectedText = "";
200-
if (this.note?.type === "code" && this.noteContext) {
201-
if (isReadOnly){
202-
const $content = await this.noteContext.getContentElement();
203-
selectedText = $content.find('.cm-matchhighlight').first().text();
204-
} else {
205-
const codeEditor = await this.noteContext.getCodeEditor();
206-
selectedText = codeEditor.getSelectedText();
207-
}
200+
if (this.note?.type === "code" && this.noteContext && !isReadOnly) {
201+
const codeEditor = await this.noteContext.getCodeEditor();
202+
selectedText = codeEditor.getSelectedText();
208203
} else {
209204
selectedText = window.getSelection()?.toString() || "";
210205
}

0 commit comments

Comments
 (0)