Skip to content

Plugin API addFloatLayer can be closed by pressing Esc #8470

Closed
@BryceAndJuly

Description

@BryceAndJuly

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

Activity

changed the title [-]Please enter the title of the bug report[/-] [+]通过API `plugin.addFloatLayer`打开的悬浮窗获得焦点后,无法通过按Esc键来关闭悬浮窗。[/+] on Jun 6, 2023
BryceAndJuly

BryceAndJuly commented on Jun 7, 2023

@BryceAndJuly
Author

我看到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

Vanessa219 commented on Jun 9, 2023

@Vanessa219
Member

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

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

Chenm4 commented on Jun 14, 2023

@Chenm4

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

Vanessa219

Vanessa219 commented on Jun 15, 2023

@Vanessa219
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Vanessa219@BryceAndJuly@Chenm4

      Issue actions

        Plugin API `addFloatLayer` can be closed by pressing `Esc` · Issue #8470 · siyuan-note/siyuan