当htmlMode为true时,Summernote html代码视图与codemirror无法正常工作

Summernote html code view when htmlMode true is not working fine with codemirror

本文关键字:codemirror 常工作 工作 视图 true htmlMode 代码 html Summernote      更新时间:2023-09-26

$(document).ready(function () {
    $('.summernote').summernote({
        codemirror: {
            theme: 'monokai',
            htmlMode: true
        }
    });
});
<textarea class="summernote"><p><br></p>
<p>Testing html </p>
<p><br> formatting<br></p></textarea>

当您单击代码视图时,它不会正确格式化html,而是使用xml。正如您所看到的,<br>标记被解释为无效的xml标记,但是htmlMode: true被设置并应该用于将内容解释为html。

似乎我需要设置:

codemirror: {
      ...
      htmlMode: true,
      lineNumbers: true,
      mode: 'text/html'
    }

尽管这些都应该是默认值。

更新的小提琴:https://jsfiddle.net/ungue/fzt257r6/41/