From 3545bdc5868dcda1b9014ce3e17bc550e7794cb3 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:59:55 -0500 Subject: [PATCH] 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. --- .../homebrew/editor/snippetbar/snippetbar.jsx | 24 +++++++++++++++---- .../snippetbar/snippetsLegacy/snippets.js | 4 ++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 0c054b12b..560786344 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -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