You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ro...@apache.org on 2024/06/18 08:17:40 UTC

(incubator-answer) branch release/1.3.5 updated: fix(editor): Fixed the issue of editor focus being lost

This is an automated email from the ASF dual-hosted git repository.

robin0716 pushed a commit to branch release/1.3.5
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


The following commit(s) were added to refs/heads/release/1.3.5 by this push:
     new 4a8485f0 fix(editor): Fixed the issue of editor focus being lost
4a8485f0 is described below

commit 4a8485f00c14788ff886c07c1e5b1945d01ad771
Author: robin <ro...@rnode.me>
AuthorDate: Tue Jun 18 16:17:32 2024 +0800

    fix(editor): Fixed the issue of editor focus being lost
---
 ui/src/components/Editor/ToolBars/image.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ui/src/components/Editor/ToolBars/image.tsx b/ui/src/components/Editor/ToolBars/image.tsx
index b4d395e2..4f72e4e1 100644
--- a/ui/src/components/Editor/ToolBars/image.tsx
+++ b/ui/src/components/Editor/ToolBars/image.tsx
@@ -110,12 +110,12 @@ const Image = ({ editorInstance }) => {
       return;
     }
 
-    // const startPos = editor.getCursor(''); codemirror 6
     const startPos = editor.getCursor();
 
     const endPos = { ...startPos, ch: startPos.ch + loadingText.length };
 
     editor.replaceSelection(loadingText);
+    editor.setReadOnly(true);
     const urls = await upload(fileList).catch((ex) => {
       console.error('upload file error: ', ex);
     });
@@ -131,9 +131,10 @@ const Image = ({ editorInstance }) => {
     if (text.length) {
       editor.replaceRange(text.join('\n'), startPos, endPos);
     } else {
-      // Clear loading text
       editor.replaceRange('', startPos, endPos);
     }
+    editor.setReadOnly(false);
+    editor.focus();
   };
 
   const paste = async (event) => {
@@ -155,6 +156,7 @@ const Image = ({ editorInstance }) => {
 
       editor.replaceRange(text.join('\n'), startPos, endPos);
       editor.setReadOnly(false);
+      editor.focus();
 
       return;
     }