'Is there a way to use a TinyMCE configuration file instead tinymce.init()?
I have to load the TinyMCE configuration in every page where it is used. Is there a chance to load the configuration once in the whole website instead to load a lot of rows of configuration commands in every page as the following code:
tinymce.init({
selector: 'textarea',
menubar: true,
dialog_type: 'modal',
fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
font_formats: "Arial=arial,helvetica,sans-serif;" +
"Arial Black=arial black,avant garde;" +
"Courier New=courier new,courier;" +
"Georgia=georgia,palatino;" +
"Helvetica=helvetica;" +
"Symbol=symbol;" +
"Times New Roman=times new roman,times;" +
"Trebuchet MS=trebuchet ms,geneva;",
referrer_policy: 'strict-origin-when-cross-origin',
plugins: 'print, code, lists, table, paste',
paste_as_text: true,
height: 400,
language: 'it',
toolbar: 'undo redo | fontselect fontsizeselect styleselect bold italic alignleft aligncenter alignright alignjustify | table tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | bullist numlist outdent indent code',
formats: {
alignleft: {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left', styles : {'text-indent': '50px'}},
aligncenter: {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center', styles : {'text-indent': '50px'}},
alignright: {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right', styles : {'text-indent': '50px'}},
alignjustify: {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full', styles : {'text-indent': '50px', 'text-align': 'justify'}}
}
});
Thanks in advance and regards! Manugi
Solution 1:[1]
I solved with the following code:
$.getScript("js/tinymce.config.js", function() {
//do something if necessary
});
where the file tinymce.config.js contains:
tinymce.init({
selector: 'textarea',
menubar: true,
dialog_type: 'modal',
fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
....
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | manugi |
