mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 05:22:40 +00:00
Fixed renderer crashing with malformed html on load
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
- Changed icon for the metadata
|
- Changed icon for the metadata
|
||||||
- Made links useable in footer (thanks u/Dustfinger1 re:249)
|
- Made links useable in footer (thanks u/Dustfinger1 re:249)
|
||||||
- Added print media queries to remove box shadow on print (thanks u/dmmagic re: 246)
|
- Added print media queries to remove box shadow on print (thanks u/dmmagic re: 246)
|
||||||
|
- Fixed realtime renderer not functioning if loaded with malformed html on load (thanks u/RattiganIV re:247)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const BrewRenderer = React.createClass({
|
|||||||
},
|
},
|
||||||
height : 0,
|
height : 0,
|
||||||
pageHeight : PAGE_HEIGHT,
|
pageHeight : PAGE_HEIGHT,
|
||||||
|
lastRender : <div></div>,
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this.updateSize();
|
this.updateSize();
|
||||||
@@ -43,7 +44,7 @@ const BrewRenderer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
if(this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||||
|
|
||||||
const pages = nextProps.text.split('\\page');
|
const pages = nextProps.text.split('\\page');
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -54,7 +55,7 @@ const BrewRenderer = React.createClass({
|
|||||||
|
|
||||||
updateSize : function() {
|
updateSize : function() {
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
if(this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -117,10 +118,11 @@ const BrewRenderer = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if(this.props.errors && this.props.errors.length) return this.lastRender;
|
||||||
return _.map(this.state.pages, (page, index)=>{
|
this.lastRender = _.map(this.state.pages, (page, index)=>{
|
||||||
return this.renderPage(page, index);
|
return this.renderPage(page, index);
|
||||||
});
|
});
|
||||||
|
return this.lastRender;
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const EditPage = React.createClass({
|
|||||||
isSaving : false,
|
isSaving : false,
|
||||||
isPending : false,
|
isPending : false,
|
||||||
errors : null,
|
errors : null,
|
||||||
htmlErrors : [],
|
htmlErrors : Markdown.validate(this.props.brew.text),
|
||||||
lastUpdated : this.props.brew.updatedAt
|
lastUpdated : this.props.brew.updatedAt
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user