8000 updateBlock plugin API does not update UI · Issue #771 · logseq/db-test · GitHub
[go: up one dir, main page]

Skip to content

updateBlock plugin API does not update UI #771

@AllanChain

Description

@AllanChain

Search first

  • I searched and no similar issues were found

What Happened?

Using logseq.Editor.updateBlock plugin API does not update the content displayed. But it does update the database and the changes will be applied after refreshing Logseq.

Reproduce the Bug

  1. Create an example 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 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+9', mode: 'editing' },
        async () => {
          const block = await logseq.Editor.getCurrentBlock()
          console.log(block)
          if (block === null) return
          await logseq.Editor.updateBlock(block.uuid, "Updated Content")
        },
        { label: 'Update Content', key: 'trigger' },
      )
    }
    
    // bootstrap
    logseq.ready(main).catch(console.error)
    {
      "name": "logseq-bug",
      "version": "1.0.0",
      "description": "",
      "main": "index.html",
      "logseq": {
        "id": "logseq-bug"
      },
      "license": "MIT"
    }
  2. Edit some block
  3. Press ctrl+shift+9
  4. The block content displayed is not changed. But it will be updated to "Updated Content" after reloading the app.

Expected Behavior

The block content is updated to "Updated Content"

Files

Screencast_20260308_103537.mp4

Browser, Desktop or Mobile Platform Information

Linux, Desktop App, 2.0.1

Additional Context

Related issue report from logseq-live-math: AllanChain/logseq-live-math#45.

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0