Browse Source

add a conditional branch to makeTextCodeBlock

WNomunomu 11 months ago
parent
commit
7d466d698d
1 changed files with 7 additions and 2 deletions
  1. 7 2
      packages/editor/src/client/stores/use-editor-shortcuts.ts

+ 7 - 2
packages/editor/src/client/stores/use-editor-shortcuts.ts

@@ -85,8 +85,13 @@ const makeTextCodeBlock: Command = (view: EditorView) => {
         insert: '\n```',
         insert: '\n```',
       });
       });
 
 
-      // Position cursor to include the entire wrapped content with markers
-      newSelections.push(EditorSelection.range(startLine.from, endLine.to + 8));
+      if (selectedText.length === 0) {
+        newSelections.push(EditorSelection.cursor(startLine.from + 4));
+      }
+      else {
+        // Position cursor to include the entire wrapped content with markers
+        newSelections.push(EditorSelection.range(startLine.from, endLine.to + 8));
+      }
     }
     }
   });
   });