mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 05:16:45 +02:00
Deprecated frontmatter field type
This commit is contained in:
@@ -1,49 +1,10 @@
|
||||
{% set value = (value is null ? field.default : value) %}
|
||||
{# Deprecated field. Alias to editor/editor.html.twig #}
|
||||
|
||||
<div class="form-field">
|
||||
<div class="form-label">
|
||||
<label>
|
||||
{% if field.help %}
|
||||
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e|tu }}">{{ field.label|tu }}</span>
|
||||
{% else %}
|
||||
{{ field.label|tu }}
|
||||
{% endif %}
|
||||
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-data">
|
||||
<div class="form-frontmatter-wrapper {{ field.size }}">
|
||||
<textarea
|
||||
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
|
||||
name="{{ (scope ~ field.name)|fieldName }}"
|
||||
id="frontmatter">{{ value|join("\n") }}</textarea>
|
||||
<div class="dragbar"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
((function(){
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById('frontmatter'), {
|
||||
mode: 'yaml',
|
||||
theme: 'paper',
|
||||
{% if field.autofocus %}
|
||||
autofocus: true,
|
||||
{% endif %}
|
||||
indentUnit: 4,
|
||||
indentWithTabs: false,
|
||||
extraKeys: {Tab: function(cm) { cm.replaceSelection(" ", "end"); }}
|
||||
});
|
||||
editor.on('change', editor.save);
|
||||
{% extends "forms/fields/editor/editor.html.twig" %}
|
||||
{% set codemirrorOptions = {'mode': 'yaml', 'indentUnit': 4, ignore: ['code'], 'autofocus': true, 'indentWithTabs': false, 'lineNumbers': true, 'gutters': ["CodeMirror-lint-markers"]}|merge(field.codemirror|default({})) %}
|
||||
|
||||
$('.dragbar').mousedown(function(e){
|
||||
e.preventDefault();
|
||||
var parentOffset = $(this).parent().offset();
|
||||
$(document).mousemove(function(e){
|
||||
$('.form-frontmatter-wrapper .CodeMirror').css('height',e.pageY - parentOffset.top);
|
||||
})
|
||||
});
|
||||
$(document).mouseup(function(e){
|
||||
$(document).unbind('mousemove');
|
||||
});
|
||||
})());
|
||||
</script>
|
||||
{# backward compatibility #}
|
||||
{% if field.showPreview %}
|
||||
{% set codemirrorOptions = codemirrorOptions|merge({'ignore': []}) %}
|
||||
{% endif %}
|
||||
{# end backward compatibility #}
|
||||
|
||||
Reference in New Issue
Block a user