Skip to content

使用 API api/block/updateBlock 更新列表项时渲染错误 #4658

Closed
@Zuoqiu-Yingyi

Description

@Zuoqiu-Yingyi

描述问题 Describe the problem

  1. 原列表项
* {: id="20210104091228-56d6mjx"}[超级链接](https://ld246.com)<br />
  {: id="20210201202130-jhxwimm"}
  1. API 参数
{
    "id": "20210104091228-56d6mjx",
    "dataType": "markdown",
    "data": "* 测试3"
}
  1. API 响应体
{
    "code": 0,
    "msg": "",
    "data": [
        {
            "doOperations": [
                {
                    "action": "update",
                    "data": "\u003cdiv data-subtype=\"u\" data-node-id=\"20210104091228-56d6mjx\" data-node-index=\"1\" data-type=\"NodeList\" class=\"list\" updated=\"20220421171642\"\u003e\u003cdiv data-marker=\"*\" data-subtype=\"u\" data-node-id=\"20220421171642-erlefd2\" data-type=\"NodeListItem\" class=\"li\" updated=\"20220421171642\"\u003e\u003cdiv class=\"protyle-action\" draggable=\"true\"\u003e\u003csvg\u003e\u003cuse xlink:href=\"#iconDot\"\u003e\u003c/use\u003e\u003c/svg\u003e\u003c/div\u003e\u003cdiv data-node-id=\"20220421171642-y40w52j\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220421171642\"\u003e\u003cdiv contenteditable=\"true\" spellcheck=\"false\"\u003e测试3\u003c/div\u003e\u003cdiv class=\"protyle-attr\" contenteditable=\"false\"\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"protyle-attr\" contenteditable=\"false\"\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"protyle-attr\" contenteditable=\"false\"\u003e\u003c/div\u003e\u003c/div\u003e",
                    "id": "20210104091228-56d6mjx",
                    "parentID": "",
                    "previousID": "",
                    "retData": null
                }
            ],
            "undoOperations": null
        }
    ]
}
<div data-subtype="u" data-node-id="20210104091228-56d6mjx" data-node-index="1" data-type="NodeList" class="list" updated="20220421171642">
    <div data-marker="*" data-subtype="u" data-node-id="20220421171642-erlefd2" data-type="NodeListItem" class="li" updated="20220421171642">
        <div class="protyle-action" draggable="true"><svg>
                <use xlink:href="#iconDot"></use>
            </svg></div>
        <div data-node-id="20220421171642-y40w52j" data-type="NodeParagraph" class="p" updated="20220421171642">
            <div contenteditable="true" spellcheck="false">测试3</div>
            <div class="protyle-attr" contenteditable="false"></div>
        </div>
        <div class="protyle-attr" contenteditable="false"></div>
    </div>
    <div class="protyle-attr" contenteditable="false"></div>
</div>

列表项变成了一个列表块
image
4. 刷新更新的块所在文档
image
刚刚更新的内容又恢复为了列表项, 但是 ID 发生的变化

  • 新 ID 为消失的列表块内的列表项 ID

期待的结果 Expected result

由于列表块内只能存在列表项, 如果使用该 API 更新, 这里需要进行一次逻辑判断

  • 待更新块为列表项时
    • 如果发送了一个列表块, 那么保持列表项 ID 不变, 在该列表项容器内部放置一个列表块
    • 如果发送了一个列表项, 那么保持列表项 ID 不变, 更新该列表项
  • 待更新块为列表块时
    • 如果发送了一个列表块, 那么保持列表块 ID 不变, 在该列表块容器内部放置多个列表项
    • 如果发送了一个列表项, 那么保持列表块 ID 不变, 在该列表块容器内部放置一个列表项

截屏或者录屏演示 Screenshot or screen recording presentation

版本环境 Version environment

  • Version: 2.0.0-beta2

Activity

self-assigned this
on Apr 21, 2022
Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Apr 21, 2022

@Zuoqiu-Yingyi
ContributorAuthor

这个 API 还有一个问题, 就是如果不设置 ial, 那么更新一次除了 idupdated, 其他所有的 IAL 字段都会被移除, 如果保持原样, 那么 updated 属性也会被覆盖
希望可以通过合并的方式更新 IAL

API 请求 IAL \ 原 IAL 存在 不存在
存在 新 IAL 新 IAL
空字符串
不存在 原 IAL
changed the title [-]使用 API `/block/updateBlock` 更新列表项时渲染错误[/-] [+]使用 API `api/block/updateBlock` 更新列表项时渲染错误[/+] on Apr 21, 2022
added this to the 2.0.4 milestone on Apr 29, 2022
88250

88250 commented on May 2, 2022

@88250
Member

如果发送了一个列表块/如果发送了一个列表项

这里似乎无法区别,因为 Markdown 都是 * foo,只能根据 id 来判断待更新块的类型然后再处理。

ial 覆盖的问题应该是预期。

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on May 2, 2022

@Zuoqiu-Yingyi
ContributorAuthor

这里似乎无法区别,因为 Markdown 都是 * foo,只能根据 id 来判断待更新块的类型然后再处理。

对对, 我就是这个意思

ial 覆盖的问题应该是预期。

这一句应该怎么理解呀❓

88250

88250 commented on May 2, 2022

@88250
Member

因为输入中没有 IAL 所以就覆盖为空了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Zuoqiu-Yingyi

      Issue actions

        使用 API `api/block/updateBlock` 更新列表项时渲染错误 · Issue #4658 · siyuan-note/siyuan