mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add badges to editor
This commit is contained in:
parent
cc68ea2e94
commit
8965ee67c3
7 changed files with 308 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
import { ReactNodeViewRenderer } from "@tiptap/react";
|
||||
import { mergeAttributes, Node } from "@tiptap/core";
|
||||
import BadgesExtension from "@/components/Objects/Editor/Extensions/Badges/BadgesExtension";
|
||||
|
||||
export default Node.create({
|
||||
name: "badge",
|
||||
group: "block",
|
||||
draggable: true,
|
||||
content: "text*",
|
||||
|
||||
// TODO : multi line support
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
color: {
|
||||
default: 'sky',
|
||||
},
|
||||
emoji: {
|
||||
default: '💡',
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{
|
||||
tag: "badge",
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ["badge", mergeAttributes(HTMLAttributes), 0];
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
return ReactNodeViewRenderer(BadgesExtension);
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue