/** * @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/proposedchanges * @publicApi */ import { ContextPlugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core"; import { type ProposedChangesController, type ProposedChangesControllerOptions } from "./proposedchangescontrollertype.js"; import { type ProposedChangesCollection } from "./proposedchangescollection.js"; import { DocumentDiffer } from "./documentdiffer.js"; import { ProposedChangesUtils } from "./proposedchangesutils.js"; import { AIEditing } from "../aicore/aiediting.js"; import { AISuggestionContainerView } from "../aicore/ui/suggestioncontainer/aisuggestioncontainerview.js"; import { type AISuggestionActionName } from "../aicore/utils/replyactions.js"; /** * Provides both an API and a UI component for reviewing a set of * {@link module:ai/toolkit/proposedchange~DocumentChange proposed document changes}. * * Use {@link #createController `createController()`} to create a * {@link module:ai/toolkit/proposedchangescontrollertype~ProposedChangesController controller} instance which binds the proposed * document changes with related editors. * * Then use {@link #createView `createView()`} to create a UI component for the proposed changes. * * {@link module:ai/toolkit/documentcompare~DocumentCompare#computeChanges Compute changes}, collect them into * a {@link module:ai/toolkit/proposedchangescollection~ProposedChangesCollection set of proposed changes}, and create a controller: * * ```ts * const changes = editor.plugins.get( 'DocumentCompare' ).computeChanges( snapshot, processedData ); * const collection = new ProposedChangesCollection( changes ); * * const proposedChanges = editor.plugins.get( 'ProposedChanges' ); // Use `Context` instance if you have multiple editors. * const controller = proposedChanges.createController( collection ); * ``` * * To restore a review, pass each change's `state` to the set: * * ```ts * const collection = new ProposedChangesCollection( * changes.map( ( change, index ) => ( { ...change, state: savedStates[ index ] } ) ) * ); * ``` * * {@link module:ai/toolkit/proposedchangescontrollertype~ProposedChangesController#attachView Attach} the proposed changes UI component * and append it where you like: * * ```ts * const view = proposedChanges.createView(); * controller.attachView( view ); * * myDomContainer.appendChild( view.element ); * * // ... * // After the controller and view are not needed anymore, remember to destroy them: * view.destroy(); * controller.destroy(); * ``` */ export declare class ProposedChanges extends ContextPlugin { /** * @inheritDoc */ static get requires(): PluginDependenciesOf<[AIEditing, DocumentDiffer, ProposedChangesUtils]>; /** * @inheritDoc */ static get pluginName(): "ProposedChanges"; /** * @inheritDoc */ static override get isOfficialPlugin(): true; /** * @inheritDoc */ static override get isPremiumPlugin(): true; init(): Promise; /** * Returns a {@link module:ai/toolkit/proposedchangescontrollertype~ProposedChangesController controller} that provides all logic * and API necessary for implementing a capability to review a set of proposed changes. * * {@link module:ai/toolkit/proposedchangescontrollertype~ProposedChangesController#attachView Attach} a {@link #createView view} * to it to let the user review the changes. * * The controller works over the given `collection`, available afterwards as its * {@link module:ai/toolkit/proposedchangescontrollertype~ProposedChangesController#collection}. The set is owned by the caller * and outlives the controller, so it can be passed to a new controller, for example to continue the review after the editor was * re-created. Destroy the controller previously bound with the set first. * * Every editor bound with the controller must have the `collaboration.channelId` configuration set, so the changes can be * matched with their documents. Otherwise, the `proposedchanges-missing-channel-id` error is thrown. * * See the examples in the {@link module:ai/toolkit/proposedchanges~ProposedChanges `ProposedChanges` plugin documentation} * to learn more. * * @param collection The set of proposed changes to review. * @param options The controller options. */ createController(collection: ProposedChangesCollection, options?: ProposedChangesControllerOptions): ProposedChangesController; /** * Returns a new view to review proposed changes. Includes a single card for each change, with the actions to accept or reject it. * All changes are wrapped into a container with additional actions: toggle view mode, accept all changes and suggest all changes. * * Attach it to a {@link #createController controller} with * {@link module:ai/toolkit/proposedchangescontrollertype~ProposedChangesController#attachView}, and place its * {@link module:ui/view~View#element `element`} anywhere in the page. * * See the examples in the {@link module:ai/toolkit/proposedchanges~ProposedChanges `ProposedChanges` plugin documentation} * to learn more. * * @param options The view options. */ createView(options?: ProposedChangesViewOptions): AISuggestionContainerView; /** * @inheritDoc */ override destroy(): void; } /** * The options of {@link module:ai/toolkit/proposedchanges~ProposedChanges#createView}. */ export interface ProposedChangesViewOptions { /** * The actions available in the view. * * Defaults to {@link module:ai/aicore/utils/replyactions~AI_REPLY_ACTIONS `AI_REPLY_ACTIONS`}. * * Suggesting changes (`'insertSuggestion'`) is offered by an attached controller only when every editor it reviews loads * the {@link module:track-changes/trackchanges~TrackChanges track changes} feature. */ availableActions?: Array; }