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

Plugin API addFloatLayer can be closed by pressing Esc #8470

Closed
BryceAndJuly opened this issue Jun 6, 2023 · 4 comments
Closed

Plugin API addFloatLayer can be closed by pressing Esc #8470

BryceAndJuly opened this issue Jun 6, 2023 · 4 comments
Assignees
Milestone

Comments

@BryceAndJuly
Copy link

BryceAndJuly commented Jun 6, 2023

Describe the problem

通过API plugin.addFloatLayer打开的悬浮窗获得焦点后,无法通过按Esc键来关闭悬浮窗。

在文档的引用数或文中的引用块弹出的悬浮弹窗,获得焦点后是可以通过按Esc键来关闭悬浮窗的。相比于将鼠标移出弹窗来关闭,通过Esc键来关闭弹窗是个很方便用户的操作,希望能在API打开的悬浮窗中保留此逻辑。

备注:演示中顶栏的插件用的是集市官方的插件示例,在挂件中也能复现此问题。

API.Esc.mp4

Expected result

相比于将鼠标移出弹窗来关闭,通过Esc键来关闭弹窗是个很方便用户的操作,希望能在API打开的悬浮窗中保留此逻辑。

Screenshot or screen recording presentation

No response

Version environment

- Version: 2.9.0
- Operating System: windows 10
- Browser (if used):

Log file

none

More information

No response

@BryceAndJuly BryceAndJuly changed the title Please enter the title of the bug report 通过API plugin.addFloatLayer打开的悬浮窗获得焦点后,无法通过按Esc键来关闭悬浮窗。 Jun 6, 2023
@BryceAndJuly
Copy link
Author

BryceAndJuly commented Jun 7, 2023

我看到main.js的最后那里在window对象上挂载了window.openFileByURL方法,能否默认把那个悬浮预览的方法addFloatLayer也挂上呢?这样在挂件就能直接用了,而且还没有【悬浮窗获得焦点后无法通过按Esc键关闭窗口】的问题。

不然现在要在挂件里用个方法,还得先去安装插件(还好有用户贡献了这个插件,不然还没法用),搞完后弹出的弹窗还有点小问题。

const g_ = new p_();

window.openFileByURL = n => {
    if (n && dg(n)) {
        const e = (0, E.on)('focus', n) === '1'
        return (
            he({
                app: g_,
                id: cl(n),
                action: e
                    ? [f.Constants.CB_GET_ALL, f.Constants.CB_GET_FOCUS]
                    : [f.Constants.CB_GET_FOCUS, f.Constants.CB_GET_CONTEXT],
                zoomIn: e
            }),
            !0
        )
    }
    return !1
}

window._addFloatLayer = n => {
    try {
        return (
            window.siyuan.blockPanels.push(
                new _s({
                    app: g_,
                    isBacklink: n.isBacklink,
                    x: n.x,
                    y: n.y,
                    targetElement: n.targetElement,
                    nodeIds: n.nodeIds
                }))
            ,
            !0
        )
    } catch (err) { console.error(err) }

}

@Vanessa219
Copy link
Member

window.openFileByURL 是为了提供移动端和 Pad 使用的,挂载其他方法目前还没有计划。

@Vanessa219 Vanessa219 changed the title 通过API plugin.addFloatLayer打开的悬浮窗获得焦点后,无法通过按Esc键来关闭悬浮窗。 API plugin.addFloatLayer can be closed by pressing esc Jun 9, 2023
@Vanessa219 Vanessa219 self-assigned this Jun 9, 2023
@Vanessa219 Vanessa219 added this to the 2.9.1 milestone Jun 9, 2023
Vanessa219 added a commit that referenced this issue Jun 9, 2023
@88250 88250 changed the title API plugin.addFloatLayer can be closed by pressing esc Plugin API addFloatLayer can be closed by pressing esc Jun 9, 2023
@88250 88250 changed the title Plugin API addFloatLayer can be closed by pressing esc Plugin API addFloatLayer can be closed by pressing Esc Jun 9, 2023
@Chenm4
Copy link

Chenm4 commented Jun 14, 2023

有一个问题是这个浮层为什么不可以移动出屏幕,有些时候它挡住了一些内容只能先关闭等看完了被挡内容再打开

@Vanessa219
Copy link
Member

里面的内容是无法显示在程序以外的,可以使用新窗口功能。

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