[英]Code highlighter not working in the quill editor
我遵循了 Quill 的文檔,但語法突出顯示不起作用。 順便說一句,即使是Quill 游樂場網頁上的示例也無法正常工作,而Quill 主頁上的示例卻可以正常工作。 這是我的代碼和 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'
});
這是一個顯示問題的 CodePen: https ://codepen.io/imabot2/pen/mdJwdZy
您需要包含語法熒光筆模塊
包括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>
啟用模塊;
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'
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.