So really simple question, how can I create a new node inside simple action? I’ve tried create and createAndFill and whatever, but for some reason it always ends up producing two nodes instead of one. I am baffled.
About the other things, I tried the setSelection but apparently did something wrong. I’ll try again at some point. The <br> element thing, well, as I am nesting inline inside the block node eg p > span I guess there won’t be any <br>s added if it’s empty? Well the whole thing breaks down if you do that as you can’t even select an empty inline node, the cursor will just skip the whole thing.
Well just as a follow-up, the problem was that while I was inserting the paragraph all right, it seems you always have to insert it at the end of the current one to break it into its own line. Because reasons, I guess. It kinda inserts the new paragraph so that it pushes the old paragraph’s last part to a completely new paragraph. Or something.
like so. Removing return true at the end of the dispatch fixed the duplication of paragraphs, dunno why. Why is that? I have so many silly questions, so sorry about that.
The true indicates that this command handled the key (or whatever it was that triggered it). Commands are allowed to ‘pass’ on actually doing anything when they don’t apply. You either had another command bound to the same key, which was taking effect, or saw the browser’s native behavior happen after your command ran.