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();
       }
     };