Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hebmor/tiptap-extension-code-block-prism

An extension for TipTap editor that adds syntax highlighting support from Prism.js .
https://github.com/hebmor/tiptap-extension-code-block-prism

jsx mdx syntax-highlighting tiptap

Last synced: 26 days ago
JSON representation

An extension for TipTap editor that adds syntax highlighting support from Prism.js .

Awesome Lists containing this project

README

        

# :bookmark:CodeBlockPrism extension for TIPTAP Editor
This extension is based on [CodeBlockLowlight](https://tiptap.dev/api/nodes/code-block-lowlight). Most of the code in this repository is taken from there.
## :cat: What for? Why not CodeBlockLowlight?

Unfortunately CodeBlockLowlight is based on [LowLight](https://github.com/wooorm/lowlight) and [Highlight.js](https://github.com/highlightjs/highlight.js/),
Highlight.js supports many languages ​​but doesn't support many useful syntax. For example: **JSX, TSX, MDX.**

The list of supported Prism.js languages ​​can be found here: https://prismjs.com/#supported-languages
## ✍️ How to use it?
```js
const editor = useEditor({
extensions: [
Document,
Paragraph,
Text,
CodeBlock,
CodeBlockPrism.configure({
defaultLanguage: 'jsx',
}),
],
content: ``,
});
```
## :hammer_and_wrench: How to style classes generated by PrismJS?
You can define styles via CSS. There are already ready-made themes, for example: [OneDark](https://github.com/AGMStudio/prism-theme-one-dark/blob/master/prism-onedark.css)