/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
/**
* @module core/errorreporter
*/
import { type CKEditorError } from "@ckeditor/ckeditor5-utils";
import { Editor } from "./editor/editor.js";
import { type Context } from "./context.js";
/**
* What a callback registered with {@link module:core/errorreporter~onEditorError} receives.
*/
export interface EditorErrorData {
	/**
	* The error that escaped.
	*/
	error: CKEditorError;
	/**
	* The editor or context the error came from — the editor as a whole, not the object that threw. That
	* one is in {@link module:utils/ckeditorerror~CKEditorError#context `error.context`}, and it is
	* whatever the throwing code happened to have at hand: a plugin, a command, the model, a writer.
	*
	* Compare this with your own instance to tell whether the error came from an editor you manage.
	*
	* When editors share an object, an error can be attributed to more than one of them. The callback is
	* then called once for each, with the same `error` and a different `source`, so `source` may be an
	* editor the error did not come from.
	*
	* `null` is reserved for errors that could not be attributed. Under the current filter such an error
	* is not reported at all, but the type does not promise that, so that the filter stays a policy rather
	* than part of the contract.
	*/
	source: Editor | Context | null;
}
export type EditorErrorCallback = (data: EditorErrorData) => void;
/**
* Registers a callback for errors that escape an editor, and returns a function that unregisters it.
*
* ```ts
* const off = onEditorError( ( { error, source } ) => {
* 	if ( source !== myEditor ) {
* 		return;
* 	}
*
* 	reportToMyErrorTracker( error );
* } );
* ```
*
* There is one registration surface for the whole page rather than one per editor, so an integrator running
* several editors compares `source` with their own instance, as above. Registering the same callback twice
* gives two independent registrations, and each unregisters on its own.
*
* One error can reach the callback more than once, once for every editor it is attributed to — see
* {@link module:core/errorreporter~EditorErrorData#source}.
*
* Reporting only. Nothing is restarted and nothing is swallowed — the error still reaches the console.
*/
export declare function onEditorError(callback: EditorErrorCallback): () => void;
