Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cut/copy/paste #900

Closed
dethe opened this issue Jan 17, 2015 · 5 comments · Fixed by #1319
Closed

Implement cut/copy/paste #900

dethe opened this issue Jan 17, 2015 · 5 comments · Fixed by #1319
Assignees
Labels

Comments

@dethe
Copy link
Member

dethe commented Jan 17, 2015

We need to reimplement cut/copy/paste. Rather than a custom context menu, this should work with standard key shortcuts (C-c, C-x, C-v for copy,cut,paste where C is Ctrl on Windows (and Linux?) and Cmd on Mac.

We'll just copy the HTML, so it should work across windows, workspaces or even between programs. We will need to check during paste operations to make sure content is being pasted into a valid location (and is not just generic HTML).

We might want to use ZeroClipboard to help get things on the real system pasteboard: https://code.google.com/p/zeroclipboard/source/browse/ZeroClipboard.js. For information about how this works (and why it is needed): https://stackoverflow.com/questions/17527870/how-does-trello-access-the-users-clipboard/17528590

@dethe
Copy link
Member Author

dethe commented Oct 1, 2015

Browsers are (finally) giving access to the clipboard. This library may help to bridge the transition: https://zenorocha.github.io/clipboard.js/

@CelticMinstrel
Copy link
Contributor

I suppose that since you seem to have selection working, the context menu isn't really necessary, but I also don't really see any reason to get rid of it? It doesn't hurt to allow both mouse and keyboard methods of doing something.

@zenorocha
Copy link

+1 for clipboard.ks ;)

@dethe dethe self-assigned this Feb 6, 2016
@dethe
Copy link
Member Author

dethe commented Feb 7, 2016

Have implemented the basics in #1319 using a hidden element that gets the innerHTML on ctrl/meta down and selects it, updating the DOM if the selected text changes. Works OK, but there is still some work to do:

  • Generalize "can I insert here" test(s) Generalize "can I insert here" test(s) #1320
  • Generalize actual insertion the same way Factor "insert" into it's own API #1322
  • Update pasteboard (hidden element) when selection changes rather than when ctrl/meta key is down
  • Provide feedback when paste fails (give reason, such as "cannot paste a step into an expression socket"
  • Don't trap the copy when nothing is selected
  • Test paste between windows, into other apps
  • Restore context menu for cut/copy/paste/clear Restore context menu #1321 (deferred, see comment below)
  • Clear selected on backspace/delete
  • Update selection after insertion in a general way Selections: Unify .selected-value and .selected-block #1323
  • Fix meta key handling when switching windows/tabs
  • Prevent multiple selections (for now)
  • Use new tests from Generalize "can I insert here" test(s) #1320 in select.js and cutandpaste.js
  • Paste inserts at selection, doesn't replace
  • Make sure we can still cut/paste normally from text inputs
  • Handle cut, not just copy/paste
  • Make sure undo events are saved for all forms of insert/remove
  • Test deleting nested blocks with instances
  • With good undo, does it make sense to always clone the block before dragging?
  • Fix up ids in instanceof attributes if needed
  • Fix styling of drag-target, drop-target, no-drop, and selected to be less colour-dependent, more consistent

@dethe
Copy link
Member Author

dethe commented Feb 17, 2016

Realized that because we leverage the system clipboard, we can't actually trigger cut/copy/paste ourselves. Well, we could, but then it would work differently than the keyboard-triggered version, and I'd like to avoid having the same thing behave differently depending how it was triggered, as much as is possible (we already have that if they choose copy/paste from the browser menu instead of the hotkeys, so adding our own with a context menu would then have 3 different versions).

On mobile this is different. They don't have a menu version, and copy/paste from one window or app to another is not as much of a priority. On mobile I can see the benefit of having double-tap on a block in the script bring up a menu for cut/copy/paste/clear and maybe undo/redo.

Will defer this feature for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants