0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 13:02:45 +00:00

Added smart componenets, page line number highlighting

This commit is contained in:
Scott Tolksdorf
2016-12-26 15:52:32 -05:00
parent 7581d155a6
commit 47396e5c7e
39 changed files with 2028 additions and 119 deletions

View File

@@ -2,11 +2,12 @@ const React = require('react');
const _ = require('lodash');
const cx = require('classnames');
const Markdown = require('naturalcrit/markdown.js');
const Markdown = require('homebrewery/markdown.js');
const ErrorBar = require('./errorBar/errorBar.jsx');
//TODO: move to the brew renderer
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx')
const Store = require('homebrewery/brew.store.js');
const PAGE_HEIGHT = 1056;
const PPR_THRESHOLD = 50;
@@ -14,24 +15,19 @@ const PPR_THRESHOLD = 50;
const BrewRenderer = React.createClass({
getDefaultProps: function() {
return {
text : '',
brewText : '',
errors : []
};
},
getInitialState: function() {
const pages = this.props.text.split('\\page');
const pages = this.props.brewText.split('\\page');
return {
viewablePageNumber: 0,
height : 0,
isMounted : false,
usePPR : true,
pages : pages,
usePPR : pages.length >= PPR_THRESHOLD,
errors : []
usePPR : pages.length >= PPR_THRESHOLD
};
},
height : 0,
@@ -49,7 +45,7 @@ const BrewRenderer = React.createClass({
componentWillReceiveProps: function(nextProps) {
if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
const pages = nextProps.text.split('\\page');
const pages = nextProps.brewText.split('\\page');
this.setState({
pages : pages,
usePPR : pages.length >= PPR_THRESHOLD