mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 18:32:41 +00:00
Update snippetbar.jsx with filter for editor/view specific menus
Add logic to filter available snippet menus based on the view/editor that is open ("text" vs "style") for both Legacy and v3.
This commit is contained in:
@@ -39,12 +39,26 @@ const Snippetbar = createClass({
|
||||
renderSnippetGroups : function(){
|
||||
let snippets = [];
|
||||
|
||||
if(this.props.view === 'text') {
|
||||
if(this.props.renderer === 'V3')
|
||||
snippets = SnippetsV3;
|
||||
|
||||
if(this.props.renderer === 'V3')
|
||||
if(this.props.view === 'text') {
|
||||
snippets = SnippetsV3.filter(SnippetsV3 => SnippetsV3.view === 'text');
|
||||
}
|
||||
else if(this.props.view === 'style') {
|
||||
snippets = SnippetsV3.filter(SnippetsV3 => SnippetsV3.view === 'style');
|
||||
}
|
||||
else
|
||||
snippets = SnippetsLegacy;
|
||||
}
|
||||
snippets = null
|
||||
else
|
||||
if(this.props.view === 'text') {
|
||||
snippets = SnippetsLegacy.filter(SnippetsLegacy => SnippetsLegacy.view === 'text');
|
||||
}
|
||||
else if(this.props.view === 'style') {
|
||||
snippets = SnippetsLegacy.filter(SnippetsLegacy => SnippetsLegacy.view === 'style');
|
||||
}
|
||||
else
|
||||
snippets = null
|
||||
|
||||
|
||||
return _.map(snippets, (snippetGroup)=>{
|
||||
return <SnippetGroup
|
||||
|
||||
@@ -13,6 +13,7 @@ module.exports = [
|
||||
{
|
||||
groupName : 'Editor',
|
||||
icon : 'fas fa-pencil-alt',
|
||||
view : 'text',
|
||||
snippets : [
|
||||
{
|
||||
name : 'Column Break',
|
||||
@@ -114,6 +115,7 @@ module.exports = [
|
||||
{
|
||||
groupName : 'PHB',
|
||||
icon : 'fas fa-book',
|
||||
view : 'text',
|
||||
snippets : [
|
||||
{
|
||||
name : 'Spell',
|
||||
@@ -181,6 +183,7 @@ module.exports = [
|
||||
{
|
||||
groupName : 'Tables',
|
||||
icon : 'fas fa-table',
|
||||
view : 'text',
|
||||
snippets : [
|
||||
{
|
||||
name : 'Class Table',
|
||||
@@ -265,6 +268,7 @@ module.exports = [
|
||||
{
|
||||
groupName : 'Print',
|
||||
icon : 'fas fa-print',
|
||||
view : 'style',
|
||||
snippets : [
|
||||
{
|
||||
name : 'A4 PageSize',
|
||||
|
||||
Reference in New Issue
Block a user