},
]);
-export const EditorPlaceholder = style([
+export const EditorPlaceholderContainer = style([
DefaultReset,
{
- position: 'absolute',
- zIndex: 1,
- width: '100%',
opacity: config.opacity.Placeholder,
pointerEvents: 'none',
userSelect: 'none',
+ },
+]);
- selectors: {
- '&:not(:first-child)': {
- display: 'none',
- },
- },
+export const EditorPlaceholderTextVisual = style([
+ DefaultReset,
+ {
+ display: 'block',
+ paddingTop: toRem(13),
+ paddingLeft: toRem(1),
},
]);
[editor, onKeyDown]
);
- const renderPlaceholder = useCallback(({ attributes, children }: RenderPlaceholderProps) => {
- // drop style attribute as we use our custom placeholder css.
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { style, ...props } = attributes;
- return (
- <Text
- as="span"
- {...props}
- className={css.EditorPlaceholder}
- contentEditable={false}
- truncate
- >
- {children}
- </Text>
- );
- }, []);
+ const renderPlaceholder = useCallback(
+ ({ attributes, children }: RenderPlaceholderProps) => (
+ <span {...attributes} className={css.EditorPlaceholderContainer}>
+ {/* Inner component to style the actual text position and appearance */}
+ <Text as="span" className={css.EditorPlaceholderTextVisual} truncate>
+ {children}
+ </Text>
+ </span>
+ ),
+ []
+ );
return (
<div className={css.Editor} ref={ref}>