From 590e9ae679526314bbfeb03677ef8278811bd893 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 9 Jun 2021 18:15:24 +0200 Subject: [PATCH] backports murph-skeleton --- assets/js/admin/modules/editor.js | 70 +++++++++---------- .../form/bootstrap_4_form_theme.html.twig | 26 +++++++ .../views/site/page_admin/_form.html.twig | 2 +- 3 files changed, 62 insertions(+), 36 deletions(-) diff --git a/assets/js/admin/modules/editor.js b/assets/js/admin/modules/editor.js index 46ca4b1..e18fad5 100644 --- a/assets/js/admin/modules/editor.js +++ b/assets/js/admin/modules/editor.js @@ -1,42 +1,44 @@ const $ = require('jquery') -tinymce.murph = tinymce.murph || {} -tinymce.murph.selector = tinymce.murph.selector || '*[data-tinymce]' -tinymce.murph.configurationBase = tinymce.murph.configurationBase || { - base_url: '/vendor/tinymce/', - cache_suffix: '?v=4.1.6', - importcss_append: true, - image_caption: true, - noneditable_noneditable_class: "mceNonEditable", - toolbar_drawer: 'sliding', - spellchecker_dialog: true, - tinycomments_mode: 'embedded', - convert_urls: false, - init_instance_callback: function (editor) { - editor.on('SetContent', () => { - tinymce.triggerSave(false, true); - }); +if (typeof tinymce !== 'undefined') { + tinymce.murph = tinymce.murph || {} + tinymce.murph.selector = tinymce.murph.selector || '*[data-tinymce]' + tinymce.murph.configurationBase = tinymce.murph.configurationBase || { + base_url: '/vendor/tinymce/', + cache_suffix: '?v=4.1.6', + importcss_append: true, + image_caption: true, + noneditable_noneditable_class: "mceNonEditable", + toolbar_drawer: 'sliding', + spellchecker_dialog: true, + tinycomments_mode: 'embedded', + convert_urls: false, + init_instance_callback: function (editor) { + editor.on('SetContent', () => { + tinymce.triggerSave(false, true); + }); - editor.on('Change', () => { - tinymce.triggerSave(false, true); - }); + editor.on('Change', () => { + tinymce.triggerSave(false, true); + }); + } } -} -tinymce.murph.modes = tinymce.murph.modes || {} + tinymce.murph.modes = tinymce.murph.modes || {} -tinymce.murph.modes.default = tinymce.murph.modes.default || { - plugins: 'print preview importcss searchreplace visualblocks visualchars fullscreen template table charmap hr pagebreak nonbreaking toc insertdatetime advlist lists wordcount textpattern noneditable help charmap quickbars link image code autoresize', - menubar: 'file edit view insert format tools table tc help', - toolbar: 'undo redo | bold italic underline strikethrough | link image | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist checklist | forecolor backcolor casechange permanentpen formatpainter removeformat | pagebreak | charmap | fullscreen preview', - quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote quickimage quicktable', - contextmenu: "link image imagetools table configurepermanentpen", -} + tinymce.murph.modes.default = tinymce.murph.modes.default || { + plugins: 'print preview importcss searchreplace visualblocks visualchars fullscreen template table charmap hr pagebreak nonbreaking toc insertdatetime advlist lists wordcount textpattern noneditable help charmap quickbars link image code autoresize', + menubar: 'file edit view insert format tools table tc help', + toolbar: 'undo redo | bold italic underline strikethrough | link image | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist checklist | forecolor backcolor casechange permanentpen formatpainter removeformat | pagebreak | charmap | fullscreen preview', + quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote quickimage quicktable', + contextmenu: "link image imagetools table configurepermanentpen", + } -tinymce.murph.modes.light = tinymce.murph.modes.light || { - contextmenu: "link image imagetools table configurepermanentpen", - quickbars_selection_toolbar: 'bold italic', - toolbar: 'undo redo | bold italic underline', + tinymce.murph.modes.light = tinymce.murph.modes.light || { + contextmenu: "link image imagetools table configurepermanentpen", + quickbars_selection_toolbar: 'bold italic', + toolbar: 'undo redo | bold italic underline', + } } const buildConfiguration = (conf) => { @@ -81,8 +83,6 @@ const doInitEditor = () => { conf.mode = 'exact' conf.elements = id - console.log(conf); - tinymce.init(conf); }) } @@ -96,5 +96,5 @@ module.exports = function() { const config = {attributes: false, childList: true, subtree: true}; observer.observe(document.querySelector('body'), config); - doInitEditor(); + $(window).ready(doInitEditor); }; diff --git a/core/Resources/views/form/bootstrap_4_form_theme.html.twig b/core/Resources/views/form/bootstrap_4_form_theme.html.twig index 419f399..ad956d5 100644 --- a/core/Resources/views/form/bootstrap_4_form_theme.html.twig +++ b/core/Resources/views/form/bootstrap_4_form_theme.html.twig @@ -112,3 +112,29 @@ {% endblock %} + +{% block form_row -%} + {%- set widget_attr = {} -%} + + {%- if help is not empty -%} + {%- set widget_attr = {attr: {'aria-describedby': id ~ "_help"}} -%} + {%- endif -%} + + {%- if compound is defined and compound -%} + {%- set element = 'fieldset' -%} + {% else %} + {%- set element = 'div' -%} + {%- endif -%} + + {% if element == 'fieldset' and not ('col-' in form.vars.row_attr.class|default('')) %} + {% set class = row_attr.class|default('') ~ ' col-md-12 form-group' %} + {% else %} + {% set class = row_attr.class|default('') ~ ' form-group' %} + {% endif %} + + <{{ element }}{% with {attr: row_attr|merge({class: class|trim})} %}{{ block('attributes') }}{% endwith %}> + {{- form_label(form) -}} + {{- form_widget(form) -}} + {{- form_help(form) -}} + +{%- endblock form_row %} diff --git a/core/Resources/views/site/page_admin/_form.html.twig b/core/Resources/views/site/page_admin/_form.html.twig index 71c0fc9..0421858 100644 --- a/core/Resources/views/site/page_admin/_form.html.twig +++ b/core/Resources/views/site/page_admin/_form.html.twig @@ -21,7 +21,7 @@
- {{ form_widget(form) }} + {{ form_widget(form, {attr: {class: 'row'}}) }}