Skip to content

Can I change the tag name of a StarterKit paragraph? #5238

Discussion options

You must be logged in to vote

Self Answer

#291

import 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,
        ];
      },
    }),
  ],
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ryuhangyeong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant