From a0303b0533bbd48332fb148671d9c1399a534cfe Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 29 May 2020 10:53:44 -0600 Subject: [PATCH] breakout codemirror field so it can be used directly (like raw) Signed-off-by: Andy Miller --- blueprints/admin/pages/raw.yaml | 2 +- .../forms/fields/codemirror/codemirror.html.twig | 10 ++++++++++ .../forms/fields/markdown/markdown.html.twig | 13 +------------ 3 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 themes/grav/templates/forms/fields/codemirror/codemirror.html.twig diff --git a/blueprints/admin/pages/raw.yaml b/blueprints/admin/pages/raw.yaml index 924a8b51..5b222ad1 100644 --- a/blueprints/admin/pages/raw.yaml +++ b/blueprints/admin/pages/raw.yaml @@ -37,7 +37,7 @@ form: lint: true content: - type: markdown + type: codemirror header.media_order: type: pagemedia diff --git a/themes/grav/templates/forms/fields/codemirror/codemirror.html.twig b/themes/grav/templates/forms/fields/codemirror/codemirror.html.twig new file mode 100644 index 00000000..e2fc8442 --- /dev/null +++ b/themes/grav/templates/forms/fields/codemirror/codemirror.html.twig @@ -0,0 +1,10 @@ +{% extends "forms/fields/editor/editor.html.twig" %} +{% set theme = config.plugins.admin.whitelabel.codemirror_theme ?? 'paper.css' %} +{% set font = config.plugins.admin.whitelabel.codemirror_md_font ?? 'sans' %} +{% set codemirrorOptions = {'mode': 'gfm', 'theme': theme, 'font': font, 'ignore': []}|merge(field.codemirror|default({})) %} + +{# backward compatibility #} +{% if field.showPreview %} + {% set codemirrorOptions = codemirrorOptions|merge({'ignore': []}) %} +{% endif %} +{# end backward compatibility #} diff --git a/themes/grav/templates/forms/fields/markdown/markdown.html.twig b/themes/grav/templates/forms/fields/markdown/markdown.html.twig index 15116316..dc2d8584 100644 --- a/themes/grav/templates/forms/fields/markdown/markdown.html.twig +++ b/themes/grav/templates/forms/fields/markdown/markdown.html.twig @@ -1,12 +1 @@ -{# Deprecated field. Alias to editor/editor.html.twig #} - -{% extends "forms/fields/editor/editor.html.twig" %} -{% set theme = config.plugins.admin.whitelabel.codemirror_theme ?? 'paper.css' %} -{% set font = config.plugins.admin.whitelabel.codemirror_md_font ?? 'sans' %} -{% set codemirrorOptions = {'mode': 'gfm', 'theme': theme, 'font': font, 'ignore': []}|merge(field.codemirror|default({})) %} - -{# backward compatibility #} -{% if field.showPreview %} - {% set codemirrorOptions = codemirrorOptions|merge({'ignore': []}) %} -{% endif %} -{# end backward compatibility #} +{% extends "forms/fields/codemirror/codemirror.html.twig" %}