Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/core/editor/src/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Props = {
const getEditorStyles = (styles: CSSProperties) => ({
...styles,
width: styles.width || 400,
paddingBottom: typeof styles.paddingBottom === 'number' ? styles.paddingBottom : 100,
paddingBottom: styles.paddingBottom ?? 100,
});

const Editor = ({
Expand Down Expand Up @@ -59,6 +59,13 @@ const Editor = ({
return () => document.removeEventListener('keydown', onKeyDown);
}, [editor.path, isReadOnly]);

useEffect(() => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's good idea to manage the editor value inside the core package.
I think the manipulation of the value should be completely on the user's side

@gloaysa gloaysa Apr 21, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point and makes sense. On the other hand, the user might not be aware of the tooling needed to build an empty block and just expect that when the editor is empty, it will display the placeholder (currently it only displays a blank space).

My current solution is also flawed, now that I think about it, since buildBlockData uses a Paragraph, and maybe the current editor doesn't have the Paragraph plugin installed.

Maybe add documentation explaining this is the expected behaviour and how to solve it? (is the reason behind #494 )

if (isReadOnly || Object.keys(editor.children).length) return;
// when editor is empty, add default empty block to display placeholder
const defaultBlock = buildBlockData({ id: generateId() });
editor.insertBlock(defaultBlock.type, { at: 0, focus: false });
}, []);

const handleEmptyZoneClick = (e: React.MouseEvent) => {
const editorEl = editor.refElement;
if (!editorEl) return;
Expand Down