From 3dd13ca32124527da56798d026b07bf9c84ca2d9 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Wed, 14 May 2025 11:13:22 +0800 Subject: [PATCH 1/2] fix(find): readonly code getSelection --- apps/client/src/widgets/find.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/client/src/widgets/find.ts b/apps/client/src/widgets/find.ts index 7580ba3a6..7ff87736a 100644 --- a/apps/client/src/widgets/find.ts +++ b/apps/client/src/widgets/find.ts @@ -197,14 +197,9 @@ export default class FindWidget extends NoteContextAwareWidget { const isReadOnly = await this.noteContext?.isReadOnly(); let selectedText = ""; - 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(); - selectedText = codeEditor.getSelectedText(); - } + if (this.note?.type === "code" && this.noteContext && !isReadOnly) { + const codeEditor = await this.noteContext.getCodeEditor(); + selectedText = codeEditor.getSelectedText(); } else { selectedText = window.getSelection()?.toString() || ""; } From 05f441924a13762006d6916f7e42447e59590a5f Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Wed, 14 May 2025 14:46:42 +0800 Subject: [PATCH 2/2] Remove read-only checks of find --- apps/client/src/widgets/find.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/client/src/widgets/find.ts b/apps/client/src/widgets/find.ts index 7ff87736a..0239251cb 100644 --- a/apps/client/src/widgets/find.ts +++ b/apps/client/src/widgets/find.ts @@ -197,7 +197,7 @@ export default class FindWidget extends NoteContextAwareWidget { const isReadOnly = await this.noteContext?.isReadOnly(); let selectedText = ""; - if (this.note?.type === "code" && this.noteContext && !isReadOnly) { + if (this.note?.type === "code" && this.noteContext) { const codeEditor = await this.noteContext.getCodeEditor(); selectedText = codeEditor.getSelectedText(); } else {