From 5c83abc13c382c69ea97de7a44da53079d2e7a4a Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Wed, 2 Mar 2016 14:37:47 -0800 Subject: [PATCH] Editor Buttons can now specify which modes they should apply to --- themes/grav/app/forms/fields/editor.js | 14 ++++++++++---- themes/grav/app/forms/fields/editor/buttons.js | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/themes/grav/app/forms/fields/editor.js b/themes/grav/app/forms/fields/editor.js index 0166fc77..5a20ff3d 100644 --- a/themes/grav/app/forms/fields/editor.js +++ b/themes/grav/app/forms/fields/editor.js @@ -90,6 +90,10 @@ export default class EditorField { $('head').append($('').attr('href', themeCSS)); } + if (options.mode === 'yaml') { + Object.assign(options.extraKeys, { Tab: function(cm) { cm.replaceSelection(' ', 'end'); }}); + } + let editor = codemirror.fromTextArea(textarea.get(0), options); textarea.data('codemirror', editor); textarea.data('toolbar', new Toolbar(textarea)); @@ -148,8 +152,9 @@ export class Toolbar { this.ui.navigation.find('.grav-editor-actions').empty().append('