import { fsm2 } from "@heydovetail/ui-components"; import { Plugin, Transaction } from "prosemirror-state"; import { Observable } from "rxjs"; import { PluginState as RangePluginState } from "../range/RangePlugin"; import { EditorSchema } from "../schema"; import { PortalProviderApi } from "../util/PortalProvider"; export interface TagGroup { id: string; title: string; color: string; tags: Tag[]; } export interface Tag { id: string; title: string; color: string; count: number | null; } export declare enum WidgetPluginStateType { DISABLED = "disabled", IDLE = "idle", SELECTING = "selecting", TAGGING = "tagging" } export interface DisabledState { readonly type: WidgetPluginStateType.DISABLED; } export interface IdleState { readonly type: WidgetPluginStateType.IDLE; } export interface SelectingState { readonly type: WidgetPluginStateType.SELECTING; readonly selections: Set<"touch" | "mouse" | "keyboard">; } export interface TaggingState { readonly type: WidgetPluginStateType.TAGGING; readonly selection: { from: number; to: number; }; } export declare type WidgetPluginState = DisabledState | IdleState | SelectingState | TaggingState; export declare const transitionWidget: (state: CurrentStateShape) => CurrentStateShape extends WidgetPluginState ? fsm2.Transition { type: WidgetPluginStateType.IDLE; selection?: undefined; } | { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; tr: (_prev: DisabledState, _: { tr: Transaction; rangePluginState: RangePluginState; }) => DisabledState; }; idle: { updateSelection: (_prev: IdleState, opts: { trigger: "touch" | "mouse" | "keyboard"; action: "remove" | "add"; }) => { type: WidgetPluginStateType.SELECTING; selections: Set<"touch" | "mouse" | "keyboard">; }; idle: (_prev: IdleState) => IdleState; tagging: (_prev: IdleState, selection: { from: number; to: number; }) => { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; toggleActive: (_prev: IdleState, _: { from: number; to: number; } | null) => { type: WidgetPluginStateType.DISABLED; }; tr: (_prev: IdleState, { tr, rangePluginState }: { tr: Transaction; rangePluginState: RangePluginState; }) => IdleState | { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; }; selecting: { idle: () => { type: WidgetPluginStateType.IDLE; }; updateSelection: (_prev: SelectingState, opts: { trigger: "touch" | "mouse" | "keyboard"; action: "remove" | "add"; }) => { type: WidgetPluginStateType.SELECTING; selections: Set<"touch" | "mouse" | "keyboard">; }; tagging: (_prev: SelectingState, selection: { from: number; to: number; }) => { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; toggleActive: (_prev: SelectingState, _: { from: number; to: number; } | null) => { type: WidgetPluginStateType.DISABLED; }; tr: (_prev: SelectingState, _: { tr: Transaction; rangePluginState: RangePluginState; }) => SelectingState; }; tagging: { idle: () => { type: WidgetPluginStateType.IDLE; }; updateSelection: (_prev: TaggingState, opts: { trigger: "touch" | "mouse" | "keyboard"; action: "remove" | "add"; }) => { type: WidgetPluginStateType.SELECTING; selections: Set<"touch" | "mouse" | "keyboard">; }; toggleActive: (_prev: TaggingState, _: { from: number; to: number; } | null) => { type: WidgetPluginStateType.DISABLED; }; tr: (_prev: TaggingState, { tr, rangePluginState }: { tr: Transaction; rangePluginState: RangePluginState; }) => { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; } | { type: WidgetPluginStateType.IDLE; selection?: undefined; }; }; }, { disabled: { toggleActive: (_prev: DisabledState, selection: { from: number; to: number; } | null) => { type: WidgetPluginStateType.IDLE; selection?: undefined; } | { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; tr: (_prev: DisabledState, _: { tr: Transaction; rangePluginState: RangePluginState; }) => DisabledState; }; idle: { updateSelection: (_prev: IdleState, opts: { trigger: "touch" | "mouse" | "keyboard"; action: "remove" | "add"; }) => { type: WidgetPluginStateType.SELECTING; selections: Set<"touch" | "mouse" | "keyboard">; }; idle: (_prev: IdleState) => IdleState; tagging: (_prev: IdleState, selection: { from: number; to: number; }) => { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; toggleActive: (_prev: IdleState, _: { from: number; to: number; } | null) => { type: WidgetPluginStateType.DISABLED; }; tr: (_prev: IdleState, { tr, rangePluginState }: { tr: Transaction; rangePluginState: RangePluginState; }) => IdleState | { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; }; selecting: { idle: () => { type: WidgetPluginStateType.IDLE; }; updateSelection: (_prev: SelectingState, opts: { trigger: "touch" | "mouse" | "keyboard"; action: "remove" | "add"; }) => { type: WidgetPluginStateType.SELECTING; selections: Set<"touch" | "mouse" | "keyboard">; }; tagging: (_prev: SelectingState, selection: { from: number; to: number; }) => { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; }; toggleActive: (_prev: SelectingState, _: { from: number; to: number; } | null) => { type: WidgetPluginStateType.DISABLED; }; tr: (_prev: SelectingState, _: { tr: Transaction; rangePluginState: RangePluginState; }) => SelectingState; }; tagging: { idle: () => { type: WidgetPluginStateType.IDLE; }; updateSelection: (_prev: TaggingState, opts: { trigger: "touch" | "mouse" | "keyboard"; action: "remove" | "add"; }) => { type: WidgetPluginStateType.SELECTING; selections: Set<"touch" | "mouse" | "keyboard">; }; toggleActive: (_prev: TaggingState, _: { from: number; to: number; } | null) => { type: WidgetPluginStateType.DISABLED; }; tr: (_prev: TaggingState, { tr, rangePluginState }: { tr: Transaction; rangePluginState: RangePluginState; }) => { type: WidgetPluginStateType.TAGGING; selection: { from: number; to: number; }; } | { type: WidgetPluginStateType.IDLE; selection?: undefined; }; }; } extends { [key in CurrentStateShape["type"]]: infer T; } ? T : never> : never; export interface PluginState { widgetState: WidgetPluginState; tagGroups: TagGroup[]; tagLookup: Map; } declare const getPluginState: (source: import("prosemirror-state").EditorState | Transaction>) => PluginState | null, getPluginStateOrThrow: (source: import("prosemirror-state").EditorState | Transaction>) => PluginState, setPluginState: (env: { state: import("prosemirror-state").EditorState>; tr?: Transaction> | undefined; dispatch?: ((tr: Transaction>) => void) | undefined; }, newPluginState: PluginState | ((prevPluginState: PluginState) => PluginState)) => void; export { getPluginStateOrThrow, getPluginState, setPluginState }; export declare class HighlightWidgetPlugin extends Plugin { constructor(portalProviderApi: PortalProviderApi, getTagGroups: () => Observable, createTag: (args: { groupId: string | null; title: string; }) => Promise); }