指南支持的协作功能

导出到 Word 转换器支持 Word 的协作功能,即评论和修订。评论功能允许您添加有关所选内容部分的通知,而修订功能则允许您提出对内容的更改建议,例如删除、插入或替换所选内容部分。

这两个功能也由 CKEditor 5 实现,因此请确保阅读 CKEditor 5 评论CKEditor 5 修订 指南以了解更多信息。

请注意,尽管导出到 Word 需要与 CKEditor 5 协作功能兼容的格式的 HTML,但转换器本身是与技术无关的。它可以与您端上的自定义集成一起使用 - 只要它支持相同的内容格式。

# 评论

评论是 Word 的一项高级功能,导出到 Word 功能与 CKEditor 5 评论 完全兼容,支持该功能。评论允许用户在不更改内容本身的情况下,向文档添加注释。

评论数据通过 config.collaboration_features.comment_threads 配置选项提供给转换器。评论元数据包含一个评论线程数组,其中包含以下属性

  • thread_id: 线程的字符串 ID (必填)。
  • is_resolved: 一个布尔值,用于确定线程是否已解决 (默认值为 false)。
  • comments: 属于该线程的评论数组。它们包含以下属性
    • content: 评论的 HTML 内容 (必填)。
    • author: 评论作者的姓名 (必填)。
    • created_at: 描述评论创建时间(以 ISO 8601 格式)的日期和时间 (可选)。

将带有评论的 HTML 内容转换为 Word 文档的示例

<p>
    <comment-start name="comment-thread-1"></comment-start>
    Hello world!
    <comment-end name="comment-thread-1"></comment-end>
</p>
{
    "config": {
        "collaboration_features": {
            "comment_threads": [
                {
                    "thread_Id": "comment-thread-1",
                    "resolved": false,
                    "comments": [
                        {
                            {
                                "author": "User 1",
                                "content": "<p>This is an example comment.</p>",
                                "created_at": "2024-05-12T10:00:00.000Z",
                            },
                            {
                                "author": "User 2",
                                "content": "<p>This is another example comment.</p>",
                                "created_at": "2024-05-12T10:30:00.000Z",
                            },
                        }
                    ]
                }
            ]
        }
    }
}

Document with comments

导出到 Word 转换器支持将 段落内联 HTML 元素超链接 作为评论的内容进行转换。

# 修订

修订是另一项高级功能,它也与 CKEditor 5 修订 兼容。要在 Word 中开始跟踪更改,请从功能区中选择“审阅”选项卡,然后启用“修订”选项。现在,对文档应用的任何更改都将被跟踪。

修订数据通过 config.collaboration_features.suggestions 提供给转换器。修订元数据包含一个建议数组,其中包含以下属性

  • id: 建议的字符串 ID (必填)。
  • author: 建议作者的姓名 (必填)。
  • created_at: 描述建议创建时间(以 ISO 8601 格式)的日期和时间 (可选)。

将带有建议的 HTML 内容转换为 Word 文档的示例

<p>
    <suggestion-start name="insertion:0:user1"></suggestion-start>
    Insertion
    <suggestion-end name="insertion:0:user1"></suggestion-end>
</p>

<p>
    <suggestion-start name="deletion:1:user1"></suggestion-start>
    Deletion
    <suggestion-end name="deletion:1:user1"></suggestion-end>
</p>
{
    "config": {
        "collaboration_features": {
            "suggestions": [
                {
                    "id": "0",
                    "author": "User 1",
                    "created_at": "2024-05-12T10:00:00.000Z",
                },
                {
                    "id": "1",
                    "author": "User 1",
                    "created_at": "2024-05-12T10:30:00.000Z",
                }
            ]
        }
    }
}

Document with suggestions

# 时区

Word 修订功能不支持指定时区的日期,所有建议都被视为本地日期和时间。您可以使用 config.timezone 选项将此类日期偏移到指定的时区。

考虑以下文档的转换

{
  "html": "<suggestion-start name=\"insertion:s1:user1\"></suggestion-start>Suggestion<suggestion-end name=\"insertion:s1:user1\"></suggestion-end>",
  "config": {
    "collaboration_features": {
      "suggestions": [
        {
          "id": "s1",
          "author": "User 1",
          "created_at": "2020-05-05T14:30:00.000Z"
        }
      ]
    }
  }
}

在 Word 中打开生成的文档后,它显示建议是在 2020 年 5 月 5 日下午 2:30:00 创建的,与本地时区无关。

将时区设置为 America/Los_Angeles 后,之前的建议将在 Word 中显示为在 2020 年 5 月 5 日上午 7:30:00 创建的,与本地时区无关。

提供的时区必须是有效的 IANA 时区 标识符。