import { HardAs, LiteralObject, Point, Rectangle, ReturnValueFn } from '@p-lc/shared'; import { Get } from 'type-fest'; import { AnyEditorPlugin, Editor, EditorDefaultPropertiesExtHkt, EditorDefaultPropertiesExtHktPlugin, EditorRawPlugin } from '../../types'; import { editorPluginEmitter } from '../editor-plugin-emitter'; import { editorPluginRootHost } from '../editor-plugin-root-host'; /** * 编辑器拖放仓库插件属性扩展高等类型 */ export interface EditorPluginDndStorePropertiesExtHkt { editor: { /** * 发射器事件 */ emitterEvents: { /** * 拖拽开始 */ dragStart: { /** * 实体 */ entity: DraggableEntity; /** * 点 */ point: Point; }; /** * 拖拽移动 */ dragMove: { /** * 点 */ point: Point; /** * 事件目标 */ target: EventTarget | null; }; /** * 拖拽移动带位置 */ dragMoveWithPos: { /** * 点 */ point: Point; /** * 位置 */ pos: DroppablePosition | null; }; /** * 拖拽结束 */ dragEnd: void; }; /** * 拖放仓库 */ dndStore: { /** * 可拖拽实体,由其他插件扩展,只用于类型推导 */ draggableEntities: LiteralObject; /** * 可放置位置,由其他插件扩展,只用于类型推导 */ droppablePositions: LiteralObject; /** * 拖拽中的实体 */ draggingEntity: DraggableEntity | null; /** * 准备距离 */ preparingDistance: number; /** * 准备(拖拽)中 */ isPreparing: boolean; /** * 拖拽中 */ isDragging: boolean; /** * 拖拽中的点 */ draggingPoint: Point; /** * 可放置选项映射表 */ droppableOptionsMap: Map>>; /** * 悬浮的(可放置)位置 */ hoveringPosition: DroppablePosition | null; /** * 可放置位置操作映射表 */ droppablePositionActionMap: Map, DroppablePositionAction>; /** * 自动滚动(判定)距离,默认:50 */ autoScrollDistance: number; /** * 自动滚动速度,每秒滚动的像素值,默认:500 */ autoScrollSpeed: number; /** * 拖拽开始 * @param entity 实体 * @param point 点 */ dragStart(entity: DraggableEntity, point: Point): void; /** * 拖拽移动 * @param point 点 * @param target 事件目标 */ dragMove(point: Point, target: EventTarget | null): void; /** * 拖拽结束 */ dragEnd(): void; /** * 应该阻止点击事件,拖拽后产生的点击事件需要被阻止 */ shouldPreventClick(): boolean; /** * 应该阻止点击事件时长,默认 100 毫秒 */ shouldPreventClickDuration: number; }; }; } /** * 编辑器事件键值:拖拽开始 */ export declare const EDITOR_EVENT_KEY_DRAG_START = "dragStart"; /** * 编辑器事件键值:拖拽移动 */ export declare const EDITOR_EVENT_KEY_DRAG_MOVE = "dragMove"; /** * 编辑器事件键值:拖拽移动带位置 */ export declare const EDITOR_EVENT_KEY_DRAG_MOVE_WITH_POS = "dragMoveWithPos"; /** * 编辑器事件键值:拖拽结束 */ export declare const EDITOR_EVENT_KEY_DRAG_END = "dragEnd"; /** * 可拖拽实体基础部分 */ export interface DraggableEntityBase { /** * 类型 */ type: string; } /** * 可拖拽实体 */ export type DraggableEntities = Get, [ 'dndStore', 'draggableEntities' ]>; /** * 可拖拽实体 */ export type DraggableEntity = HardAs, [DraggableEntityType]>, DraggableEntityBase>; /** * 可拖拽实体类型 */ export type DraggableEntityType = HardAs, string>; /** * 可放置位置基础部分 */ export interface DroppablePositionBase { /** * 类型 */ type: string; /** * 边界 */ bounding: Rectangle; } /** * 可放置位置 */ export type DroppablePositions = Get, [ 'dndStore', 'droppablePositions' ]>; /** * 可放置位置 */ export type DroppablePosition = HardAs, [DroppablePositionType]>, DroppablePositionBase>; /** * 可放置位置类型 */ export type DroppablePositionType = HardAs, string>; /** * 可放置位置操作 */ export interface DroppablePositionAction { /** * 可放置位置操作 * @param entity 实体 * @param pos 位置 */ (entity: DraggableEntity, pos: DroppablePosition): void; } /** * 可放置选项 */ export interface DroppableOptions { /** * 计算悬浮的位置 */ calcHoveringPosition: CaclHoveringPosition; } /** * 计算悬浮的位置,当拖拽到当前原生元素上方时会触发 */ export interface CaclHoveringPosition { /** * 计算悬浮的位置,当拖拽到当前原生元素上方时会触发 * @param entity 实体 * @param point 鼠标悬浮的点 * @param el HTML 元素 * @returns 返回位置或 null 将不会继续遍历原生父元素 */ (entity: DraggableEntity, point: Point, el: HTMLElement): DroppablePosition | null | void; } /** * EditorPluginDndStorePropertiesExtHkt 辅助类型 */ export interface $EditorPluginDndStorePropertiesExtHkt extends EditorDefaultPropertiesExtHkt { type: EditorPluginDndStorePropertiesExtHkt>; } /** * 编辑器拖放仓库插件 */ export declare const editorPluginDndStore: EditorRawPlugin<$EditorPluginDndStorePropertiesExtHkt, typeof editorPluginEmitter | typeof editorPluginRootHost>; //# sourceMappingURL=editor-plugin-dnd-store.d.ts.map