{% macro plugin(type="tinymce") -%} {% if type=="tinymce" %} {% elif type=="ckeditor" %} {% 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 %} {% macro setValue(name, param, type="tinymce") -%} {% if type=="tinymce" %} tinymce.get("{{ name }}").setContent({{ param }}); {% elif type=="ckeditor" %} CKEDITOR.instances["{{ name }}"].setData({{ param }}); {% endif %} {%- endmacro %}