Skip to content

[Feature] Convert rich-text clipboard (Word, Office, HTML, Google Docs) to Markdown on paste, like Obsidian #1064

Open

Description

@vlcinsky

Summary

When I paste formatted content (MS Word, other Office apps, web pages, Google Docs) into the ZenNotes editor, the result is plain text: bullets, numbering, nesting, headings, bold/italic, links and tables are lost. Obsidian converts the text/html part of the clipboard to Markdown on paste by default, and the result is usually a usable Markdown note straight away. I would like the same in ZenNotes.

Current behavior

ZenNotes 2.83.0 (desktop)
OS: macOS 27.0.1, arm64
Engine: Electron 41.10.7 (Chromium 146.0.7680.216, Node 24.18.0)
Install: macOS app bundle
  1. In Word, create a short document with a heading, a nested bullet list, a numbered list, a bold/italic phrase, a hyperlink and a small table.
  2. Select all, copy, and paste into a ZenNotes note in.
  3. Result
    4. when using p in normal mode or Cmd+V in insert mode: it inserts an image (see Pasting a text copied from MS Word (on MacOS) inserts an image #1062 )
    5. when using Cmd+Alt+Shift+V in insert mode:
    6. bold, underlined text, headers and tables are inserted as plain text without any formatting
    7. ordered and unordered lists looks better, but use tab to delimit the bullet/number and remaining text what breaks the flow

Expected behavior

On paste (both p in normal mode and Cmd+V in insert mode), if the clipboard contains text/html (Word, Excel/Numbers/Sheets ranges, browsers and Google Docs all provide it), convert it to Markdown and insert that instead of the plain-text flavor.

Source element Expected Markdown
Headings H1-H6 # to ######
Bold / italic / strikethrough **x** / *x* / ~~x~~
Bulleted lists, including nested - item, indented 2 or 4 spaces per level
Numbered lists, including nested 1. item
Links [text](url)
Tables GFM pipe tables with a header row
Inline code / code blocks backticks / fenced block
Block quotes > text
Images see "Images" below

Controls

  • Settings > Editor: toggle "Convert pasted HTML to Markdown", default on (as in Obsidian).
  • Shortcut for the opposite behavior: Cmd/Ctrl+Shift+V pastes plain text only (Obsidian does the same).
  • Command palette: "Paste as Markdown" and "Paste as plain text", so they work whatever the toggle is set to. This also covers Vim users: normal-mode p pastes from a register and is not a natural place for conversion, so a named command or leader mapping that can be remapped would fit the existing keymap system.
  • Pasting from inside ZenNotes itself, or when the HTML is just a wrapper around plain text, should not be altered.

Images

Inline images in clipboard HTML are often data: URIs or file references. Suggested behavior: save them with the existing image-paste mechanism (the same one used when pasting a screenshot) and insert a normal embed link, rather than inlining base64 into the note. A first version could skip images and leave a short placeholder.

How Obsidian handles this today

Findings from Obsidian's forum and community plugin pages, not from testing every version myself:

  • Obsidian has an editor setting that converts pasted HTML to Markdown, on by default. It was called "Auto convert HTML" and appears under the name "Convert pasted HTML to Markdown" in newer forum posts. Cmd/Ctrl+Shift+V pastes without formatting.
  • The conversion is done with the Turndown library, exposed to plugins as htmlToMarkdown().
  • It works well for web pages: headings, bold/italic, links, lists and simple tables generally come through.
  • It is weaker for Word and Office: users report that bullet hierarchies from Word are not preserved, that LibreOffice Writer headings arrive as plain text with numbering, that tables and images may not transfer, and that images can arrive as long base64 strings.
  • Google Docs pastes are bolded wholesale because Docs wraps the clipboard HTML in a <b style="font-weight:normal"> element and uses styled spans instead of <strong>. A community plugin ("Google Docs Paste") exists to rewrite that HTML before conversion.
  • Pasting spreadsheet ranges (Excel, Sheets, Numbers, Calc) into a Markdown table is handled by a community plugin ("Excel to Markdown Table"), which suggests the core behavior does not cover it.
  • There is a long-standing forum request to offer both a "raw" and a "formatted" paste and let the user choose which one Ctrl+V does, because the single on/off toggle forces a tradeoff.
  • A "Paste Reformatter" plugin adds regex-based cleanup of the HTML before conversion (for example Word's smart quotes and empty elements), so a cleanup step is something people want.

Takeaway: the Obsidian baseline is "HTML to Markdown via Turndown, on by default, Shift to bypass". ZenNotes can match that and avoid the known gaps by pre-processing Word/Docs HTML and converting spreadsheet ranges to pipe tables.

Implementation notes (suggestions, not requirements)

  • The editor is CodeMirror 6, so this fits a paste handler (EditorView.domEventHandlers({ paste })) that reads clipboardData.getData('text/html'), converts it, and inserts the result as one undoable transaction.
  • Turndown plus turndown-plugin-gfm (tables, strikethrough, task lists) is the same approach Obsidian uses and runs in both Electron and the browser, so the web and Go-server runtime get it too.
  • Add small pre-processing rules before conversion: Word mso-list paragraphs to real lists, Google Docs docs-internal-guid wrapper and font-weight:700 spans to <strong>, unwrapping google.com/url?q= redirect links, dropping empty spans and <o:p>.
  • Fall back to plain text if conversion throws or produces an empty result.

Acceptance criteria

  1. Pasting the Word test document above produces headings, nested bullets, numbered list, bold/italic, link and a pipe table.
  2. The same for a web page selection (Firefox and Chrome) and Google Docs.
  3. Cmd/Ctrl+Shift+V inserts plain text with no conversion.
  4. The setting can disable conversion, and the commands "Paste as Markdown" / "Paste as plain text" are available in the palette and remappable.
  5. One undo step reverts the whole paste.
  6. Pasting plain text, or text copied from ZenNotes, is unchanged.

Alternatives considered

  • Doing the conversion outside the app (Pandoc, online converters, Obsidian) works but breaks the keyboard-first flow that ZenNotes is built around.
  • An MCP/CLI-only import would not help with ordinary copy and paste.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions