Selaa lähdekoodia

Merge pull request #1185 from openNAMU/dev

Dev
잉여개발기 (SPDV) 4 vuotta sitten
vanhempi
sitoutus
ac2ca4f813

+ 8 - 6
route/edit.py

@@ -156,7 +156,7 @@ def edit_2(conn, name):
                 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,
+                        value: document.getElementById('textarea_edit_view').value,
                         language: 'plaintext',
                         theme: \'''' + monaco_thema + '''\'
                     });
@@ -186,16 +186,18 @@ def edit_2(conn, name):
                     <div    id="monaco_editor"
                             class="content" 
                             ''' + monaco_display + '''></div>
-                    <textarea   id="content"
+                    <textarea   id="textarea_edit_view"
                                 ''' + editor_display + '''
-                                class="content" 
-                                placeholder="''' + p_text + '''" 
-                                name="content">''' + html.escape(data) + '''</textarea>
+                                class="content"
+                                placeholder="''' + p_text + '''">''' + html.escape(data) + '''</textarea>
                     <hr class="main_hr">
                     <input  placeholder="''' + load_lang('why') + '''" 
                             name="send">
                     <textarea   style="display: none;" 
                                 id="origin">''' + html.escape(data) + '''</textarea>
+                    <textarea   style="display: none;"
+                                name="content"
+                                id="content"></textarea>
                     <input  style="display: none;" 
                             name="ver" 
                             value="''' + doc_ver + '''">
@@ -211,7 +213,7 @@ def edit_2(conn, name):
                     <button id="preview" 
                             type="button" 
                             onclick="
-                                monaco_to_content(); 
+                                monaco_to_content();
                                 load_preview(\'''' + url_pas(name) + '''\');
                             ">''' + load_lang('preview') + '''</button>
                 </form>

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.0-beta (stable2) (beta4) (dev16)",
+        "r_ver" : "v3.4.0-beta (stable2) (beta5) (dev20)",
         "c_ver" : "3400101",
         "s_ver" : "12"
     }

+ 9 - 6
views/main_css/js/load_editor.js

@@ -35,7 +35,7 @@ function do_insert_data(name, data, monaco = 0) {
 
 function monaco_to_content() {
     try {
-        document.getElementById('content').innerHTML = window.editor.getValue();
+        document.getElementById('textarea_edit_view').value = window.editor.getValue();
     } catch(e) {}
 }
 
@@ -43,6 +43,7 @@ function do_not_out() {
     window.addEventListener('DOMContentLoaded', function() {
         window.onbeforeunload = function() {
             monaco_to_content();
+            section_edit_do();
             
             data = document.getElementById('content').value;
             origin = document.getElementById('origin').value;
@@ -130,7 +131,7 @@ function pasteListener(e) {
 
 function load_preview(name) {
     var s_data = new FormData();
-    s_data.append('data', document.getElementById('content').value);
+    s_data.append('data', document.getElementById('textarea_edit_view').value);
 
     var url = "/api/w/" + name;
     var url_2 = "/api/markup";
@@ -162,7 +163,7 @@ function section_edit_init() {
     );
     
     if(data_server['markup'] === 'namumark') {
-        var data = document.getElementById('content').value;
+        var data = document.getElementById('textarea_edit_view').value;
         var data_org = data;
         var data_section = Number(data_server['section']);
         var re_heading = /(^|\n)(={1,6})(#)? ?([^=]+) ?#?={1,6}(\n|$)/;
@@ -185,7 +186,7 @@ function section_edit_init() {
                 data = data_org.slice(start_point, end_point);
                 data = data.replace(/\n$/, '');
                 
-                document.getElementById('content').value = data;
+                document.getElementById('textarea_edit_view').value = data;
                 
                 data_server['start_point'] = start_point;
                 data_server['end_point'] = end_point;
@@ -209,12 +210,12 @@ function section_edit_do() {
     
     if(data_server['start_point'] !== undefined) {
         var data = document.getElementById('origin').value;
-        var data_section = document.getElementById('content').value;
+        var data_section = document.getElementById('textarea_edit_view').value;
         
         var start_point = data_server['start_point'];
         var end_point = data_server['end_point'];
         
-        if(data.length >= end_point) {            
+        if(data.length >= end_point) {
             var data_new = '';
             data_new += data.slice(0, start_point);
             data_new += data_section;
@@ -222,5 +223,7 @@ function section_edit_do() {
             
             document.getElementById('content').value = data_new;
         }
+    } else {
+        document.getElementById('content').value = document.getElementById('textarea_edit_view').value;
     }
 }

+ 15 - 16
views/main_css/js/load_shortcut.js

@@ -4,15 +4,14 @@ document.onkeyup = function(e) {
 }
 
 document.onkeypress = function(e) {
-    let doc_shortcut = /^\/(w|history)\//i;
-    
-    shortcut_key_list[e.key] = 1;
+    let shortcut_check = event.target.tagName.toLowerCase();
     if(
-        window.location.pathname.match(doc_shortcut) ||
-        window.location.pathname === '/recent_change' ||
-        window.location.pathname === '/recent_changes' ||
-        window.location.pathname === '/recent_discuss'
+        shortcut_check !== 'input' &&
+        shortcut_check !== 'textarea'
     ) {
+        let doc_shortcut = /^\/(w|history|edit|acl|topic|xref)\//i;
+
+        shortcut_key_list[e.key] = 1;
         if(shortcut_key_list['f'] === 1) {
             window.location.href = '/';
         } else if(shortcut_key_list['c'] === 1) {
@@ -22,15 +21,15 @@ document.onkeypress = function(e) {
         } else if(shortcut_key_list['a'] === 1) {
             window.location.href = '/random';
         }
-    }
-    
-    if(window.location.pathname.match(doc_shortcut)) {
-        if(shortcut_key_list['w'] === 1) {
-            window.location.pathname = window.location.pathname.replace(doc_shortcut, '/w/');
-        } else if(shortcut_key_list['e'] === 1) {
-            window.location.pathname = window.location.pathname.replace(doc_shortcut, '/edit/');
-        } else if(shortcut_key_list['h'] === 1) {
-            window.location.pathname = window.location.pathname.replace(doc_shortcut, '/history/');
+
+        if(window.location.pathname.match(doc_shortcut)) {
+            if(shortcut_key_list['w'] === 1) {
+                window.location.pathname = window.location.pathname.replace(doc_shortcut, '/w/');
+            } else if(shortcut_key_list['e'] === 1) {
+                window.location.pathname = window.location.pathname.replace(doc_shortcut, '/edit/');
+            } else if(shortcut_key_list['h'] === 1) {
+                window.location.pathname = window.location.pathname.replace(doc_shortcut, '/history/');
+            }
         }
     }
 }

+ 10 - 4
views/main_css/js/render_onmark.js

@@ -244,7 +244,9 @@ function do_onmark_link_render(data, data_js, name_doc, name_include, data_nowik
 
             num_link += 1;
             var num_link_str = String(num_link - 1);
-            if(link_real.match(file_re)) {
+            if(link_real.match(/<|>/)) {
+                return '<link_s>' + x_1 + '<link_e>';
+            } else if(link_real.match(file_re)) {
                 var file_load_type = link_real.match(file_re)[1];
                 var file_name = link_real.replace(file_re, '');
 
@@ -446,6 +448,9 @@ function do_onmark_link_render(data, data_js, name_doc, name_include, data_nowik
             }
         });
     }
+    
+    data = data.replace(/<link_s>/, '[[');
+    data = data.replace(/<link_e>/, ']]');
 
     if(category_data !== '') {
         if(name_include === '') {
@@ -670,7 +675,7 @@ function do_onmark_middle_render(data, data_js, name_include, data_nowiki, name_
 
                         return middle_data_before + '<span id="' + name_include + 'nowiki_html_' + String(html_n) + '"></span>';
                     } else if(middle_type_sub === 'wiki') {
-                        var middle_wiki_re = /^(?:[^ ]+)(?: style=['"]([^\n'"]*)['"])?\n?/;
+                        var middle_wiki_re = /^(?:[^ ]+)(?: style=['"]([^\n'"]*)['"])?[^\n]*\n?/;
                         var middle_wiki = middle_data_x_1.match(middle_wiki_re);
                         middle_wiki = middle_wiki[1] ? middle_wiki[1] : '';
                         middle_wiki = middle_wiki.replace(/position/, '');
@@ -713,10 +718,11 @@ function do_onmark_middle_render(data, data_js, name_include, data_nowiki, name_
                     } else if(middle_type_sub === 'syntax') {
                         syntax_n += 1;
 
-                        var middle_syntax = middle_data_x_1.match(/^(?:[^ ]+) ([^\n]+)\n/);
+                        let middle_syntax_re = /^(?:[^ ]+) ([^\n]+)\n?/;
+                        var middle_syntax = middle_data_x_1.match(middle_syntax_re);
                         middle_syntax = middle_syntax ? middle_syntax[1] : 'python';
 
-                        middle_data_all = middle_data_x_1.replace(/^(?:[^ ]+) ([^\n]+)\n/, '');
+                        middle_data_all = middle_data_x_1.replace(middle_syntax_re, '');
 
                         data_nowiki[name_include + 'nowiki_syntax_' + String(syntax_n)] = middle_data_all;
                         data_js += do_data_try_insert(