From ea538dbab3ad52798a9f9343e1cbdd5b68fe9189 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 19 Dec 2018 12:21:57 +0100 Subject: [PATCH] core: handle all basic editing actions in MarkdownInput --- core/templates/core/markdown_textarea.jinja | 138 +++++++++++++++++++- 1 file changed, 132 insertions(+), 6 deletions(-) diff --git a/core/templates/core/markdown_textarea.jinja b/core/templates/core/markdown_textarea.jinja index 054c29f9..cbfaad07 100644 --- a/core/templates/core/markdown_textarea.jinja +++ b/core/templates/core/markdown_textarea.jinja @@ -1,4 +1,5 @@
+ {# Depends on this package https://github.com/sparksuite/simplemde-markdown-editor #} {# The simplemde script can be included twice, it's safe in the code #} @@ -49,12 +50,137 @@ previewRender: function(plainText, preview){ // Async method return customMarkdownParser(plainText, preview); }, - showIcons: ["code", "table", "clean-block"] - }); - - // Change the behavior of the markdown guide button to use our page - $("[title='Markdown Guide']").each(function() { - $(this).prop("href", "/page/Aide_sur_la_syntaxe/"); + // showIcons: ["code", "table", "clean-block"], + toolbar: [ + { + name: "heading", + action: SimpleMDE.toogleHeadingSmaller, + className: "fa fa-header", + title: "Heading" + }, + { + name: "italic", + action: SimpleMDE.toggleItalic, + className: "fa fa-italic", + title: "Italic" + }, + { + name: "bold", + action: SimpleMDE.toggleBold, + className: "fa fa-bold", + title: "Bold" + }, + { + name: "strikethrough", + action: SimpleMDE.toggleStrikethrough, + className: "fa fa-strikethrough", + title: "Strikethrough" + }, + { + name: "underline", + action: function customFunction(editor){ + var cm = editor.codemirror; + cm.replaceSelection('__' + cm.getSelection() + '__'); + }, + className: "fa fa-underline", + title: "Underline" + }, + { + name: "sup", + action: function customFunction(editor){ + var cm = editor.codemirror; + cm.replaceSelection('' + cm.getSelection() + ''); + }, + className: "fa fa-superscript", + title: "Sup" + }, + { + name: "sub", + action: function customFunction(editor){ + var cm = editor.codemirror; + cm.replaceSelection('' + cm.getSelection() + ''); + }, + className: "fa fa-subscript", + title: "Sub" + }, + { + name: "code", + action: SimpleMDE.toggleCodeBlock, + className: "fa fa-code", + title: "Code" + }, + "|", + { + name: "quote", + action: SimpleMDE.toggleBlockquote, + className: "fa fa-quote-left", + title: "Quote" + }, + { + name: "unordered-list", + action: SimpleMDE.toggleUnorderedList, + className: "fa fa-list-ul", + title: "Generic List" + }, + { + name: "ordered-list", + action: SimpleMDE.toggleOrderedList, + className: "fa fa-list-ol", + title: "Numbered List" + }, + "|", + { + name: "link", + action: SimpleMDE.drawLink, + className: "fa fa-link", + title: "Create Link" + }, + { + name: "image", + action: SimpleMDE.drawImage, + className: "fa fa-picture-o", + title: "Insert Image" + }, + { + name: "table", + action: SimpleMDE.drawTable, + className: "fa fa-table", + title: "Insert Table" + }, + "|", + { + name: "clean-block", + action: SimpleMDE.cleanBlock, + className: "fa fa-eraser fa-clean-block", + title: "Clean block" + }, + "|", + { + name: "preview", + action: SimpleMDE.togglePreview, + className: "fa fa-eye no-disable", + title: "Toggle Preview" + }, + { + name: "side-by-side", + action: SimpleMDE.toggleSideBySide, + className: "fa fa-columns no-disable no-mobile", + title: "Toggle Side by Side" + }, + { + name: "fullscreen", + action: SimpleMDE.toggleFullScreen, + className: "fa fa-arrows-alt no-disable no-mobile", + title: "Toggle Fullscreen" + }, + "|", + { + name: "guide", + action: "/page/Aide_sur_la_syntaxe", + className: "fa fa-question-circle", + title: "Markdown Guide" + }, + ] });
\ No newline at end of file