mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 23:02:45 +00:00
Lint
This commit is contained in:
@@ -40,7 +40,7 @@ const BrewPage = (props)=>{
|
|||||||
...props
|
...props
|
||||||
};
|
};
|
||||||
const pageRef = useRef(null);
|
const pageRef = useRef(null);
|
||||||
let cleanText = safeHTML(props.contents);
|
const cleanText = safeHTML(props.contents);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(!pageRef.current) return;
|
if(!pageRef.current) return;
|
||||||
@@ -77,7 +77,7 @@ const BrewPage = (props)=>{
|
|||||||
centerObserver.disconnect();
|
centerObserver.disconnect();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return <div className={props.className} id={`p${props.index + 1}`} data-index={props.index} ref={pageRef} style={props.style} {...props.attributes}>
|
return <div className={props.className} id={`p${props.index + 1}`} data-index={props.index} ref={pageRef} style={props.style} {...props.attributes}>
|
||||||
<div className='columnWrapper' dangerouslySetInnerHTML={{ __html: cleanText }} />
|
<div className='columnWrapper' dangerouslySetInnerHTML={{ __html: cleanText }} />
|
||||||
</div>;
|
</div>;
|
||||||
@@ -185,11 +185,11 @@ const BrewRenderer = (props)=>{
|
|||||||
return <BrewPage className='page phb' index={index} key={index} contents={html} style={styles} onVisibilityChange={handlePageVisibilityChange} />;
|
return <BrewPage className='page phb' index={index} key={index} contents={html} style={styles} onVisibilityChange={handlePageVisibilityChange} />;
|
||||||
} else {
|
} else {
|
||||||
if(pageText.startsWith('\\page')) {
|
if(pageText.startsWith('\\page')) {
|
||||||
let firstLineTokens = Markdown.marked.lexer(pageText.split('\n', 1)[0])[0].tokens;
|
const firstLineTokens = Markdown.marked.lexer(pageText.split('\n', 1)[0])[0].tokens;
|
||||||
let injectedTags = firstLineTokens.find(obj => obj.injectedTags !== undefined)?.injectedTags;
|
const injectedTags = firstLineTokens.find((obj)=>obj.injectedTags !== undefined)?.injectedTags;
|
||||||
if(injectedTags) {
|
if(injectedTags) {
|
||||||
styles = {...styles, ...injectedTags.styles};
|
styles = { ...styles, ...injectedTags.styles };
|
||||||
styles = _.mapKeys(styles, (v, k) => _.camelCase(k)); // Convert CSS to camelCase for React
|
styles = _.mapKeys(styles, (v, k)=>_.camelCase(k)); // Convert CSS to camelCase for React
|
||||||
attributes = injectedTags.attributes;
|
attributes = injectedTags.attributes;
|
||||||
}
|
}
|
||||||
pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line
|
pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ const Editor = createClass({
|
|||||||
(this.props.renderer == 'V3' && line.match(/^(?=\\page(?:{[^\n{}]+})?$)/))) {
|
(this.props.renderer == 'V3' && line.match(/^(?=\\page(?:{[^\n{}]+})?$)/))) {
|
||||||
|
|
||||||
if(lineNumber > 0) // Since \page is optional on first line of document,
|
if(lineNumber > 0) // Since \page is optional on first line of document,
|
||||||
editorPageCount += 1; // don't use it to increment page count; stay at 1
|
editorPageCount += 1; // don't use it to increment page count; stay at 1
|
||||||
|
|
||||||
// add back the original class 'background' but also add the new class '.pageline'
|
// add back the original class 'background' but also add the new class '.pageline'
|
||||||
codeMirror.addLineClass(lineNumber, 'background', 'pageLine');
|
codeMirror.addLineClass(lineNumber, 'background', 'pageLine');
|
||||||
|
|||||||
@@ -1002,7 +1002,7 @@ const Markdown = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Markdown;
|
export default Markdown;
|
||||||
|
|||||||
Reference in New Issue
Block a user