diff --git a/themes/grav/js/mdeditor.js b/themes/grav/js/mdeditor.js
index c56c2580..152be99e 100644
--- a/themes/grav/js/mdeditor.js
+++ b/themes/grav/js/mdeditor.js
@@ -1,6 +1,58 @@
((function(){
var editors = [];
+ var toolbarIdentifiers = [ 'bold', 'italic', 'strike', 'link', 'image', 'blockquote', 'listUl', 'listOl' ];
+ if (typeof window.customToolbarElements !== 'undefined') {
+ window.customToolbarElements.forEach(function(customToolbarElement) {
+ toolbarIdentifiers.push(customToolbarElement.identifier);
+ });
+ }
+
+ var toolbarButtons = {
+ fullscreen: {
+ title : 'Fullscreen',
+ label : ''
+ },
+ bold : {
+ title : 'Bold',
+ label : ''
+ },
+ italic : {
+ title : 'Italic',
+ label : ''
+ },
+ strike : {
+ title : 'Strikethrough',
+ label : ''
+ },
+ blockquote : {
+ title : 'Blockquote',
+ label : ''
+ },
+ link : {
+ title : 'Link',
+ label : ''
+ },
+ image : {
+ title : 'Image',
+ label : ''
+ },
+ listUl : {
+ title : 'Unordered List',
+ label : ''
+ },
+ listOl : {
+ title : 'Ordered List',
+ label : ''
+ }
+ };
+
+ if (typeof window.customToolbarElements !== 'undefined') {
+ window.customToolbarElements.forEach(function(customToolbarElement) {
+ toolbarButtons[customToolbarElement.identifier] = customToolbarElement.button;
+ });
+ }
+
var debounce = function(func, wait, immediate) {
var timeout;
return function() {
@@ -44,7 +96,7 @@
autocomplete : true,
height : 500,
codemirror : { mode: 'htmlmixed', theme: 'paper', lineWrapping: true, dragDrop: true, autoCloseTags: true, matchTags: true, autoCloseBrackets: true, matchBrackets: true, indentUnit: 4, indentWithTabs: false, tabSize: 4, hintOptions: {completionSingle:false}, extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"} },
- toolbar : [ 'bold', 'italic', 'strike', 'link', 'image', 'blockquote', 'listUl', 'listOl' ],
+ toolbar : toolbarIdentifiers,
lblPreview : '',
lblCodeview : '',
lblMarkedview: ''
@@ -314,46 +366,7 @@
};
this._initToolbar = function(editor) {
- editor.addButtons({
-
- fullscreen: {
- title : 'Fullscreen',
- label : ''
- },
- bold : {
- title : 'Bold',
- label : ''
- },
- italic : {
- title : 'Italic',
- label : ''
- },
- strike : {
- title : 'Strikethrough',
- label : ''
- },
- blockquote : {
- title : 'Blockquote',
- label : ''
- },
- link : {
- title : 'Link',
- label : ''
- },
- image : {
- title : 'Image',
- label : ''
- },
- listUl : {
- title : 'Unordered List',
- label : ''
- },
- listOl : {
- title : 'Ordered List',
- label : ''
- }
-
- });
+ editor.addButtons(toolbarButtons);
addAction('bold', '**$1**');
addAction('italic', '_$1_');
@@ -406,6 +419,16 @@
}
});
+ if (typeof window.customToolbarElements !== 'undefined') {
+ window.customToolbarElements.forEach(function(customToolbarElement) {
+ editor.element.on('action.' + customToolbarElement.identifier, function() {
+ if (editor.getCursorMode() == 'markdown') {
+ customToolbarElement.processAction(editor);
+ }
+ });
+ });
+ }
+
editor.element.on('cursorMode', function(e, param) {
if (editor.editor.options.mode == 'gfm') {
var pos = editor.editor.getDoc().getCursor();