@@ -9,16 +9,13 @@ import {
99} from '@angular/forms' ;
1010import { Router , ActivatedRoute , RouterLink } from '@angular/router' ;
1111
12- /** CKEditor5 Imports */
13- import ClassicEditor from '@ckeditor/ckeditor5-build-classic' ;
14-
1512/** Custom Imports */
1613import { clientParameterLabels , loanParameterLabels , repaymentParameterLabels } from '../template-parameter-labels' ;
1714
1815/** Custom Services */
1916import { TemplatesService } from '../templates.service' ;
2017import { FaIconComponent } from '@fortawesome/angular-fontawesome' ;
21- import { CKEditorModule } from '@ckeditor/ckeditor5 -angular' ;
18+ import { EditorComponent , EditorModule , TINYMCE_SCRIPT_SRC } from '@tinymce/tinymce -angular' ;
2219import {
2320 MatAccordion ,
2421 MatExpansionPanel ,
@@ -37,18 +34,37 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
3734 imports : [
3835 ...STANDALONE_SHARED_IMPORTS ,
3936 FaIconComponent ,
40- CKEditorModule ,
37+ EditorModule ,
4138 MatAccordion ,
4239 MatExpansionPanel ,
4340 MatExpansionPanelHeader ,
4441 MatExpansionPanelTitle
42+ ] ,
43+ providers : [
44+ {
45+ provide : TINYMCE_SCRIPT_SRC ,
46+ useValue : 'assets/tinymce/tinymce.min.js'
47+ }
4548 ]
4649} )
4750export class CreateEditComponent implements OnInit {
48- /** CKEditor5 */
49- public Editor = ClassicEditor ;
50- /** CKEditor5 Template Reference */
51- @ViewChild ( 'ckEditor' , { static : true } ) ckEditor : any ;
51+ /** TinyMCE instance configuration */
52+ tinymceConfig = {
53+ base_url : 'assets/tinymce' ,
54+ suffix : '.min' ,
55+ menubar : false ,
56+ branding : false ,
57+ height : 320 ,
58+ forced_root_block : false ,
59+ statusbar : false ,
60+ elementpath : false ,
61+ resize : false ,
62+ plugins : 'lists link table media codesample' ,
63+ toolbar :
64+ 'undo redo | blocks | bold italic underline | link | numlist bullist outdent indent | alignleft aligncenter alignright alignjustify | table media | removeformat'
65+ } ;
66+ /** TinyMCE component reference */
67+ @ViewChild ( 'tinymceEditor' , { static : false } ) tinymceEditor : EditorComponent ;
5268
5369 /** Template form. */
5470 templateForm : UntypedFormGroup ;
@@ -166,6 +182,7 @@ export class CreateEditComponent implements OnInit {
166182 } ) ;
167183 }
168184 this . setEditorContent ( '' ) ;
185+ this . templateForm . get ( 'text' ) . setValue ( '' ) ;
169186 } ) ;
170187 if ( this . mode === 'create' ) {
171188 this . templateForm . get ( 'entity' ) . patchValue ( 0 ) ;
@@ -192,44 +209,31 @@ export class CreateEditComponent implements OnInit {
192209 }
193210
194211 /**
195- * Adds text to CKEditor at cursor position.
212+ * Adds text to the editor at cursor position.
196213 * @param {string } label Template parameter label.
197214 */
198215 addText ( label : string ) {
199- if ( this . ckEditor && this . ckEditor . editorInstance ) {
200- this . ckEditor . editorInstance . model . change ( ( writer : any ) => {
201- const insertPosition = this . ckEditor . editorInstance . model . document . selection . getFirstPosition ( ) ;
202- writer . insertText ( label , insertPosition ) ;
203- } ) ;
204- }
216+ this . tinymceEditor ?. editor ?. insertContent ( label ) ;
205217 }
206218
207219 /**
208- * Gets the contents of CKEditor .
220+ * Gets the contents of the editor .
209221 */
210222 getEditorContent ( ) {
211- if ( this . ckEditor && this . ckEditor . editorInstance ) {
212- return this . ckEditor . editorInstance . getData ( ) ;
213- }
214- return '' ;
223+ return this . tinymceEditor ?. editor ?. getContent ( { format : 'html' } ) || '' ;
215224 }
216225
217226 /**
218- * Sets the contents of CKEditor .
227+ * Sets the contents of the editor .
219228 * @param {string } content Editor Content
220229 */
221230 setEditorContent ( content : string ) {
222- if ( this . ckEditor && this . ckEditor . editorInstance ) {
223- return this . ckEditor . editorInstance . setData ( content ) ;
231+ if ( this . tinymceEditor ?. editor ) {
232+ this . tinymceEditor . editor . setContent ( content || '' ) ;
224233 }
225234 return '' ;
226235 }
227236
228- onEditorChange ( event : any ) {
229- const editorContent = event . editor . getData ( ) ;
230- this . templateForm . get ( 'text' ) . setValue ( editorContent ) ;
231- }
232-
233237 /**
234238 * Submits a template.
235239 */
0 commit comments