From cc47a01865bc11558bac8044c5b6de9d88302c12 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 17 Feb 2026 14:34:37 +0400 Subject: [PATCH] Add callback types to StyleManager --- packages/core/src/editor/types.ts | 5 +-- packages/core/src/style_manager/index.ts | 4 +-- packages/core/src/style_manager/types.ts | 42 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/packages/core/src/editor/types.ts b/packages/core/src/editor/types.ts index 2c8d415e5..82b88b3d5 100644 --- a/packages/core/src/editor/types.ts +++ b/packages/core/src/editor/types.ts @@ -15,7 +15,7 @@ import { ParserEvent, ParserEventCallback } from '../parser/types'; import { RichTextEditorEvent, RichTextEditorEventCallback } from '../rich_text_editor'; import { SelectorEvent, SelectorEventCallback } from '../selector_manager/types'; import { StorageEvent, StorageEventCallback } from '../storage_manager/types'; -import { StyleManagerEvent } from '../style_manager'; +import { StyleManagerEvent, StyleManagerEventCallback } from '../style_manager/types'; import { EditorConfig } from './config/config'; import EditorModel from './model/Editor'; @@ -62,7 +62,8 @@ export interface EditorEventCallbacks ParserEventCallback, RichTextEditorEventCallback, SelectorEventCallback, - StorageEventCallback + StorageEventCallback, + StyleManagerEventCallback { [key: string]: any[]; } diff --git a/packages/core/src/style_manager/index.ts b/packages/core/src/style_manager/index.ts index de5abf53c..a64d4b70f 100644 --- a/packages/core/src/style_manager/index.ts +++ b/packages/core/src/style_manager/index.ts @@ -68,9 +68,7 @@ import { PropertyTypes, StyleManagerEvents, StyleTarget } from './types'; import { CustomPropertyView } from './view/PropertyView'; import SectorsView from './view/SectorsView'; -export type { PropertyTypes, StyleModuleParam, StyleTarget } from './types'; - -export type StyleManagerEvent = `${StyleManagerEvents}`; +export type { PropertyTypes, StyleManagerEventCallback, StyleModuleParam, StyleTarget } from './types'; const propDef = (value: any) => value || value === 0; diff --git a/packages/core/src/style_manager/types.ts b/packages/core/src/style_manager/types.ts index e4b432a6c..0193116af 100644 --- a/packages/core/src/style_manager/types.ts +++ b/packages/core/src/style_manager/types.ts @@ -1,5 +1,10 @@ import StyleManager from '.'; +import { AddOptions, ObjectAny, RemoveOptions } from '../common'; import StyleableModel from '../domain_abstract/model/StyleableModel'; +import Property, { PropertyProps } from './model/Property'; +import PropertyStack from './model/PropertyStack'; +import Sector, { SectorProperties } from './model/Sector'; +import Sectors from './model/Sectors'; import { PropertyNumberProps } from './model/PropertyNumber'; import { PropertySelectProps } from './model/PropertySelect'; import { PropertyStackProps } from './model/PropertyStack'; @@ -84,5 +89,42 @@ export enum StyleManagerEvents { } /**{END_EVENTS}*/ +export type StyleManagerEvent = `${StyleManagerEvents}`; + +export interface StyleManagerPropertyUpdateEventData { + property: Property; + from: Partial; + to: Partial; + value: any; + opts: ObjectAny; +} + +export interface StyleManagerLayerSelectEventData { + property: PropertyStack; +} + +export interface StyleManagerCustomEventData { + container: HTMLElement | undefined; +} + +export interface StyleManagerAllEventData { + event: string; + model?: Sector | Sectors; + options: ObjectAny; +} + +export interface StyleManagerEventCallback { + [StyleManagerEvents.sectorAdd]: [Sector, AddOptions]; + [StyleManagerEvents.sectorRemove]: [Sector, RemoveOptions]; + [StyleManagerEvents.sectorUpdate]: [Sector, Partial, ObjectAny]; + [StyleManagerEvents.propertyAdd]: [Property, AddOptions]; + [StyleManagerEvents.propertyRemove]: [Property, RemoveOptions]; + [StyleManagerEvents.propertyUpdate]: [StyleManagerPropertyUpdateEventData]; + [StyleManagerEvents.target]: [StyleTarget | undefined]; + [StyleManagerEvents.layerSelect]: [StyleManagerLayerSelectEventData]; + [StyleManagerEvents.custom]: [StyleManagerCustomEventData]; + [StyleManagerEvents.all]: [StyleManagerAllEventData]; +} + // need this to avoid the TS documentation generator to break export default StyleManagerEvents;