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

Desktop: Fixes #11274: Fix content dropped into the Markdown editor is missing a cursor preview or dropped at the wrong location #11289

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Oct 29, 2024

Summary

This pull request:

  1. resolves Dragging and dropping text no longer shows preview caret #11274
  2. resolves a similar (but not identical) issue reported on the forum.

In particular:

  1. In-editor content was dropped at the correct location, but no preview cursor was shown.
  2. Notes were dropped at the last editor cursor location.

Note

This pull request targets release-3.1.

Screen recording

Screencast.from.2024-10-29.15-54-21.webm

Manual testing plan

MacOS (Sequoia): (MacOS testing done before rebasing on release-3.1).

  1. Drag a note from the note list over the editor.
  2. Verify that a preview cursor is visible.
  3. Drop the note at a location distinct from the current editor cursor.
  4. Verify that the note is dropped at that position.

Fedora 41:

  1. Open Chromium.
    • Files from Firefox and the Files app often fail to drop into Joplin. This is the case with both with the new and legacy editors. Drag and drop from Chromium's "Downloads" list seems to work consistently.
  2. Download 2-3 images (2 PNGs, 1 SVG).
  3. Drop a PNG from the downloads list into Joplin's Markdown editor.
  4. Verify that the image drops successfully.
  5. Drop the SVG from the downloads list into a different location in Joplin's Markdown editor.
  6. Verify that the image is dropped at the mouse's last location.
  7. Drop a note from the note list into the editor.
  8. Verify that a note link is added at the mouse's last location.
  9. Select text in the editor.
  10. Drag and drop the text to a different part of the editor.
  11. Verify that the text is moved.

@@ -253,6 +254,8 @@ const createEditor = (

// Apply styles to entire lines (block-display decorations)
decoratorExtension,
dropCursor(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change shows where content will be dropped. See the CodeMirror documentation for dropCursor.

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
dropItems: async (cmd: any) => {
dropItems: async (cmd: DropCommandValue) => {
let pos = cmd.pos && editorRef.current.editor.posAtCoords({ x: cmd.pos.clientX, y: cmd.pos.clientY });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

posAtCoords is how CodeMirror internally determines the drop location for content — this makes the drop location of content processed by Joplin match CodeMirror's drop cursor.

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fix content dropped into the Markdown editor is missing a cursor preview or dropped at the wrong location Desktop: Fixes #11274: Fix content dropped into the Markdown editor is missing a cursor preview or dropped at the wrong location Oct 29, 2024
@laurent22 laurent22 merged commit 612d72d into laurent22:release-3.1 Oct 30, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants