fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

Ctrl+C on selected cells sometimes results in an error "Error copying cells: [object ClipboardEvent]" Firefox + Ubuntu #2856

Closed Alseidon closed 3 months ago

Alseidon commented 3 months ago

I wanted to copy multiple cells of a notebook to paste them later in the terminal (without opening the file with a text editor), so I selected them and pressed Ctrl+C. This works with one cell, but with multiple it prompts a popup with an error: "Error copying cells: [object ClipboardEvent]" (nothing in the Julia REPL). image

I don't know if copying multiple cells is supposedly supported, but the error message isn't clear in any case.

fonsp commented 3 months ago

What browser and OS is this? Can you try with an updated / different browser?

fonsp commented 3 months ago

You can use the browser dev tools to read the error message in more detail

Alseidon commented 3 months ago

What browser and OS is this? Can you try with an updated / different browser?

Firefox 123.0, on Ubuntu 22.04.4 LTS x86_64. I almost never use browser dev tools, but the Firefox console (F12, console tab) didn't output anything when prompting the error.

I got the source of the error wrong though. Copying multiple cells doesn't seem to be the issue; I now also get it with single cell selection. Here is an example of a notebook where it doesn't work : link.

It's random though; I successfully copy-pasted two cells at some point, then nothing, even when restarting Firefox or Pluto+Julia. Copying works in the same session, with Chromium 123.0.6312.58 -- probably Firefox related then?

fonsp commented 3 months ago

Are you sure you have the right console? You should see this log

https://github.com/fonsp/Pluto.jl/blob/8d792abceb35263a84dec3a909054db8e3c39544/frontend/components/Editor.js#L1320

Do you see other logs from Pluto? I see this

image
Alseidon commented 3 months ago

Here is what I see upon opening the notebook: image

I think it's the right console? And after trying to copy, nothing moves: image

fonsp commented 3 months ago

Can you update Pluto and try again?

Alseidon commented 3 months ago

Can you update Pluto and try again?

Done. An error now appears :

image

Error copying cells 
copy { target: div.cm-line, clipboardData: DataTransfer }
​
bubbles: true
​
cancelBubble: false
​
cancelable: true
​
clipboardData: DataTransfer { dropEffect: "none", effectAllowed: "uninitialized", mozCursor: "auto", … }
​
composed: true
​
currentTarget: null
​
defaultPrevented: true
​
eventPhase: 0
​
explicitOriginalTarget: <body class="no-MαθJax">
​
isTrusted: true
​
originalTarget: <div class="cm-line">
​
returnValue: false
​
srcElement: <div class="cm-line">
​
target: <div class="cm-line">
​
timeStamp: 25179
​
type: "copy"
​
<get isTrusted()>: function isTrusted()
​
<prototype>: ClipboardEventPrototype { clipboardData: Getter, … }
 DOMException: Clipboard write is not allowed. editor.375e8ab9.js:1047:10218
    Oc http://localhost:1234/editor.375e8ab9.js:1047