Merge pull request 'Utilisation de https://github.com/sparksuite/simplemde-markdown-editor comme éditeur' (#71) from new_editor into dev

Reviewed-on: https://gitea.planet-casio.com/devs/PCv5/pulls/71
This commit is contained in:
Darks 2020-09-18 17:40:08 +02:00
commit cb3efc2503
4 changed files with 45 additions and 28 deletions

7
app/static/css/simplemde.min.css vendored Normal file

File diff suppressed because one or more lines are too long

15
app/static/scripts/simplemde.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,28 +1,23 @@
{% macro text_editor(field, label=True) %}
<div class="editor">
{{ field.label if label }}
<div class="buttons">
<button type="button" title="Gras" onclick="edit(this, 'bold')"><img src="{{ url_for('static', filename = 'icons/editor/format-bold.svg') }}" alt="Gras" /></button>
<button type="button" title="Italique" onclick="edit(this, 'italic')"><img src="{{ url_for('static', filename = 'icons/editor/format-italic.svg') }}" alt="Italique" /></button>
<button type="button" title="Souligné" onclick="edit(this, 'underline')"><img src="{{ url_for('static', filename = 'icons/editor/format-underline.svg') }}" alt="Souligné" /></button>
<button type="button" title="Barré" onclick="edit(this, 'strikethrough')"><img src="{{ url_for('static', filename = 'icons/editor/format-strikethrough.svg') }}" alt="Barré" /></button>
<button type="button" title="Titre 1" onclick="edit(this, 'h1')"><img src="{{ url_for('static', filename = 'icons/editor/format-header-1.svg') }}" alt="Titre 1" /></button>
<button type="button" title="Titre 2" onclick="edit(this, 'h2')"><img src="{{ url_for('static', filename = 'icons/editor/format-header-2.svg') }}" alt="Titre 2" /></button>
<button type="button" title="Titre 3" onclick="edit(this, 'h3')"><img src="{{ url_for('static', filename = 'icons/editor/format-header-3.svg') }}" alt="Titre 3" /></button>
<button type="button" title="Liste à puces" onclick="edit(this, 'list-bulleted')"><img src="{{ url_for('static', filename = 'icons/editor/format-list-bulleted.svg') }}" alt="Liste à puces" /></button>
<button type="button" title="Liste numérotée" onclick="edit(this, 'list-numbered')"><img src="{{ url_for('static', filename = 'icons/editor/format-list-numbered.svg') }}" alt="Liste numérotée" /></button>
<button type="button" title="Citation" onclick="edit(this, 'quote')"><img src="{{ url_for('static', filename = 'icons/editor/format-quote-close.svg') }}" alt="Citation" /></button>
<button type="button" title="Code" onclick="edit(this, 'code')"><img src="{{ url_for('static', filename = 'icons/editor/code-braces.svg') }}" alt="Code" /></button>
<button type="button" title="Spoiler" onclick="edit(this, 'spoiler')"><img src="{{ url_for('static', filename = 'icons/editor/comment-alert-outline.svg') }}" alt="Spoiler" /></button>
<button type="button" title="Lien" onclick="edit(this, 'link')"><img src="{{ url_for('static', filename = 'icons/editor/link-variant.svg') }}" alt="Lien" /></button>
</div>
{{ field() }}
{% for error in field.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
{{ field.label if label }}
{{ field() }}
<script>
window.addEventListener("load", function(){
var simplemde = new SimpleMDE({
element: document.getElementById("{{field.name}}"),
autofocus: true,
hideIcons: ["guide", "side-by-side", "fullscreen", "heading"],
showIcons: ["code", "table", "horizontal-rule", "ordered-list", "unordered-list", "heading-1", "heading-2", "heading-3", "strikethrough"],
insertTexts: {
image: ["![](https://", ")"],
link: ["[", "](https://)"],
},
spellChecker: false,
forceSync: true,
});
});
</script>
{% for error in field.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
{% endmacro %}

View File

@ -17,19 +17,19 @@ def render(*args, styles=[], scripts=[], **kwargs):
'css/header.css',
'css/container.css',
'css/widgets.css',
'css/editor.css',
'css/form.css',
'css/footer.css',
'css/flash.css',
'css/table.css',
'css/pagination.css',
'css/responsive.css',
'css/simplemde.min.css',
]
scripts_ = [
'scripts/trigger_menu.js',
'scripts/pc-utils.js',
'scripts/smartphone_patch.js',
'scripts/editor.js',
'scripts/simplemde.min.js'
]
for s in styles: