I have installed ng2-CKEditor on my Angular project
npm install ng2-ckeditor --save
with the following config :
public getConfigOfCKEditor(): any {
const toolbarGroups = [
'/',
{ name: 'document', groups: ['mode', 'doctools', 'document'] },
{ name: 'editing', groups: ['find', 'selection', 'spellchecker', 'editing'] },
{ name: 'forms', groups: ['forms'] },
'/',
{ name: 'clipboard', groups: ['clipboard', 'undo'] },
{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi', 'paragraph'] },
'/',
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup'] },
{ name: 'links', groups: ['links'] },
{ name: 'styles', groups: ['styles'] },
{ name: 'colors', groups: ['colors'] },
{ name: 'tools', groups: ['tools'] },
{ name: 'others', groups: ['others'] },
{ name: 'about', groups: ['about'] },
{ name: 'insert', groups: ['codesnippet'] }
];
const removeButtons: string = 'Source,Templates,Save,NewPage,Print,Replace,Scayt,SelectAll,Form,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Blockquote,CreateDiv,Language,Image,Flash,Table,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe,ShowBlocks,About,Checkbox,Find,Preview,Styles,Format,Anchor';
return {
toolbarGroups: toolbarGroups,
removeButtons: removeButtons,
codeSnippet_theme: 'school_book',
codeSnippet_languages: { javascript: 'JavaScript', php: 'PHP' }
};
}
my app.component.html :
<ckeditor [(ngModel)]="ckeditorContent" [config]="this.config" [readonly]="false"
debounce="500">
</ckeditor>
Know, How can I add the code snippet plugin to the CKEditor ?
NOTE: CodeSnipet Plugin Documentation
Try with
4.9.2
version of ckeditor:and then:
https://stackblitz.com/edit/angular-vyrisr?file=src%2Findex.html
Hope it helps!