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.
43.1.0 (September 5, 2024)
We are happy to announce the release of CKEditor 5 v43.1.0.
Release highlights
This release includes important bug fixes and enhancements for the editor:
-
Block merge fields: In contrast to regular, inline merge fields, the block merge fields are designed to represent complex, block-level structures, such as a dynamically generated table, a row of products, or a personalized call-to-action segment. Block merge fields are supposed to be replaced by arbitrary HTML data when the document template is post-processed or exported to a PDF or Word file.
-
Nested dropdown menus: this release introduces a new UI component: nested dropdown menus. They can be used by feature developers to easily provide an advanced user interface where UI elements are organized into a nested menu structure.
-
Customizable accessible label: You can now configure the label for the accessible editable area through the editor settings, ensuring it fits your system’s needs.
-
Improved table and cell border controls: It is now easier to manage both table and cell borders. The table user interface now clearly indicates the default border settings, allowing you to set “no borders” (None
) for tables and cells without any additional configuration.
⚠️ In some cases this update may lead to data changes in the tables’ HTML markup when the editor loads them. However, visually nothing will change, and the experience will be the same.
The full list of enhancements can be found below.