How to insert a block (or how to insert a markdown?


#1

Is me agian.

Now I wanna to insert a markdown content.

I use defaultMarkdownParser.parse to parse the markdown into a Node

But I found that tr.replaceSelectionWith method can insert a inline node but can not insert a block node.

Is that any methods can insert a block node?

Or I missed something in the guide?


#2

That isn’t the case though—it can insert block nodes as well. The issue might be that it fails to find a way to fit the node at the given position. It sounds like you are parsing a whole document, which may be the problem—a document node won’t fit anywhere inside a document.


#3

Wow! That is the issue! I have achieved it! Thank you!


#4

@marijn I have a another question.

When I call the Editor props clipboardTextParser or transformPasted, it come up an error

Uncaught TypeError: this.nodes[node.type.name] is not a function

at DOMSerializer.serializeNode

Or I should ask how to get the clipboard data?


#5

You generally can’t access the clipboard from JavaScript, except when handling a paste event. Maybe you’re interested in the handlePaste prop?