diff --git a/src/selector_manager/index.ts b/src/selector_manager/index.ts index 83fdaccc6..4fa9f572c 100644 --- a/src/selector_manager/index.ts +++ b/src/selector_manager/index.ts @@ -83,6 +83,7 @@ import ClassTagsView from './view/ClassTagsView'; import EditorModel from '../editor/model/Editor'; import Component from '../dom_components/model/Component'; import { ItemManagerModule } from '../abstract/Module'; +import { StyleModuleParam } from '../style_manager'; const isId = (str: string) => isString(str) && str[0] == '#'; const isClass = (str: string) => isString(str) && str[0] == '.'; @@ -185,9 +186,9 @@ export default class SelectorManager extends ItemManagerModule, opts: StyleModuleParam<'select', 1> = {}) { const targets = Array.isArray(value) ? value : [value]; - const toSelect: any[] = this.em.get('StyleManager').select(targets, opts); + const toSelect: any[] = this.em.Styles.select(targets, opts); this.selected.reset(this.__getCommonSelectors(toSelect)); const selTags = this.selectorTags; const res = toSelect diff --git a/src/style_manager/index.ts b/src/style_manager/index.ts index c55092e6f..882d59bcf 100644 --- a/src/style_manager/index.ts +++ b/src/style_manager/index.ts @@ -96,6 +96,8 @@ export const evLayerSelect = `${evPfx}layer:select`; export const evTarget = `${evPfx}target`; export const evCustom = `${evPfx}custom`; +export type StyleModuleParam = Parameters[N]; + const propDef = (value: any) => value || value === 0; const events = { @@ -359,7 +361,10 @@ export default class StyleManager extends ItemManagerModule< * // Set as a target the CSS selector * styleManager.select('.btn > span'); */ - select(target: StyleTarget | string, opts: { stylable?: boolean; component?: Component } = {}) { + select( + target: StyleTarget | string | (StyleTarget | string)[], + opts: { stylable?: boolean; component?: Component } = {} + ) { const { em } = this; const trgs = isArray(target) ? target : [target]; const { stylable } = opts; @@ -375,7 +380,7 @@ export default class StyleManager extends ItemManagerModule< model = rule; } - targets.push(model); + targets.push(model as StyleTarget); }); const component = opts.component || targets.filter(t => isComponent(t)).reverse()[0];