@@ -23,8 +23,9 @@ import { MOBILE_MEDIA_QUERY } from "../../../utils/mediaQueryBreakpoints";
2323import FileIcon from "../../../utils/FileIcon" ;
2424import DownloadPanel from "./DownloadPanel/DownloadPanel" ;
2525import InstructionsPanel from "./InstructionsPanel/InstructionsPanel" ;
26+ import SidebarPanel from "./SidebarPanel" ;
2627
27- const Sidebar = ( { options = [ ] } ) => {
28+ const Sidebar = ( { options = [ ] , plugins = [ ] } ) => {
2829 const { t } = useTranslation ( ) ;
2930
3031 let menuOptions = [
@@ -79,6 +80,22 @@ const Sidebar = ({ options = [] }) => {
7980 } ,
8081 ] . filter ( ( option ) => options . includes ( option . name ) ) ;
8182
83+ let pluginMenuOptions = plugins . map ( ( plugin ) => {
84+ return {
85+ name : plugin . name ,
86+ icon : plugin . icon ,
87+ title : plugin . title ,
88+ position : plugin . position || "top" ,
89+ panel : ( ) => (
90+ < SidebarPanel heading = { plugin . heading } Button = { plugin . button } >
91+ { plugin . panel ( ) }
92+ </ SidebarPanel >
93+ ) ,
94+ } ;
95+ } ) ;
96+
97+ menuOptions = [ ...menuOptions , ...pluginMenuOptions ] ;
98+
8299 const isMobile = useMediaQuery ( { query : MOBILE_MEDIA_QUERY } ) ;
83100 const projectImages = useSelector ( ( state ) => state . editor . project . image_list ) ;
84101 const instructionsSteps = useSelector (
@@ -103,17 +120,23 @@ const Sidebar = ({ options = [] }) => {
103120 removeOption ( "instructions" , instructionsSteps ) ;
104121 }
105122
123+ const autoOpenPlugin = plugins ?. find ( ( plugin ) => plugin . autoOpen ) ;
124+
106125 const [ option , setOption ] = useState (
107- instructionsEditable || instructionsSteps ? "instructions" : "file" ,
126+ autoOpenPlugin
127+ ? autoOpenPlugin . name
128+ : instructionsEditable || instructionsSteps
129+ ? "instructions"
130+ : "file" ,
108131 ) ;
109132
110133 const hasInstructions = instructionsSteps && instructionsSteps . length > 0 ;
111134
112135 useEffect ( ( ) => {
113- if ( instructionsEditable || hasInstructions ) {
136+ if ( ! autoOpenPlugin && ( instructionsEditable || hasInstructions ) ) {
114137 setOption ( "instructions" ) ;
115138 }
116- } , [ instructionsEditable , hasInstructions ] ) ;
139+ } , [ autoOpenPlugin , instructionsEditable , hasInstructions ] ) ;
117140
118141 const toggleOption = ( newOption ) => {
119142 if ( option !== newOption ) {
0 commit comments