Update README

This commit is contained in:
Dominic Gannaway
2021-06-28 22:39:24 +01:00
committed by acywatson
parent 56aa676ddc
commit dbe55a5231

View File

@ -31,14 +31,9 @@ function Editor() {
throw error; throw error;
}, []) }, [])
// Some placeholder text to be used when the editor
// field is empty.
const placeholderText = 'Enter some plain text...';
// Create an Outline editor instance and also a ref // Create an Outline editor instance and also a ref
// that we need to pass to our content editable. // that we need to pass to our content editable.
const [editor, contentEditableRef] = useOutlineEditor( const [editor, contentEditableRef, showPlaceholder] = useOutlineEditor(
placeholderText,
onError, onError,
); );
@ -47,21 +42,26 @@ function Editor() {
// Our <div> content editable element with some basic styling. // Our <div> content editable element with some basic styling.
return ( return (
<div <div>
{...eventHandlers} <div
ref={contentEditableRef} {...eventHandlers}
contentEditable={true} ref={contentEditableRef}
role="textbox" contentEditable={true}
spellCheck={true} role="textbox"
style={{ spellCheck={true}
outline: 0, style={{
overflowWrap: 'break-word', outline: 0,
padding: '10px', overflowWrap: 'break-word',
userSelect: 'text', padding: '10px',
whiteSpace: 'pre-wrap', userSelect: 'text',
}} whiteSpace: 'pre-wrap',
tabIndex={0} }}
/> tabIndex={0}
/>
{showPlaceholder && (
<div className="placeholder">Enter some plain text...</div>
)}
</div>
); );
} }
``` ```