mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 00:00:50 +00:00
feat: add quick toggle comment functionality in the editor (#13107)
This commit is contained in:
@@ -174,7 +174,7 @@ const isSpecialEditorFileName = (value: string) => {
|
||||
if (!normalized) {
|
||||
return false;
|
||||
}
|
||||
return specialEditorFileNames.some((filename) => normalized === filename || normalized.startsWith(`${filename}.`));
|
||||
return specialEditorFileNames.some((filename) => normalized === filename);
|
||||
};
|
||||
|
||||
export const resolveEditorLanguage = (path: string, extension = '', name = '') => {
|
||||
|
||||
@@ -41,6 +41,7 @@ export async function loadMonacoLanguageSupport() {
|
||||
import('monaco-editor/esm/vs/editor/contrib/folding/browser/folding.js'),
|
||||
import('monaco-editor/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js'),
|
||||
import('monaco-editor/esm/vs/editor/contrib/clipboard/browser/clipboard.js'),
|
||||
import('monaco-editor/esm/vs/editor/contrib/comment/browser/comment.js'),
|
||||
import('monaco-editor/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js'),
|
||||
import('monaco-editor/esm/vs/editor/contrib/find/browser/findController.js'),
|
||||
import('monaco-editor/esm/vs/editor/contrib/multicursor/browser/multicursor.js'),
|
||||
|
||||
@@ -965,6 +965,8 @@ const initEditor = async () => {
|
||||
editor.getModel()?.pushEOL(config.eol);
|
||||
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, quickSave);
|
||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Slash, quickToggleComment);
|
||||
editor.focus();
|
||||
|
||||
editor.onDidChangeModelContent(() => {
|
||||
if (editor) {
|
||||
@@ -980,6 +982,10 @@ const quickSave = () => {
|
||||
saveContent();
|
||||
};
|
||||
|
||||
const quickToggleComment = () => {
|
||||
void editor?.getAction('editor.action.commentLine')?.run();
|
||||
};
|
||||
|
||||
const openHistoryDrawer = () => {
|
||||
if (!form.value.path) {
|
||||
MsgWarning(i18n.global.t('file.historyNeedFile'));
|
||||
|
||||
Reference in New Issue
Block a user