Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix(paste): paste plaintext with separate paragraphs
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud authored and backportbot-nextcloud[bot] committed Oct 18, 2023
commit 48f4c5641a4190d09fa4374903e5cb66a4f55f3d
9 changes: 7 additions & 2 deletions src/extensions/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@ const Markdown = Extension.create({
const doc = document.cloneNode(false)
const dom = doc.createElement('div')
if (shiftKey) {
// Treat single newlines as linebreaks and double newlines as paragraph breaks when pasting as plaintext
dom.innerHTML = '<p>' + str.replaceAll('\n', '<br />').replaceAll('<br /><br />', '</p><p>') + '</p>'
// Treat double newlines as paragraph breaks when pasting as plaintext
for (const part of str.split('\n\n')) {
const para = doc.createElement('p')
// Treat single newlines as linebreaks
para.innerText = part
dom.append(para)
}
} else {
dom.innerHTML = markdownit.render(str)
}
Expand Down