Pasting rich text (links) on macOS

Pasting rich text with embedded links on macOS does not preserve/convert the links. Is this a known issue, and is there a workaround?

(For example: copy linked text from a browser window – if I paste in TextEdit, the link is preserved; if I paste in logseq, it comes in as plaintext)

edit: looking around a bit, I guess this would need something like turndown.

Just to note, this is not about verbatim links within text – eg https://link.here/... (auto-linking works fine) – but rather copying text with fully-rendered links, which is stored in some rich intermediate format by the OS. When I paste such text elsewhere, the links are (usually) preserved.

In any case, after looking around a bit I tweaked renderer.js in the ElectronFiddle clipboard example like this:

var TurndownService = require('turndown')
...
pasteButton.onclick = () => {
  var html = clipboard.readHTML()
  var turndownService = new TurndownService()
  var markdown = turndownService.turndown(html)

  textarea.value = markdown
}
...

And it seems to do what I am looking for: when I paste some text with links that I’ve copied from (eg) Slack, the app gets the rich formatted HTML, then turndown converts to fairly usable markdown (there is some CSS junk included at the beginning, but presumably that can be filtered).

Should this be an issue/feature request for the LogSeq main app, or should something like this be done as a plugin?

2 Likes

I’m noticing the same issue (I’m on Windows, though). Great job finding a solution.

This is standard in Roam and Obsidian, so I think it should be in the main app. Could you perhaps make a pull request?

Has anyone figured a workaround for this problem for the Windows desktop version of Logseq? I’m having the same issue and can’t figure out how to paste text into Logseq with the links intact. Thanks!