You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
InlineContent in custom block has strange overflow control.
To Reproduce
create custom block(which has InlineContent)
Type in InlineContent without spacing(i.e. long single string)
Block overflow expands out of editor
Misc
Node version: v20.6.0
Package manager: pnpm
Browser: Chrome Version 117.0.5938.149 (Official Build) (arm64)
Side issue:
I am building a block with 2 editable rich-text fields. However, I cant have 2 InlineContent working in one block. So one of them is built-in InlineContent, another is ContentEditable from 'react-contenteditable'. When onClick of the custom block, it always focus on InlineContent but not ContentEditable. Is it possible to focus on other parts of the block(i.e.ContentEditable)? Also, is it possible that other parts of the block trigger onEditorContentChange so that its content can be saved in topLevelBlocks?
Sorry if there are too many issues in one report. Really appreciate the work of BlockNote nevertheless! It will certainly be a huge improvement if I can built my ideal BlockNote.
};
// Creates a new editor instance.
const editor: BlockNoteEditor = useBlockNote({
// Listens for when the editor's contents change.
blockSchema: customSchema,
slashMenuItems: [
...getDefaultReactSlashMenuItems(customSchema),
addPinBlock,
],
onEditorContentChange: (editor) =>
// Converts the editor's contents to an array of Block objects.
setBlocks(editor.topLevelBlocks),
});
Thanks for documenting this issue! Regarding having 2 editable fields in one block - that's currently a limitation of the custom blocks API, they're really designed to only have 1 InlineContent element. You can get around the focus issue in a somewhat hacky way with a focus event handler on your InlineContent component, and trigger onEditorContentChange by storing the text of the second input field as one of the block's props (this will also ensure that the second input field's content doesn't get reset). Keep in mind that while this should work, the functionality isn't officially supported so you may run into a few issues.
Describe the bug

InlineContent in custom block has strange overflow control.
To Reproduce
Misc
Side issue:
I am building a block with 2 editable rich-text fields. However, I cant have 2 InlineContent working in one block. So one of them is built-in InlineContent, another is ContentEditable from 'react-contenteditable'. When onClick of the custom block, it always focus on InlineContent but not ContentEditable. Is it possible to focus on other parts of the block(i.e.ContentEditable)? Also, is it possible that other parts of the block trigger onEditorContentChange so that its content can be saved in topLevelBlocks?
Sorry if there are too many issues in one report. Really appreciate the work of BlockNote nevertheless! It will certainly be a huge improvement if I can built my ideal BlockNote.
Source code if needed:
`
//imports same as custom block in https://www.blocknotejs.org/docs/block-types
//...
const [blocks, setBlocks] = useState<Block[] | null>(null);
const titleRef = useRef(null);
const contentRef = useRef(null);
const blocknotePinBlock = createReactBlockSpec({
type: 'pin',
propSchema: {
...defaultProps,
title: {
default: 'Pin-',
},
context: {
default: '',
},
colorTag: {
default: '#ff0000',
},
collapsed: {
default: false,
},
},
containsInlineContent: true,
});
const customSchema = {
// Adds all default blocks.
...defaultBlockSchema,
// Adds the custom pin block.
pin: blocknotePinBlock,
} satisfies BlockSchema;
const addPinBlock: ReactSlashMenuItem = {
name: 'Insert Pin Block',
execute: (editor) => {
const title: string | null = 'Pin-' + pinNumber.current;
const context: string | null = '';
};
// Creates a new editor instance.
const editor: BlockNoteEditor = useBlockNote({
// Listens for when the editor's contents change.
blockSchema: customSchema,
slashMenuItems: [
...getDefaultReactSlashMenuItems(customSchema),
addPinBlock,
],
onEditorContentChange: (editor) =>
// Converts the editor's contents to an array of Block objects.
setBlocks(editor.topLevelBlocks),
});
return (
console.log(JSON.stringify(blocks, null, 2)),
(
<BlockNoteView editor={editor} theme={'light'} />
)
);
}`
The text was updated successfully, but these errors were encountered: