From f0da78f0a655caeb62ce959847b57919b1de0748 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 4 Dec 2015 20:23:41 +0100 Subject: [PATCH] Allow to set hidePreview: true on `markdown` field type when defining blueprints. Since the preview is based around the concept of a page, and renders its content, we cannot use it there --- themes/grav/js/mdeditor.js | 52 ++++++++++++------- .../forms/fields/markdown/markdown.html.twig | 2 +- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/themes/grav/js/mdeditor.js b/themes/grav/js/mdeditor.js index d023d1d7..db4c1d5c 100644 --- a/themes/grav/js/mdeditor.js +++ b/themes/grav/js/mdeditor.js @@ -66,30 +66,14 @@ }; }; - var template = [ - '
', - '
', - '
    ', - '
    ', - '', - '
    ', - '', - '
    ', - '
    ', - '
    ', - '
    ', - '
    ', - '
    ' - ].join(''); + var template = ''; var MDEditor = function(editor, options){ - var tpl = '' + template, $this = this, + var $this = this, task = 'task' + GravAdmin.config.param_sep; + var tpl = '' + this.defaults = { markdown : false, autocomplete : true, @@ -107,6 +91,34 @@ this.CodeMirror = CodeMirror; this.buttons = {}; + template = [ + '
    ', + '
    ', + '
      ', + '
      ', + '
        ']; + + if (!$this.element.data('grav-preview-disabled')) { + template.push('
      • {:lblCodeview}
      • '); + template.push('
      • {:lblPreview}
      • '); + } + + template.push( + '
      • ', + '
      ', + '
      ', + '', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ' + ); + + template = template.join(''); + + tpl += template; tpl = tpl.replace(/\{:lblPreview\}/g, this.options.lblPreview); tpl = tpl.replace(/\{:lblCodeview\}/g, this.options.lblCodeview); diff --git a/themes/grav/templates/forms/fields/markdown/markdown.html.twig b/themes/grav/templates/forms/fields/markdown/markdown.html.twig index a0bf5bf8..4d530eb7 100644 --- a/themes/grav/templates/forms/fields/markdown/markdown.html.twig +++ b/themes/grav/templates/forms/fields/markdown/markdown.html.twig @@ -9,7 +9,7 @@ {% block field %}
      - +
      {% endblock %} \ No newline at end of file