瀏覽代碼

133069 add optional

soumaeda 2 年之前
父節點
當前提交
21cb3f31f8
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      packages/editor/src/components/CodeMirrorEditor/Toolbar/TextFormatTools.tsx

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

@@ -43,9 +43,9 @@ export const TextFormatTools = (props: TextFormatToolsType): JSX.Element => {
 
   const createReplaceSelectionHandler = useCallback((prefix: string, suffix: string) => {
     return () => {
-      const selection = view.state.sliceDoc(
-        view.state.selection.main.from,
-        view.state.selection.main.to,
+      const selection = view?.state.sliceDoc(
+        view?.state.selection.main.from,
+        view?.state.selection.main.to,
       );
       const cursorPos = view.state.selection.main.head;
       let curPosAfterReplacing = {};