Browse Source

backports murph-skeleton

develop
Simon Vieille 1 week ago
parent
commit
590e9ae679
  1. 72
      assets/js/admin/modules/editor.js
  2. 26
      core/Resources/views/form/bootstrap_4_form_theme.html.twig
  3. 2
      core/Resources/views/site/page_admin/_form.html.twig

72
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);
});
editor.on('Change', () => {
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);
});
}
}
}
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);
};

26
core/Resources/views/form/bootstrap_4_form_theme.html.twig

@ -112,3 +112,29 @@
</div>
</template>
{% 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) -}}
</{{ element|default('div') }}>
{%- endblock form_row %}

2
core/Resources/views/site/page_admin/_form.html.twig

@ -21,7 +21,7 @@
<div class="row">
<div class="col-md-8 p-2">
{{ form_widget(form) }}
{{ form_widget(form, {attr: {class: 'row'}}) }}
</div>
<div class="col-md-4 p-3">
<ul class="nav nav-pills">

Loading…
Cancel
Save