Selaa lähdekoodia

임시로 강조라도 추가

https://github.com/openNAMU/openNAMU/issues/1036
잉여개발기 2 vuotta sitten
vanhempi
sitoutus
f0e944bcd9
2 muutettua tiedostoa jossa 47 lisäystä ja 9 poistoa
  1. 1 1
      version.json
  2. 46 8
      views/main_css/js/route/editor.js

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-dev33",
+        "r_ver" : "v3.5.0-dev34",
         "c_ver" : "3500376",
         "s_ver" : "3500113"
     }

+ 46 - 8
views/main_css/js/route/editor.js

@@ -214,16 +214,54 @@ class PlaceholderContentWidget {
     }
 }
 
-function do_monaco_init(monaco_thema) {
-    require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.40.0/min/vs' }});
-    require.config({ 'vs/nls': { availableLanguages: { '*': 'ko' } }});
+function do_monaco_init(monaco_thema, markup = "") {
+    require.config({ paths: { 'vs' : 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.40.0/min/vs' }});
+    require.config({ 'vs/nls' : { availableLanguages: { '*' : 'ko' } }});
     require(["vs/editor/editor.main"], function () {
+        monaco.languages.register({ id : "namumark" });
+        monaco.languages.setMonarchTokensProvider("namumark", {
+            tokenizer : {
+                root : [
+                    [/\[/, "namumark-color"],
+                    [/\]/, "namumark-color"],
+                    
+                    [/\{/, "namumark-color"],
+                    [/\}/, "namumark-color"],
+
+                    [/'/, "namumark-color"],
+                    [/-/, "namumark-color"],
+                    [/~/, "namumark-color"],
+                    [/=/, "namumark-color"],
+                    [/_/, "namumark-color"],
+                    [/\^/, "namumark-color"],
+                    [/,/, "namumark-color"],
+
+                    [/\\/, "namumark-color"],
+                    [/\*/, "namumark-color"],
+                ],
+            },
+        });
+
+        let thema_set = [["namumark", "vs"], ["namumark-vs-dark", "vs-dark"]]
+        for(let for_a = 0; for_a < thema_set.length; for_a++) {
+            monaco.editor.defineTheme(thema_set[for_a][0], {
+                base : thema_set[for_a][1],
+                inherit : true,
+                rules : [
+                    { token : "namumark-color", foreground : "d94844" },
+                ],
+                colors : {
+                    "editor.foreground" : "",
+                },
+            });
+        }
+
         window.editor = monaco.editor.create(document.getElementById('opennamu_monaco_editor'), {
-            value: document.getElementById('opennamu_edit_textarea').value,
-            language: 'plaintext',
-            automaticLayout: true,
-            wordWrap: true,
-            theme: monaco_thema
+            value : document.getElementById('opennamu_edit_textarea').value,
+            language : 'namumark',
+            automaticLayout : true,
+            wordWrap : true,
+            theme : "namumark" + (monaco_thema === "" ? "" : "-" + monaco_thema)
         });
 
         new PlaceholderContentWidget(document.getElementById('opennamu_edit_textarea').placeholder, window.editor);