Skip to content

Update the parent_id of blocks below a heading block when updating the heading block #14871

Closed
@TCOTC

Description

@TCOTC
Contributor

标题块变更之后,需要更新子块的 parent_id

  • 创建或转换标题块 → 更新子块的 parent_id
    移动标题块 → 更新移动前的子块的 parent_id、更新移动后的子块的 parent_id
    文档块转标题块 → 更新转换后的子块的 parent_id
    插件创建标题块的逻辑不知道是不是一样的?

p.s. 子块只有一层,如果子块是容器块或者子级标题块,则子块的子块不需要更新 parent_id


先创建标题块再创建子块,可以查到标题块;先创建子块再创建标题块,无法查到标题块:

video.webm
SELECT * 
FROM blocks 
WHERE id IN (
    SELECT parent_id 
    FROM blocks 
    WHERE id=''
)

Activity

changed the title [-]创建或转换标题块之后,需要更新子块的 parent_id[/-] [+]标题块变更之后,需要更新子块的 parent_id[/+] on May 21, 2025
self-assigned this
on May 22, 2025
added this to the 3.1.31 milestone on May 24, 2025
changed the title [-]标题块变更之后,需要更新子块的 parent_id[/-] [+]Update the `parent_id` of blocks below a heading block when updating the heading block[/+] on May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@TCOTC

      Issue actions

        Update the `parent_id` of blocks below a heading block when updating the heading block · Issue #14871 · siyuan-note/siyuan