Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const selector = this.element.querySelector('.tinymce').id;
const input = this.element.querySelector('input');
let plugins = 'image media table link paste contextmenu textpattern autolink codesample';
let toolbar1 = '';
let inline = true;
if (this.element.dataset.theme === 'modern') {
plugins = 'print autosave autoresize preview paste code searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern';
toolbar1 = 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | ltr rtl';
inline = false;
}
// for remove cache
tinymce.remove(`#${selector}`);
tinymce.init({
branding: false,
selector: `#${selector}`,
theme: this.element.dataset.theme,
min_height: 300,
height: 300,
max_height: 600,
plugins,
toolbar1,
insert_toolbar: 'quickimage quicktable media codesample fullscreen',
selection_toolbar:
'bold italic | quicklink h2 h3 blockquote | alignleft aligncenter alignright alignjustify | outdent indent | removeformat ',
inline,
convert_urls: false,
image_caption: true,
document.addEventListener('turbolinks:before-cache', function() {
TinyMCE.remove();
window.selectedCountry = null;
window.selectedCountries = null;
$('.select2')
.select2()
.each(function(i, item) {
$(item).select2('destroy');
});
// $('.dataTableBuilder').each(function(i, item){
// $(item).DataTable().destroy();
// });
});
disconnect() {
tinymce.remove(`#${this.element.querySelector('.tinymce').id}`);
}
}
this.saveButton.addEventListener('click', () => {
tinymce.remove(`#${this.el.getAttribute('id')}`)
this.saveButtonContainer.parentNode.removeChild(this.saveButtonContainer)
this.sendData()
})
})
destroyEditor() {
if ( this.editor ) {
forEach( [ 'change', 'keyup', 'setcontent', 'init' ], eventName => {
this.editor.off( eventName );
} );
}
this.editorContainer && tinymce.remove( this.editorContainer );
this.editor = null;
this.editorContainer = null;
}
return () => {
tinymce.remove(editorRef.current);
};
}, [plugins, toolbar]);
destroyEditor = () => {
forEach(
EVENTS,
function( eventHandler, eventName ) {
if ( this.props[ eventHandler ] ) {
this._editor.off( eventName, this.props[ eventHandler ] );
}
}.bind( this )
);
tinymce.remove( this._editor );
this._editor = null;
autosize.destroy( this.textInput.current );
};