TinyMCE“强制根阻止”导致Google Chrome浏览器出现问题

时间:2018-12-03 10:44:42

标签: google-chrome tinymce-4

当我在TinyMCE配置中将forced_root_block更改为false时,在Google Chrome中键入空格会引起麻烦。空格键似乎“挂起”。 Microsoft Edge没有问题。我不确定这个问题何时开始,因为我一直都不使用Chrome,但我猜只是最近才使用。我之所以使用此设置,是因为我希望使用Enter键将换行符<br>换成<p>换行。

我试图在下面的代码片段中重现此行为,但我无法使其运行。无论如何,这是我自己的网站上的same example。这个问题可以解决,还是Chrome的问题?

编辑:无论使用forced_root_block设置如何,使用Internet Explorer似乎都存在空格问题。尽管空格键没有挂起,但会产生&nbsp;而不是普通空格。因此,我认为问题与TinyMCE有关,而不与浏览器有关。

tinymce.init({
  selector: 'textarea',
  height: 150,
  width: 400,
  theme: 'modern',
  verify_html: false,
  menubar: false,
  statusbar: false,
  forced_root_block: false,
  paste_as_text: true,
  plugins: [
    'advlist autolink lists link image charmap print preview hr anchor pagebreak',
    'searchreplace wordcount visualblocks visualchars code fullscreen',
    'insertdatetime media nonbreaking save table contextmenu directionality',
    'emoticons template paste textcolor colorpicker textpattern imagetools'
  ],
  toolbar1: 'bold italic | link | forecolor backcolor emoticons emoji | removeformat',
  contextmenu: 'paste | link image inserttable | cell row column deletetable',
  image_advtab: true,

  relative_urls: false,
  remove_script_host: true,
});
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<form id="form1">
  <textarea id="fldMessage" cols="58" rows="15" runat="server"></textarea>
</form>

1 个答案:

答案 0 :(得分:0)

设置forced_root_block: false时,是在告诉TinyMCE在按下Enter键时插入<br>,而不是创建新的块元素(<p>)。

当按下 Enter 键时,您希望发生什么? TinyMCE将创建一个新块或插入一个换行符-您是否需要其他行为?如果是这样,您将需要捕获 Enter 键并以编程方式执行所需的操作。