/** * @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 ai/toolkit/proposedchangescontroller */ import { type Editor, type ContextInterface } from "@ckeditor/ckeditor5-core"; import { type EmitterMixinConstructor } from "@ckeditor/ckeditor5-utils"; import { type ProposedChangesController, type ProposedChangesControllerOptions } from "./proposedchangescontrollertype.js"; import { type ProposedChangesCollection } from "./proposedchangescollection.js"; import { type AISuggestionContainerView } from "../aicore/ui/suggestioncontainer/aisuggestioncontainerview.js"; declare const ProposedChangesControllerBase: EmitterMixinConstructor; /** * Binds together a {@link module:ai/toolkit/proposedchangescollection~ProposedChangesCollection set of proposed changes} with related * editor instances and (optionally) with the view component. * * When an `AISuggestionContainerView` is {@link #attachView attached}, the controller will provide all necessary data to render and * update the view according to the proposed changes set. It will also fully integrate with the editor instance to handle all user * interaction coming from the view. * * The controller also provides methods for handling the proposed document changes: {@link #applyChange}, * {@link #applyAllChanges}, {@link #rejectChange}, {@link #previewChange}, {@link #highlightChange}. * * One controller instance handles all changes from the proposed changes set, even when they are related to multiple editor instances. */ export declare class ProposedChangesControllerImpl extends ProposedChangesControllerBase implements ProposedChangesController { /** * The set of proposed changes under review. */ readonly collection: ProposedChangesCollection; /** * @param context The editor the changes were captured from, or the context whose editors they are spread over. * @param collection The set of proposed changes to review. * @param options The controller options. */ constructor(context: Editor | ContextInterface, collection: ProposedChangesCollection, options?: ProposedChangesControllerOptions); /** * Attaches a view to the controller. The view gets all necessary data to be rendered, is refreshed when needed, and all view's events * are handled by the controller and reflected onto the editor document and proposed changes set state. Replaces the currently attached * view, if there is one. * * @param view The view to bind with controller. */ attachView(view: AISuggestionContainerView): void; /** * Detaches the currently attached view. Does nothing when none is attached. */ detachView(): void; /** * Sets whether the attached view shows the proposed changes as a diff against the original content, or the proposed content * alone. Re-renders the view and updates its toggle accordingly. The mode is kept for a view attached later. * * The in-document preview has its own mode, which takes this one as its starting value whenever a preview is opened from the view. * * @param showDiff Whether the changes are shown as a diff. */ setShowDiff(showDiff: boolean): void; /** * Detaches the view and stops following the set of proposed changes. Neither is destroyed - the controller owns * neither of them. The controller must not be used afterwards. */ destroy(): void; /** * Applies the given proposed change to the related document and updates the change's state. * * Does nothing if the change * {@link module:ai/toolkit/proposedchangescollection~ProposedChangesCollection#isWritable cannot be applied} to * the document, or the related document is not available. * * Throws the same errors as {@link module:ai/toolkit/documentcompare~DocumentCompare#applyPatch}, for example, when the change * fails the validation against the current document. In such case, the change state is not updated. * * @param index The {@link module:ai/toolkit/proposedchange~ProposedChange#index index} in the collection of the change to apply. * @param asSuggestions Whether to apply the change as a track-changes suggestion (`true`) or directly (`false`). */ applyChange(index: number, asSuggestions: boolean): void; /** * Applies every proposed change that * {@link module:ai/toolkit/proposedchangescollection~ProposedChangesCollection#isWritable can be applied} * to the related documents, and updates the changes' state. * * The changes applied to one document make one undo step, so undoing it takes back all of them at once. * * @param asSuggestions Whether to apply the changes as track-changes suggestions (`true`) or directly (`false`). */ applyAllChanges(asSuggestions: boolean): void; /** * Rejects the given proposed change. Only the change's state is updated, the related document is left as it is. * * Does nothing for a change which * {@link module:ai/toolkit/proposedchangescollection~ProposedChangesCollection#isActionable cannot be acted on}. * A change related to read-only content can still be rejected. * * @param index The {@link module:ai/toolkit/proposedchange~ProposedChange#index index} in the collection of the change to reject. */ rejectChange(index: number): void; /** * Scrolls the document to the position where content related to the given change sits. Does nothing for a change whose related * content is gone. * * @param index The {@link module:ai/toolkit/proposedchange~ProposedChange#index index} in the collection of the change to * scroll to. */ scrollToChange(index: number): void; /** * Highlights the content given change covers. Does nothing for a change whose related content is gone, or for a change which * was already accepted or rejected. The highlight can be turned off by {@link #hideHighlight}. * * @param index The {@link module:ai/toolkit/proposedchange~ProposedChange#index index} in the collection of the change to * highlight. */ highlightChange(index: number): void; /** * Previews a proposed change in the document: highlights the content it covers, scrolls to it, and opens the balloon over it * with the change preview. * * The balloon provides user interface to accept, suggest, or reject the change, or to navigate to other proposed changes. * After a decision made in the balloon or on a card, the preview moves to the next actionable change, or closes when none * is left. Applying or suggesting all the changes at once closes it. Deciding through the API, for instance, with * {@link #applyChange `applyChange()`} or {@link #rejectChange `rejectChange()`}, does not move the preview. * * @param index The {@link module:ai/toolkit/proposedchange~ProposedChange#index index} in the collection of the change to preview. */ previewChange(index: number): void; /** * Turns off the highlight, if this controller set one. Does nothing otherwise. Notably, this will not turn off a highlight set * elsewhere. */ hideHighlight(): void; } export {};