cocreate icon indicating copy to clipboard operation
cocreate copied to clipboard

Copy/paste

Open edemaine opened this issue 3 years ago • 11 comments

This would be particularly useful for pasting across boards or pages.

  • [x] Copy objects (Ctrl/Meta-C) stores object contents
  • [x] Copy objects (Ctrl-C) stores SVG contents too (for pasting into Illustrator?)
    • I got this to work when copying from Firefox and pasting into Inkscape. Illustrator 2021 does not seem to receive SVG content (currently). Chrome also fails to copy the content; see this Chrome bug.
  • [x] Paste (Ctrl-V or paste event) detects object contents and recreates (and selects) objects on current page
    • [ ] Should the objects be offset to be visible if they aren't?
    • [ ] Or can we capture Ctrl-Shift-V / Ctrl-Alt-V and paste to mouse / screen center only then?
  • [x] Paste turns ASCII text into text objects (done in #142)
  • [x] Paste turns URLs into image objects (#144)
  • [x] Copy/paste works across pages/boards/tabs/windows
  • [x] Cut objects (Ctrl/Meta-X)
  • [ ] Buttons for copy/cut/paste/duplicate (for touch interfaces). Add as buttons around select rectangle
  • [ ] Select and copy (no cut or paste) from History view (need to support toggling between move and select modes within History)

edemaine avatar Sep 15 '20 03:09 edemaine

I would like to paste screenshots into cocreate so that I can annotate them. These screenshots are typically of code, or parts of a gui. I use these in teaching.

jkitchin avatar Sep 18 '20 14:09 jkitchin

@jkitchin Yep, that is issue #22.

edemaine avatar Sep 18 '20 15:09 edemaine

This web page has an explanation, working code, and a live demo for how to gracefully copy/paste nontrivial data (with SVG as an example). I expected a Blob of type 'image/svg+xml' to be pasted, but that is not the case — that's currently unsupported. Instead, the clipboard should contain multiple representations of the same data. The raw svg appears with type 'text/plain', and a rendering of the svg is included as an 'image/png'.

duetosymmetry avatar Oct 10 '20 15:10 duetosymmetry

(moved your message for you)

Yeah, I have some experience in Coauthor with defining a custom data type for internal representations of data. Oh, actually, looks like I only did so for dragging (also here), but I assume/hope the clipboard can behave similarly. This would let Cocreate -> Cocreate copy/paste work with the internal database representations.

Although the example app you linked doesn't fill a image/svg+xml slot, I imagine it could, for apps that support it. Worth testing with programs like Inkscape and Illustrator.

edemaine avatar Oct 10 '20 16:10 edemaine

For those following this issue, cut/copy/paste via Ctrl/Command-X/C/V now works quite well. In particular, you can now copy objects from one page to another, or even between boards! You can also paste links to images and they'll get embedded (part of #144), or paste text and it'll turn into a text object (part of #142).

edemaine avatar Feb 01 '21 20:02 edemaine

@edemaine I'm not quite sure what I might be doing wrong, but I cannot seem to copy text from one board to the next using crtrl C then V. I can't even copy/paste text within the same board. Any advice?

ashawdr avatar Mar 24 '21 22:03 ashawdr

What server, operating system, and browser are you using? For CSAIL, Windows, Chrome it works well.

edemaine avatar Mar 24 '21 23:03 edemaine

Gather.Town, Windows, and Chrome. I think the issue might be with Gather, I'm just not quite sure how to fix it.

ashawdr avatar Mar 25 '21 13:03 ashawdr

Yeah, Gather.Town is running an older version of Cocreate, which doesn't have this feature. We need to wait until they update...

edemaine avatar Mar 25 '21 13:03 edemaine

I've started implementing

Should the objects be offset to be visible if they aren't?

in the commit above; here are some conceptual questions copied from the commit message:

  • edemaine#94 suggests this should only apply if the original location falls outside the viewport. Is it ever desirable that pasted content appears exactly at its original location? If so, should the test be "original location entirely on screen" or "original location partially on screen"?

  • It would be nice if pasted content could appear at the mouse instead (a la Inkscape), but unfortunately it seems like there's no way to get the cursor position without a mouse event, and doing something like storing the position of the most recent mouse event seems messy.

  • Should the paste offset always be grid-snapped even if snapping is disabled? This is probably barely noticeable when unwanted but greatly annoyance-reducing when wanted.

tckmn avatar Apr 26 '21 16:04 tckmn

I think I'm now convinced that Ctrl-V should paste in the center of the view, or mouse cursor if it's been seen since the last pointerleave event. (This matches Inkscape behavior. Illustrator always pastes at center of view.)

Ctrl-Alt-V (Inkscape's shortcut) or Ctrl-Shift-V could be the new way to access "paste in place". It's useful e.g. when copying things into previously duplicated pages. It will only work for content copied from the current Cocreate window, but that's probably all we need.

Should probably only round when grid snapping is off.

edemaine avatar May 05 '21 19:05 edemaine