/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-editor/src/components/block-list/layout.js
41 строка
1012 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { createContext, useContext } from '@wordpress/element'; import { getLayoutType } from '../../layouts'; import { useSettings } from '../use-settings'; export const defaultLayout = { type: 'default' }; const Layout = createContext( defaultLayout ); Layout.displayName = 'BlockLayoutContext'; /** * Allows to define the layout. */ export const LayoutProvider = Layout.Provider; /** * React hook used to retrieve the layout config. */ export function useLayout() { return useContext( Layout ); } export function LayoutStyle( { layout = {}, css, ...props } ) { const layoutType = getLayoutType( layout.type ); const [ blockGapSupport ] = useSettings( 'spacing.blockGap' ); const hasBlockGapSupport = blockGapSupport !== null; if ( layoutType ) { if ( css ) { return <style>{ css }</style>; } const layoutStyle = layoutType.getLayoutStyle?.( { hasBlockGapSupport, layout, ...props, } ); if ( layoutStyle ) { return <style>{ layoutStyle }</style>; } } return null; }