mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 23:12:39 +00:00
Remove snippet.params
This commit is contained in:
@@ -167,7 +167,7 @@ const SnippetGroup = createClass({
|
|||||||
},
|
},
|
||||||
handleSnippetClick : function(e, snippet){
|
handleSnippetClick : function(e, snippet){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.props.onSnippetClick(execute(snippet.gen, this.props.brew, { ...snippet.params, cursorPos: this.props.cursorPos }));
|
this.props.onSnippetClick(execute(snippet.gen, this.props));
|
||||||
},
|
},
|
||||||
renderSnippets : function(snippets){
|
renderSnippets : function(snippets){
|
||||||
return _.map(snippets, (snippet)=>{
|
return _.map(snippets, (snippet)=>{
|
||||||
|
|||||||
@@ -33,43 +33,37 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
name : 'Footer',
|
name : 'Footer',
|
||||||
icon : 'fas fa-shoe-prints',
|
icon : 'fas fa-shoe-prints',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(),
|
||||||
subsnippets : [
|
subsnippets : [
|
||||||
{
|
{
|
||||||
name : 'Footer from H1',
|
name : 'Footer from H1',
|
||||||
icon : 'fas fa-dice-one',
|
icon : 'fas fa-dice-one',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(1)
|
||||||
params : { headerSize: 1 }
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Footer from H2',
|
name : 'Footer from H2',
|
||||||
icon : 'fas fa-dice-two',
|
icon : 'fas fa-dice-two',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(2)
|
||||||
params : { headerSize: 2 }
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Footer from H3',
|
name : 'Footer from H3',
|
||||||
icon : 'fas fa-dice-three',
|
icon : 'fas fa-dice-three',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(3)
|
||||||
params : { headerSize: 3 }
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Footer from H4',
|
name : 'Footer from H4',
|
||||||
icon : 'fas fa-dice-four',
|
icon : 'fas fa-dice-four',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(4)
|
||||||
params : { headerSize: 4 }
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Footer from H5',
|
name : 'Footer from H5',
|
||||||
icon : 'fas fa-dice-five',
|
icon : 'fas fa-dice-five',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(5)
|
||||||
params : { headerSize: 5 }
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Footer from H6',
|
name : 'Footer from H6',
|
||||||
icon : 'fas fa-dice-six',
|
icon : 'fas fa-dice-six',
|
||||||
gen : FooterGen.createFooter,
|
gen : FooterGen.createFooterFunc(6)
|
||||||
params : { headerSize: 6 }
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
createFooter : function(brew, params){
|
createFooterFunc : function(headerSize=1){
|
||||||
const cursorPos = params.cursorPos;
|
return (props)=>{
|
||||||
const headerSize = params.headerSize || 1;
|
const cursorPos = props.cursorPos;
|
||||||
|
|
||||||
let header='';
|
let header='';
|
||||||
while (header.length < headerSize) {
|
while (header.length < headerSize) {
|
||||||
header = header.concat('#');
|
header = header.concat('#');
|
||||||
}
|
}
|
||||||
header = header.concat(' ');
|
header = header.concat(' ');
|
||||||
|
|
||||||
const textArray = brew.text.split('\n').slice(0, cursorPos.line).reverse();
|
const textArray = props.brew.text.split('\n').slice(0, cursorPos.line).reverse();
|
||||||
const textArrayFilter = textArray.filter((line)=>{ return line.slice(0, header.length) == header; });
|
const textArrayFilter = textArray.filter((line)=>{ return line.slice(0, header.length) == header; });
|
||||||
const text = textArrayFilter[0]?.slice(header.length) || 'PART 1 | SECTION NAME';
|
const text = textArrayFilter[0]?.slice(header.length).trim() || 'PART 1 | SECTION NAME';
|
||||||
|
|
||||||
return `\n{{footnote ${text}}}\n`;
|
return `\n{{footnote ${text}}}\n`;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user