Contribute to this guide

guide更新至 CKEditor 5 v39.x

更新 CKEditor 5 安装时,请确保所有包的版本一致,以避免错误。

对于自定义构建,您可尝试删除 package-lock.jsonyarn.lock 文件(如果适用),并在重新构建编辑器之前重新安装所有包。为了获得最佳效果,请确保您使用最新的包版本。

# 更新至 CKEditor 5 v39.0.0

发布日期:2023 年 8 月 2 日。

有关 39.0.0 版本中引入的所有更改的完整列表,请参阅 CKEditor 5 v39.0.0 的发行说明

以下是升级到 CKEditor 5 v39.0.0 时需要注意的最重要的更改。

# 将颜色选择器引入表格和表格单元格属性功能

从 CKEditor 5 v39.0.0 开始,表格样式工具 将在其用户界面中为与颜色相关的工具显示颜色选择器。

就像 将颜色选择器引入字体颜色和字体背景颜色功能 一样,您可以决定此新功能是否适合您的集成,以及是否选择退出。

您可以将 colorPickercolorPicker 配置选项设置为 false,以在所有表格样式工具中消除颜色选择器

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        table: {
            /* ... */

            tableProperties: {
                // Disable the color picker for the table properties feature.
                colorPicker: false
            },

            tableCellProperties: {
                // Disable the color picker for the table cell properties feature.
                colorPicker: false
            }
        }
        toolbar: [
            'heading', 'bulletedList', 'numberedList', 'fontColor', 'fontBackgroundColor', 'insertTable', 'undo', 'redo'
        ]
    } )
    .then( /* ... */ )
    .catch( /* ... */ );

# 适应 ckeditor5-cbox 包中的更改

# CKBox 库依赖关系

@ckeditor/ckeditor5-cbox 包现在仅与 CKBox 库版本 2.0.0 或更高版本一起运行。请确保您的 HTML 中设置了以下脚本标签以加载正确的版本

<script src="https://cdn.ckbox.io/ckbox/2.0.0/ckbox.js"></script>

# 本地 CKBox 后端调整

CKBox 后端已在 2.0.0 版本中发布。使用 CKBox 后端本地版本的用户需要更新到此版本以确保兼容性。

此外,编辑器配置参数 ckbox.assetsOrigin 通常与本地版本一起使用,现在不再需要。这是因为插件不再自行构建资产 URL,而是使用后端直接提供的 URL。您应从编辑器配置中删除 ckbox.assetsOrigin 参数。

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        /* ... */

        // CKBox configuration parameters.
        ckbox: {
            serviceOrigin: 'https://your-service-origin.com',

            // This parameter is no longer needed and should be removed.
            assetsOrigin: 'https://your-assets-origin.com'
        }
    } )

# 视图元素占位符

enablePlaceholder() 函数不再获取占位符内容作为 options 参数的 text 属性。要定义占位符的值,您需要将其指定为传递到 options 对象中的 elementplaceholder 属性

element.placeholder = 'Type something…';

enablePlaceholder( {
    view: editingView,
    element: element,
    isDirectHost: false,
    keepOnFocus: true
} );