2020-02-08 05:05:43 +03:00
|
|
|
{% macro plugin(type="tinymce") -%}
|
|
|
|
|
{% if type=="tinymce" %}
|
|
|
|
|
<script type="text/javascript" src="/static/tinymce/tinymce.min.js"></script>
|
|
|
|
|
{% elif type=="ckeditor" %}
|
|
|
|
|
<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
|
|
|
|
|
{% endif %}
|
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
|
|
{% macro ckeditor(name) -%}
|
|
|
|
|
CKEDITOR.replace( '{{ name }}', {
|
|
|
|
|
customConfig: '/static/js/ckeditor-conf.js'
|
|
|
|
|
} );
|
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
|
|
{% macro tinymce(name) -%}
|
|
|
|
|
tinymce.init({
|
|
|
|
|
selector: 'textarea#{{ name }}',
|
|
|
|
|
height: 400,
|
|
|
|
|
language: 'ru',
|
|
|
|
|
plugins: "code link image table",
|
|
|
|
|
toolbar: "table tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"
|
|
|
|
|
});
|
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
|
|
{% macro getValue(name, param, type="tinymce") -%}
|
|
|
|
|
{% if type=="tinymce" %}
|
|
|
|
|
let value = tinymce.get("{{ name }}").getContent();
|
|
|
|
|
if (value != {{ param }}) {
|
|
|
|
|
{{ param }} = value;
|
|
|
|
|
}
|
|
|
|
|
{% elif type=="ckeditor" %}
|
|
|
|
|
var value = CKEDITOR.instances["{{ name }}"].getData();
|
|
|
|
|
if (value != {{ param }}) {
|
|
|
|
|
{{ param }} = value;
|
|
|
|
|
}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{%- endmacro %}
|
2020-02-16 22:59:11 +03:00
|
|
|
|
|
|
|
|
{% macro setValue(name, param, type="tinymce") -%}
|
|
|
|
|
{% if type=="tinymce" %}
|
|
|
|
|
tinymce.get("{{ name }}").setContent({{ param }});
|
|
|
|
|
{% elif type=="ckeditor" %}
|
|
|
|
|
CKEDITOR.instances["{{ name }}"].setData({{ param }});
|
|
|
|
|
{% endif %}
|
|
|
|
|
{%- endmacro %}
|