1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 14:41:23 +02:00

Custom wrapper component (#978)

* Provide prop to pass in custom wrapper component

* Fix linting

* Fix lint

* PR Feedback - change propName container -> tagName; remove custom-wrapper example

* Reset examples/index.js
This commit is contained in:
Craig
2017-08-16 09:53:28 -07:00
committed by Ian Storm Taylor
parent 31aa33b4d3
commit 8469c64d9e
2 changed files with 9 additions and 5 deletions

View File

@@ -62,7 +62,8 @@ class Content extends React.Component {
spellCheck: Types.bool.isRequired,
state: Types.object.isRequired,
style: Types.object,
tabIndex: Types.number
tabIndex: Types.number,
tagName: Types.string
}
/**
@@ -72,7 +73,8 @@ class Content extends React.Component {
*/
static defaultProps = {
style: {}
style: {},
tagName: 'div'
}
/**
@@ -826,7 +828,8 @@ class Content extends React.Component {
render() {
const { props } = this
const { className, readOnly, state, tabIndex, role } = props
const { className, readOnly, state, tabIndex, role, tagName } = props
const Container = tagName
const { document } = state
const children = document.nodes
.map(node => this.renderNode(node))
@@ -855,7 +858,7 @@ class Content extends React.Component {
debug('render', { props })
return (
<div
<Container
data-slate-editor
key={this.tmp.forces}
ref={this.ref}
@@ -891,7 +894,7 @@ class Content extends React.Component {
>
{children}
{this.props.children}
</div>
</Container>
)
}

View File

@@ -962,6 +962,7 @@ function Plugin(options = {}) {
state={state}
style={props.style}
tabIndex={props.tabIndex}
tagName={props.tagName}
/>
)
}