Skip to content

don't intercept pastes inside citation ids#1060

Open
kevinushey wants to merge 3 commits into
quarto-dev:mainfrom
kevinushey:bugfix/windows-doi-paste
Open

don't intercept pastes inside citation ids#1060
kevinushey wants to merge 3 commits into
quarto-dev:mainfrom
kevinushey:bugfix/windows-doi-paste

Conversation

@kevinushey

@kevinushey kevinushey commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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 handlePaste plugins in registration order, and the generic paste extension (behaviors/paste.ts) is registered before the cite mark's paste_cite_doi plugin. Inside a cite_id mark the generic handlers form a pincer that prevents paste_cite_doi from ever running on Windows:

  • Clipboards carrying text/html (e.g. a DOI copied from a browser page) are consumed by pasteHtmlHandler's isWindows() branch (the workaround for ProseMirror freezing on multi-paragraph pastes).
  • Plain-text-only clipboards are consumed by pasteMarkdownHandler (the cite marks don't set noInputRules, so allowMarkdownPaste returns 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 false when the selection is inside a cite_id mark, 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.ts covering the fixed cases plus the preserved behaviors (Office content and Windows text/html pastes 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 under test/api are orphaned -- no runner is configured for them, and test/README.md notes 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 the editor workspace package as a devDependency of the extension.

Verified tsc --noEmit and the panmirror bundle build pass. Manual verification on Windows is still pending.

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
@posit-snyk-bot

posit-snyk-bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants