-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[example-studio] Add example on how to wrap and customize the block e…
…ditor
- Loading branch information
1 parent
2917354
commit 6ed66b4
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/example-studio/components/FunkyEditor/FunkyEditor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import SlateEditor from '@sanity/form-builder/lib/inputs/BlockEditor-slate' | ||
export default class FunkyEditor extends React.Component { | ||
static propTypes = { | ||
type: PropTypes.shape({ | ||
title: PropTypes.string | ||
}).isRequired, | ||
level: PropTypes.number, | ||
value: PropTypes.array, | ||
onChange: PropTypes.func.isRequired | ||
}; | ||
|
||
handleChange = event => { | ||
this.props.onChange(event) | ||
} | ||
|
||
render() { | ||
const {type, value, level} = this.props | ||
return ( | ||
<div> | ||
<h3>Take me to Funky Town</h3> | ||
<SlateEditor | ||
type={type} | ||
level={level} | ||
value={value === undefined ? '' : value} | ||
onChange={this.handleChange} | ||
/> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default} from './FunkyEditor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters