/*!
* Jodit Editor PRO (https://xdsoft.net/jodit/)
* See LICENSE.md in the project root for license information.
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
*/
import type { IFileBrowser } from "jodit/esm/types/index";
import { ViewComponent } from "jodit/esm/core/component/index";
/**
* The `save` callback the core `openImageEditor` passes to `open()`. It routes
* `(newname, box)` to the connector's resize/crop, then fires `success()` and
* (for in-content edits) an `onSuccess(newUrl)` that swaps the `
`.
*
* `action: 'saved'` (jodit ≥ 4.12.34) tells the core the file was already
* persisted by this editor: it skips the server resize/crop and only runs the
* success wiring with `newPath`.
*/
interface ImageEditorSave {
(newname: string | void, box: {
action: 'resize' | 'crop' | 'saved';
box: {
w: number;
h: number;
};
newPath?: string;
}, success: () => void, failed: (error: Error) => void): void;
}
/**
* The view that instantiates the editor: a file browser (finder pencil / Image
* properties → Edit). `IFileBrowser` already combines `IViewWithToolbar`,
* `IDlgs` and `dataProvider`; using the named interface (not an ad-hoc `&`
* intersection) keeps `tsc` from over-instantiating the deep view types.
*/
type HostView = IFileBrowser;
/**
* PRO replacement for Jodit's core image editor, backed by the standalone
* `@jodit/image-editor` package (crop, resize, rotate, flip, filters, finetune,
* text annotations).
*
* It is registered as `Jodit.modules.ImageEditor`, so **every** path that opens
* the image editor — the finder pencil, Image properties → Edit, a direct
* `getInstance('ImageEditor')` — instantiates it via `getInstance`'s module
* fallback (the event fires on the *file browser's* emitter, which is why an
* `jodit.e` listener never worked).
*
* `@jodit/image-editor` is bundled as a dependency (it is part of the PRO
* editor), so the class is imported directly.
*
* The core editor speaks a server "resize/crop the original file" language; this
* one produces a fully edited `Blob`. So on save it uploads the blob through the
* connector's `imageSave` action (overwriting the source file), then reports
* `action: 'saved'` to the core's save callback — which skips the server
* resize/crop and runs only the `success`/`onSuccess` machinery, reusing
* finder's refresh and image-properties' `
` swap without reimplementing
* either.
*/
export declare class ProImageEditor extends ViewComponent {
/** Marker for callers/tests. */
readonly isProImageEditor = true;
className(): string;
open(url: string, save: ImageEditorSave): Promise;
/**
* Rebuilds the editor's top bar as a native Jodit toolbar in the dialog
* header — Save / Save as, dimensions, zoom, reset / undo / redo — driven by
* the `@jodit/image-editor` public API (`save()`, `saveAs()`, `update(...)`)
* and kept in sync by subscribing to the editor store. Returns a disposer.
*/
private mountToolbar;
/**
* "Save as" — prompt for a new file name, then persist the edited blob under
* it (mirrors the core editor's Save-as UX and its `onSave(name, …)` call).
*/
private saveAs;
/**
* Persists the edited blob. With `newName` it writes a new file ("Save as");
* without it, it overwrites the source ("Save"). Either way it then reuses
* the core's `save()` success/onSuccess wiring (finder refresh, in-content
* `
` swap) with a no-op resize of the resulting file.
*/
private persist;
/**
* Uploads the edited blob through the connector's `imageSave` action and
* returns the saved file's new path (`''` for older connectors that don't
* report it).
*/
private uploadEdited;
/**
* `ImageEditorActionBox.action: 'saved'` appeared in jodit 4.12.34 — an
* older core routes unknown actions into a server crop, which fails the
* save. Detected from the host view's version.
*/
private coreSupportsSaved;
private connectorUrl;
private loadImage;
private loadViaConnector;
private blobSize;
private error;
}
export {};