Spaces:
Sleeping
Sleeping
Download components/extensions/CustomCodeBlock.ts from codebybrody/codebydante: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/spaces/codebybrody/codebydante/resolve/c0f0601edf43a8487f75ea12fdec93d8aa366128/components/extensions/CustomCodeBlock.ts
- Command line
-
hf download hf://spaces/codebybrody/codebydante@c0f0601edf43a8487f75ea12fdec93d8aa366128/components/extensions/CustomCodeBlock.ts
-
curl -L -o CustomCodeBlock.ts https://huggingface.co/spaces/codebybrody/codebydante/resolve/c0f0601edf43a8487f75ea12fdec93d8aa366128/components/extensions/CustomCodeBlock.ts
1.66 kB
| import { CodeBlock } from '@tiptap/extension-code-block'; | |
| import { ReactNodeViewRenderer } from '@tiptap/react'; | |
| import { CodeBlockComponent } from '../CodeBlockComponent'; | |
| export const CustomCodeBlock = CodeBlock.extend({ | |
| addNodeView() { | |
| return ReactNodeViewRenderer(CodeBlockComponent); | |
| }, | |
| addAttributes() { | |
| return { | |
| language: { | |
| default: null, | |
| }, | |
| filename: { | |
| default: null, | |
| }, | |
| collapsible: { | |
| default: true, | |
| parseHTML: (element) => element.getAttribute('data-collapsible') !== 'false', | |
| renderHTML: (attributes) => { | |
| return { | |
| 'data-collapsible': attributes.collapsible, | |
| }; | |
| }, | |
| }, | |
| showLineNumbers: { | |
| default: false, | |
| parseHTML: (element) => element.getAttribute('data-show-line-numbers') === 'true', | |
| renderHTML: (attributes) => { | |
| return { | |
| 'data-show-line-numbers': attributes.showLineNumbers, | |
| }; | |
| }, | |
| }, | |
| wrapText: { | |
| default: false, | |
| parseHTML: (element) => element.getAttribute('data-wrap-text') === 'true', | |
| renderHTML: (attributes) => { | |
| return { | |
| 'data-wrap-text': attributes.wrapText, | |
| }; | |
| }, | |
| } | |
| }; | |
| }, | |
| content: 'text*', | |
| marks: '_', | |
| }); | |