Unverified Commit b8b11061 authored by Sebastian Castro's avatar Sebastian Castro
Browse files

Adds wysiwyg option for textarea field in form builder

parent a3cb570f
......@@ -458,24 +458,48 @@
.error, .form-error {
color: $error-color;
}
}
.field-wysiwyg {
margin-top: 2rem;
.input-field .prefix~.cke {
margin-left: 3rem;
width: calc(100% - 3rem);
border: none;
border-bottom: 1px solid #ced4de !important;
}
.label-wysiwyg, .material-icons {
top: -5px !important;
}
.cke_button__about {
display: none;
}
.cke_top {
border-radius: 5px 5px 0 0;
border: none;
padding-left: 5px;
padding-bottom: 5px;
}
.cke_contents {
margin-left: -20px;
}
a.cke_button_on {
background-color: #e8e8e8;
border: none;
border-radius: 2px;
padding: 4px 6px;
}
.cke_toolgroup {
margin: 0;
}
.cke_toolbar_separator {
width: 0;
}
.cke_toolgroup a.cke_button:last-child:after, .cke_toolgroup a.cke_button.cke_button_disabled:hover:last-child:after {
content: none;
}
}
.cke_dialog_body {
max-width: 800px;
margin: 0 auto;
}
}
\ No newline at end of file
......@@ -55,6 +55,11 @@
},
textarea: {
icon: iconAttr,
subtype: { label: 'Type', options: {
'textarea': 'Editeur simple',
'wysiwyg': 'Editeur enrichi',
},
},
errorMsg: errorMsgAttrs,
separator: { label: '' }, // separate important attrs from others
},
......@@ -187,7 +192,7 @@
.address-field .name-wrap, .address-field .access-wrap, .address-field .required-wrap,
.taxonomy-field .name-wrap, .taxonomy-field .access-wrap, .taxonomy-field .required-wrap, .taxonomy-field .placeholder-wrap, .taxonomy-field .value-wrap,
.title-field .name-wrap, .title-field .access-wrap, .title-field .required-wrap,
.textarea-field .subtype-wrap, .checkbox-field .field-options, .checkbox-field .required-wrap,
.checkbox-field .field-options, .checkbox-field .required-wrap,
.paragraph-field .subtype-wrap, .header-field .subtype-wrap,
.email-field .name-wrap, .image-field .name-wrap, .images-field .name-wrap, .images-field .placeholder-wrap, .images-field .value-wrap, .images-field .required-wrap, .files-field .name-wrap, .files-field .placeholder-wrap, .files-field .value-wrap, .files-field .required-wrap
{ display: none !important; }
......
......@@ -40,6 +40,9 @@
{% if field.type == "date" %}
{% set inputClass = inputClass ~ " datepicker" %}
{% endif %}
{% if field.type == "textarea" and field.subtype == "wysiwyg" %}
{% set inputClass = inputClass ~ " ace-editor" %}
{% endif %}
{# NAME #}
{% set baseName = field.type == "title" ? "element" : "data" %}
......@@ -79,7 +82,7 @@
{% endif %}
{# LABEL #}
<label for="input-{{ field.name }}" data-error="{{ errorMsg|default('') }}" class="gogo-form-label"><span class="to-html">{{ field.label|raw }}</span>{% if field.required|default(false) %}<span class="mandatory-asterisk"></span>{% endif %}</label>
<label for="input-{{ field.name }}" data-error="{{ errorMsg|default('') }}" class="gogo-form-label label-{{ field.type }} {% if field.subtype is defined %}label-{{ field.subtype }}{% endif %}"><span class="to-html">{{ field.label|raw }}</span>{% if field.required|default(false) %}<span class="mandatory-asterisk"></span>{% endif %}</label>
{% if field.type == "date" %}
<script>
......@@ -96,5 +99,19 @@
});
</script>
{% endif %}
{% if field.type == "textarea" and field.subtype == "wysiwyg" %}
<script src="//cdn.ckeditor.com/4.14.0/basic/ckeditor.js"></script>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace('input-{{ field.name }}');
CKEDITOR.on( 'instanceReady', function( evt ) {
var editorBody = $('.cke_wysiwyg_frame').contents().find('body');
editorBody.css('background-color', 'transparent');
editorBody.css('color', '{{ config.defaultTextContentColor }}');
} );
</script>
{% endif %}
</div>
......@@ -5,7 +5,7 @@
{% set elementValue = element.data[field.name] is defined ? element.data[field.name] : element.privateData[field.name] is defined ? element.privateData[field.name] : null %}
{% endif %}
<div class="field-container field-{{field.type}}" id="field-{{ field.name|default('unknown-name') }}"
<div class="field-container field-{{field.type}} {% if field.subtype is defined %}field-{{field.subtype}}{% endif %}" id="field-{{ field.name|default('unknown-name') }}"
{% if field.access is defined and not is_granted("ROLE_ADMIN") %}style="display:none"{% endif %}>
{# STANDARD INPUT #}
{% if field.type == "text" or field.type == "title" or field.type == "textarea" or field.type == "date" or field.type == "number" or field.type == "email" or field.type == "image"%}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment