@@ -156,16 +156,49 @@ export default class TinyMCE {
156156 }
157157 }
158158 }
159- async initPluginFixes ( ) {
159+
160+ async initPlugins ( ) {
160161 var self = this ;
162+
161163 const lang = self . options . tiny . language ;
162164
163- // fix help plugin
164- // see https://community.plone.org/t/tinymce-menubar-settings-not-working-6-1-1/22190/1
165- if ( self . options . tiny . plugins . includes ( "help" ) ) {
166- await import ( `tinymce/plugins/help/js/i18n/keynav/${ lang } .js` ) ;
165+ let valid_plugins = [ ] ;
166+
167+ // tinyMCE Plugins
168+ for ( const plugin of self . options . tiny . plugins ) {
169+
170+ if ( plugin == "plonelink" || plugin == "ploneimage" ) {
171+ valid_plugins . push ( plugin ) ;
172+ continue ;
173+ } else if ( plugin == "template" ) {
174+ // load backported template plugin
175+ const TemplatePlugin = ( await import ( "./js/template" ) ) . default ;
176+ TemplatePlugin ( ) ;
177+ valid_plugins . push ( plugin ) ;
178+ continue ;
179+ } else if ( plugin == "emoticons" ) {
180+ // fix emiticons plugin
181+ // see https://community.plone.org/t/tinymce-menubar-settings-not-working-6-1-1/22190/1
182+ await import ( `tinymce/plugins/emoticons/js/emojis.min.js` ) ;
183+
184+ } else if ( plugin == "help" ) {
185+ // fix help plugin
186+ // see https://community.plone.org/t/tinymce-menubar-settings-not-working-6-1-1/22190/1
187+ await import ( `tinymce/plugins/help/js/i18n/keynav/${ lang } .js` ) ;
188+ }
189+
190+ try {
191+ await import ( "tinymce/plugins/" + plugin ) ;
192+ valid_plugins . push ( plugin ) ;
193+ } catch {
194+ log . debug ( "Could not load TinyMCE plugin: " , plugin ) ;
195+ }
167196 }
197+
198+ self . options . tiny . plugins = valid_plugins ;
199+
168200 }
201+
169202 async init ( ) {
170203 import ( "./tinymce.scss" ) ;
171204
@@ -254,10 +287,6 @@ export default class TinyMCE {
254287 } ) ;
255288 } ;
256289
257- await self . initLanguage ( ) ;
258-
259- await self . initPluginFixes ( ) ;
260-
261290 if ( typeof self . options . folderTypes === "string" ) {
262291 self . options . folderTypes = self . options . folderTypes . split ( "," ) ;
263292 }
0 commit comments