@@ -84,13 +84,31 @@ define([
8484 } ;
8585 }
8686
87- until ( isAttached ( this . $el ) ) . then ( function ( ) {
88- this . editor = CKEDITOR . replace ( this . $el [ 0 ] , {
87+ function convertStringsToRegExDeep ( arr ) {
88+ function processEntry ( [ key , value ] ) {
89+ value = ( typeof value === "string" )
90+ ? new RegExp ( value , 'i' )
91+ : Array . isArray ( value )
92+ ? arr . map ( ( value , index ) => processEntry ( [ index , value ] ) [ 1 ] )
93+ : ( typeof value === "object" && value !== null )
94+ ? Object . fromEntries ( Object . entries ( value ) . map ( processEntry ) )
95+ : value ;
96+ return [ key , value ] ;
97+ }
98+ return arr . map ( ( value , index ) => processEntry ( [ index , value ] ) [ 1 ] )
99+ }
100+
101+ until ( isAttached ( this . $el ) ) . then ( ( ) => {
102+ return CKEDITOR . create ( this . $el [ 0 ] , {
89103 dataIndentationChars : '' ,
90104 disableNativeSpellChecker : false ,
91105 enterMode : CKEDITOR [ Origin . constants . ckEditorEnterMode ] ,
92106 entities : false ,
93- extraAllowedContent : Origin . constants . ckEditorExtraAllowedContent ,
107+ htmlSupport : {
108+ // Convert all allow/disallow strings to regexp, as config is json only
109+ allow : convertStringsToRegExDeep ( ( Origin . constants . ckEditorHtmlSupport && Origin . constants . ckEditorHtmlSupport . allow ) || [ ] ) ,
110+ disallow : convertStringsToRegExDeep ( ( Origin . constants . ckEditorHtmlSupport && Origin . constants . ckEditorHtmlSupport . disallow ) || [ ] )
111+ } ,
94112 on : {
95113 change : function ( ) {
96114 this . trigger ( 'change' , this ) ;
@@ -112,24 +130,50 @@ define([
112130 elements . forEach ( function ( element ) { writer . setRules ( element , rules ) ; } ) ;
113131 }
114132 } ,
115- toolbar : [
116- { name : 'document' , groups : [ 'mode' , 'document' , 'doctools' ] , items : [ 'Source' , '-' , 'ShowBlocks' ] } ,
117- { name : 'clipboard' , groups : [ 'clipboard' , 'undo' ] , items : [ 'PasteText' , 'PasteFromWord' , '-' , 'Undo' , 'Redo' ] } ,
118- { name : 'editing' , groups : [ 'find' , 'selection' , 'spellchecker' ] , items : [ 'Find' , 'Replace' , '-' , 'SelectAll' ] } ,
119- { name : 'paragraph' , groups : [ 'list' , 'indent' , 'blocks' , 'align' , 'bidi' ] , items : [ 'NumberedList' , 'BulletedList' , '-' , 'Outdent' , 'Indent' , '-' , 'Blockquote' , 'CreateDiv' ] } ,
120- { name : 'direction' , items : [ 'BidiLtr' , 'BidiRtl' ] } ,
121- '/' ,
122- { name : 'basicstyles' , groups : [ 'basicstyles' , 'cleanup' ] , items : [ 'Bold' , 'Italic' , 'Underline' , 'Strike' , 'Subscript' , 'Superscript' , '-' , 'RemoveFormat' ] } ,
123- { name : 'styles' , items : [ 'JustifyLeft' , 'JustifyCenter' , 'JustifyRight' , 'JustifyBlock' ] } ,
124- { name : 'links' , items : [ 'Link' , 'Unlink' ] } ,
125- { name : 'colors' , items : [ 'TextColor' , 'BGColor' ] } ,
126- { name : 'insert' , items : [ 'SpecialChar' , 'Table' ] } ,
127- { name : 'tools' , items : [ ] } ,
128- { name : 'others' , items : [ '-' ] }
129- ]
130- } ) ;
131- } . bind ( this ) ) ;
132-
133+ plugins : window . CKEDITOR . pluginsConfig ,
134+ toolbar : {
135+ items : [
136+ 'sourceEditing' ,
137+ 'showBlocks' ,
138+ 'undo' ,
139+ 'redo' ,
140+ '|' ,
141+ 'findAndReplace' ,
142+ 'selectAll' ,
143+ '|' ,
144+ 'numberedList' ,
145+ 'bulletedList' ,
146+ 'blockQuote' ,
147+ 'indent' ,
148+ 'outdent' ,
149+ '|' ,
150+ 'bold' ,
151+ 'italic' ,
152+ 'underline' ,
153+ 'strikethrough' ,
154+ 'subscript' ,
155+ 'superscript' ,
156+ 'alignment' ,
157+ 'removeFormat' ,
158+ '|' ,
159+ 'link' ,
160+ 'fontColor' ,
161+ 'fontBackgroundColor' ,
162+ '|' ,
163+ 'specialCharacters' ,
164+ 'insertTable'
165+ ] ,
166+ shouldNotGroupWhenFull : true
167+ }
168+ } ) . then ( editor => {
169+ this . editor = editor
170+ CKEDITOR . instances = CKEDITOR . instances || [ ]
171+ CKEDITOR . instances . length = CKEDITOR . instances . length || 0 ;
172+ this . editor . id = CKEDITOR . instances . length
173+ CKEDITOR . instances . length ++ ;
174+ CKEDITOR . instances [ this . editor . id ] = this . editor
175+ } )
176+ } ) ;
133177 return this ;
134178 } ;
135179
@@ -149,8 +193,8 @@ define([
149193
150194 // ckeditor removal
151195 Backbone . Form . editors . TextArea . prototype . remove = function ( ) {
152- this . editor . removeAllListeners ( ) ;
153- CKEDITOR . remove ( this . editor ) ;
196+ this . editor . stopListening ( )
197+ delete CKEDITOR . instances [ this . editor . id ]
154198 } ;
155199
156200 // add override to allow prevention of validation
0 commit comments