🎨 Modify code block logic

This commit is contained in:
2025-11-17 22:11:16 +08:00
parent 59db8dd177
commit a08c0d8448
11 changed files with 156 additions and 65 deletions

View File

@@ -4,6 +4,7 @@ import * as prettier from "prettier/standalone";
import { getActiveNoteBlock } from "./state";
import { getLanguage } from "./lang-parser/languages";
import { SupportedLanguage } from "./types";
import { USER_EVENTS } from "./annotation";
export const formatBlockContent = (view) => {
if (!view || view.state.readOnly)
@@ -87,7 +88,7 @@ export const formatBlockContent = (view) => {
},
selection: EditorSelection.cursor(currentBlockFrom + Math.min(formattedContent.cursorOffset, formattedContent.formatted.length)),
scrollIntoView: true,
userEvent: "input"
userEvent: USER_EVENTS.INPUT
});
return true;
@@ -100,4 +101,4 @@ export const formatBlockContent = (view) => {
// 执行异步格式化
performFormat();
return true; // 立即返回 true表示命令已开始执行
};
};