soumaeda 2 лет назад
Родитель
Сommit
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) => {
   const createReplaceSelectionHandler = useCallback((prefix: string, suffix: string) => {
     return () => {
     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;
       const cursorPos = view.state.selection.main.head;
       let curPosAfterReplacing = {};
       let curPosAfterReplacing = {};