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 open-siyuan-url-plugin and open-siyuan-url-block #8927

Merged

Conversation

Zuoqiu-Yingyi
Copy link
Contributor

@Zuoqiu-Yingyi Zuoqiu-Yingyi commented Aug 7, 2023

  • Please commit to the dev branch
  • For contributing new features, please supplement and improve the corresponding user guide documents
  • For bug fixes, please describe the problem and solution via code comments
  • For text improvements (such as typos and wording adjustments), please submit directly

Add some plugin event buses
添加插件事件总线

  • open-siyuan-url
    • 打开 siyuan://foo
      open siyuan://foo
  • open-siyuan-url-blocks
    • 打开 siyuan://blocks/<块 ID>
      open siyuan://blocks/<block ID>
  • open-siyuan-url-plugins
    • 打开 siyuan://plugins/<插件名>
      open siyuan://plugins/<plugin name>
    • 仅派发给插件名对应的插件
      This event only send to the plugin with the same name

已通过测试 (Windows 11)
Tested passed (Windows 11)

@suka233
Copy link

suka233 commented Aug 11, 2023

萌佬牛哇,请求一个需求,现在的自定义协议链接的逻辑是,点击参数符合规范的思源超链接,就直接调用openFile()打开指定插件了,但是有时候,这样太粗暴了。
比如说,我在思源已经存在了一个某个插件的tab页,这个tab页有自己的data,但是用户可以点击超链接,直接再打开一个相同data数据的tab页,这样,就会造成插件的tab页数据混乱。。。不知道我讲清楚没有,
如果可以规范一下自定义协议链接的参数,比如说,加上
siyuan://plugins/plugin-samplecustom_tab?title=自定义页签&icon=iconFace&data={"text": "This is the custom plugin tab I opened via protocol."}&options={'directOpen':'false'}
这样,插件既可以通过监听open-siyuan-url-plugins获取到上面的url参数值,又可以自主调控是否根据data打开tab页,更灵活

后期options内可以携带更多的参数,适配更多的功能

@Zuoqiu-Yingyi
Copy link
Contributor Author

后期options内可以携带更多的参数,适配更多的功能

自己定义一个 URL 自己解析就可以了

@suka233
Copy link

suka233 commented Aug 11, 2023

萌佬牛哇,请求一个需求,现在的自定义协议链接的逻辑是,点击参数符合规范的思源超链接,就直接调用openFile()打开指定插件了,但是有时候,这样太粗暴了。 比如说,我在思源已经存在了一个某个插件的tab页,这个tab页有自己的data,但是用户可以点击超链接,直接再打开一个相同data数据的tab页,这样,就会造成插件的tab页数据混乱。。。不知道我讲清楚没有, 如果可以规范一下自定义协议链接的参数,比如说,加上 siyuan://plugins/plugin-samplecustom_tab?title=自定义页签&icon=iconFace&data={"text": "This is the custom plugin tab I opened via protocol."}&options={'directOpen':'false'} 这样,插件既可以通过监听open-siyuan-url-plugins获取到上面的url参数值,又可

后期options内可以携带更多的参数,适配更多的功能

自己定义一个 URL 自己解析就可以了

那有可能是我理解错误,等到pr合并上去,我再试试看看~~

@Vanessa219 Vanessa219 changed the title Add plugin event bus open-siyuan-url, open-siyuan-url-blocks and open-siyuan-url-plugins Add plugin event bus open-siyuan-url Aug 11, 2023
@Vanessa219 Vanessa219 merged commit 75ad2a2 into siyuan-note:dev Aug 11, 2023
4 checks passed
@Vanessa219 Vanessa219 added this to the 2.10.0 milestone Aug 11, 2023
@Zuoqiu-Yingyi Zuoqiu-Yingyi deleted the feat/plugin-event-bus-open-siyuan-url branch August 11, 2023 16:08
@Vanessa219 Vanessa219 changed the title Add plugin event bus open-siyuan-url Add plugin event bus open-siyuan-url-plugin and open-siyuan-url-block Aug 12, 2023
Vanessa219 added a commit that referenced this pull request Aug 12, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this pull request Aug 12, 2023
Vanessa219 added a commit to siyuan-note/petal that referenced this pull request Aug 12, 2023
Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan-packages-monorepo that referenced this pull request Aug 14, 2023
Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan-plugin-monaco-editor that referenced this pull request Aug 15, 2023
@suka233
Copy link

suka233 commented Sep 22, 2023

后期options内可以携带更多的参数,适配更多的功能

自己定义一个 URL 自己解析就可以了

现有的open-siyuan-url-plugins逻辑看起来似乎是如果匹配到指定插件,就必定会走到openFile这一步,也就是必定会打开tab页。但是有时候外部调用自定义协议链接并不仅仅是想要打开tab页,而是希望做其它的事情 :比如说可以根据传入的参数打开文档或者新建文档之类的。类似的需求描述可以看看这个#6875

监听open-siyuan-url这个事件倒是可以实现上述需求,但是我看这个功能并没有被合并上去。。。
请问一下V姐这是为啥捏 @Vanessa219

如果萌佬有空的话,可否再次提交一下open-siyuan-url的PR,或者给open-siyuan-url-plugins加上一个额外的解析参数,如果携带了这个参数,就不走openFile的逻辑了。

@Zuoqiu-Yingyi
Copy link
Contributor Author

@suka233 请关注 #9256

@suka233
Copy link

suka233 commented Sep 25, 2023

@suka233 请关注 #9256

赞 感谢萌佬

Zuoqiu-Yingyi added a commit to Zuoqiu-Yingyi/siyuan-packages-monorepo that referenced this pull request Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants