diff --git a/packages/excalidraw/components/DefaultSidebar.tsx b/packages/excalidraw/components/DefaultSidebar.tsx index 4f1aa91e8..447a2d3c2 100644 --- a/packages/excalidraw/components/DefaultSidebar.tsx +++ b/packages/excalidraw/components/DefaultSidebar.tsx @@ -61,6 +61,7 @@ export const DefaultSidebar = Object.assign( className, onDock, docked, + libraryEnabled, ...rest }: Merge< MarkOptional, "children">, @@ -102,15 +103,19 @@ export const DefaultSidebar = Object.assign( {searchIcon} - - {LibraryIcon} - + {libraryEnabled && ( + + {LibraryIcon} + + )} - - - + {libraryEnabled && ( + + + + )} diff --git a/packages/excalidraw/components/LayerUI.tsx b/packages/excalidraw/components/LayerUI.tsx index b2e0d446f..d6ad0cfd1 100644 --- a/packages/excalidraw/components/LayerUI.tsx +++ b/packages/excalidraw/components/LayerUI.tsx @@ -156,7 +156,8 @@ const LayerUI = ({ }: LayerUIProps) => { const device = useDevice(); const tunnels = useInitializeTunnels(); - + const showLibrary = + UIOptions.libraryEnabled === undefined ? true : UIOptions.libraryEnabled; const TunnelsJotaiProvider = tunnels.tunnelsJotai.Provider; const [eyeDropperState, setEyeDropperState] = useAtom(activeEyeDropperAtom); @@ -375,11 +376,11 @@ const LayerUI = ({ ); }; - const renderSidebars = () => { return ( { trackEvent( "sidebar", diff --git a/packages/excalidraw/components/Sidebar/common.ts b/packages/excalidraw/components/Sidebar/common.ts index 239b16fc9..cd3ba2c3b 100644 --- a/packages/excalidraw/components/Sidebar/common.ts +++ b/packages/excalidraw/components/Sidebar/common.ts @@ -25,6 +25,10 @@ export type SidebarProps

= { * supply alongside `docked` prop in order to make the Sidebar user-dockable */ onDock?: (docked: boolean) => void; + /** + * Allow hiding library button, default: true + */ + libraryEnabled?: boolean; docked?: boolean; className?: string; // NOTE sidebars we use internally inside the editor must have this flag set. diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.ts index ebc31029c..a0957888a 100644 --- a/packages/excalidraw/types.ts +++ b/packages/excalidraw/types.ts @@ -646,6 +646,7 @@ export type UIOptions = Partial<{ tools: { image: boolean; }; + libraryEnabled?: boolean; /** @deprecated does nothing. Will be removed in 0.15 */ welcomeScreen?: boolean; }>;