Skip to content

Plugin cannot register command shortcut with editing mode #10392

@AllanChain

Description

@AllanChain

Search first

  • I searched and no similar issues were found

What Happened?

When using logseq.App.registerCommandShortcut to register command shortcuts in plugins, if the mode is set to editing, then the shortcut is not actually registered.

Reproduce the Bug

  1. Create a simple plugin
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Logseq selection bug</title>
</head>
<body>
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/@logseq/libs"></script>
<script src="./index.js"></script>
</body>
</html>
function main () {
  logseq.App.registerCommandShortcut(
    { binding: 'mod+shift+7' },
    () => logseq.UI.showMsg('123'),
  )
  logseq.App.registerCommandShortcut(
    { binding: 'mod+shift+8', mode: 'editing' },
    () => logseq.UI.showMsg('456'),
  )
  logseq.App.registerCommandShortcut(
    { binding: 'mod+shift+9', mode: 'non-editing' },
    () => logseq.UI.showMsg('789'),
  )
}

// bootstrap
logseq.ready(main).catch(console.error)
{
  "name": "logseq-cmd-bug",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "logseq": {
    "id": "logseq-cmd-bug"
  },
  "license": "MIT"
}
  1. Open Logseq, when editing a block, press ctrl+shift+8
  2. Go to settings, find plugin section in keymap

Expected Behavior

  1. 456 message is displayed
  2. mod+shift+8 keymap is present

Screenshots

  1. no message shown
  2. mod+shift+8 keymap is absent

Desktop or Mobile Platform Information

Linux, Desktop App v0.9.19

Additional Context

global and non-editing mode works fine. Only editing mode fails.

Are you willing to submit a PR? If you know how to fix the bug.

  • I'm willing to submit a PR (Thank you!)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions