I'm new to Tiptap editor, is using regex pattern to extract title and content to store in table recommended in Tiptap editor? Or is there a more recommended approach

const cleanContent = (content: string) => { // Clean string from empty paragraphs and leading/ending spaces return content.replace(/

</p>/g, ‘’).trim(); };

const editor = useEditor({ onUpdate({ editor }) {

  const getHtml = editor.getHTML();

  const cleanedContent = cleanContent(getHtml);

  // extract title and content
  const title = getHtml.match(/<h1>(.*?)<\/h1>/)?.[1] || '';
  const content = cleanedContent.replace(/<h1>.*?<\/h1>/, '').trim();

  if (title !== draftTitle) {
    onTitleChange(title);
  }

  if (content !== draftContent) {
    onContentChange(content);
  }
},

});