1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-03 04:02:33 +02:00

rename plugin.render to renderPortal, and add plugin.render

This commit is contained in:
Ian Storm Taylor
2017-03-02 18:19:39 -08:00
parent fa4f9dff6c
commit 2a5d3ee556
6 changed files with 119 additions and 77 deletions

View File

@@ -43,6 +43,10 @@ When the user pastes content into the editor, the core plugin handles all pastes
When the user makes a new selection in the DOM, the core plugin updates that selection in Slate's internal data model, re-rendering if it needs to.
### `render`
Renders all of the default contents of the editor!
### `schema`
The core plugin defines a schema that enforces a few constraints on the content and defines default block and inline node renderer components—wrapping in a `<div>` and `<span>`, respectively. Each of these components contains `shouldComponentUpdate` logic that prevents unnecessary re-renders.

View File

@@ -20,6 +20,8 @@ When the editor needs to resolve a plugin-related handler, it will loop through
- [Other Properties](#other-properties)
- [`onChange`](#onchange)
- [`onBeforeChange`](#onbeforechange)
- [`render`](#render)
- [`renderPortal`](#renderportal)
- [`schema`](#schema)
@@ -181,7 +183,7 @@ The `data` object is a convenience object created to standardize the paste metad
If no other plugin handles this event, it will be handled by the [Core plugin](./core.md).
### `onSelect`
`Function onSelect(event: Event, data: Object, state: State, editor: Editor => State || Void`
`Function onSelect(event: Event, data: Object, state: State, editor: Editor) => State || Void`
This handler is called whenever the native DOM selection changes.
@@ -216,6 +218,16 @@ The `onBeforeChange` handler isn't a native browser event handler. Instead, it i
Like `onChange`, `onBeforeChange` is cummulative.
### `render`
`Function render(props: Object, state: State, editor: Editor) => Object || Void`
The `render` property allows you to define higher-order-component-like behavior. It is passed all of the properties of the editor, including `props.children`. You can then choose to wrap the existing `children` in any custom elements or proxy the properties however you choose. This can be useful for rendering toolbars, styling the editor, rendering validation, etc.
### `renderPortal`
`Function renderPortal(state: State, editor: Editor) => Object || Void`
The `renderPortal` property allows you to define extra elements that will render outside of the editor, in a separate [portal](). This is useful for rendering hovering menus, or other cases where you don't need to render inside the editor, but want to add elements to the DOM.
### `schema`
`Object`