ソースを参照

add a conditional branch to makeTextCodeBlock

WNomunomu 1 年間 前
コミット
7d466d698d
1 ファイル変更7 行追加2 行削除
  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```',
       });
 
-      // 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));
+      }
     }
   });