/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/customize-widgets/src/controls/sidebar-control.js
58 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { dispatch } from '@wordpress/data'; import SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter'; import getInserterOuterSection from './inserter-outer-section'; import { store as customizeWidgetsStore } from '../store'; const getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`; export default function getSidebarControl() { const { wp: { customize }, } = window; return class SidebarControl extends customize.Control { constructor( ...args ) { super( ...args ); this.subscribers = new Set(); } ready() { const InserterOuterSection = getInserterOuterSection(); this.inserter = new InserterOuterSection( getInserterId( this.id ), {} ); customize.section.add( this.inserter ); this.sectionInstance = customize.section( this.section() ); this.inspector = this.sectionInstance.inspector; this.sidebarAdapter = new SidebarAdapter( this.setting, customize ); } subscribe( callback ) { this.subscribers.add( callback ); return () => { this.subscribers.delete( callback ); }; } onChangeSectionExpanded( expanded, args ) { if ( ! args.unchanged ) { // Close the inserter when the section collapses. if ( ! expanded ) { dispatch( customizeWidgetsStore ).setIsInserterOpened( false ); } this.subscribers.forEach( ( subscriber ) => subscriber( expanded, args ) ); } } }; }