Spaces:
Sleeping
Sleeping
File size: 1,661 Bytes
7b0525c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 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: '_',
});
|