Can I change the tag name of a StarterKit paragraph? #5238
Answered
by
ryuhangyeong
ryuhangyeong
asked this question in
Questions & Help
-
const editor = useEditor?.({
extensions: [
StarterKit.configure?.({
paragraph: {
HTMLAttributes: {
tagName: "div", // ??
},
},
}),
],
content: editTipTapDataTextContent || "",
}); In my requirement I need to use div tag instead of p tag. Is there a way to translate it? |
Beta Was this translation helpful? Give feedback.
Answered by
ryuhangyeong
Jun 16, 2024
Replies: 1 comment
-
Self Answerimport Paragraph from "@tiptap/extension-paragraph";
import { mergeAttributes } from "@tiptap/core";
const editor = useEditor?.({
extensions: [
StarterKit.configure?.({}),
Paragraph.extend({
parseHTML() {
return [{ tag: "div" }];
},
renderHTML({ HTMLAttributes }) {
return [
"div",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
0,
];
},
}),
],
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ryuhangyeong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Self Answer
#291