32 lines
783 B
TypeScript
32 lines
783 B
TypeScript
import { Node, mergeAttributes } from "@tiptap/core";
|
|
|
|
export const Div = Node.create({
|
|
name: "divBlock",
|
|
group: "block",
|
|
content: "block+",
|
|
defining: true,
|
|
|
|
addAttributes() {
|
|
return {
|
|
class: {
|
|
default: null as string | null,
|
|
parseHTML: (el) => (el as HTMLElement).getAttribute("class"),
|
|
renderHTML: (attrs) => (attrs.class ? { class: attrs.class } : {}),
|
|
},
|
|
style: {
|
|
default: null as string | null,
|
|
parseHTML: (el) => (el as HTMLElement).getAttribute("style"),
|
|
renderHTML: (attrs) => (attrs.style ? { style: attrs.style } : {}),
|
|
},
|
|
};
|
|
},
|
|
|
|
parseHTML() {
|
|
return [{ tag: "div" }];
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ["div", mergeAttributes(HTMLAttributes), 0];
|
|
},
|
|
});
|