siyuan icon indicating copy to clipboard operation
siyuan copied to clipboard

前端 API

Open BryceAndJuly opened this issue 2 years ago • 8 comments

在什么情况下你需要该特性?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

BryceAndJuly avatar Jun 01 '22 03:06 BryceAndJuly