-
-
Notifications
You must be signed in to change notification settings - Fork 637
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When parsing HTML using tryParseHTMLToBlocks, attributes such as data-background-color and data-text-color are not preserved. Instead, they are replaced with the value "default". This makes it impossible to retain custom attributes for blocks when working with stored HTML content.
To Reproduce
import { useEffect } from 'react';
import '@blocknote/core/fonts/inter.css';
import { BlockNoteView } from '@blocknote/mantine';
import '@blocknote/mantine/style.css';
import { useCreateBlockNote } from '@blocknote/react';
export default function App() {
const editor = useCreateBlockNote();
const initialHtml = `<h1 data-background-color="brown" data-level="1">Brown Header</h1>`;
useEffect(() => {
async function loadInitialHTML() {
const blocks = await editor.tryParseHTMLToBlocks(initialHtml);
editor.replaceBlocks(editor.document, blocks);
}
loadInitialHTML();
}, [editor]);
// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
}
Misc
- Node version: v20.12.2
- Package manager: yarn
- Browser: Google Chrome
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
