0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-07 12:02:44 +00:00

jsx files

This commit is contained in:
Víctor Losada Hernández
2025-03-18 19:47:49 +01:00
parent f076e05f49
commit 8e37806791
10 changed files with 150 additions and 153 deletions

View File

@@ -196,7 +196,7 @@ const BrewRenderer = (props)=>{
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
} }
let html = Markdown.render(pageText, index); const html = Markdown.render(pageText, index);
return <BrewPage className={classes} index={index} key={index} contents={html} style={styles} attributes={attributes} onVisibilityChange={handlePageVisibilityChange} />; return <BrewPage className={classes} index={index} key={index} contents={html} style={styles} attributes={attributes} onVisibilityChange={handlePageVisibilityChange} />;
} }

View File

@@ -25,7 +25,7 @@ const HeaderNav = React.forwardRef(({}, pagesRef)=>{
'.toc' : ()=>{ return 'Table of Contents'; }, '.toc' : ()=>{ return 'Table of Contents'; },
}; };
const getHeaderContent = el => el.querySelector('h1')?.textContent; const getHeaderContent = (el)=>el.querySelector('h1')?.textContent;
const topLevelPageSelector = Object.keys(topLevelPages).join(','); const topLevelPageSelector = Object.keys(topLevelPages).join(',');
@@ -52,25 +52,23 @@ const HeaderNav = React.forwardRef(({}, pagesRef)=>{
depth : 7, // All unmatched elements with IDs are set to the maximum depth (7) depth : 7, // All unmatched elements with IDs are set to the maximum depth (7)
text : el.textContent, // Use `textContent` because `innerText` is affected by rendering, e.g. 'content-visibility: auto' text : el.textContent, // Use `textContent` because `innerText` is affected by rendering, e.g. 'content-visibility: auto'
link : el.id link : el.id
} };
if(el.classList.contains('page')) { if(el.classList.contains('page')) {
let text = `Page ${el.id.slice(1)}`; // Get the page # by trimming off the 'p' from the ID let text = `Page ${el.id.slice(1)}`; // Get the page # by trimming off the 'p' from the ID
const pageType = Object.keys(topLevelPages).find(pageType => el.querySelector(pageType)); const pageType = Object.keys(topLevelPages).find((pageType)=>el.querySelector(pageType));
if(pageType) if(pageType)
text += ` - ${topLevelPages[pageType](el, pageType)}` // If a Top Level Page, add extra label text += ` - ${topLevelPages[pageType](el, pageType)}`; // If a Top Level Page, add extra label
navEntry.depth = 0; // Pages are always at the least indented level navEntry.depth = 0; // Pages are always at the least indented level
navEntry.text = text; navEntry.text = text;
navEntry.className = 'pageLink'; navEntry.className = 'pageLink';
} } else if(el.localName.match(/^h[1-6]/)){ // Header elements H1 through H6
else if(el.localName.match(/^h[1-6]/)){ // Header elements H1 through H6
navEntry.depth = el.localName[1]; // Depth is set by the header level navEntry.depth = el.localName[1]; // Depth is set by the header level
} }
navList.push(navEntry); navList.push(navEntry);
}); });
return _.map(navList, (navItem, index)=> return _.map(navList, (navItem, index)=><HeaderNavItem {...navItem} key={index} />
<HeaderNavItem {...navItem} key={index} />
); );
}; };

View File

@@ -4,7 +4,6 @@ const React = require('react');
const createClass = require('create-react-class'); const createClass = require('create-react-class');
const _ = require('lodash'); const _ = require('lodash');
import request from '../../utils/request-middleware.js'; import request from '../../utils/request-middleware.js';
const Nav = require('naturalcrit/nav/nav.jsx');
const Combobox = require('client/components/combobox.jsx'); const Combobox = require('client/components/combobox.jsx');
const TagInput = require('../tagInput/tagInput.jsx'); const TagInput = require('../tagInput/tagInput.jsx');

View File

@@ -259,7 +259,7 @@ const Snippetbar = createClass({
</div> </div>
</div> </div>
) );
}, },
render : function(){ render : function(){

View File

@@ -8,13 +8,13 @@ const TagInput = ({ unique = true, values = [], ...props }) => {
const [tagList, setTagList] = useState(values.map((value)=>({ value, editing: false }))); const [tagList, setTagList] = useState(values.map((value)=>({ value, editing: false })));
useEffect(()=>{ useEffect(()=>{
handleChange(tagList.map((context)=>context.value)) handleChange(tagList.map((context)=>context.value));
}, [tagList]) }, [tagList]);
const handleChange = (value)=>{ const handleChange = (value)=>{
props.onChange({ props.onChange({
target : { value } target : { value }
}) });
}; };
const handleInputKeyDown = ({ evt, value, index, options = {} })=>{ const handleInputKeyDown = ({ evt, value, index, options = {} })=>{
@@ -35,7 +35,7 @@ const TagInput = ({ unique = true, values = [], ...props }) => {
} }
// add new tag // add new tag
if(originalValue === null){ if(originalValue === null){
return [...prevContext, { value: newValue, editing: false }] return [...prevContext, { value: newValue, editing: false }];
} }
// update existing tag // update existing tag
return prevContext.map((context, i)=>{ return prevContext.map((context, i)=>{
@@ -65,7 +65,7 @@ const TagInput = ({ unique = true, values = [], ...props }) => {
className='tag' className='tag'
onClick={()=>editTag(index)}> onClick={()=>editTag(index)}>
{context.value} {context.value}
<button onClick={(evt)=>{evt.stopPropagation(); submitTag(null, context.value, index)}}><i className='fa fa-times fa-fw'/></button> <button onClick={(evt)=>{evt.stopPropagation(); submitTag(null, context.value, index);}}><i className='fa fa-times fa-fw'/></button>
</li> </li>
); );
}; };

View File

@@ -100,7 +100,7 @@ const HomePage = createClass({
return <div className='homePage sitePage'> return <div className='homePage sitePage'>
<Meta name='google-site-verification' content='NwnAQSSJZzAT7N-p5MY6ydQ7Njm67dtbu73ZSyE5Fy4' /> <Meta name='google-site-verification' content='NwnAQSSJZzAT7N-p5MY6ydQ7Njm67dtbu73ZSyE5Fy4' />
{this.renderNavbar()} {this.renderNavbar()}
<div className="content"> <div className='content'>
<SplitPane onDragFinish={this.handleSplitMove}> <SplitPane onDragFinish={this.handleSplitMove}>
<Editor <Editor
ref={this.editor} ref={this.editor}

View File

@@ -223,7 +223,7 @@ const NewPage = createClass({
render : function(){ render : function(){
return <div className='newPage sitePage'> return <div className='newPage sitePage'>
{this.renderNavbar()} {this.renderNavbar()}
<div className="content"> <div className='content'>
<SplitPane onDragFinish={this.handleSplitMove}> <SplitPane onDragFinish={this.handleSplitMove}>
<Editor <Editor
ref={this.editor} ref={this.editor}