Skip to content

Commit 7fe0d60

Browse files
committed
fix(editor): Fixed the issue of editor focus being lost
1 parent 07316da commit 7fe0d60

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ui/src/components/Editor/ToolBars/image.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ const Image = ({ editorInstance }) => {
110110
return;
111111
}
112112

113-
// const startPos = editor.getCursor(''); codemirror 6
114113
const startPos = editor.getCursor();
115114

116115
const endPos = { ...startPos, ch: startPos.ch + loadingText.length };
117116

118117
editor.replaceSelection(loadingText);
118+
editor.setReadOnly(true);
119119
const urls = await upload(fileList).catch((ex) => {
120120
console.error('upload file error: ', ex);
121121
});
@@ -131,9 +131,10 @@ const Image = ({ editorInstance }) => {
131131
if (text.length) {
132132
editor.replaceRange(text.join('\n'), startPos, endPos);
133133
} else {
134-
// Clear loading text
135134
editor.replaceRange('', startPos, endPos);
136135
}
136+
editor.setReadOnly(false);
137+
editor.focus();
137138
};
138139

139140
const paste = async (event) => {
@@ -155,6 +156,7 @@ const Image = ({ editorInstance }) => {
155156

156157
editor.replaceRange(text.join('\n'), startPos, endPos);
157158
editor.setReadOnly(false);
159+
editor.focus();
158160

159161
return;
160162
}

0 commit comments

Comments
 (0)