CodeEditApp / CodeEditTextView

A text editor specialized for displaying and editing code documents. Written in pure Swift.
https://codeeditapp.github.io/CodeEditTextView/documentation/codeedittextview/
MIT License
69 stars 13 forks source link

✨ Drag and Drop Selected Text #42

Open austincondiff opened 4 months ago

austincondiff commented 4 months ago

Description

This feature enables users to drag and drop selected text within the editor, enhancing the flexibility and ease of text manipulation. Users can quickly rearrange, duplicate, or relocate content without relying solely on traditional cut, copy, and paste commands.

Behavior on Drag

Behavior on Drop

Additional Considerations

Screenshots

https://github.com/user-attachments/assets/7809451d-8be4-416b-b0c9-5f362138eaeb

  1. Dragging a range within a single line to a new position in the same line
  2. Dragging a line to a new position

https://github.com/user-attachments/assets/f98869b4-f736-4d13-9887-4c296556b3f1

  1. Dragging a range within a single line to another line
  2. Dragging a range within a single line to create a new line
  3. Copying text with the key
thecoolwinter commented 5 days ago

https://github.com/user-attachments/assets/0dc4f7e1-63fb-44b8-b154-18f20cbc9ab1

I have a new implementation getting going. Here's the initial drag interaction updated from the existing one. Needs a few adjustments for the drop animation and I'd like to add a little plus symbol on the cursor while dragging

For the drop I still need to implement the drop interaction on the textview but that is next.

An interesting thing to note: the drag and drop interaction will need to cut the contents of the drag when dragging inside the editor, but just copy the contents when dragging outside the view.

austincondiff commented 4 days ago

Nice work so far and good observation one the cut vs copy! The cursor plus symbol should probably only appear when holding while dragging to duplicate the selection when dropped. Which adds another piece of criteria...

Upon dragging selected text...

I will update the issue description with this.