mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-13 16:56:04 +01:00
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
This commit is contained in:
@@ -66,30 +66,14 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var template = [
|
var template = '';
|
||||||
'<div class="grav-mdeditor clearfix" data-mode="tab" data-active-tab="code">',
|
|
||||||
'<div class="grav-mdeditor-navbar">',
|
|
||||||
'<ul class="grav-mdeditor-navbar-nav grav-mdeditor-toolbar"></ul>',
|
|
||||||
'<div class="grav-mdeditor-navbar-flip">',
|
|
||||||
'<ul class="grav-mdeditor-navbar-nav">',
|
|
||||||
'<li class="grav-mdeditor-button-code mdeditor-active"><a>{:lblCodeview}</a></li>',
|
|
||||||
'<li class="grav-mdeditor-button-preview"><a>{:lblPreview}</a></li>',
|
|
||||||
'<li><a data-mdeditor-button="fullscreen"><i class="fa fa-fw fa-expand"></i></a></li>',
|
|
||||||
'</ul>',
|
|
||||||
'</div>',
|
|
||||||
'<p class="grav-mdeditor-preview-text" style="display: none;">Preview</p>',
|
|
||||||
'</div>',
|
|
||||||
'<div class="grav-mdeditor-content">',
|
|
||||||
'<div class="grav-mdeditor-code"></div>',
|
|
||||||
'<div class="grav-mdeditor-preview"><div></div></div>',
|
|
||||||
'</div>',
|
|
||||||
'</div>'
|
|
||||||
].join('');
|
|
||||||
|
|
||||||
var MDEditor = function(editor, options){
|
var MDEditor = function(editor, options){
|
||||||
var tpl = '' + template, $this = this,
|
var $this = this,
|
||||||
task = 'task' + GravAdmin.config.param_sep;
|
task = 'task' + GravAdmin.config.param_sep;
|
||||||
|
|
||||||
|
var tpl = ''
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
markdown : false,
|
markdown : false,
|
||||||
autocomplete : true,
|
autocomplete : true,
|
||||||
@@ -107,6 +91,34 @@
|
|||||||
this.CodeMirror = CodeMirror;
|
this.CodeMirror = CodeMirror;
|
||||||
this.buttons = {};
|
this.buttons = {};
|
||||||
|
|
||||||
|
template = [
|
||||||
|
'<div class="grav-mdeditor clearfix" data-mode="tab" data-active-tab="code">',
|
||||||
|
'<div class="grav-mdeditor-navbar">',
|
||||||
|
'<ul class="grav-mdeditor-navbar-nav grav-mdeditor-toolbar"></ul>',
|
||||||
|
'<div class="grav-mdeditor-navbar-flip">',
|
||||||
|
'<ul class="grav-mdeditor-navbar-nav">'];
|
||||||
|
|
||||||
|
if (!$this.element.data('grav-preview-disabled')) {
|
||||||
|
template.push('<li class="grav-mdeditor-button-code mdeditor-active"><a>{:lblCodeview}</a></li>');
|
||||||
|
template.push('<li class="grav-mdeditor-button-preview"><a>{:lblPreview}</a></li>');
|
||||||
|
}
|
||||||
|
|
||||||
|
template.push(
|
||||||
|
'<li><a data-mdeditor-button="fullscreen"><i class="fa fa-fw fa-expand"></i></a></li>',
|
||||||
|
'</ul>',
|
||||||
|
'</div>',
|
||||||
|
'<p class="grav-mdeditor-preview-text" style="display: none;">Preview</p>',
|
||||||
|
'</div>',
|
||||||
|
'<div class="grav-mdeditor-content">',
|
||||||
|
'<div class="grav-mdeditor-code"></div>',
|
||||||
|
'<div class="grav-mdeditor-preview"><div></div></div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
template = template.join('');
|
||||||
|
|
||||||
|
tpl += template;
|
||||||
tpl = tpl.replace(/\{:lblPreview\}/g, this.options.lblPreview);
|
tpl = tpl.replace(/\{:lblPreview\}/g, this.options.lblPreview);
|
||||||
tpl = tpl.replace(/\{:lblCodeview\}/g, this.options.lblCodeview);
|
tpl = tpl.replace(/\{:lblCodeview\}/g, this.options.lblCodeview);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{% block field %}
|
{% block field %}
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<div class="form-data form-markdown-wrapper cm-s-paper">
|
<div class="form-data form-markdown-wrapper cm-s-paper">
|
||||||
<textarea data-grav-mdeditor="{{ { 'markdown': true }|json_encode|e('html_attr') }}" name="{{ (scope ~ field.name)|fieldName }}" data-grav-urlpreview="{{ base_url }}/media/{{ admin.route|trim('/') }}.json">{{ value|join("\n")|e('html') }}</textarea>
|
<textarea data-grav-mdeditor="{{ { 'markdown': true }|json_encode|e('html_attr') }}" name="{{ (scope ~ field.name)|fieldName }}" {% if field.hidePreview %}data-grav-preview-disabled="true"{% endif %} data-grav-urlpreview="{{ base_url }}/media/{{ admin.route|trim('/') }}.json">{{ value|join("\n")|e('html') }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user