Reputation: 197
Question I know this might sound insane but I want to be able to trigger a new paragraph both by pressing enter as is the default but also by clicking a button. Ive been digging around the docs and github but clearly nobody is as stupid as me and I have not found similar examples.
What im trying My assumption is that I could use createParagraphNear? But im having trouble with it. Neither of the two commands below seem to actually do anything for me. I expected that a new empty paragraph wold appear and the docs dont explain createParagraphNear much at all so I was a bit conflicted about wheter this command is even doing what I think it is. Or if im just way off here.
Heres a gif of me executing the above lines and showing that no new paragraph is entered. Is this expected behavior or am I messing something up?
Motivation The real reason I want this is because I have this pseudo Twitter like idea where instead of tweet character limits theres just a paragraph character limit. I want to automatically trigger a new paragraph if the amount of characters in the current paragraph exedes some number. I figure first step of accomplishing this is learning how to take control over when a new paragraph is entered. And then the next step is to figure out if I can trigger this when the current paragraph reaches a limit.
So yeah, I hope that context makes my question sound less dumb
Upvotes: 0
Views: 427
Reputation: 1
Adding selectParentNode()
helped me.
editor.chain().selectParentNode().createParagraphNear().focus().run()
Upvotes: 0