var React = require('react') var cx = require('classnames') var PT = React.PropTypes var marked = require('marked') var Listener = require('../../listener') var renderer = new marked.Renderer() renderer.link = function (href, title, text) { return '' + text + ''; } marked.setOptions({ gfm: true, sanitize: true, tables: true, breaks: true, pedantic: false, smartLists: true, smartypants: true, renderer: renderer }) var PaperItem = React.createClass({ mixins: [ Listener({ storeAttrs: function (getters, props) { return { node: getters.getNode(props.id), isActiveView: getters.isActiveView(), isActive: getters.isActive(props.id), isSelected: getters.isSelected(props.id), editState: getters.editState(props.id), } }, initStoreState: function (state, getters, props) { var node = state.node return { lazyChildren: !props.isRoot && node.collapsed && node.children.length } }, updateStoreState: function (state, getters, props) { var node = state.node return { lazyChildren: this.state.lazyChildren && node.collapsed } }, shouldGetNew: function (nextProps) { return nextProps.id !== this.props.id || nextProps.store !== this.props.store }, getListeners: function (props, events) { return [events.nodeChanged(props.id), events.nodeViewChanged(props.id)] }, }) ], componentWillMount: function () { // get plugin update functions this._plugin_updates = null this.props.plugins.forEach((plugin) => { if (!plugin.componentDidUpdate) return if (!this._plugin_updates) { this._plugin_updates = [plugin.componentDidUpdate] } else { this._plugin_updates.push(plugin.componentDidUpdate) } }) }, /** Use to check what things are updating when */ componentDidUpdate: function (prevProps, prevState) { if (this._plugin_updates) { this._plugin_updates.map((fn) => fn.call(this, prevProps, prevState)) } }, /* fromMix: function (part) { if (!this.props.plugins) return var items = [] for (var i=0; i{this.state.node.content} case 1: return

{this.state.node.content}

case 2: return

{this.state.node.content}

case 3: return

{this.state.node.content}

default: return
{this.state.node.content}
} }, render: function () { if (this.state.node.children.length) { var children = this.state.node.children.map((id, i) => ) return
{this.header()} {children}
} var content = this.state.node.content if (!content) return

if (this.state.node.type === 'image') { return

} if (this.state.node.type === 'ipython') { content = '```\n' + content + '\n```' } return

}, }) module.exports = PaperItem