mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
43 lines
No EOL
779 B
TypeScript
43 lines
No EOL
779 B
TypeScript
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
import { mergeAttributes, Node } from "@tiptap/core";
|
|
import ButtonsExtension from "./ButtonsExtension";
|
|
|
|
export default Node.create({
|
|
name: "button",
|
|
group: "block",
|
|
draggable: true,
|
|
content: "text*",
|
|
|
|
addAttributes() {
|
|
return {
|
|
emoji: {
|
|
default: '🔗',
|
|
},
|
|
link: {
|
|
default: '',
|
|
},
|
|
color: {
|
|
default: 'blue',
|
|
},
|
|
alignment: {
|
|
default: 'left',
|
|
},
|
|
};
|
|
},
|
|
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: "button-block",
|
|
},
|
|
];
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ["button-block", mergeAttributes(HTMLAttributes), 0];
|
|
},
|
|
|
|
addNodeView() {
|
|
return ReactNodeViewRenderer(ButtonsExtension);
|
|
},
|
|
}); |