mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 15:32:40 +00:00
Merge pull request #1626 from naturalcrit/V3ChangelogPrep
\page alone on line, fix snippets crashing empty brew
This commit is contained in:
@@ -30,7 +30,7 @@ const BrewRenderer = createClass({
|
||||
if(this.props.renderer == 'legacy') {
|
||||
pages = this.props.text.split('\\page');
|
||||
} else {
|
||||
pages = this.props.text.split(/^\\page/gm);
|
||||
pages = this.props.text.split(/^\\page$/gm);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -62,7 +62,7 @@ const BrewRenderer = createClass({
|
||||
if(this.props.renderer == 'legacy') {
|
||||
pages = this.props.text.split('\\page');
|
||||
} else {
|
||||
pages = this.props.text.split(/^\\page/gm);
|
||||
pages = this.props.text.split(/^\\page$/gm);
|
||||
}
|
||||
this.setState({
|
||||
pages : pages,
|
||||
|
||||
@@ -68,10 +68,9 @@ const Editor = createClass({
|
||||
},
|
||||
|
||||
handleInject : function(injectText){
|
||||
const text = (
|
||||
this.isText() && this.props.brew.text ||
|
||||
this.isStyle() && (this.props.brew.style ?? DEFAULT_STYLE_TEXT)
|
||||
);
|
||||
let text;
|
||||
if(this.isText()) text = this.props.brew.text;
|
||||
if(this.isStyle()) text = this.props.brew.style ?? DEFAULT_STYLE_TEXT;
|
||||
|
||||
const lines = text.split('\n');
|
||||
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);
|
||||
|
||||
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'));
|
||||
},
|
||||
|
||||
@@ -122,7 +121,7 @@ const Editor = createClass({
|
||||
|
||||
// New Codemirror styling for V3 renderer
|
||||
if(this.props.renderer == 'V3') {
|
||||
if(line.startsWith('\\page')){
|
||||
if(line.match(/^\\page$/)){
|
||||
codeMirror.addLineClass(lineNumber, 'background', 'pageLine');
|
||||
r.push(lineNumber);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ module.exports = [
|
||||
{{wide
|
||||
Everything in here will be extra wide. Tables, text, everything!
|
||||
Beware though, CSS columns can behave a bit weird sometimes. You may
|
||||
have to rely on the automatic column-break rather than \`\column\` if
|
||||
you mix columns and wide blocks on the same page.
|
||||
have to manually place column breaks with \`\column\` to make the
|
||||
surrounding text flow with this wide block the way you want.
|
||||
}}
|
||||
\n`
|
||||
},
|
||||
|
||||
@@ -197,7 +197,7 @@ const EditPage = createClass({
|
||||
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
|
||||
|
||||
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(transfer) {
|
||||
|
||||
@@ -161,7 +161,7 @@ const NewPage = createClass({
|
||||
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) {
|
||||
const res = await request
|
||||
|
||||
@@ -45,7 +45,7 @@ const PrintPage = createClass({
|
||||
key={index} />;
|
||||
});
|
||||
} 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)
|
||||
return (
|
||||
<div className='page' id={`p${index + 1}`} key={index} >
|
||||
|
||||
Reference in New Issue
Block a user