代码之家  ›  专栏  ›  技术社区  ›  Ungue

当htmlMode true不能与codemirror一起正常工作时,Summernote html代码视图

  •  1
  • Ungue  · 技术社区  · 10 年前

    $(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。

    1 回复  |  直到 10 年前
        1
  •  1
  •   Ungue    10 年前

    我似乎需要设置:

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

    尽管这些是默认值。

    更新的fiddle: https://jsfiddle.net/ungue/fzt257r6/41/