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

Frontend API #5066

Closed
Tracked by #5086
BryceAndJuly opened this issue Jun 1, 2022 · 26 comments
Closed
Tracked by #5086

Frontend API #5066

BryceAndJuly opened this issue Jun 1, 2022 · 26 comments
Assignees
Milestone

Comments

@BryceAndJuly
Copy link

在什么情况下你需要该特性?In what scenarios do you need this feature?

目前来看,这两个方法在挂件中的应用带来的体验提升是非常明显的,它让挂件跟笔记文档之间的联系更加紧密。但是当前需要手动在main.js挂载方法的做法并不适用于每一个用户,如果开发者能默认开放这两种方法并简要描述一下其用法,那将是极好的。

之前尝试过在思维导图挂件中使用这两个方法,效果不错,希望PC端能默认支持,如果移动端伺服的时候也能支持,那就更好了。
https://ld246.com/article/1651156033109

描述可能的最优解决方案 Describe the optimal solution

以下是之前做过的一些粗浅的尝试:

之前尝试过在挂件中使用上述两种方法:

// 跳转
(0, window.parent._M.openFileById)({
  id: myId,
  position: "right",
  hasContext: !0,
  action: window.parent._o.Constants.CB_GET_HL,
});

// 悬浮预览
window.parent.siyuan.blockPanels.push(
  new window.parent._a.BlockPanel({
    targetElement: e.target,
    nodeIds: Arr,
  })
);

PC端windows平台 V 2.0.12 目前是通过以下方法手动挂载:

t.WYSIWYG=class

替换成:

window._o=n(1828);window._M=n(5751);t.WYSIWYG=class
t.initBlockPopover=()

替换成:

window._a=n(3781);t.initBlockPopover=()

移动端的话,之前在 v2.0.9 为了手机伺服的时候能在挂件中正常使用这两个功能,尝试过使用代理来替换main.js文件,实测是可用的,如果默认支持,则会方便很多:

t.initBlockPopover=()

替换成:

window._a=n(5933);t.initBlockPopover=()
t.WYSIWYG=class

替换成:

window._M=n(7683);window._o=n(2930);t.WYSIWYG=class

描述候选的解决方案 Describe the candidate solution

No response

其他信息 Other information

No response

@choyy
Copy link

choyy commented Jun 1, 2022

支持
如果能够悬浮预览,挂件与思源内容能够打通,像思维导图、excalidraw、timeline这些挂件体验会好很多

@Vanessa219 Vanessa219 self-assigned this Jun 1, 2022
@Vanessa219 Vanessa219 added this to the backlog milestone Jun 1, 2022
@88250 88250 changed the title 建议默认开放【悬浮预览】与【引用块跳转】的方法 支持块引悬浮预览和编辑器页签打开块前端接口 Jun 1, 2022
@88250 88250 changed the title 支持块引悬浮预览和编辑器页签打开块前端接口 支持块引悬浮预览和编辑器页签打开块的前端接口 Jun 1, 2022
@Zuoqiu-Yingyi
Copy link
Contributor

@BryceAndJuly 目前可以通过模拟单击的方式实现打开块与打开块并聚焦
https://github.com/Zuoqiu-Yingyi/siyuan-theme-dark-plus/blob/b500654851084345c4be89208b4e47decf25d3d2/script/utils/misc.js#L90-L150

@BryceAndJuly
Copy link
Author

@Zuoqiu-Yingyi Zuoqiu-Yingyi
给力喔。

@Vanessa219 Vanessa219 changed the title 支持块引悬浮预览和编辑器页签打开块的前端接口 添加前端接口 Jun 6, 2022
@Vanessa219
Copy link
Member

Vanessa219 commented Jun 6, 2022

  • Menu
  • Dialog
  • Setting
  • Lute
  • confirm
  • showMessage
  • fetchGet, fetchPost, fetchSyncPost
  • getFrontend
  • getBackend
  • adaptHotkey
  • openTab
  • plugin.openSetting
  • plugin.addStatusBar
  • plugin.loadData, plugin.saveData, plugin.removeData
  • plugin.eventBus: "ws-main" | "click-blockicon" | "click-editorcontent" | "click-pdf" | "click-editortitleicon" | "open-noneditableblock" | "loaded-protyle"
  • plugin.i18n
  • plugin.addTopBar
  • plugin.addTab
  • plugin.addDock
  • plugin.addFloatLayer
  • plugin.addIcons
  • plugin.addCommand
  • plugin.onload, plugin.onLayoutReady, plugin.onunload,

@Zuoqiu-Yingyi
Copy link
Contributor

Zuoqiu-Yingyi commented Jun 6, 2022

  • 弹消息

@Vanessa219 这个功能已经由内核 API 实现了 #5102 , 且应用更广泛(比如在非 iframe 中打开的挂件), 应该没有必要支持了

@88250 88250 changed the title 添加前端接口 前端 API Jun 14, 2022
@terwer
Copy link
Contributor

terwer commented Jul 20, 2022

期待啊,目前想做挂件,奈何没有更直接的文档和api支持

@william2113
Copy link

D 大,这个特性预计什么时候会发布呢

@88250
Copy link
Member

88250 commented Jul 31, 2022

@william2113 还没有具体的时间表,请关注 https://github.com/orgs/siyuan-note/projects/1

@Yuminis98
Copy link

Yuminis98 commented Jan 25, 2023

请问一下,这个前端API的作用和插件有什么区别吗?
还是说前端API只是面对开发者开发主题的?
以后用户有自由下载的扩展功能的机制吗?

@88250
Copy link
Member

88250 commented Jan 25, 2023

@Yuminis98 还在考虑,插件是封装更好的,前端 API 是基础。

@HowcanoeWang
Copy link

HowcanoeWang commented Feb 1, 2023

【feature request】
当文件不存在时,GetFile API 返回null或者undefined,方便后续写判断,而不是直接报404错误

@Zuoqiu-Yingyi
Copy link
Contributor

【feature request】 当文件不存在时,GetFile API 返回null或者undefined,方便后续写判断,而不是直接报404错误

404 错误也可以作为判断条件呀

Vanessa219 added a commit that referenced this issue May 28, 2023
Vanessa219 added a commit that referenced this issue May 28, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 28, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 28, 2023
Vanessa219 added a commit that referenced this issue May 29, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 29, 2023
Vanessa219 added a commit that referenced this issue May 29, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 29, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 29, 2023
Vanessa219 added a commit that referenced this issue May 30, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 30, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 30, 2023
Vanessa219 added a commit that referenced this issue May 30, 2023
Vanessa219 added a commit that referenced this issue May 30, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 30, 2023
Vanessa219 added a commit that referenced this issue May 31, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue May 31, 2023
Vanessa219 added a commit that referenced this issue May 31, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue Jun 1, 2023
Vanessa219 added a commit to siyuan-note/petal that referenced this issue Jun 2, 2023
Vanessa219 added a commit to siyuan-note/petal that referenced this issue Jun 2, 2023
Vanessa219 added a commit that referenced this issue Jun 2, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue Jun 2, 2023
@BryceAndJuly
Copy link
Author

@Vanessa219 有个问题要请教一下,如果想在挂件里使用Plugin.addFloatLayer()方法,也就是根据块ID弹出悬浮窗的话,需要怎么使用呢?

有看到一个plugin-sample,但是它的引入方式看起来并不适用于挂件。

import { Plugin } from "siyuan";

@Zuoqiu-Yingyi
Copy link
Contributor

@Vanessa219 有个问题要请教一下,如果想在挂件里使用Plugin.addFloatLayer()方法,也就是根据块ID弹出悬浮窗的话,需要怎么使用呢?

可以使用 open API 这个插件, 该插件会将插件 API 暴露至全局变量 openAPI

@BryceAndJuly
Copy link
Author

@Zuoqiu-Yingyi 嗯,好的,感谢提醒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Already Done
Development

No branches or pull requests