Skip to content

Commit

Permalink
fix: example/code-hightlight
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfupeng1988 committed Jul 14, 2021
1 parent ccccdc6 commit 7885988
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/editor/examples/code-highlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>demo</title>
<title>code-highlight demo</title>

<!-- 引入 prism css -->
<link href="https://cdn.jsdelivr.net/npm/prismjs@latest/themes/prism.css" rel="stylesheet">
</head>
<body>
<p>代码高亮 - 使用 <a href="https://prismjs.com/" target="_blank">prism.js</a></p>
<p>由 wangEditor 生成的代码,可支持代码高亮显示</p>
<p>【注意】不可异步设置 html 内容,否则无法高亮显示 <button id="btn-test">测试一下</button></p>

<p>由 wangEditor 生成的代码,可支持代码高亮显示。使用 <a href="https://prismjs.com/" target="_blank">prism.js</a> ,支持多主题</p>
<p>【注意】异步设置 html 内容时,需要执行 <code>Prism.highlightAll()</code> <button id="btn-test">测试一下</button></p>

<div>
<p>javascript</p>
<pre>
Expand All @@ -37,6 +36,7 @@
document.getElementById('btn-test').addEventListener('click', () => {
document.getElementById('code1').innerHTML = 'const b = 200;\nfunction fn(y) { return y + 20 };\n// comment'
document.getElementById('code2').innerHTML = '&lt;p&gt;text2&lt;/p&gt;'
Prism.highlightAll()
})
</script>
</body>
Expand Down

0 comments on commit 7885988

Please sign in to comment.