0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-16 01:42:47 +00:00

Merge pull request #1626 from naturalcrit/V3ChangelogPrep

\page alone on line, fix snippets crashing empty brew
This commit is contained in:
Trevor Buckner
2021-08-31 12:45:37 -04:00
committed by GitHub
6 changed files with 12 additions and 13 deletions

View File

@@ -30,7 +30,7 @@ const BrewRenderer = createClass({
if(this.props.renderer == 'legacy') { if(this.props.renderer == 'legacy') {
pages = this.props.text.split('\\page'); pages = this.props.text.split('\\page');
} else { } else {
pages = this.props.text.split(/^\\page/gm); pages = this.props.text.split(/^\\page$/gm);
} }
return { return {
@@ -62,7 +62,7 @@ const BrewRenderer = createClass({
if(this.props.renderer == 'legacy') { if(this.props.renderer == 'legacy') {
pages = this.props.text.split('\\page'); pages = this.props.text.split('\\page');
} else { } else {
pages = this.props.text.split(/^\\page/gm); pages = this.props.text.split(/^\\page$/gm);
} }
this.setState({ this.setState({
pages : pages, pages : pages,

View File

@@ -68,10 +68,9 @@ const Editor = createClass({
}, },
handleInject : function(injectText){ handleInject : function(injectText){
const text = ( let text;
this.isText() && this.props.brew.text || if(this.isText()) text = this.props.brew.text;
this.isStyle() && (this.props.brew.style ?? DEFAULT_STYLE_TEXT) if(this.isStyle()) text = this.props.brew.style ?? DEFAULT_STYLE_TEXT;
);
const lines = text.split('\n'); const lines = text.split('\n');
const cursorPos = this.refs.codeEditor.getCursorPosition(); const cursorPos = this.refs.codeEditor.getCursorPosition();
@@ -79,7 +78,7 @@ const Editor = createClass({
this.refs.codeEditor.setCursorPosition(cursorPos.line + injectText.split('\n').length, cursorPos.ch + injectText.length); this.refs.codeEditor.setCursorPosition(cursorPos.line + injectText.split('\n').length, cursorPos.ch + injectText.length);
if(this.isText()) this.props.onTextChange(lines.join('\n')); if(this.isText()) this.props.onTextChange(lines.join('\n'));
if(this.isStyle()) this.props.onStyleChange(lines.join('\n')); if(this.isStyle()) this.props.onStyleChange(lines.join('\n'));
}, },
@@ -122,7 +121,7 @@ const Editor = createClass({
// New Codemirror styling for V3 renderer // New Codemirror styling for V3 renderer
if(this.props.renderer == 'V3') { if(this.props.renderer == 'V3') {
if(line.startsWith('\\page')){ if(line.match(/^\\page$/)){
codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); codeMirror.addLineClass(lineNumber, 'background', 'pageLine');
r.push(lineNumber); r.push(lineNumber);
} }

View File

@@ -43,8 +43,8 @@ module.exports = [
{{wide {{wide
Everything in here will be extra wide. Tables, text, everything! Everything in here will be extra wide. Tables, text, everything!
Beware though, CSS columns can behave a bit weird sometimes. You may Beware though, CSS columns can behave a bit weird sometimes. You may
have to rely on the automatic column-break rather than \`\column\` if have to manually place column breaks with \`\column\` to make the
you mix columns and wide blocks on the same page. surrounding text flow with this wide block the way you want.
}} }}
\n` \n`
}, },

View File

@@ -197,7 +197,7 @@ const EditPage = createClass({
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId); const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
const brew = this.state.brew; const brew = this.state.brew;
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page/gm)) || []).length + 1; brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
if(this.state.saveGoogle) { if(this.state.saveGoogle) {
if(transfer) { if(transfer) {

View File

@@ -161,7 +161,7 @@ const NewPage = createClass({
brew.text = brew.text.slice(index + 5); brew.text = brew.text.slice(index + 5);
}; };
brew.pageCount=((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page/gm)) || []).length + 1; brew.pageCount=((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
if(this.state.saveGoogle) { if(this.state.saveGoogle) {
const res = await request const res = await request

View File

@@ -45,7 +45,7 @@ const PrintPage = createClass({
key={index} />; key={index} />;
}); });
} else { } else {
return _.map(this.state.brewText.split(/^\\page/gm), (pageText, index)=>{ return _.map(this.state.brewText.split(/^\\page$/gm), (pageText, index)=>{
pageText += `\n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear) pageText += `\n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear)
return ( return (
<div className='page' id={`p${index + 1}`} key={index} > <div className='page' id={`p${index + 1}`} key={index} >