javascript - Code highlighter not working in the quill editor - Stack Overflow

I followed the documentation of Quill, but the syntax highlighting is not working. By the way, even the

I followed the documentation of Quill, but the syntax highlighting is not working. By the way, even the example on the Quill playground webpage is not working, while the example on the Quill home page is working. Here is my code and a link to CodePen.

HTML

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

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:

I followed the documentation of Quill, but the syntax highlighting is not working. By the way, even the example on the Quill playground webpage is not working, while the example on the Quill home page is working. Here is my code and a link to CodePen.

HTML

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

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

Share Improve this question edited Feb 29, 2020 at 15:49 Fifi 3,6153 gold badges31 silver badges62 bronze badges asked Mar 9, 2019 at 18:09 marcos souzamarcos souza 7611 gold badge10 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6 +50

You need to include the Syntax Highlighter Module

Include HighLightJs;

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

<!-- CloudFare CDN -->
<script src="//cdnjs.cloudflare./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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744285558a4566780.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信