import type { ServiceIdentifier } from '@blocksuite/global/di'; import type { IBound, IPoint } from '@blocksuite/global/gfx'; import { Signal } from '@preact/signals-core'; import type { PointerEventState } from '../../event/index.js'; import type { GfxController } from '../controller.js'; import { GfxExtension } from '../extension.js'; import { type BaseTool, type GfxToolsFullOptionValue, type GfxToolsMap, type GfxToolsOption } from './tool.js'; type BuiltInHookEvent = { data: T; preventDefault(): void; }; type BuiltInEventMap = { beforeToolUpdate: BuiltInHookEvent<{ toolName: keyof GfxToolsMap; }>; toolUpdate: BuiltInHookEvent<{ toolName: keyof GfxToolsMap; }>; }; export type SupportedHooks = keyof BuiltInEventMap; declare const supportedEvents: readonly ["dragStart", "dragEnd", "dragMove", "pointerMove", "contextMenu", "pointerDown", "pointerUp", "click", "doubleClick", "tripleClick", "pointerOut"]; export type SupportedEvents = (typeof supportedEvents)[number]; export declare enum MouseButton { FIFTH = 4, FOURTH = 3, MAIN = 0, MIDDLE = 1, SECONDARY = 2 } export interface ToolEventTarget { /** * Add a hook before the event is handled by the tool. * Return false to prevent the tool from handling the event. * @param evtName * @param handler */ addHook(evtName: K, handler: (evtState: K extends SupportedHooks ? BuiltInEventMap[K] : PointerEventState) => void | boolean): void; } export declare const eventTarget: unique symbol; export declare class ToolController extends GfxExtension { static key: string; private readonly _builtInHookSlot; private readonly _disposableGroup; private readonly _toolOption$; private readonly _tools; readonly currentToolName$: Signal; readonly dragging$: Signal; /** * The area that is being dragged. * The coordinates are in browser space. */ readonly draggingViewArea$: Signal; /** * The last mouse move position * The coordinates are in browser space */ readonly lastMousePos$: Signal; get currentTool$(): { readonly value: BaseTool> | undefined; peek(): BaseTool> | undefined; }; get currentToolOption$(): { peek(): GfxToolsFullOptionValue; readonly value: GfxToolsFullOptionValue; }; /** * The area that is being dragged. * The coordinates are in model space. */ get draggingArea$(): { value(): { x: number; y: number; w: number; h: number; startX: number; startY: number; endX: number; endY: number; }; peek(): { x: number; y: number; w: number; h: number; startX: number; startY: number; endX: number; endY: number; }; }; static extendGfx(gfx: GfxController): void; private _createBuiltInHookCtx; private _initializeEvents; private _register; get(key: K): GfxToolsMap[K]; mounted(): void; setTool(toolName: GfxToolsFullOptionValue, ...args: [void]): void; setTool(toolName: K, ...args: K extends keyof GfxToolsOption ? [option: GfxToolsOption[K]] : [void]): void; unmounted(): void; } export declare const ToolControllerIdentifier: ServiceIdentifier; declare module '../controller.js' { interface GfxController { readonly tool: ToolController; } } export {}; //# sourceMappingURL=tool-controller.d.ts.map