-
-
Notifications
You must be signed in to change notification settings - Fork 640
Description
copy and paste issue on custom block note
We are using BlockNote in our React application and have created a custom "callout" block in the editor. While the block renders and functions correctly initially, we encounter a problem when copying and pasting it.
After pasting, the editor renders the wrapper and its text content separately. Additionally, when we attempt to edit the pasted content, the text unexpectedly moves back into the parent frame!
We reproduced this behavior using your official example for custom blocks:
https://stackblitz.com/github/TypeCellOS/BlockNote/tree/main/examples/06-custom-schema/01-alert-block?file=src%2FApp.tsx
The issue persists across both version 0.33.0 and 0.35.0.
Would you kindly review this and let us know if it's a bug or if there's a workaround?
import {
insertOrUpdateBlock,
BlockNoteEditor,
BlockSchema,
defaultProps,
} from "@blocknote/core";
import { createReactBlockSpec } from "@blocknote/react";
import { LightbulbIcon } from "lucide-react";
export const CalloutBlockSpec = createReactBlockSpec(
{
type: "callout",
propSchema: {
textAlignment: defaultProps.textAlignment,
textColor: defaultProps.textColor,
backgroundColor: defaultProps.backgroundColor,
},
content: "inline",
},
{
render: ({ block, contentRef }) => {
return (
<div
className="bg-gray-50 border-[1px] min-h-[68px] border-e123 rounded-[8px] flex items-center gap-3 px-4"
data-block-id={block.id}
data-node-type="callout"
>
<LightbulbIcon
className="h-5 w-5 flex-shrink-0 text-gray-500"
aria-hidden="true"
/>
<p
className="text-sm font-normal text-gray-600 inline-content"
ref={contentRef}
/>
</div>
);
},
},
);
export default function customCalloutBlock<BSchema extends BlockSchema>(
editor: BlockNoteEditor<BSchema>,
) {
return {
title: "Callout",
onItemClick: () => {
insertOrUpdateBlock(editor, {
type: "callout",
props: {
textAlignment: "left",
textColor: "gray-600",
} as any,
});
},
aliases: ["callout"],
group: "Section 1",
key: "bi_callout",
icon: <LightbulbIcon size={18} />,
};
}
- Node version: {
"@blocknote/core": "^0.33.0",
"@blocknote/mantine": "^0.33.0",
"@blocknote/react": "^0.33.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
} - Package manager: pnpm
- Browser: all
I would appreciate if you could look into this sooner than later π