Skip to content
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 plugin event bus switch-protyle #9454

Closed
shenjinglei opened this issue Oct 20, 2023 · 15 comments
Closed

Add plugin event bus switch-protyle #9454

shenjinglei opened this issue Oct 20, 2023 · 15 comments
Assignees
Milestone

Comments

@shenjinglei
Copy link

In what scenarios do you need this feature?

我正在开发“关系图增强”插件,我想要实现根据当前文档自动更新关系图的功能。当前我的做法是监听click-editorcontent事件,但是这需要用户在打开文档后额外再点击一次内容块,才能触发该插件重新绘图。

Describe the optimal solution

最好能提供一个类似 TabSelectedChanged 的事件。这样我能根据当前文档的变化来重新绘图。我看到当前思源自带的关系图是能根据当前文档自动更新的,我不知道是怎么实现的,我想是不是我漏过了什么其他实现方式,也可以指导我下。
Snipaste_2023-10-20_09-52-41

Describe the candidate solution

No response

Other information

No response

@Vanessa219
Copy link
Member

修改文档时没有更新对应的关系图,你是怎么操作以后会更新对应的关系图的?

@shenjinglei
Copy link
Author

插件设置中有一个“自动跟随打开的文档”,需要选择“是”。
image
image

@shenjinglei
Copy link
Author

如果是增加了链接,增加了文章。需要手动点一下刷新按钮去更新下数据。

@Vanessa219
Copy link
Member

切换文档主要通过 updatePanelByEditor 中的 updateBacklinkGraph 进行更新。由于页签可以分屏,因此在点击的时候也会调用该方法,如果需要使用的话,插件需要自己记录 protyle.block.rootID 和 protyle.block.id,然后判断是否需要更新。

@88250
Copy link
Member

88250 commented Oct 28, 2023

没有问题的话我先关闭了哦,如果还有问题请继续跟帖,谢谢。

@88250 88250 closed this as completed Oct 28, 2023
@shenjinglei
Copy link
Author

那 updatePanelByEditor 中的 updateBacklinkGraph,可以做一个事件出来吗?方便插件监听来更新插件的渲染。

@Vanessa219 Vanessa219 changed the title 希望增加一个当前文档变更的事件接口 Add plugin event bus switch-protyle Oct 28, 2023
@Vanessa219 Vanessa219 self-assigned this Oct 28, 2023
@Vanessa219 Vanessa219 added this to the 2.10.13 milestone Oct 28, 2023
@Vanessa219
Copy link
Member

那 updatePanelByEditor 中的 updateBacklinkGraph,可以做一个事件出来吗?方便插件监听来更新插件的渲染。

可以的, switch-protyle

@Vanessa219 Vanessa219 reopened this Oct 28, 2023
Vanessa219 added a commit that referenced this issue Oct 28, 2023
@shenjinglei
Copy link
Author

哈哈,那太好啦,谢谢。

Vanessa219 added a commit to siyuan-note/petal that referenced this issue Oct 28, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue Oct 28, 2023
@Vanessa219
Copy link
Member

dev 分支已提交,你试一下

@shenjinglei
Copy link
Author

我现在还没有siyuan的开发环境,dev暂时还跑不起来。

@88250
Copy link
Member

88250 commented Oct 28, 2023

等会发布 dev 版吧。

@shenjinglei
Copy link
Author

好的

@shenjinglei
Copy link
Author

shenjinglei commented Oct 28, 2023

  • 我这边测试了, switch-protyle事件没有问题。
  • 但是发现,在关闭最后一个页签后。页签位置显示空白,然后就再也打不开文档了。重启思源之后也无法打开任何文档。切换另一个工作空间能正常使用。(可复现,未安装插件)
    test1
  • 思源是安装的 siyuan-v202310281648-win.exe
  • 但是显示的版本是
    test2

@Vanessa219
Copy link
Member

谢谢反馈,更新到昨晚的版本再试试。界面损坏的话可以使用重置界面。

@shenjinglei
Copy link
Author

dev4版本已测试,没发现问题。

appdev pushed a commit to appdev/siyuan-unlock that referenced this issue Oct 31, 2023
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