|
|
@@ -19,6 +19,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
post_ver = flask.request.form.get('ver', '')
|
|
|
if flask.request.method == 'POST':
|
|
|
edit_repeat = 'error' if post_ver != doc_ver else 'post'
|
|
|
+ edit_repeat = 'error' if do_type == 'preview' else 'post'
|
|
|
else:
|
|
|
edit_repeat = 'get'
|
|
|
|
|
|
@@ -113,6 +114,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
doc_section_edit_apply = 'X'
|
|
|
data_section = ''
|
|
|
data_section_where = ''
|
|
|
+ data_preview = ''
|
|
|
|
|
|
if edit_repeat == 'get':
|
|
|
if do_type == 'load':
|
|
|
@@ -175,22 +177,43 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
count += 1
|
|
|
else:
|
|
|
data = flask.request.form.get('content', '')
|
|
|
- warning_edit = load_lang('exp_edit_conflict') + ' '
|
|
|
-
|
|
|
- if flask.request.form.get('ver', '0') == '0':
|
|
|
- warning_edit += '<a href="/raw/' + url_pas(name) + '">(r' + doc_ver + ')</a>'
|
|
|
+ data = data.replace('\r\n', '\n')
|
|
|
+
|
|
|
+ data_section_where = flask.request.form.get('doc_section_data_where', '')
|
|
|
+ doc_section_edit_apply = flask.request.form.get('doc_section_edit_apply', '')
|
|
|
+
|
|
|
+ doc_ver = flask.request.form.get('ver', '')
|
|
|
+
|
|
|
+ if do_type != 'preview':
|
|
|
+ warning_edit = load_lang('exp_edit_conflict') + ' '
|
|
|
+
|
|
|
+ if flask.request.form.get('ver', '0') == '0':
|
|
|
+ warning_edit += '<a href="/raw/' + url_pas(name) + '">(r' + doc_ver + ')</a>'
|
|
|
+ else:
|
|
|
+ warning_edit += '' + \
|
|
|
+ '<a href="/diff/' + flask.request.form.get('ver', '1') + '/' + doc_ver + '/' + url_pas(name) + '">' + \
|
|
|
+ '(r' + doc_ver + ')' + \
|
|
|
+ '</a>' + \
|
|
|
+ ''
|
|
|
+
|
|
|
+ warning_edit += '<hr class="main_hr">'
|
|
|
+ editor_top_text = warning_edit + editor_top_text
|
|
|
else:
|
|
|
- warning_edit += '' + \
|
|
|
- '<a href="/diff/' + flask.request.form.get('ver', '1') + '/' + doc_ver + '/' + url_pas(name) + '">' + \
|
|
|
- '(r' + doc_ver + ')' + \
|
|
|
- '</a>' + \
|
|
|
- ''
|
|
|
-
|
|
|
- warning_edit += '<hr class="main_hr">'
|
|
|
- editor_top_text = warning_edit + editor_top_text
|
|
|
+ data_preview = render_set(
|
|
|
+ doc_name = name,
|
|
|
+ doc_data = data,
|
|
|
+ data_in = ''
|
|
|
+ )
|
|
|
|
|
|
if data_section == '':
|
|
|
data_section = data
|
|
|
+
|
|
|
+ if section == '':
|
|
|
+ form_action = 'formaction="/edit/' + url_pas(name) + '"'
|
|
|
+ form_action_preview = 'formaction="/edit_preview/' + url_pas(name) + '"'
|
|
|
+ else:
|
|
|
+ form_action = 'formaction="/edit_section/' + str(section) + '/' + url_pas(name) + '"'
|
|
|
+ form_action_preview = 'formaction="/edit_section_preview/' + str(section) + '/' + url_pas(name) + '"'
|
|
|
|
|
|
editor_top_text += '<a href="/edit_filter">(' + load_lang('edit_filter_rule') + ')</a>'
|
|
|
|
|
|
@@ -205,17 +228,8 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
add_get_file = '''
|
|
|
<link rel="stylesheet"
|
|
|
data-name="vs/editor/editor.main"
|
|
|
- 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>
|
|
|
- <script>
|
|
|
- function opennamu_edit_turn_off_monaco() {
|
|
|
- do_monaco_to_textarea();
|
|
|
-
|
|
|
- document.getElementById('opennamu_js_edit_textarea_view').style.display = 'block';
|
|
|
- document.getElementById('opennamu_monaco_editor').style.display = 'none';
|
|
|
- document.getElementById('opennamu_monaco_editor').remove();
|
|
|
- }
|
|
|
- </script>
|
|
|
+ href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.1/min/vs/editor/editor.main.min.css">
|
|
|
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.1/min/vs/loader.min.js"></script>
|
|
|
'''
|
|
|
|
|
|
editor_top_text += ' <a href="javascript:opennamu_edit_turn_off_monaco();">(' + load_lang('turn_off_monaco') + ')</a>'
|
|
|
@@ -226,14 +240,15 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
monaco_thema = ''
|
|
|
|
|
|
add_script = '''
|
|
|
- require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs' }});
|
|
|
+ require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.1/min/vs' }});
|
|
|
+ require.config({ 'vs/nls': { availableLanguages: { '*': 'ko' } }});
|
|
|
require(["vs/editor/editor.main"], function () {
|
|
|
window.editor = monaco.editor.create(document.getElementById('opennamu_monaco_editor'), {
|
|
|
- value: document.getElementById('opennamu_js_edit_textarea_view').value,
|
|
|
+ value: document.getElementById('opennamu_edit_textarea').value,
|
|
|
language: 'plaintext',
|
|
|
+ automaticLayout: true,
|
|
|
wordWrap: true,
|
|
|
- theme: \'''' + monaco_thema + '''\',
|
|
|
- minimap: { enabled: false }
|
|
|
+ theme: \'''' + monaco_thema + '''\'
|
|
|
});
|
|
|
});
|
|
|
'''
|
|
|
@@ -251,18 +266,34 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
return easy_minify(flask.render_template(skin_check(),
|
|
|
imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('edit') + ')' + sub_menu, 0])],
|
|
|
data = editor_top_text + add_get_file + '''
|
|
|
+ <script>
|
|
|
+ function opennamu_edit_turn_off_monaco() {
|
|
|
+ do_monaco_to_textarea();
|
|
|
+
|
|
|
+ document.getElementById('opennamu_edit_textarea').style.display = 'block';
|
|
|
+ document.getElementById('opennamu_monaco_editor').style.display = 'none';
|
|
|
+ document.getElementById('opennamu_monaco_editor').remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ function do_monaco_to_textarea() {
|
|
|
+ if(document.getElementById('opennamu_monaco_editor')) {
|
|
|
+ try {
|
|
|
+ document.getElementById('opennamu_edit_textarea').value = window.editor.getValue();
|
|
|
+ } catch(e) {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </script>
|
|
|
<form method="post">
|
|
|
- <textarea style="display: none;" id="opennamu_js_edit_origin" name="doc_data_org">''' + html.escape(data_section) + '''</textarea>
|
|
|
+ <textarea style="display: none;" id="opennamu_edit_origin" name="doc_data_org">''' + html.escape(data_section) + '''</textarea>
|
|
|
<textarea style="display: none;" name="doc_section_data_where">''' + data_section_where + '''</textarea>
|
|
|
<input style="display: none;" name="doc_section_edit_apply" value="''' + doc_section_edit_apply + '''">
|
|
|
|
|
|
- <textarea style="display: none;" id="opennamu_js_edit_textarea" name="content"></textarea>
|
|
|
<input style="display: none;" name="ver" value="''' + doc_ver + '''">
|
|
|
|
|
|
- <div>''' + edit_button(monaco_on) + '''</div>
|
|
|
+ <div>''' + edit_button('opennamu_edit_textarea', 'opennamu_monaco_editor') + '''</div>
|
|
|
|
|
|
<div id="opennamu_monaco_editor" class="content" ''' + monaco_display + '''></div>
|
|
|
- <textarea id="opennamu_js_edit_textarea_view" ''' + editor_display + ''' class="content" placeholder="''' + p_text + '''">''' + html.escape(data_section) + '''</textarea>
|
|
|
+ <textarea id="opennamu_edit_textarea" ''' + editor_display + ''' class="content" name="content" placeholder="''' + p_text + '''">''' + html.escape(data_section) + '''</textarea>
|
|
|
<hr class="main_hr">
|
|
|
|
|
|
<input placeholder="''' + load_lang('why') + '''" name="send">
|
|
|
@@ -270,18 +301,35 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
|
|
|
''' + captcha_get() + ip_warning() + get_edit_text_bottom_check_box() + get_edit_text_bottom() + '''
|
|
|
|
|
|
- <button id="opennamu_js_save" type="submit">''' + load_lang('save') + '''</button>
|
|
|
- <button id="opennamu_js_preview" type="button">''' + load_lang('preview') + '''</button>
|
|
|
+ <button id="opennamu_save_button" type="submit" ''' + form_action + ''' onclick="do_monaco_to_textarea(); do_stop_exit_release();">''' + load_lang('save') + '''</button>
|
|
|
+ <button id="opennamu_preview_button" type="submit" ''' + form_action_preview + ''' onclick="do_monaco_to_textarea(); do_stop_exit_release();">''' + load_lang('preview') + '''</button>
|
|
|
</form>
|
|
|
|
|
|
<hr class="main_hr">
|
|
|
- <div id="opennamu_js_preview_area"></div>
|
|
|
+ <div id="opennamu_preview_area">''' + data_preview + '''</div>
|
|
|
|
|
|
<script>
|
|
|
+ function do_stop_exit() {
|
|
|
+ window.onbeforeunload = function() {
|
|
|
+ do_monaco_to_textarea();
|
|
|
+
|
|
|
+ let data = document.getElementById('opennamu_edit_textarea').value;
|
|
|
+ let origin = document.getElementById('opennamu_edit_origin').value;
|
|
|
+ if(data !== origin) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function do_stop_exit_release() {
|
|
|
+ window.onbeforeunload = function () {}
|
|
|
+ }
|
|
|
+
|
|
|
+ do_stop_exit();
|
|
|
do_paste_image();
|
|
|
+
|
|
|
''' + add_script + '''
|
|
|
</script>
|
|
|
- <!-- JS : edit.js -->
|
|
|
''',
|
|
|
menu = [
|
|
|
['w/' + url_pas(name), load_lang('return')],
|