bloomreach-experience-react-sdk
Advanced tools
Comparing version
{ | ||
"name": "bloomreach-experience-react-sdk", | ||
"version": "0.2.1", | ||
"version": "0.3.0-rc1", | ||
"description": "BloomReach Experience SDK for React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,3 +8,24 @@ import React from 'react'; | ||
export default class CmsContainerItem extends React.Component { | ||
renderContainerItem(component, pageModel, preview, componentDefinitions) { | ||
renderContainerItem(configuration, pageModel, preview, componentDefinitions) { | ||
if (preview && configuration) { | ||
return ( | ||
<div className="hst-container-item" | ||
ref={(containerItemElm) => { this.addMetaData(containerItemElm, configuration, preview); }}> | ||
<React.Fragment> | ||
{ this.renderContainerItemComponent(configuration, pageModel, preview, componentDefinitions) } | ||
</React.Fragment> | ||
</div> | ||
); | ||
} else if (configuration) { | ||
return ( | ||
<React.Fragment> | ||
{ this.renderContainerItemComponent(configuration, pageModel, preview, componentDefinitions) } | ||
</React.Fragment> | ||
); | ||
} else { | ||
return null; | ||
} | ||
} | ||
renderContainerItemComponent(component, pageModel, preview, componentDefinitions) { | ||
// based on the type of the component, render a different React component | ||
@@ -49,10 +70,3 @@ if (component.label in componentDefinitions) { | ||
{ componentDefinitions => | ||
<div className="hst-container-item" | ||
ref={(containerItemElm) => { this.addMetaData(containerItemElm, configuration, preview); }}> | ||
<React.Fragment> | ||
{ configuration && | ||
this.renderContainerItem(configuration, pageModel, preview, componentDefinitions) | ||
} | ||
</React.Fragment> | ||
</div> | ||
this.renderContainerItem(configuration, pageModel, preview, componentDefinitions) | ||
} | ||
@@ -59,0 +73,0 @@ </ComponentDefinitionsContext.Consumer> |
@@ -8,15 +8,18 @@ import React from 'react'; | ||
renderContainerWrapper(configuration, preview) { | ||
// based on the name of the container, render a different wrapper | ||
switch (configuration.name) { | ||
// add additional cases here if you need custom HTML for a container | ||
default: | ||
return ( | ||
// need to wrap container inside a div instead of React.Fragment because otherwise HTML comments are not removed | ||
<div> | ||
<div className="hst-container" | ||
ref={(containerElm) => { this.addMetaData(containerElm, configuration, preview); }}> | ||
{ this.renderContainer(configuration) } | ||
</div> | ||
if (preview) { | ||
return ( | ||
// need to wrap container inside a div instead of React.Fragment because otherwise HTML comments are not removed | ||
<div> | ||
<div className="hst-container" | ||
ref={(containerElm) => { this.addMetaData(containerElm, configuration, preview); }}> | ||
{ this.renderContainer(configuration) } | ||
</div> | ||
); | ||
</div> | ||
); | ||
} else { | ||
return ( | ||
<React.Fragment> | ||
{ this.renderContainer(configuration) } | ||
</React.Fragment> | ||
); | ||
} | ||
@@ -23,0 +26,0 @@ } |
@@ -55,3 +55,3 @@ import React from 'react'; | ||
// create edit content button and pass as a prop | ||
const manageContentButton = React.createElement(ManageContentButton, { content: content, preview: preview }, null); | ||
const manageContentButton = preview ? React.createElement(ManageContentButton, { content: content, preview: preview }, null) : null; | ||
@@ -58,0 +58,0 @@ return ( |
@@ -49,3 +49,3 @@ import React from 'react'; | ||
}); | ||
if (this.cms && typeof this.cms.createOverlay === 'function') { | ||
if (this.state.preview && this.cms && typeof this.cms.createOverlay === 'function') { | ||
this.cms.createOverlay(); | ||
@@ -56,3 +56,3 @@ } | ||
initializeCmsIntegration() { | ||
if (typeof window !== 'undefined') { | ||
if (this.state.preview && typeof window !== 'undefined') { | ||
window.SPA = { | ||
@@ -128,15 +128,13 @@ renderComponent: (id, propertiesMap) => { | ||
return ( | ||
<React.Fragment> | ||
<ComponentDefinitionsContext.Provider value={this.state.componentDefinitions}> | ||
<PageModelContext.Provider value={pageModel}> | ||
<PreviewContext.Provider value={this.state.preview}> | ||
<CreateLinkContext.Provider value={this.state.createLink}> | ||
{ this.props.children() } | ||
</CreateLinkContext.Provider> | ||
</PreviewContext.Provider> | ||
</PageModelContext.Provider> | ||
</ComponentDefinitionsContext.Provider> | ||
</React.Fragment> | ||
<ComponentDefinitionsContext.Provider value={this.state.componentDefinitions}> | ||
<PageModelContext.Provider value={pageModel}> | ||
<PreviewContext.Provider value={this.state.preview}> | ||
<CreateLinkContext.Provider value={this.state.createLink}> | ||
{ this.props.children() } | ||
</CreateLinkContext.Provider> | ||
</PreviewContext.Provider> | ||
</PageModelContext.Provider> | ||
</ComponentDefinitionsContext.Provider> | ||
); | ||
} | ||
} |
@@ -35,3 +35,3 @@ import React from 'react'; | ||
} else { | ||
throw 'render-cms-component has no supplied page model'; | ||
console.log('<RenderCmsComponent> has no supplied page model'); | ||
return null; | ||
@@ -38,0 +38,0 @@ } |
@@ -49,3 +49,3 @@ import pathToRegexp from 'path-to-regexp'; | ||
newUrls.channelPath = urls.channelPath ? urls.channelPath : defaultUrls.channelPath; | ||
newUrls.previewPrefix = urls.previewPrefix ? urls.previewPrefix : defaultUrls.previewPrefix; | ||
newUrls.previewPrefix = urls.previewPrefix !== undefined ? urls.previewPrefix : defaultUrls.previewPrefix; | ||
newUrls.apiPath = urls.apiPath ? urls.apiPath : defaultUrls.apiPath; | ||
@@ -52,0 +52,0 @@ newUrls.apiComponentRenderingUrlSuffix = urls.apiComponentRenderingUrlSuffix ? urls.apiComponentRenderingUrlSuffix : defaultUrls.apiComponentRenderingUrlSuffix; |
@@ -51,3 +51,3 @@ import globalCmsUrls from './cms-urls'; | ||
} | ||
if (preview) { | ||
if (preview && cmsUrls.previewPrefix !== '') { | ||
url += '/' + cmsUrls.previewPrefix; | ||
@@ -54,0 +54,0 @@ } |
Sorry, the diff of this file is too big to display
240349
0.3%1081
1.31%