CKEditor5 code block feature for integration with PrismJS
NOTE: Only for custom builds.
- Create folders
/src/plugun/codeblock
- Put the content
src
folder from current repo to/src/plugun/codeblock
of your ckeditor build - In your
ckeditor.js
update configuration:// ... import CodeBlock from './plugin/codeblock/codeblock'; // ... ClassicEditor.builtinPlugins = [ // ... // TableToolbar, // ... add plugin to build in list CodeBlock ]; // ... ClassicEditor.defaultConfig = { // ... provide default configuration codeblock: { languages: [ 'cpp', 'cs', 'lua', 'xml', 'js', 'php' ] }, // ... add new button for toolbar toolbar: { items: [ // ... // 'mediaEmbed', 'codeblock', // ... ] }, // ... };
In a result you should have code-block feature that will render next structure:
<pre class="line-numbers"><code class="lang-cpp">#include <codeblock>
using everywhere;
</code></pre>
NOTE: In editor code block will be not highlighted. You have apply PrismJS in your applications where you render results from editor (news page, blog post, etc.).
- Write tests
- Create documentations
- Cleanup the code
- customize classes for
<pre>
tag - customize languages list and translations
- npm package