1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-09 08:46:35 +02:00

fix renderers in core plugin

This commit is contained in:
Ian Storm Taylor
2016-07-06 14:48:40 -07:00
parent de4afd38b1
commit 14e02b1c67

View File

@@ -4,6 +4,28 @@ import keycode from 'keycode'
import { isCommand, isCtrl, isWindowsCommand, isWord } from '../utils/event' import { isCommand, isCtrl, isWindowsCommand, isWord } from '../utils/event'
import { IS_WINDOWS, IS_MAC } from '../utils/environment' import { IS_WINDOWS, IS_MAC } from '../utils/environment'
/**
* Default block renderer.
*/
const DEFAULT_BLOCK = props => <div>{props.children}</div>
/**
* Default inline renderer.
*
* @type {Component}
*/
const DEFAULT_INLINE = props => <span>{props.children}</span>
/**
* Default mark renderer.
*
* @type {Object}
*/
const DEFAULT_MARK = {}
/** /**
* Export. * Export.
*/ */
@@ -121,7 +143,7 @@ export default {
}, },
/** /**
* The core `onPaste` handler. * The core `onPaste` handler, which treats everything as plain text.
* *
* @param {Event} e * @param {Event} e
* @param {Object} paste * @param {Object} paste
@@ -146,7 +168,8 @@ export default {
}, },
/** /**
* Default `node` renderer. * The core `node` renderer, which uses plain `<div>` or `<span>` depending on
* what kind of node it is.
* *
* @param {Node} node * @param {Node} node
* @return {Component} component * @return {Component} component
@@ -154,19 +177,19 @@ export default {
renderNode(node) { renderNode(node) {
return node.kind == 'block' return node.kind == 'block'
? (props) => <div>{props.children}</div> ? DEFAULT_BLOCK
: (props) => <span>{props.children}</span> : DEFAULT_INLINE
}, },
/** /**
* Default `mark` renderer. * The core `mark` renderer, with no styles.
* *
* @param {Mark} mark * @param {Mark} mark
* @return {Object} style * @return {Object} style
*/ */
renderMark(mark) { renderMark(mark) {
return {} return DEFAULT_MARK
} }
} }