import { InspectorControls } from '@wordpress/block-editor'; import { PanelBody, TextControl, BaseControl, SelectControl, Button, CheckboxControl, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { useLanguage } from '../../hooks/useLanguage'; import { useGlobalStore } from '../../state/global'; import { useLanguageStore } from '../../state/language'; import { useThemeStore } from '../../state/theme'; import { AttributesPropsAndSetter } from '../../types'; import { languages } from '../../util/languages'; import { FontSizeSelect, FontLineHeightSelect, FontFamilySelect, } from '../components/FontSelect'; import { FooterSelect } from '../components/FooterSelect'; import { HeaderSelect } from '../components/HeaderSelect'; import { HeightPanel } from '../components/HeightPanel'; import { ThemesPanel } from '../components/ThemesPanel'; import { BlurControl } from './BlurControl'; import { HighlightingControl } from './HighlightingControl'; export const SidebarControls = ({ attributes, setAttributes, }: AttributesPropsAndSetter) => { const [language, setLanguage] = useLanguage({ attributes, setAttributes }); const { recentLanguages } = useLanguageStore(); const { updateThemeHistory } = useThemeStore(); const { setPreviousSettings } = useGlobalStore(); const { headerType, footerType } = attributes; const footersNeedingLinks = ['simpleStringEnd', 'simpleStringStart']; const showHeaderTextEdit = ['simpleString'].includes(headerType); const showFooterTextEdit = footersNeedingLinks.includes(footerType); const showFooterLinkEdit = footersNeedingLinks.includes(footerType); const showFooterLinkTargetEdit = footersNeedingLinks.includes(footerType); return (
({ label: label.replace( 'ANSI', 'ANSI (experimental)', ), value, }), )} /> {recentLanguages?.length > 0 ? ( <> {__('Recently Used', 'code-block-pro')}
{recentLanguages?.map((lang) => ( ))}
) : null}
{showHeaderTextEdit && ( { setAttributes({ headerString }); }} value={attributes.headerString ?? ''} /> )} {showFooterTextEdit && ( { setAttributes({ footerString }); }} value={attributes.footerString ?? ''} /> )} {showFooterLinkEdit && ( { setAttributes({ footerLink }); }} value={attributes.footerLink ?? ''} /> )} {showFooterLinkTargetEdit && ( { setAttributes({ footerLinkTarget }); updateThemeHistory({ ...attributes, footerLinkTarget, }); }} /> )}
{ setAttributes({ lineNumbers }); updateThemeHistory({ ...attributes, lineNumbers, }); }} /> {attributes.lineNumbers && ( { setAttributes({ startingLineNumber }); }} value={attributes.startingLineNumber} /> )}
{ setAttributes({ headerType }); updateThemeHistory({ ...attributes, headerType }); }} /> { setAttributes({ footerType }); updateThemeHistory({ ...attributes, footerType }); }} />

{__('Font Size', 'code-block-pro')}

{ setAttributes({ fontSize }); updateThemeHistory({ ...attributes, fontSize }); }} />

{__('Line Height', 'code-block-pro')}

{ setAttributes({ lineHeight }); updateThemeHistory({ ...attributes, lineHeight, }); }} />
{ setAttributes({ fontFamily }); updateThemeHistory({ ...attributes, fontFamily, }); }} />
{ setAttributes({ clampFonts }); updateThemeHistory({ ...attributes, clampFonts, }); }} />
{ setPreviousSettings({ copyButton: value }); setAttributes({ copyButton: value }); }} /> { setAttributes({ disablePadding }); updateThemeHistory({ ...attributes, disablePadding, }); }} />
); };