import * as React from 'react'; import { Actions } from './components/Actions'; import { BaseView } from './components/BaseView'; import { GlobalSettings } from './components/GlobalSettings'; import { OtherActions } from './components/OtherActions'; import { SeoStatus } from './components/SeoStatus'; import { Spinner } from './components/Spinner'; import { FolderAndFiles } from './components/FolderAndFiles'; import { Metadata } from './components/Metadata'; import { SponsorMsg } from './components/SponsorMsg'; import useMessages from './hooks/useMessages'; import { FeatureFlag } from '../components/features/FeatureFlag'; import { FEATURE_FLAG } from '../constants/Features'; import { GitAction } from './components/Git/GitAction'; import { CustomView } from './components/CustomView'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { usePrevious } from './hooks/usePrevious'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; import { InitializeAction } from './components/InitializeAction'; export interface IViewPanelProps { } export const ViewPanel: React.FunctionComponent = ( { }: React.PropsWithChildren ) => { const [isDevMode, setIsDevMode] = useState(false); const { loading, mediaSelecting, metadata, settings, folderAndFiles, focusElm, unsetFocus, localeReady, mode } = useMessages(); const prevMediaSelection = usePrevious(mediaSelecting); const [scrollY, setScrollY] = useState(0); const allPanelValues = useMemo(() => { return Object.values(FEATURE_FLAG.panel).filter(v => v !== FEATURE_FLAG.panel.globalSettings) }, [FEATURE_FLAG.panel]); const scollListener = useCallback((e: Event) => { if (!mediaSelecting) { setScrollY(window.scrollY); } }, [mediaSelecting]); useEffect(() => { if (prevMediaSelection && !mediaSelecting) { setTimeout(() => { window.scrollTo({ top: scrollY, }) }, 10); } }, [mediaSelecting, prevMediaSelection]); useEffect(() => { window.addEventListener('scroll', scollListener, true); return () => { window.removeEventListener('scroll', scollListener, true); } }, [mediaSelecting]); useEffect(() => { if (window.fmExternal && window.fmExternal.isDevelopment) { setIsDevMode(true); } }, []); if (mediaSelecting) { return (

{l10n.t(LocalizationKey.panelViewPanelMediaInsert)}

); } if (loading && !localeReady) { return ; } if (!metadata || Object.keys(metadata || {}).length === 0) { return ; } return (
{ isDevMode && ( ) }
{!loading && ()} { !loading && settings && settings.seo && ( ) } {!loading && settings && metadata && ( )} { !loading && ( ) }
); };