How to use '\n' for newline

I want to use ‘\n’ for new line, not <br />. how can i do this? (keep paste ‘\n’ normal)

You could take a look at how the code_block node type in the basic schema works, and do something similar to that (it disables whitespace preservation in its parseDOM rule, sets code: true in its spec to make the default enter command work differently, and uses an HTML node type that’s styled with white-space: pre).

Note that you may need to configure your keybinding for enter anyway, unless your whole document is one single block node, to distinguish between inserting a line break and starting a new block.

1 Like