/** * @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 */ import React from 'react'; import type { EventInfo, Editor, EditorConfig, EditorWatchdog, WatchdogConfig, ContextWatchdog } from 'ckeditor5'; import { type CKEditorConfigContextMetadata } from './context/setCKEditorReactContextMetadata.js'; import { EditorWatchdogAdapter } from './EditorWatchdogAdapter.js'; import { type EditorRelaxedConstructor } from '@ckeditor/ckeditor5-integrations-common'; export default class CKEditor extends React.Component> { /** * After mounting the editor, the variable will contain a reference to the created editor. * @see: https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html */ private domContainer; /** * Unlocks element in editor semaphore after destroy editor instance. */ private editorSemaphore; static contextType: React.Context | null>; constructor(props: Props); private get _semaphoreValue(); /** * An watchdog instance. */ get watchdog(): EditorWatchdog | EditorWatchdogAdapter | null; /** * An editor instance. */ get editor(): Editor | null; /** * The CKEditor component should not be updated by React itself. * However, if the component identifier changes, the whole structure should be created once again. */ shouldComponentUpdate(nextProps: Readonly>): boolean; /** * Initialize the editor when the component is mounted. */ componentDidMount(): void; /** * Re-render the entire component once again. The old editor will be destroyed and the new one will be created. */ componentDidUpdate(): void; /** * Destroy the editor before unmounting the component. */ componentWillUnmount(): void; /** * Async destroy attached editor and unlock element semaphore. */ private _unlockLifeCycleSemaphore; /** * Unlocks previous editor semaphore and creates new one.. */ private _initLifeCycleSemaphore; /** * Render a
element which will be replaced by CKEditor. */ render(): React.ReactNode; /** * Initializes the editor by creating a proper watchdog and initializing it with the editor's configuration. */ private _initializeEditor; /** * Creates editor in watchdog context. * * @param watchdog Watchdog adapter. * @param config Editor configuration. * @returns Editor instance. */ private _watchdogCreateEditor; /** * Creates an editor from the element and configuration. * * @param config CKEditor 5 editor configuration. * @returns Editor instance. */ private _createEditor; /** * It gets an extended configuration containing the entries required for the integration configuration. * * @param resetData Assigns `data` prop value to the configuration if true. * @param config The configuration of the editor. * @returns Shallow copy of config. */ private _getMergedConfig; /** * Destroys the editor by destroying the watchdog. */ private _destroyEditor; } export interface Props { editor: EditorRelaxedConstructor & { EditorWatchdog: typeof EditorWatchdog; ContextWatchdog: typeof ContextWatchdog; }; contextItemMetadata?: CKEditorConfigContextMetadata; config?: EditorConfig; watchdogConfig?: WatchdogConfig; disableWatchdog?: boolean; onReady?: (editor: TEditor) => void; onAfterDestroy?: (editor: TEditor) => void; onError?: (error: Error, details: ErrorDetails) => void; onChange?: (event: EventInfo, editor: TEditor) => void; onFocus?: (event: EventInfo, editor: TEditor) => void; onBlur?: (event: EventInfo, editor: TEditor) => void; data?: string; disabled?: boolean; id?: any; } interface ErrorDetails { phase: 'initialization' | 'runtime'; willEditorRestart?: boolean; } export {};