Code Blocks in TypeScript Block Editor control
18 Nov 20181 minute to read
The Syncfusion Block Editor allows you to render code snippets with syntax highlighting by setting the block’s blockType property to Code. You can customize the available programming languages and set a default language using the properties property.
Global Code Settings
You can configure global settings for code blocks using the codeBlockSettings property in the Block Editor root configuration. This ensures consistent behavior for syntax highlighting and language options across all code blocks.
The codeBlockSettings property supports the following options:
| Property | Description | Default Value |
|---|---|---|
| languages | Specifies the array of language options for syntax highlighting. | [] |
| defaultLanguage | Defines the default language to use for syntax highlighting. | ‘plaintext’ |
Configure code properties
For Code blocks, you can specify the language for syntax highlighting using the properties property. This property supports the following options:
- language: The default language value used for syntax highlighting.
Block type & properties
// Adding Code block
{
blockType: 'Code',
content: [
{
const x = 10;
}
],
properties: {
language: 'javascript'
}
}The following example demonstrates how to configure and render a Code block within the Block Editor.