【问题标题】:Add Font Family Feature to CKEditor Toolbar in Angular将字体系列功能添加到 Angular 中的 CKEditor 工具栏
【发布时间】:2019-04-10 19:49:43
【问题描述】:

遗憾的是,我无法将字体系列功能添加到 Angular 中的 CKEditor 工具栏。

我在控制台中收到以下错误:

toolbarview-item-unavailable:请求的工具栏项是 不可用。阅读更多: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-toolbarview-item-unavailable

{name: "fontFamily"}

这是我的项目的样子:

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>

【问题讨论】:

    标签: angular ckeditor toolbar font-family ckeditor5


    【解决方案1】:

    正如我在GH issue 中回复您的那样,很遗憾,FontFamily 插件不存在于Balloon Editor 构建中。因此,您有两个选择:

    1. this guide 之后使用包外部的自定义插件构建一个编辑器,然后将该编辑器移动到 Angular 存储库。其余部分在Angular integration guide 中进行了描述。
    2. these steps 之后的源代码构建编辑器。虽然第一种方法得到官方支持,但我无法告诉您从源代码构建是否可行,因为我没有花太多时间研究它及其边缘情况。
    3. 使用Document Editor,其中包含FontFamily 插件。

    【讨论】:

    • 感谢您的帮助,我开始基于 Balloon 创建自己的自定义构建。在这里你可以找到我现在卡在哪里:GH >> P.S.:我添加了一个 error_logs 目录,在里面你可以找到我得到的错误日志。
    • 这是因为导入不正确 - import Font from '@ckeditor/ckeditor5-font'; 应该是 import Font from '@ckeditor/ckeditor5-font/src/font'; 我们不会在源包中公开默认入口点,因为它们可能以不同的方式使用。
    • 我已经提交了对custom balloon editor repo 的修复,并且还成功地安装了来自 GH 的自定义构建并导入到我的 Angular 6 项目中。非常感谢您的帮助,
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    • 2022-01-19
    • 1970-01-01
    相关资源
    最近更新 更多