Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 5782 #5783

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
18 changes: 13 additions & 5 deletions docs/libraries/slate-react/editable.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,22 @@ An example usage might look like:

```jsx
<Editable
renderPlaceholder={({ attributes, children }) => (
<div {...attributes} style={{ fontStyle: 'italic', color: 'gray' }}>
{children}
</div>
)}
placeholder="Enter text here..."
renderPlaceholder={({ attributes, children }) => {
const styledAttributes = {
...attributes,
style: {
...attributes.style,
color: 'gray',
},
};
return <div {...styledAttributes}>{children}</div>;
}}
/>
```

Note that the `attributes` prop that comes in will contain a `style` object already. This object contains important styling properties which will make the placeholder behave like a placeholder. As such, it is advisible to extend styles and to focus on things like changing colors, opacity etc. Changing positioning, for example, could cause undesirable behavior.

#### `scrollSelectionIntoView?: (editor: ReactEditor, domRange: DOMRange) => void`

Slate has its own default method to scroll a DOM selection into view that works for most cases; however, if the default behavior isn't working for you, possible due to some complex styling, you may need to override the default behavior by providing a different function here.
Expand Down
Loading