在 Sulu 2.2.1

问题描述

我尝试在 Sulu CMS(版本 2.2.1)中使用 CKeditor5 设置字体颜色,我按照 this doc 来执行此操作。

所以首先我将这一行添加到 assets/admin/package.json 文件中(到“依赖项”对象中):

"@ckeditor/ckeditor5-font": "^23.0.0",

然后我将此行添加到 assets/admin/index.js 文件中:

import {ckeditorPluginRegistry,ckeditorConfigRegistry} from 'sulu-admin-bundle/containers';
import Font from '@ckeditor/ckeditor5-font/src/font';

ckeditorPluginRegistry.add(Font);
ckeditorConfigRegistry.add((config) => ({
    toolbar: [...config.toolbar,'fontColor','fontBackgroundColor'],}));

然后我运行这个命令:bin/console sulu:admin:update-build 对于提出的问题,我回答如下:

  • 是否要覆盖本地版本的“index.js”? N
  • 是否要覆盖本地版本的“package.json”? N
  • 像上面一样将“package.json”合并在一起?
  • 您要立即创建构建吗?

这项工作很棒,我可以将颜色和背景颜色设置到我的 text_editor 内容类型中。

但是当我尝试添加带有 single_media_selection 内容类型的图像时,我在浏览器控制台中有一个带有此错误的空白页面:

TypeError: (void 0) is not a function

如果我删除所有添加的行,single_media_selection 效果很好,但我无法将颜色更改为 CKeditor。

我是不是哪里弄错了?

解决方法

在您提到的文档中,有一个 comment 说明您必须使用 "@ckeditor/ckeditor5-font": "^18.0.0",如果您使用的是 sulu 2.1 和 "@ckeditor/ckeditor5-font": "^23.0.0",如果您使用的是 sulu 2.2 和更高版本。

既然您提到您使用的是 sulu 2.1,这可能是错误的。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...