import { EditorState, Transaction, Command } from 'prosemirror-state'; import { Node } from 'prosemirror-model'; import { EditorView } from 'prosemirror-view'; import { I as ImageLayoutTarget, S as SetImageWrapTypeOptions } from './ImageExtension-BlI5afZD.js'; /** * Image commands — thin re-exports from the extension system. * * Wrap-type transitions for floating images. Inline↔anchor conversions are * structural and live in a follow-up; this surface only covers anchor↔anchor. */ /** * Insert an image node at `pos`, wrapping with the `insertion` mark when * suggesting mode is active. Centralizes the tracked-image-insert flow * so React `useFileIO`, Vue `useImageActions`, and clipboard-paste * paths all share one source of truth — adding a fresh image in * suggesting mode always round-trips as `{run with drawing}`. * * Caller responsibility: produce the `image` node via `schema.nodes.image.create`. * This helper handles the dispatch + optional mark application. * * @public */ declare function insertImageNode(state: EditorState, dispatch: ((tr: Transaction) => void) | undefined, imageNode: Node, pos: number): boolean; /** * Default max width (px) for an image inserted from a file picker — the content * area of a US Letter page at 96dpi (~6.375in). Images wider than this are * scaled down to fit the column, matching Word and keeping the painter's * `max-width: 100%` from shrinking the rendered height out from under the * reserved line height (which would leave a gap below the image). */ declare const INSERT_IMAGE_MAX_WIDTH_PX = 612; /** * Result returned by a host that persists an image outside the collaborative * document. The identifier must be opaque: it is safe to share in document * state, but it is not itself a URL or bearer credential. * * @public */ interface ImageUploadResult { assetId: string; } /** * Metadata supplied to a host image uploader after the browser has decoded * the local file. Dimensions are the original pixel dimensions, before the * editor scales the rendered node to the page width. * * @public */ interface ImageUploadContext { width: number; height: number; } /** * Optional host hook for persisting image bytes before an image node is * inserted. When present, the editor inserts only the returned opaque asset * identity and never places a data URL in ProseMirror. * * @public */ type ImageUploadHandler = (file: File, context: ImageUploadContext) => Promise; /** * Options for {@link insertImageFromFile}. * * @public */ interface InsertImageFromFileOptions { maxWidth?: number; imageUploadHandler?: ImageUploadHandler; onError?: (error: unknown) => void; onInserted?: () => void; } /** * Read an image `File` (from a file picker or drop), fit it to the page width, * and insert it inline at the current selection. This is the single source of * truth for "insert an image from a file" — the React and Vue adapters both * call it, so insertion behaves identically: no intermediate dialog, the image * is sized to fit the column, and it round-trips as an inline drawing (with the * `insertion` mark applied in suggesting mode, via {@link insertImageNode}). * * By default the file is stored as a data URL for backward compatibility. If * `imageUploadHandler` is provided, the file is decoded through a temporary * object URL, uploaded before insertion, and only the returned opaque asset ID * is stored in the node. `onError` reports a failed read, decode, or upload, * and `onInserted` runs after the node lands (e.g. to refocus). * * @public */ declare function insertImageFromFile(view: EditorView, file: File, opts?: InsertImageFromFileOptions): Promise; /** * Change a floating image's wrap layout. `pos` is the PM document position of * the image node; `target` is either an OOXML wrap type (square / tight / * topAndBottom / behind / inFront / inline) or a directional convenience * choice (`squareLeft` / `squareRight`). * * `opts.initialPositionEmu` is used when promoting an inline image to an * anchor — the caller measures the image's current rendered offset relative * to the column origin in EMUs and passes it through, so the new float lands * exactly where the inline glyph used to sit (matches Word's behavior). */ declare function setImageWrapType(pos: number, target: ImageLayoutTarget, opts?: SetImageWrapTypeOptions): Command; export { type ImageUploadHandler as I, INSERT_IMAGE_MAX_WIDTH_PX as a, type ImageUploadContext as b, type ImageUploadResult as c, type InsertImageFromFileOptions as d, insertImageNode as e, insertImageFromFile as i, setImageWrapType as s };