feat: adds more prismjs syntax highlighting options for code blocks (#961)
This commit is contained in:
@@ -39,7 +39,19 @@ This field uses `prismjs` for syntax highlighting and `react-simple-code-editor`
|
||||
|
||||
In addition to the default [field admin config](/docs/fields/overview#admin-config), the Code field type also allows for the customization of a `language` property.
|
||||
|
||||
Currently, the `language` property only supports JavaScript syntax but more support will be added as requested.
|
||||
The following `prismjs` plugins are imported, enabling the `language` property to accept the following values:
|
||||
|
||||
| Plugin | Language |
|
||||
| ---------------------------- | ----------- |
|
||||
| **`prism-css`** | `css` |
|
||||
| **`prism-clike`** | `clike` |
|
||||
| **`prism-markup`** | `markup`, `html`, `xml`, `svg`, `mathml`, `ssml`, `atom`, `rss` |
|
||||
| **`prism-javascript`** | `javascript`, `js` |
|
||||
| **`prism-json`** | `json` |
|
||||
| **`prism-jsx`** | `jsx` |
|
||||
| **`prism-typescript`** | `typescript`, `ts` |
|
||||
| **`prism-tsx`** | `tsx` |
|
||||
| **`prism-yaml`** | `yaml`, `yml` |
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -2,7 +2,14 @@ import React, { useCallback, useState } from 'react';
|
||||
import Editor from 'react-simple-code-editor';
|
||||
import { highlight, languages } from 'prismjs/components/prism-core';
|
||||
import 'prismjs/components/prism-clike';
|
||||
import 'prismjs/components/prism-css';
|
||||
import 'prismjs/components/prism-markup';
|
||||
import 'prismjs/components/prism-javascript';
|
||||
import 'prismjs/components/prism-json';
|
||||
import 'prismjs/components/prism-jsx';
|
||||
import 'prismjs/components/prism-typescript';
|
||||
import 'prismjs/components/prism-tsx';
|
||||
import 'prismjs/components/prism-yaml';
|
||||
import useField from '../../useField';
|
||||
import withCondition from '../../withCondition';
|
||||
import Label from '../../Label';
|
||||
|
||||
Reference in New Issue
Block a user