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
Add a new API Move block
#7903
Comments
Move block
目前只能提供非批量移动接口,如果要批量操作的话需要多次调用。 Issue 的话不用双语,使用母语即可,这样反馈效率更高一些。 |
好的,感谢 D大 @88250 。我有些功能细节问题想问一下:移动多个有层级的 block 的过程中要如何保证他们的层级关系? 就比如我下面列举的情况。我有一个标题块 A,下面的是这个文档块的子块 Aa 。显然 A 的 parent 是他所在的文档块,所以移动标题块 A 到另一个文档块下就会更改他的 parent_id。 但是 Aa 的 parnet_id 仍然是 A 没有变,那么后面如果我希望继续保持 Aa 和 A 的层次关系,还有必要移动 Aa吗? 或者更进一步,如果 move api 要实现的话,它的行为逻辑是什么样子的呢? |
只移动 a 的话 parent_id 会被改成移动后的父块 id,不是 A 的 id。 |
@88250 也就是说只移动父块会自动破坏原来的父子关系是吗?那么是否意味着,如果需要保持原来的层级关系,就需要:
也就是说,如果需要移动具有层级关系的一堆块,需要手动解析他们的关系,然后在 move 的过程中保持原来的层级关系? |
标题块比较特殊,它不是容器块,所以如果要带其下方块一起移动的话需要先将标题块折叠。 |
我先关闭了,如果还有问题请继续跟帖,谢谢 🙏 |
添加 API 移动块
In what scenarios do you need this feature?
中文
使用背景
无论怎么推崇双链写作法,思源都是一款提供了文档树的笔记软件,为了更好地支持用户对于整理文档组织逻辑的需求,移动 blocks 功能还是有必要的。
例如:我有好几个笔记本,每个笔记本的主题都完全不同。我并不想把所有的记录都写在同一个笔记本下,原因在于:
但是也不想每次记笔记都来回切换笔记本。所以我的做法一般是写的时候全部在统一一个笔记本内,然后等到晚上整理的时候,把各个主题块移动到各自的笔记本下。
功能请求
在 UI 操作中,我们可以通过选择+拖动的方式,把若干的块移动到另一个 parent blocks 下。我希望可以提供类似功能的 API 。
目前我们可以在 API 里曲折地实现类似的功能:1) 获取 markdown 内容 2)用
insertBlock
插入新的地方 3) 删除原来的 block。但是这个方法,在于剪切的方式会丢失原本的 ID,如果需要移动的 blocks 本身有反向链接,那么那个链接的目标就会丢失。所以我认为需要一个更加原生的、通过修改
parent_id
,在保证不丢失原始的 ID 信息的前提下实现移动块的方法。English
Background
No matter how much we praise the double-linked writing method, Siyuan is still a note-taking software that provides a document tree. In order to better support users' needs for organizing document logic, the move blocks function is necessary.
For example: I have several notebooks, each with a completely different main topic. I don't want to write all my notes in the same notebook for the following reasons:
But I also don’t want to switch notebooks every time I take notes. So my approach is to write everything in the same notebook when writing, and then move each blocks to their correspondent notebooks when organizing today's notes at night.
Feature Request
In UI operation, we can move several blocks to another parent block by selecting and dragging. I hope to provide an API with the same functionality.
Currently, we can implement similar functions in the API in a convoluted way: 1) Get the markdown content 2) Insert a new block with
insertBlock
3) Delete the original block. However, this method will lose the original ID in the cutting process. If the blocks that need to be moved have reverse links themselves, then the target of that link will be lost.Therefore, I think we need a more native method to move blocks by modifying the
parent_id
while ensuring that the original ID information is not lost.By the way
感觉同时写中英文的 Issue 好麻烦。。。
Describe the optimal solution
I know little about your source code. But as I think it might no be so hard to implement the aforementioned functionality. Cause it seems that we can make it use by changing the
parent_id
in database.Following given the template definition for this API.
/api/block/moveBlocks
Parameters
Move all
srcBlocksID
blocks todesParentID
srcBlocksID: List
desParentID: str
action
/api/block/appendBlock
/api/block/prependBlock
Return:
It depends on you.
Describe the candidate solution
No response
Other information
No response
The text was updated successfully, but these errors were encountered: