diff --git a/example/index.html b/example/index.html index f3e5affb..6ab62374 100644 --- a/example/index.html +++ b/example/index.html @@ -101,7 +101,7 @@ h('dd', {}, this.props.widgetsFor('posts').getIn(['widgets', 'front_limit']) || 0), h('dt', {}, 'Default Author'), - h('dd', {}, this.props.widgetsFor('posts').getIn(['data', 'front_limit']) || 'None'), + h('dd', {}, this.props.widgetsFor('posts').getIn(['data', 'author']) || 'None'), h('dt', {}, 'Default Thumbnail'), h('dd', {}, thumb && h('img', {src: this.props.getAsset(thumb).toString()})) diff --git a/src/components/PreviewPane/PreviewPane.js b/src/components/PreviewPane/PreviewPane.js index b7da6e36..33171a9e 100644 --- a/src/components/PreviewPane/PreviewPane.js +++ b/src/components/PreviewPane/PreviewPane.js @@ -29,54 +29,48 @@ export default class PreviewPane extends React.Component { if (authorField) this.inferedFields[authorField] = INFERABLE_FIELDS.author; } + _getWidget = (field, value, props) => { + const { fieldsMetaData, getAsset } = props; + const widget = resolveWidget(field.get('widget')); + return React.createElement(widget.preview, { + field, + key: field.get('name'), + value: value && Map.isMap(value) ? value.get(field.get('name')) : value, + metadata: fieldsMetaData && fieldsMetaData.get(field.get('name')), + getAsset, + }); + }; + widgetFor = (name) => { - const { fields, entry, fieldsMetaData, getAsset } = this.props; + const { fields, entry } = this.props; const field = fields.find(f => f.get('name') === name); let value = entry.getIn(['data', field.get('name')]); - const metadata = fieldsMetaData.get(field.get('name')); const labelledWidgets = ['string', 'text', 'number']; if (Object.keys(this.inferedFields).indexOf(name) !== -1) { value = this.inferedFields[name].defaultPreview(value); } else if (value && labelledWidgets.indexOf(field.get('widget')) !== -1 && value.toString().length < 50) { value =