Skip to content

使用 API /api/block/updateBlock 无法更新文档块 #4165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zuoqiu-Yingyi opened this issue Mar 6, 2022 · 1 comment
Closed

使用 API /api/block/updateBlock 无法更新文档块 #4165

Zuoqiu-Yingyi opened this issue Mar 6, 2022 · 1 comment
Assignees
Labels
Milestone

Comments

@Zuoqiu-Yingyi
Copy link
Contributor

描述问题 Describe the problem

使用 API /api/block/updateBlock 不能更新文档块, 请求体与响应体如下所示, 但是文档不会更新

// 请求体
{
    "id": "20200812220555-lj3enxa",
    "dataType": "markdown",
    "data": ""
}

// 响应体
{
    "code": 0,
    "msg": "",
    "data": [
        {
            "doOperations": [
                {
                    "action": "update",
                    "data": "<div data-node-id=\"20200812220555-lj3enxa\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220306121715\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\"></div></div>",
                    "id": "20200812220555-lj3enxa",
                    "parentID": "",
                    "previousID": "",
                    "retData": null
                }
            ],
            "undoOperations": null
        }
    ]
}

期待的结果 Expected result

将文档块渲染为 data 字段的内容

版本环境 Version environment

  • Version: 1.8.7

更多信息 More information

目前由于编辑区的动态加载功能, 无法全选整篇文档的内容, 因此无法在保留文档块的前提下删除文档块内部全部内容, 而使用 API 也无法实现该功能:

  • 使用 API /api/filetree/removeDoc 会将文档块整个删除, 关联该文档块的引用与超链接全部失效
@88250 88250 self-assigned this Mar 6, 2022
@88250 88250 added this to the 1.8.8 milestone Mar 6, 2022
@88250 88250 added Bug and removed Enhancement labels Mar 6, 2022
@88250 88250 closed this as completed Mar 8, 2022
@Zuoqiu-Yingyi
Copy link
Contributor Author

Zuoqiu-Yingyi commented May 13, 2022

刚刚有朋友发现了一个问题 删除文档内容 · Issue #47, 使用该 API 更新文档块时, 如果请求体 data 字段设置为空字符串 "" 或者只有换行符 "\n" "\n\n" 的字符串, 如果该文档已经在编辑器中打开, 那么被更新的文档 DOM 会如下所示, 一个块都没有

<div class="protyle-wysiwyg protyle-wysiwyg--attr" spellcheck="false" contenteditable="true" style="padding: 16px 96px 380.5px;" data-doc-type="NodeDocument"></div>

关闭该文档后再重新打开又出现了两个空的段落块


但是空文档块应该存在一个空的段落块, 如下所示

<div class="protyle-wysiwyg protyle-wysiwyg--attr" spellcheck="false" contenteditable="true" data-doc-type="NodeDocument" style="padding: 16px 96px 380.5px;">
  <div data-node-id="20220513185535-5uuae2l" data-node-index="0" data-type="NodeParagraph" class="p" updated="20220513185535">
    <div contenteditable="true" spellcheck="false"></div>
    <div class="protyle-attr" contenteditable="false"></div>
  </div>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants