import { fsm2 } from "@heydovetail/ui-components"; import { Plugin, Transaction } from "prosemirror-state"; import { EditorSchema, NodeTypeName } from "../schema"; import { DocPos } from "../types"; import { PortalProviderApi } from "../util/PortalProvider"; import { AttachmentService } from "./AttachmentService"; export declare const enum FileSource { DRAG_DROP = 0, PASTE = 1, FILE_PICKER = 2 } /** * An attachment upload that is pending, i.e. waiting for an `id` from * `AttachmentService`. In practice this happens when interacting with the notes * service and waiting for an ID to be confirmed. */ export interface PendingItem { readonly pos: DocPos; readonly id: string; readonly source: FileSource; } interface PendingState { readonly type: "default"; readonly items: ReadonlyArray; } export declare const transitionPending: (state: CurrentStateShape) => CurrentStateShape extends PendingState ? fsm2.Transition; }) => { type: "default"; items: PendingItem[]; }; remove: ({ type, items }: PendingState, opts: { id: string; }) => { type: "default"; items: PendingItem[]; }; add: ({ type, items }: PendingState, opts: { items: ReadonlyArray; }) => { type: "default"; items: PendingItem[]; }; }; }, { default: { tr: (prev: PendingState, { tr }: { tr: Transaction; }) => { type: "default"; items: PendingItem[]; }; remove: ({ type, items }: PendingState, opts: { id: string; }) => { type: "default"; items: PendingItem[]; }; add: ({ type, items }: PendingState, opts: { items: ReadonlyArray; }) => { type: "default"; items: PendingItem[]; }; }; } extends { [key in CurrentStateShape["type"]]: infer T; } ? T : never> : never; export declare type DropPreviewState = { readonly type: "hidden"; } | { readonly type: "visible"; readonly pos: DocPos; }; export declare const transitionDropPreview: (state: CurrentStateShape) => CurrentStateShape extends DropPreviewState ? fsm2.Transition; }) => { readonly type: "hidden"; }; visible: (_: { readonly type: "hidden"; }, { pos }: { pos: DocPos; }) => { type: "visible"; pos: DocPos; }; }; visible: { tr: (prev: { readonly type: "visible"; readonly pos: DocPos; }, { tr }: { tr: Transaction; }) => { type: "hidden"; pos?: undefined; } | { type: "visible"; pos: DocPos; }; hidden: () => { type: "hidden"; }; visible: (_: { readonly type: "visible"; readonly pos: DocPos; }, { pos }: { pos: DocPos; }) => { type: "visible"; pos: DocPos; }; }; }, { hidden: { tr: (prev: { readonly type: "hidden"; }, _: { tr: Transaction; }) => { readonly type: "hidden"; }; visible: (_: { readonly type: "hidden"; }, { pos }: { pos: DocPos; }) => { type: "visible"; pos: DocPos; }; }; visible: { tr: (prev: { readonly type: "visible"; readonly pos: DocPos; }, { tr }: { tr: Transaction; }) => { type: "hidden"; pos?: undefined; } | { type: "visible"; pos: DocPos; }; hidden: () => { type: "hidden"; }; visible: (_: { readonly type: "visible"; readonly pos: DocPos; }, { pos }: { pos: DocPos; }) => { type: "visible"; pos: DocPos; }; }; } extends { [key in CurrentStateShape["type"]]: infer T; } ? T : never> : never; export interface PluginState { dropPreview: DropPreviewState; pending: PendingState; presentFilePicker: { accept: string; } | null; } declare const 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 { setPluginState, getPluginStateOrThrow }; export declare class AttachmentPlugin extends Plugin { private readonly selectionSubject; private readonly editableSubject; constructor(portalProviderApi: PortalProviderApi, attachmentService: AttachmentService); }