|
|
@@ -19,6 +19,57 @@ def edit_timeout(func, args = (), timeout = 3):
|
|
|
pool.close()
|
|
|
pool.join()
|
|
|
return 0
|
|
|
+
|
|
|
+def edit_editor(curs, ip, data_main = '', do_type = 'edit'):
|
|
|
+ monaco_editor_top = ''
|
|
|
+ editor_display = ''
|
|
|
+ add_get_file = ''
|
|
|
+ monaco_display = ''
|
|
|
+
|
|
|
+ monaco_on = get_main_skin_set(curs, flask.session, 'main_css_monaco', ip)
|
|
|
+ if monaco_on == 'use':
|
|
|
+ editor_display = 'style="display: none;"'
|
|
|
+ add_get_file = '''
|
|
|
+ <link rel="stylesheet"
|
|
|
+ data-name="vs/editor/editor.main"
|
|
|
+ href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs/editor/editor.main.min.css">
|
|
|
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs/loader.min.js"></script>
|
|
|
+ '''
|
|
|
+
|
|
|
+ monaco_editor_top = '<a href="javascript:opennamu_edit_turn_off_monaco();">(' + load_lang('turn_off_monaco') + ')</a>'
|
|
|
+
|
|
|
+ if flask.request.cookies.get('main_css_darkmode', '0') == '1':
|
|
|
+ monaco_thema = 'vs-dark'
|
|
|
+ else:
|
|
|
+ monaco_thema = ''
|
|
|
+
|
|
|
+ add_script = 'do_monaco_init("' + monaco_thema + '");'
|
|
|
+ else:
|
|
|
+ monaco_display = 'style="display: none;"'
|
|
|
+ add_script = 'opennamu_edit_turn_off_monaco();'
|
|
|
+
|
|
|
+ curs.execute(db_change('select data from other where name = "edit_help"'))
|
|
|
+ sql_d = curs.fetchall()
|
|
|
+ p_text = html.escape(sql_d[0][0]) if sql_d and sql_d[0][0] != '' else load_lang('default_edit_help')
|
|
|
+
|
|
|
+ if do_type == 'edit':
|
|
|
+ textarea_size = 'opennamu_textarea_500'
|
|
|
+ else:
|
|
|
+ textarea_size = 'opennamu_textarea_100'
|
|
|
+
|
|
|
+ return add_get_file + '''
|
|
|
+ <textarea style="display: none;" id="opennamu_edit_origin" name="doc_data_org">''' + html.escape(data_main) + '''</textarea>
|
|
|
+ <div>''' + monaco_editor_top + ' ' + edit_button('opennamu_edit_textarea', 'opennamu_monaco_editor') + '''</div>
|
|
|
+
|
|
|
+ <div id="opennamu_monaco_editor" class="''' + textarea_size + '''" ''' + monaco_display + '''></div>
|
|
|
+ <textarea id="opennamu_edit_textarea" ''' + editor_display + ''' class="''' + textarea_size + '''" name="content" placeholder="''' + p_text + '''">''' + html.escape(data_main) + '''</textarea>
|
|
|
+ <hr class="main_hr">
|
|
|
+ <script>
|
|
|
+ do_stop_exit();
|
|
|
+ do_paste_image('opennamu_edit_textarea', 'opennamu_monaco_editor');
|
|
|
+ ''' + add_script + '''
|
|
|
+ </script>
|
|
|
+ '''
|
|
|
|
|
|
def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
with get_db_connect() as conn:
|
|
|
@@ -256,58 +307,21 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
|
|
|
editor_top_text += '<a href="/edit_filter">(' + load_lang('edit_filter_rule') + ')</a>'
|
|
|
|
|
|
- curs.execute(db_change('select data from other where name = "edit_help"'))
|
|
|
- sql_d = curs.fetchall()
|
|
|
- p_text = html.escape(sql_d[0][0]) if sql_d and sql_d[0][0] != '' else load_lang('default_edit_help')
|
|
|
-
|
|
|
- monaco_on = get_main_skin_set(curs, flask.session, 'main_css_monaco', ip)
|
|
|
- if monaco_on == 'use':
|
|
|
- editor_display = 'style="display: none;"'
|
|
|
- monaco_display = ''
|
|
|
- add_get_file = '''
|
|
|
- <link rel="stylesheet"
|
|
|
- data-name="vs/editor/editor.main"
|
|
|
- href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs/editor/editor.main.min.css">
|
|
|
- <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.37.1/min/vs/loader.min.js"></script>
|
|
|
- '''
|
|
|
-
|
|
|
- editor_top_text += ' <a href="javascript:opennamu_edit_turn_off_monaco();">(' + load_lang('turn_off_monaco') + ')</a>'
|
|
|
-
|
|
|
- if flask.request.cookies.get('main_css_darkmode', '0') == '1':
|
|
|
- monaco_thema = 'vs-dark'
|
|
|
- else:
|
|
|
- monaco_thema = ''
|
|
|
-
|
|
|
- add_script = 'do_monaco_init("' + monaco_thema + '");'
|
|
|
- else:
|
|
|
- editor_display = ''
|
|
|
- monaco_display = 'style="display: none;"'
|
|
|
- add_get_file = ''
|
|
|
- add_script = 'opennamu_edit_turn_off_monaco();'
|
|
|
-
|
|
|
if editor_top_text != '':
|
|
|
editor_top_text += '<hr class="main_hr">'
|
|
|
|
|
|
sub_menu = ' (' + str(section) + ')' if section != '' else ''
|
|
|
-
|
|
|
+
|
|
|
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>
|
|
|
-
|
|
|
- </script>
|
|
|
+ data = editor_top_text + '''
|
|
|
<form method="post">
|
|
|
- <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 + '''">
|
|
|
|
|
|
<input style="display: none;" name="ver" value="''' + doc_ver + '''">
|
|
|
|
|
|
- <div>''' + edit_button('opennamu_edit_textarea', 'opennamu_monaco_editor') + '''</div>
|
|
|
-
|
|
|
- <div id="opennamu_monaco_editor" class="opennamu_textarea_500" ''' + monaco_display + '''></div>
|
|
|
- <textarea id="opennamu_edit_textarea" ''' + editor_display + ''' class="opennamu_textarea_500" name="content" placeholder="''' + p_text + '''">''' + html.escape(data_section) + '''</textarea>
|
|
|
- <hr class="main_hr">
|
|
|
+ ''' + edit_editor(curs, ip, data_section) + '''
|
|
|
|
|
|
<input placeholder="''' + load_lang('why') + '''" name="send">
|
|
|
<hr class="main_hr">
|
|
|
@@ -320,12 +334,6 @@ def edit(name = 'Test', section = 0, do_type = ''):
|
|
|
|
|
|
<hr class="main_hr">
|
|
|
<div id="opennamu_preview_area">''' + data_preview + '''</div>
|
|
|
-
|
|
|
- <script>
|
|
|
- do_stop_exit();
|
|
|
- do_paste_image('opennamu_edit_textarea', 'opennamu_monaco_editor');
|
|
|
- ''' + add_script + '''
|
|
|
- </script>
|
|
|
''',
|
|
|
menu = [
|
|
|
['w/' + url_pas(name), load_lang('return')],
|