关于javascript:TinyMCE4:如何将Enter键功能更改为Shift Enter键?

TinyMCE4: How to change Enter key functionality to Shift + Enter key?

在TinyMCE4中按Enter时,将创建一个新段落。有什么方法可以更改TinymCE4的配置,以便Enter应该像Shift Enter一样工作?

Enter键时,我想要一个<br/>标记而不是<pa>标记。


是的,有一个选项。它是forced_root_block

来自文档:

This option enables you to make sure that any non block elements or
text nodes are wrapped in block elements. For example something will
result in output like:

something

. This option
is enabled by default as of 3.0a1.

If you set this option to false
it will never produce p tags on enter or automatically it will instead
produce br elements and Shift+Enter will produce a p.

您还应该注意文档中的警告,但:

Note that not using p elements as root block can severely cripple the
functionality of the editor.


您可以使用forced_root_block。可能不是,这很可能会破坏很多东西。


文档中确实有一个选项可供选择:

https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block

请注意,消除块元素通常是一个"非常不好的主意",因为编辑器中的许多其他操作实际上仅在将内容组织成块时才起作用。使用此功能需要您自担风险。