Skip to content

Commit

Permalink
Summernote basic toolbar
Browse files Browse the repository at this point in the history
* Add a toolbar variation to HTML Editor
* Use HTML editor's basic toolbar on dynamic fields

refs #1774
  • Loading branch information
gagnieray committed Feb 21, 2024
1 parent 97b72cf commit 944dd0a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<div class="field{% if field.isRequired() %} required{% endif %}{% if get_class(field) == 'Galette\\DynamicFields\\File' %} wide{% endif %}">
{{ _self.draw_field(field, field_data, disabled, loop.index, object, masschange) }}
{% if field.getInformation() %}
<p class="exemple">{{ field.getInformation()|raw }}</p>
<div class="exemple">{{ field.getInformation()|raw }}</div>
{% endif %}
</div>
{% endfor %}
Expand Down
26 changes: 18 additions & 8 deletions galette/templates/default/elements/scripts.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,28 @@
<script type="text/javascript" src="{{ base_path() }}/assets/js/summernote.min.js"></script>
<script type="text/javascript" src="{{ base_path() }}/assets/js/lang/summernote-{{ i18n.getID()|replace({'_': '-'}) }}.min.js"></script>
<script type="text/javascript">
function activateHtmlEditor(elt) {
elt.summernote({
lang: '{{ i18n.getID()|replace({'_': '-'}) }}',
disableDragAndDrop: true,
height: 240,
toolbar: [
function activateHtmlEditor(elt, basic) {
if (basic === true) {
var _toolbar = [
['font', ['bold', 'italic', 'strikethrough', 'clear']],
['para', ['ul', 'ol']],
['insert', ['link']],
['view', ['codeview']]
];
} else {
var _toolbar = [
['style', ['style']],
['font', ['bold', 'italic', 'strikethrough', 'clear']],
['para', ['ul', 'ol', 'paragraph']],
['insert', ['link', 'picture']],
['view', ['codeview', 'help']]
],
['view', ['codeview']]
];
}
elt.summernote({
lang: '{{ i18n.getID()|replace({'_': '-'}) }}',
disableDragAndDrop: true,
height: 240,
toolbar: _toolbar,
styleTags: [
'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
{% block javascripts %}
<script>
$(function() {
activateHtmlEditor($('#field_information'));
activateHtmlEditor($('#field_information'), true);
});
</script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
modal_class: "tiny",
modal_content_class: "scrolling",
modal_onapprove: modal_onapprove,
modal_action_onshow: "activateHtmlEditor($('#field_information'));"
modal_action_onshow: "activateHtmlEditor($('#field_information'), true);"
} %}
}
_editDynField();
Expand Down

0 comments on commit 944dd0a

Please sign in to comment.