瀏覽代碼

注释补全

mxd 3 年之前
父節點
當前提交
7d0fee9066
共有 1 個文件被更改,包括 36 次插入0 次删除
  1. 36 0
      magic-editor/src/console/src/scripts/editor/magic-script.js

+ 36 - 0
magic-editor/src/console/src/scripts/editor/magic-script.js

@@ -17,6 +17,41 @@ export const initializeMagicScript = () => {
             ['[', ']'],
             ['(', ')'],
         ],
+        onEnterRules: [
+            {
+                // e.g. /** | */
+                beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
+                afterText: /^\s*\*\/$/,
+                action: {
+                    indentAction: monaco.languages.IndentAction.IndentOutdent,
+                    appendText: ' * '
+                }
+            },
+            {
+                // e.g. /** ...|
+                beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
+                action: {
+                    indentAction: monaco.languages.IndentAction.None,
+                    appendText: ' * '
+                }
+            },
+            {
+                // e.g.  * ...|
+                beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
+                action: {
+                    indentAction: monaco.languages.IndentAction.None,
+                    appendText: '* '
+                }
+            },
+            {
+                // e.g.  */|
+                beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
+                action: {
+                    indentAction: monaco.languages.IndentAction.None,
+                    removeText: 1
+                }
+            }
+        ],
         comments: {
             lineComment: '//',
             blockComment: ['/*', '*/'],
@@ -29,6 +64,7 @@ export const initializeMagicScript = () => {
             {open: '"""', close: '"""', notIn: ['string.multi']},
             {open: '"', close: '"', notIn: ['string']},
             {open: '\'', close: '\'', notIn: ['string']},
+            {open: '/**', close: ' */', notIn: ['string'] }
         ],
     })