What is @ckeditor/ckeditor5-code-block?
@ckeditor/ckeditor5-code-block is a plugin for CKEditor 5 that allows users to insert and manage code blocks within the editor. It provides syntax highlighting and formatting for various programming languages, making it easier to include and display code snippets in content.
What are @ckeditor/ckeditor5-code-block's main functionalities?
Inserting Code Blocks
This feature allows users to insert code blocks into the editor. The code sample demonstrates how to configure CKEditor 5 to include the CodeBlock plugin and add a button to the toolbar for inserting code blocks.
ClassicEditor.create(document.querySelector('#editor'), { plugins: [CodeBlock], toolbar: ['codeBlock'] })
Syntax Highlighting
This feature provides syntax highlighting for different programming languages. The code sample shows how to configure the CodeBlock plugin to support JavaScript and Python syntax highlighting.
ClassicEditor.create(document.querySelector('#editor'), { plugins: [CodeBlock], codeBlock: { languages: [ { language: 'javascript', label: 'JavaScript' }, { language: 'python', label: 'Python' } ] } })
Customizing Code Block Styles
This feature allows users to customize the styles of code blocks. The code sample demonstrates how to configure the CodeBlock plugin to apply custom CSS classes to code blocks.
ClassicEditor.create(document.querySelector('#editor'), { plugins: [CodeBlock], codeBlock: { styles: [ { element: 'pre', classes: ['custom-code-block'] } ] } })
Other packages similar to @ckeditor/ckeditor5-code-block
prismjs
Prism is a lightweight, extensible syntax highlighter. It is a standalone library that can be integrated into various editors and applications. Unlike @ckeditor/ckeditor5-code-block, which is specifically designed for CKEditor 5, Prism can be used with any text editor or web application.
highlight.js
Highlight.js is a popular syntax highlighter that works in the browser as well as on the server. It automatically detects the language of the code block and applies appropriate syntax highlighting. While @ckeditor/ckeditor5-code-block is tailored for CKEditor 5, Highlight.js can be used independently or integrated into different editors.
ace-builds
Ace is a standalone code editor written in JavaScript. It provides syntax highlighting, code folding, and other features for editing code. Unlike @ckeditor/ckeditor5-code-block, which is a plugin for CKEditor 5, Ace is a full-fledged code editor that can be embedded in web applications.
44.2.0 (February 12, 2025)
We are happy to announce the release of CKEditor 5 v44.2.0.
Release Highlights
🖥️ Enhanced Source Code Editing (⭐)
Introducing new premium feature: Enhanced Source Code Editing. It displays the source code in a dialog and is compatible with all editor types. It offers syntax highlighting, code completion, code folding, and other advanced functionalities. Additionally, it supports both HTML and Markdown formats.
📤 Uploadcare and image optimizer (⭐)
We have integrated the Uploadcare image manager service, enabling you to upload and edit images to their cloud environment. You can upload files from various sources, including local devices, social media, or online drives ensuring rapid uploads. The integration takes care of efficient media delivery with responsive images mechanism, making sure your users will save bandwidth and have faster website loading. You can also optimize images with the built-in image editor which offers a range of features, such as cropping, rotating, flipping, photo filters and more. All this directly from the editor, try it out!
🖼️ Image Merge Fields (⭐)
Image merge fields are a new type of merge fields, dedicated for image placeholders. They maintain all standard image interactions, like styling, resizing or captions (in which you can use merge fields too!) At the same time, they keep all merge fields functionalities, like data previews or document export integration. In the document data, image merge fields are represented like other images, however their src
attribute is set to a respective merge field, for example, src="{{CompanyLogo}}"
, making them easy to post-process!
📝 Track Changes Preview (⭐)
We have added the preview mode that displays a document with all suggestions accepted. Accessible from the track changes dropdown, this modal preview helps check the final content without extensive markers.
😀 Emoji support
They are here! 🎉 🥳 🎊 Insert emojis effortlessly in the editor by typing :
or through a user-friendly emoji picker. This feature enhances the richness of your content by allowing quick access to a wide range of emojis.
⚡ Performance improvements: Part 4
Here comes the final batch of the planned performance improvements in the editor loading speed area, that we worked on through a couple of past releases.
- A new caching mechanism in
Mapper
now handles model-to-view mappings, substantially improving performance for loading and saving data. - Images with specified height and width automatically use
[loading="lazy"]
in the editing area, optimizing the loading time (read more on MDN). This attribute is only applied during editing to enhance the loading efficiency of images, and it does not reflect in the final data output.
We are greatly satisfied with the improved editor loading times. At the same time, we acknowledge some other problematic areas, and we will keep delivering more performance-related improvements in the future.