@@ -31,6 +31,7 @@ import { loadingOverlay } from '@/app/components/editor/plugins/LoadingOverlayEx
3131import { extractPageContent } from '@/app/utils/contentExtractor' ;
3232import { formatEngineResults , ResultsMap } from '@/app/utils/resultFormatter' ;
3333import { casbinLinter , createPolicyLinter , requestLinter } from '@/app/utils/casbinLinter' ;
34+ import { isInsideIframe } from '@/app/utils/iframeDetector' ;
3435import { useLang } from '@/app/context/LangContext' ;
3536import { useAutoCarousel } from '@/app/context/AutoCarouselContext' ;
3637import type { EngineType } from '@/app/config/engineConfig' ;
@@ -69,6 +70,11 @@ export const EditorScreen = () => {
6970 const skipNextEffectRef = useRef ( false ) ;
7071 const sidePanelChatRef = useRef < { openDrawer : ( message : string ) => void } | null > ( null ) ;
7172 const policyViewRef = useRef < any | null > ( null ) ;
73+
74+ // Memoize iframe detection since it doesn't change during the session
75+ const isIframe = useMemo ( ( ) => {
76+ return isInsideIframe ( ) ;
77+ } , [ ] ) ;
7278 const { setupEnforceContextData, setupHandleEnforceContextChange } = useSetupEnforceContext ( {
7379 onChange : setEnforceContextDataPersistent ,
7480 data : enforceContextData ,
@@ -256,32 +262,34 @@ export const EditorScreen = () => {
256262 return (
257263 < div className = "flex flex-col h-full w-full overflow-hidden" >
258264 < Toaster position = "top-center" />
259- { /* Header with Casbin logo and Policy Editor text */ }
260- < div
261- className = { clsx (
262- 'flex items-center gap-3 px-4 py-2 border-b border-border' ,
263- theme === 'dark' ? 'bg-slate-900' : 'bg-white' ,
264- ) }
265- >
266- < img
267- src = "https://cdn.casbin.org/img/casbin_logo_1024x256.png"
268- alt = "Casbin Logo"
269- className = "h-8 w-auto"
270- />
271- < span className = { clsx ( 'text-xl font-semibold' , textClass ) } > { t ( 'Policy Editor' ) } </ span >
272- < a
273- href = "/gallery"
265+ { /* Header with Casbin logo and Policy Editor text - hidden when inside iframe */ }
266+ { ! isIframe && (
267+ < div
274268 className = { clsx (
275- 'ml-auto px-4 py-2 rounded-lg font-medium transition-all duration-200' ,
276- 'bg-primary text-primary-foreground' ,
277- 'hover:bg-primary/90 shadow-sm hover:shadow-md' ,
278- 'flex items-center gap-2' ,
269+ 'flex items-center gap-3 px-4 py-2 border-b border-border' ,
270+ theme === 'dark' ? 'bg-slate-900' : 'bg-white' ,
279271 ) }
280272 >
281- < img src = "/modelGallery.svg" alt = "Model Gallery" className = { clsx ( 'w-5 h-5' , iconFilterClass ) } />
282- < span > { t ( 'Model Gallery' ) } </ span >
283- </ a >
284- </ div >
273+ < img
274+ src = "https://cdn.casbin.org/img/casbin_logo_1024x256.png"
275+ alt = "Casbin Logo"
276+ className = "h-8 w-auto"
277+ />
278+ < span className = { clsx ( 'text-xl font-semibold' , textClass ) } > { t ( 'Policy Editor' ) } </ span >
279+ < a
280+ href = "/gallery"
281+ className = { clsx (
282+ 'ml-auto px-4 py-2 rounded-lg font-medium transition-all duration-200' ,
283+ 'bg-primary text-primary-foreground' ,
284+ 'hover:bg-primary/90 shadow-sm hover:shadow-md' ,
285+ 'flex items-center gap-2' ,
286+ ) }
287+ >
288+ < img src = "/modelGallery.svg" alt = "Model Gallery" className = { clsx ( 'w-5 h-5' , iconFilterClass ) } />
289+ < span > { t ( 'Model Gallery' ) } </ span >
290+ </ a >
291+ </ div >
292+ ) }
285293 { /* Main content area */ }
286294 < div className = "flex flex-col sm:flex-row flex-1 overflow-hidden" >
287295 { /* Mobile sidebar toggle - shown only on mobile when showCustomConfig is true */ }
0 commit comments