简体   繁体   English

代码荧光笔在 quill 编辑器中不起作用

[英]Code highlighter not working in the quill editor

I followed the documentation of Quill, but the syntax highlighting is not working.我遵循了 Quill 的文档,但语法突出显示不起作用。 By the way, even the example on the Quill playground webpage is not working, while the example on the Quill home page is working.顺便说一句,即使是Quill 游乐场网页上的示例也无法正常工作,而Quill 主页上的示例却可以正常工作。 Here is my code and a link to CodePen.这是我的代码和 CodePen 的链接。

HTML HTML

<div id="editor-container"><pre>for(int i=0;i<10;i++)
  printf ("Hello");</pre>
</div>

JS JS

var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block']
    ]
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});

Here is a CodePen showing the issue: https://codepen.io/imabot2/pen/mdJwdZy这是一个显示问题的 CodePen: https ://codepen.io/imabot2/pen/mdJwdZy

You need to include the Syntax Highlighter Module您需要包含语法荧光笔模块

Include HighLightJs ;包括HighLightJs

<!-- Local file -->
<script href="highlight.js"></script>

<!-- CloudFare CDN -->
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>

Enable module;启用模块;

var quill = new Quill('#editor-container', {
    modules: {
        syntax: true,                          # <-- Enable module
        toolbar: [
            [{ header: [1, 2, false] }],
            ['bold', 'italic', 'underline'],
            ['image', 'code-block']
        ]
    },
    placeholder: 'Compose an epic...',
    theme: 'snow'  // or 'bubble'
});

Updated codePen;更新了代码笔; https://codepen.io/0stone0/pen/poJwBzw https://codepen.io/0stone0/pen/poJwBzw

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM