Skip to content

Plugin API supports opening block attribute panel by block id #14276

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
loonghfut opened this issue Mar 4, 2025 · 7 comments
Closed

Plugin API supports opening block attribute panel by block id #14276

loonghfut opened this issue Mar 4, 2025 · 7 comments
Assignees
Milestone

Comments

@loonghfut
Copy link

loonghfut commented Mar 4, 2025

希望插件api支持通过块id来打开块属性面板

In what scenarios do you need this feature?

插件希望实现双击日历事件后弹出事件块的属性面板,方便修改相关属性
虽然目前通过曲线的方式实现了(即先弹出包裹protyle的dialog,在模拟鼠标点击块的右上角,最后摧毁dialog),很不优雅,且在某些情况下会点击到错误的元素。

Image

Image

Image

Describe the optimal solution

思源插件api支持直接通过块id来直接打开块属性面板

Image

Describe the candidate solution

No response

Other information

No response

@TCOTC
Copy link
Contributor

TCOTC commented Mar 4, 2025

打开块属性面板

需要能指定打开的是 内置 数据库 自定义 之中的哪一个,并且 数据库 不存在时需要有错误处理

@loonghfut
Copy link
Author

打开块属性面板

需要能指定打开的是 内置 数据库 自定义 之中的哪一个,并且 数据库 不存在时需要有错误处理

确实,感谢提醒

@Vanessa219
Copy link
Member

目前系统内部的方法如下,你看一下是否满足?

export const openAttr = (nodeElement: Element, focusName = "bookmark", protyle?: IProtyle) => {

@loonghfut
Copy link
Author

目前系统内部的方法如下,你看一下是否满足?

感谢V姐回复,
感觉只要能让插件调用openAttr就行,nodeElement可以用/api/block/getBlockDOM获取, protyle可以不填对吧?
(个人理解)

@loonghfut
Copy link
Author

openFileAttr(response.data, focusName, protyle);

导出这个也行,可以避免调用/api/block/getBlockDOM,但不知道为什么要做(nodeElement.getAttribute("data-type") === "NodeThematicBreak")判断,是为了防止什么情况呢?
(个人理解)

@Vanessa219
Copy link
Member

分割线上没有属性,使用数据库属性的话 protyle 是必须传的。

@loonghfut
Copy link
Author

感谢V姐解答,
可以先直接导出 openAttr, 可供插件调用就行(之后我再试试能不能达到预计结果)

Vanessa219 added a commit that referenced this issue Mar 6, 2025

Unverified

This user has not yet uploaded their public signing key.
Vanessa219 added a commit to siyuan-note/petal that referenced this issue Mar 6, 2025

Unverified

This user has not yet uploaded their public signing key.
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue Mar 6, 2025
@Vanessa219 Vanessa219 added this to the 3.1.25 milestone Mar 6, 2025
@88250 88250 changed the title 希望插件api支持通过块id来打开块属性面板 Plugin API supports opening block attribute panel by block id Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants