mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +08:00
fix: strip carriage return chars from text pasted as code and add missing paste meta information
This commit is contained in:
parent
f74f1ac885
commit
b1c56e6f16
@ -171,7 +171,14 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
|
||||
tr.setSelection(TextSelection.near(tr.doc.resolve(Math.max(0, tr.selection.from - 2))))
|
||||
|
||||
// add text to code block
|
||||
tr.insertText(text)
|
||||
// strip carriage return chars from text pasted as code
|
||||
// see: https://github.com/ProseMirror/prosemirror-view/commit/a50a6bcceb4ce52ac8fcc6162488d8875613aacd
|
||||
tr.insertText(text.replace(/\r\n?/g, '\n'))
|
||||
|
||||
// store meta information
|
||||
// this is useful for other plugins that depends on the paste event
|
||||
// like the paste rule plugin
|
||||
tr.setMeta('paste', true)
|
||||
|
||||
view.dispatch(tr)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user