don't intercept pastes inside citation ids#1060
Open
kevinushey wants to merge 3 commits into
Open
Conversation
The generic markdown / html paste handlers were consuming pastes that occur inside a cite_id mark, preventing the cite mark's own paste handler from offering to insert a citation when a DOI is pasted after '@'. On Windows this made DOI paste citations entirely unreachable, since the html paste handler consumes any paste carrying text/html there. Addresses rstudio/rstudio#18295
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Avoids adding new external devDependencies (vitest, jsdom) for a test runner: the vscode extension suite is the only test harness exercised by CI, and the paste handlers import cleanly in the extension host (prosemirror-view guards its DOM access at import time). The 'editor' workspace package is added as a devDependency of the extension for the test's imports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses rstudio/rstudio#18295
Problem
In the visual editor on Windows, typing
@and pasting a DOI (e.g.https://doi.org/10.1000/182) does nothing, whereas on Linux/macOS the editor offers to look up the DOI and insert a citation.Cause
ProseMirror consults
handlePasteplugins in registration order, and the generic paste extension (behaviors/paste.ts) is registered before the cite mark'spaste_cite_doiplugin. Inside acite_idmark the generic handlers form a pincer that preventspaste_cite_doifrom ever running on Windows:text/html(e.g. a DOI copied from a browser page) are consumed bypasteHtmlHandler'sisWindows()branch (the workaround for ProseMirror freezing on multi-paragraph pastes).pasteMarkdownHandler(the cite marks don't setnoInputRules, soallowMarkdownPastereturns true inside a citation). This variant also affects macOS and Linux.Since
isWindows()keys off the user agent, this affects any Windows client, including browsers connecting to a Linux server.Fix
Both generic handlers now return
falsewhen the selection is inside acite_idmark, allowing the cite mark's own paste handler to process the paste (insert the DOI, offer to insert a citation, or fall back to a plain-text insert for non-DOI content).Tests
Added
apps/vscode/src/test/editor-paste.test.tscovering the fixed cases plus the preserved behaviors (Office content and Windowstext/htmlpastes outside citations are still handled, plain text outside citations is still pasted as markdown). The 3 regression cases fail without the fix.The tests live in the vscode extension suite (rather than
packages/editor, whose jest-style tests undertest/apiare orphaned -- no runner is configured for them, andtest/README.mdnotes their fixtures no longer work) because it is the only harness exercised by CI, and this avoids adding a new test runner dependency. The tests exercise the editor package directly and don't use the vscode API; the only dependency change is adding theeditorworkspace package as a devDependency of the extension.Verified
tsc --noEmitand the panmirror bundle build pass. Manual verification on Windows is still pending.