Skip to content

File vanished during cut/copy and paste #1155

Closed
logseq/logseq
#13177

Description

@judy9910082-svg

Search first

  • I searched and no similar issues were found

What Happened?

After cut/copying a file (ex. pdf) previously imported to Logseq and pasting it to another page, it vanishes and only paste a blank node.

Reproduce the Bug

  1. import a PDF
  2. select the node with ctrl+A
  3. cut/copy the node
  4. paste it at another page ...then you get nothing but a blank node

Expected Behavior

should've been able to bring the PDF imported to another page

Screenshots

screen shot of Logseq problem.docx

Desktop or Mobile Platform Information

mac OS Tahoe 26.5.2
Logseq DB 2.0.1

Additional Context

No response

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

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

Activity

  1. transferred this issue fromlogseq/logseqon Sep 6, 2026
  2. yuxi-liu-wired commented on Oct 28, 2026

    @yuxi-liu-wired

    Copy/paste of an asset block (a PDF, for example) pastes nothing. The target block stays empty. I read the code but did not reproduce this in the app, and I am not changing it without a decision, because every fix means choosing who owns the asset file.

    What happens: insert-blocks in deps/outliner/src/logseq/outliner/core.cljs removes asset blocks when outliner-op is :paste, or when it inserts a template ((remove ldb/asset?)). It came in with fb9e735934 ("paste query block should create new block"). That commit does not say why assets are dropped. The reason is probably that an asset block cannot be copied as an entity. The file lives at assets/<block uuid>.<type> (asset-file-name in components/block/asset.cljs), so a copy with a new uuid would point to a file that does not exist. When every copied block is an asset, nothing is inserted and the empty target stays empty, which is what the report describes. Templates that contain an asset lose it the same way.

    Two things that bear on the choice:

    • Cut and paste does not go through this path. paste-blocks in handler/editor.cljs moves the recycled blocks with move-blocks!, which keeps their uuid. Only copy and paste (and templates) are affected.
    • new-asset-block in handler/editor/assets.cljs refuses a file whose checksum already belongs to an asset ("asset already exists"). The app treats one file as one asset block.

    Options:

    1. Paste a block that links to the original asset block (:block/link), the way "copy as embed" already does in paste-copied-blocks-or-text. The file stays single and the checksum rule still holds. The pasted block is a live view of the original, so deleting the original asset (delete-asset-of-block!) breaks every pasted copy, and the copy does not carry its own caption.
    2. Paste a reference to the original, either ((uuid)) or a markdown link [title](../assets/<uuid>.<ext>). Images already copy this way since b29088b88c, and this extends it to every type (PDF, audio, video). It is the smallest change, but it is text and not an asset block, so the pasted thing is not tagged Asset and has no asset properties.
    3. Copy the file under a new uuid and create a new asset block with a new checksum entry. The pasted block is independent. This needs file I/O in the worker on every paste, and the checksum dedup would have to allow the copy. It is the most work, and it stores the file twice.
    4. Keep dropping assets, but say so. Show a notice ("asset blocks can't be pasted, use the embed copy") and do not leave an empty block behind. No new behaviour, but PDFs still cannot be copied between pages.

    My suggestion is option 1, with option 4's notice for any case it does not cover. Which of these do you want? I will write the fix and its test once it is chosen.

  3. judy9910082-svg commented on Nov 8, 2026

    @judy9910082-svg
    Author

    Option 2 is not ideal due to the loss of asset properties.
    Option 3 is a viable alternative; however, if the pasted block becomes a new file, will the PDF highlights still be preserved in the new file?

    I think Option 1 with the notice you suggested would be great, but I still have a few concerns:

    1. Visual distinction: Will it look distinct enough to indicate it is a copy, helping prevent accidental deletion of the original?

    2. Cut vs. Copy: What happens if I want to "cut" instead of "copy"? Under Option 1, is there still a risk of losing the file?

    3. Batch actions: How would this work if I want to copy or cut multiple files at once?

    Thank you for your time and for discussing this with me!

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

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