Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/app-desktop/gui/note-viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,20 @@

wrapper.querySelectorAll('style').forEach(s => s.remove());

// Code blocks contain a hidden <pre class="joplin-source"> with the raw Markdown.
// External editors don't apply Joplin's CSS (display: none), causing the code
// to appear twice when pasted. Remove them from the clipboard copy.
//
// This does NOT affect pasting into Joplin's Rich Text Editor — TinyMCE's
// onPaste handler converts pasted HTML to Markdown and back (via processPastedHtml),
// so it never reads .joplin-source from clipboard HTML.
wrapper.querySelectorAll('.joplin-source').forEach(s => s.remove());

// The focus dummy is a hidden link ("Note viewer top") used for accessibility.
// It leaks into clipboard HTML because its container only hides via overflow.
const focusDummy = wrapper.querySelector('#joplin-content-focus-dummy');
if (focusDummy && focusDummy.parentElement) focusDummy.parentElement.remove();

const inlineTags = new Set(['STRONG', 'EM', 'CODE', 'S', 'DEL', 'INS', 'MARK', 'SUP', 'SUB', 'U', 'SPAN', 'A']);
let node = range.commonAncestorContainer;
if (node.nodeType === Node.TEXT_NODE) node = node.parentElement;
Expand Down
Loading