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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user