Ver Fonte

fix editor

2du há 5 anos atrás
pai
commit
8aed093487

+ 10 - 7
route/edit.py

@@ -184,25 +184,27 @@ def edit_2(conn, name):
                         href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/editor/editor.main.min.css">
                 <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/loader.min.js"></script>
             '''
+            
+            if flask.request.cookies.get('main_css_darkmode', '0') == '1':
+                monaco_thema = 'vs-dark'
+            else:
+                monaco_thema = ''
+            
             add_script = '''
                 require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs' }});
                 require(["vs/editor/editor.main"], function () {
                     window.editor = monaco.editor.create(document.getElementById('monaco_editor'), {
                         value: document.getElementById('content').value,
                         language: 'plaintext',
-                        theme: 'vs-dark'
+                        theme: \'''' + monaco_thema + '''\'
                     });
                 });
-
-                function monaco_to_content() {
-                    document.getElementById('content').innerHTML = window.editor.getValue();
-                }
             '''
         else:
             editor_display = ''
             monaco_display = 'style="display: none;"'
             add_get_file = ''
-            add_script = 'function monaco_to_content() {}'
+            add_script = ''
 
         return easy_minify(flask.render_template(skin_check(), 
             imp = [name, wiki_set(), custom(), other2(['(' + load_lang('edit') + ')', 0])],
@@ -224,7 +226,8 @@ def edit_2(conn, name):
                                 name="content">''' + html.escape(data) + '''</textarea>
                     <hr class="main_hr">
                     <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                    <input id="origin" name="ver" value="''' + doc_ver + '''">
+                    <textarea style="display: none;" id="origin">''' + html.escape(data) + '''</textarea>
+                    <input style="display: none;" name="ver" value="''' + doc_ver + '''">
                     <hr class="main_hr">
                     ''' + captcha_get() + ip_warring() + cccb_text + '''
                     <button id="save"

+ 1 - 1
route/tool/func.py

@@ -578,7 +578,7 @@ def next_fix(link, num, page, end = 50):
 
 def other2(data):
     global req_list
-    main_css_ver = '59'
+    main_css_ver = '60'
     data += ['' for _ in range(0, 3 - len(data))]
 
     if req_list == '':

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.2.0-stable-13 (beta-50) (dev-2021-02-21-01)",
+        "r_ver" : "v3.2.0-stable-13 (beta-51) (dev-2021-02-21-02)",
         "c_ver" : "3203400",
         "s_ver" : "11"
     }

+ 5 - 8
views/main_css/css/main.css

@@ -173,14 +173,11 @@ body {
 
 @media (max-width: 768px) {
     table {
-    min-width: 100%;
-}
- .table_safe {
-    min-width: 100%;
-}
-}
-#origin {
-    display: none;
+        min-width: 100%;
+    }
+    .table_safe {
+        min-width: 100%;
+    }
 }
 
 .all_in_data {

+ 8 - 0
views/main_css/js/load_editor.js

@@ -16,9 +16,17 @@ function do_insert_data(name, data) {
     }
 }
 
+function monaco_to_content() {
+    try {
+        document.getElementById('content').innerHTML = window.editor.getValue();
+    } catch(e) {}
+}
+
 function do_not_out() {
     window.addEventListener('DOMContentLoaded', function() {
         window.onbeforeunload = function() {
+            monaco_to_content();
+            
             data = document.getElementById('content').value;
             origin = document.getElementById('origin').value;
             if(data !== origin) {

+ 27 - 2
views/main_css/js/load_onmark_render.js

@@ -89,15 +89,35 @@ function do_onmark_heading_render(data) {
 
 function do_onmark_link_render(data, data_js, name_doc, name_include) {
     var link_num = 0;
+    var category_data = '';
+    var category_re = /^(분류|category):/i;
+    var file_re = /^(파일|file):/i;
     data = data.replace(/\[\[(((?!\]\]).)+)\]\]/g, function(x, x_1) {
         var link_split = x_1.split('|');
         var link_real = link_split[0];
         var link_out = link_split[1] ? link_split[1] : link_split[0];
+        var link_out_2 = link_split[1] ? link_split[1] : '';
         
         link_num += 1;
         var link_num_str = String(link_num - 1);
-        
-        if(link_real.match(/^http(s)?:\/\//)) {
+        if(link_real.match(file_re)) {
+            var file_name = link_real.replace(file_re, '');
+            console.log(file_name);
+            
+            return '';
+        } else if(link_real.match(category_re)) {
+            var category_link = link_real.replace(category_re, '');
+            
+            category_data = (category_data === '' ? '<div id="cate_all"><div id="cate">Category : ' : category_data);
+            category_data += '' +
+                '<a class="' + name_include + 'link_finder" ' +
+                    'href="/w/category:' + do_url_change(category_link) + '">' +
+                    category_link +
+                '</a> | ' +
+            ''
+            
+            return '';
+        } else if(link_real.match(/^http(s)?:\/\//)) {
             var i = 0;
             while(i < 2) {
                 if(i === 0) {
@@ -146,6 +166,8 @@ function do_onmark_link_render(data, data_js, name_doc, name_include) {
         }
     });
     
+    data += (category_data === '' ? '' : (category_data.replace(/\| $/, '') + '</div></div>'))
+    
     return [data, data_js];
 }
 
@@ -321,6 +343,8 @@ function do_onmark_middle_render(data, data_js, name_include) {
                 
                 data = data.replace(middle_re, '<span id="' + name_include + 'render_contect_' + String(html_n) + '">');
                 middle_stack.push('</span>');
+            } else if(middle_data[1] === '#!folding') {
+                                
             } else {
                 data = data.replace(middle_re, '<middle_start>' + middle_data[1]);   
             }
@@ -418,6 +442,7 @@ function do_onmark_render(test_mode = 1, name_id = '', name_include = '', name_d
         ).replace(/\n/g, '<br>') + '<br>';
     }
     var data_js = '';
+    var data_backlink = [];
     
     var var_data = do_onmark_nowiki_before_render(data, data_js, name_include);
     data = var_data[0];