soumaeda 2 년 전
부모
커밋
faf7752f1e
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      packages/editor/src/components/CodeMirrorEditor/Toolbar/TextFormatTools.tsx

+ 4 - 2
packages/editor/src/components/CodeMirrorEditor/Toolbar/TextFormatTools.tsx

@@ -53,8 +53,10 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
 
       if (insertText) {
         view?.dispatch(insertText);
-        curPosAfterReplacing = cursorPos + prefix.length;
-        view?.dispatch({ selection: { anchor: curPosAfterReplacing } });
+        if (cursorPos) {
+          curPosAfterReplacing = cursorPos + prefix.length;
+        }
+        view?.dispatch({ selection: { anchor: curPosAfterReplacing as number } });
         view?.focus();
       }
     };