import { Range, Selection } from './selection'; import { Component, Formatter, FormatValue, ComponentConstructor, Attribute, StackableFormatter, State } from '../model/_api'; /** * Textbus 状态查询状态枚举 */ export declare enum QueryStateType { /** 正常 */ Normal = "Normal", /** 当前不可用 */ Disabled = "Disabled", /** 当前状态为生效 */ Enabled = "Enabled" } /** * Textbus 状态查询结果;`state === Enabled` 时 `value` 为 `V`,否则为 `null`。 */ export type QueryState = { state: QueryStateType.Normal; value: null; } | { state: QueryStateType.Disabled; value: null; } | { state: QueryStateType.Enabled; value: V; }; /** * 查询可堆叠格式时的结果:`Enabled` 时 `value` 为选区内该格式的全部取值(含重叠多条)。 */ export type QueryStackableState = { state: QueryStateType.Normal; value: null; } | { state: QueryStateType.Disabled; value: null; } | { state: QueryStateType.Enabled; value: T[]; }; /** * Textbus 状态查询类,用于查询组件或格式在当前选区的状态 */ export declare class Query { private selection; constructor(selection: Selection); /** * 查询格式在当前选区的状态 * @param formatter 要查询的格式 */ queryFormat(formatter: StackableFormatter): QueryStackableState; queryFormat(formatter: Formatter): QueryState; /** * 根据指定范围查询格式在当前选区的状态 * @param formatter 要查询的格式 * @param range 要查询的格式的范围 */ queryFormatByRange(formatter: StackableFormatter, range: Range): QueryStackableState; queryFormatByRange(formatter: Formatter, range: Range): QueryState; /** * 查询属性在当前选区的状态 * @param attribute */ queryAttribute(attribute: Attribute): QueryState; /** * 根据指定范围查询属性在当前选区的状态 * @param attribute * @param range */ queryAttributeByRange(attribute: Attribute, range: Range): QueryState; /** * 查询组件在选区内的状态 * @param componentConstructor 要查询的组件 * @param filter 查询结构过滤函数,过滤不需要的数据 */ queryComponent>(componentConstructor: U, filter?: (instance: Component) => boolean): QueryState>; /** * 根据指定范围查询组件在选区内的状态 * @param componentConstructor 要查询的组件 * @param range 要查询的范围 * @param filter 查询结构过滤函数,过滤不需要的数据 */ queryComponentByRange>(componentConstructor: U, range: Range, filter?: (instance: Component) => boolean): QueryState>; /** * 查询当前选区是否包含在组件内 * @param componentConstructor 要查询的组件 */ queryWrappedComponent(componentConstructor: ComponentConstructor): QueryState>; /** * 查询当前选区是否包含在组件内 * @param componentConstructor 要查询的组件 * @param range 要查询的范围 */ queryWrappedComponentByRange(componentConstructor: ComponentConstructor, range: Range): QueryState>; private getStatesByRange; private compareFormatRanges; /** * 选区内每个下标位置都至少有一条该 formatter 的 range 覆盖时返回 true。 */ private isRangeFullyCoveredByFormatter; /** * 可堆叠格式:选区并集全覆盖时返回按 range 排序后的全部 value;否则 null。 */ private getStackableStatesByRange; private mergeStackableScopes; private queryFormatByScopes; private mergeState; private getWrappedStateByComponent; private getStateByComponent; private getStateByAttribute; }