Add Font Family Feature to CKEditor Toolbar in Angular

Viewed 4547

Sadly I could not manage to add the font family feature to the CKEditor's toolbar in Angular.

I'm getting the following error in the console:

toolbarview-item-unavailable: The requested toolbar item is unavailable. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-toolbarview-item-unavailable

{name: "fontFamily"}

Here is how my project looks like:

app.module.ts

...
import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
import { CkeditorComponent } from './ckeditor/ckeditor.component';
...

@NgModule( {
    declarations: [
        ...
        CkeditorComponent
    ],
    imports: [
        ...
        CKEditorModule,
        ...
    ],
    ...
} )

ckeditor.component.ts

import * as BalloonEditor from '@ckeditor/ckeditor5-build-balloon';

@Component( {
    ...
} )

export class CkeditorComponent {
    public Editor = BalloonEditor;

    public editorConfig = {
        fontFamily: {
          options: [
            'default',
            'Ubuntu, Arial, sans-serif',
            'Ubuntu Mono, Courier New, Courier, monospace'
          ]
        },
        toolbar: [
          'heading', 'bulletedList', 'numberedList', 'fontFamily'
        ]
    };
}

ckeditor.component.html

<ckeditor 
  [editor]="Editor" 
  [config]="editorConfig"
  data="<p>Hello world!</p>"></ckeditor>
1 Answers

As I replied to you in the GH issue, the FontFamily plugin is, unfortunately, not present in the Balloon Editor build. Thus you have two options:

  1. Build an editor with a custom plugin outside of the package following this guide and then move that editor to the angular repository. The rest is described in the Angular integration guide.
  2. Build editor from source following these steps. While the first approach is officially supported I can't tell you that building from source will work as I didn't spend much time investigating it and its edge-cases.
  3. Use the Document Editor, which contains the FontFamily plugin.
Related