style(BlockEditor): improve block spacing and placeholder visibility behavior
- increase block vertical padding from py-0.5 to py-1.5 for better readability - increase editor container vertical padding from py-3 to py-6 - show placeholder text only on hover or focus instead of always visible
This commit is contained in:
@@ -196,7 +196,7 @@ const Block = forwardRef(function Block(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="relative group flex items-start gap-1 px-1 py-0.5"
|
className="relative group flex items-start gap-1 px-1 py-1.5"
|
||||||
onMouseEnter={() => setHovered(true)}
|
onMouseEnter={() => setHovered(true)}
|
||||||
onMouseLeave={() => setHovered(false)}
|
onMouseLeave={() => setHovered(false)}
|
||||||
draggable={draggable}
|
draggable={draggable}
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ export default function BlockEditor({
|
|||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
onKeyDown={handleGlobalKeyDown}
|
onKeyDown={handleGlobalKeyDown}
|
||||||
className={`block-editor border rounded-xl bg-white dark:bg-neutral-900/60 px-3 py-3 ${error ? 'border-red-500/50' : 'border-neutral-300 dark:border-neutral-700/50'} ${className}`}
|
className={`block-editor border rounded-xl bg-white dark:bg-neutral-900/60 px-3 py-6 ${error ? 'border-red-500/50' : 'border-neutral-300 dark:border-neutral-700/50'} ${className}`}
|
||||||
>
|
>
|
||||||
<BlockEditorStyles />
|
<BlockEditorStyles />
|
||||||
{placeholder && blocks.length === 1 && !blocks[0].content && (
|
{placeholder && blocks.length === 1 && !blocks[0].content && (
|
||||||
@@ -516,10 +516,14 @@ function BlockEditorStyles() {
|
|||||||
return (
|
return (
|
||||||
<style>{`
|
<style>{`
|
||||||
.block-editor [contenteditable][data-placeholder]:empty::before {
|
.block-editor [contenteditable][data-placeholder]:empty::before {
|
||||||
content: attr(data-placeholder);
|
content: '';
|
||||||
color: rgb(163 163 163);
|
color: rgb(163 163 163);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
.block-editor .group:hover [contenteditable][data-placeholder]:empty::before,
|
||||||
|
.block-editor [contenteditable][data-placeholder]:empty:focus::before {
|
||||||
|
content: attr(data-placeholder);
|
||||||
|
}
|
||||||
.dark .block-editor [contenteditable][data-placeholder]:empty::before {
|
.dark .block-editor [contenteditable][data-placeholder]:empty::before {
|
||||||
color: rgb(82 82 82);
|
color: rgb(82 82 82);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user