0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 17:32:38 +00:00

Shift Footer generation to snippet

This commit is contained in:
G.Ambatte
2023-06-03 13:30:32 +12:00
parent 052c255068
commit d2b2e69123
5 changed files with 30 additions and 36 deletions

View File

@@ -323,7 +323,8 @@ const Editor = createClass({
theme={this.props.brew.theme}
undo={this.undo}
redo={this.redo}
historySize={this.historySize()} />
historySize={this.historySize()}
cursorPos={this.refs.codeEditor?.getCursorPosition() || {}} />
{this.renderEditor()}
</div>

View File

@@ -15,8 +15,8 @@ ThemeSnippets['V3_5eDMG'] = require('themes/V3/5eDMG/snippets.js');
ThemeSnippets['V3_Journal'] = require('themes/V3/Journal/snippets.js');
ThemeSnippets['V3_Blank'] = require('themes/V3/Blank/snippets.js');
const execute = function(val, brew){
if(_.isFunction(val)) return val(brew);
const execute = function(val, brew, params){
if(_.isFunction(val)) return val(brew, params);
return val;
};
@@ -33,7 +33,8 @@ const Snippetbar = createClass({
renderer : 'legacy',
undo : ()=>{},
redo : ()=>{},
historySize : ()=>{}
historySize : ()=>{},
cursorPos : {}
};
},
@@ -105,6 +106,7 @@ const Snippetbar = createClass({
snippets={snippetGroup.snippets}
key={snippetGroup.groupName}
onSnippetClick={this.handleSnippetClick}
cursorPos={this.props.cursorPos}
/>;
});
},
@@ -165,7 +167,7 @@ const SnippetGroup = createClass({
},
handleSnippetClick : function(e, snippet){
e.stopPropagation();
this.props.onSnippetClick(execute(snippet.gen, this.props.brew));
this.props.onSnippetClick(execute(snippet.gen, this.props.brew, { cursorPos: this.props.cursorPos }));
},
renderSnippets : function(snippets){
return _.map(snippets, (snippet)=>{