backports murph-skeleton

This commit is contained in:
Simon Vieille 2021-06-09 18:15:24 +02:00
parent f5bd7d10c5
commit 590e9ae679
3 changed files with 62 additions and 36 deletions

View File

@ -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);
};

View File

@ -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 %}

View File

@ -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">