11import React from "react"
22import toReact from "./toReact"
33
4- // Computes an array of types and type map for a pseudo-
4+ // Computes an array of types and a type map for a pseudo-
55// React element.
66function computeTypeInfo ( element ) {
77 const types = [ ]
@@ -22,7 +22,7 @@ function computeTypeInfo(element) {
2222
2323// Decorates pseudo-React elements; sets element.pos to
2424// "at-start", "at-center", or "at-end".
25- function decoratePos ( elements ) {
25+ function decorate ( elements ) {
2626 for ( let x = 0 ; x < elements . length ; x ++ ) {
2727 if ( ! x || typeof elements [ x - 1 ] === "string" || typeof elements [ x ] === "string" ) {
2828 // No-op
@@ -39,7 +39,7 @@ function decoratePos(elements) {
3939}
4040
4141// Parses spans to pseudo-React elements.
42- function parseSpans ( spans ) {
42+ function parse ( spans ) {
4343 const elements = [ ]
4444 for ( const span of spans ) {
4545 if ( ! span . formats . length ) {
@@ -63,16 +63,17 @@ function parseSpans(spans) {
6363 lastRef . props . children = span . content
6464 elements . push ( element )
6565 }
66- decoratePos ( elements )
66+ decorate ( elements )
6767 return elements
6868}
6969
70+ // React renderer for the VDOM state (e.g. state.elements).
7071const ReactRenderer = ( { state, dispatch, renderableMap } ) => (
7172 state . elements . map ( ( { type : T , spans, ...props } ) => (
7273 React . createElement ( T , {
7374 key : props . uuid ,
7475 ...props ,
75- } , toReact ( parseSpans ( spans ) , renderableMap ) )
76+ } , toReact ( parse ( spans ) , renderableMap ) )
7677 ) )
7778)
7879
0 commit comments