Currently, my goal is to create a visual editor by utilizing the tiptap library.
Although v2 of tiptap is more commonly used, there are instances where v1 is necessary.
However, I encountered an issue with tiptap's behavior when pasting plain text, discovering that the condition set in the ProseMirror library was not as expected.
https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.js#L57-L59
text.trim().split(/(?:\r\n?|\n)+/).forEach(block => {
dom.appendChild(document.createElement("p")).appendChild(serializer.serializeNode(schema.text(block, marks)))
})
It appears that ProseMirror converts a single newline to <p></p>
.
I am looking to modify this behavior so that it will convert to <br>
for one newline and <p></p>
for two newlines.
Unfortunately, I am facing difficulties in implementing this change.
editorProps: {
clipboardTextParser(text, $context) {
console.log(text)
console.log($context)
// :(
}
}
I started by attempting to override ProseMirror's clipboardTextParser
using tiptap's EditorProps
feature. However, I struggled with understanding how to reference the necessary variables and objects from ProseMirror within editorProps.
If there is a way to achieve this modification, or if tiptap offers similar functionality to clipboardTextParser
, any guidance would be greatly appreciated.
Please excuse any language errors in my explanation. Thank you for your assistance!