From 265ad69edce1bcaf6f8d5a548bb4cbe6c3754ef3 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Wed, 16 Mar 2016 18:39:01 -0700 Subject: [PATCH] Added built-in heading buttons in Editor --- .../grav/app/forms/fields/editor/buttons.js | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/themes/grav/app/forms/fields/editor/buttons.js b/themes/grav/app/forms/fields/editor/buttons.js index 9c6649ac..bab43800 100644 --- a/themes/grav/app/forms/fields/editor/buttons.js +++ b/themes/grav/app/forms/fields/editor/buttons.js @@ -112,6 +112,76 @@ export default { } } }, + { + headers: { + identifier: 'headers', + title: 'Headers', + label: '', + modes: ['gfm', 'markdown'], + children: [ + { + h1: { + identifier: 'h1', + label: '1', + modes: ['gfm', 'markdown'], + action({ codemirror, button, textarea }) { + replacer({ name: 'h1', replace: '# $1', codemirror, button, mode: 'replaceLine' }); + } + } + }, + { + h2: { + identifier: 'h2', + label: '2', + modes: ['gfm', 'markdown'], + action({ codemirror, button, textarea }) { + replacer({ name: 'h2', replace: '## $1', codemirror, button, mode: 'replaceLine' }); + } + } + }, + { + h3: { + identifier: 'h3', + label: '3', + modes: ['gfm', 'markdown'], + action({ codemirror, button, textarea }) { + replacer({ name: 'h3', replace: '### $1', codemirror, button, mode: 'replaceLine' }); + } + } + }, + { + h4: { + identifier: 'h4', + label: '4', + modes: ['gfm', 'markdown'], + action({ codemirror, button, textarea }) { + replacer({ name: 'h4', replace: '#### $1', codemirror, button, mode: 'replaceLine' }); + } + } + }, + { + h5: { + identifier: 'h5', + label: '5', + modes: ['gfm', 'markdown'], + action({ codemirror, button, textarea }) { + replacer({ name: 'h5', replace: '##### $1', codemirror, button, mode: 'replaceLine' }); + } + } + }, + { + h6: { + identifier: 'h6', + label: '6', + modes: ['gfm', 'markdown'], + action({ codemirror, button, textarea }) { + replacer({ name: 'h6', replace: '###### $1', codemirror, button, mode: 'replaceLine' }); + } + } + } + ] + } + }, { bold: { identifier: 'bold',