/** * @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/aireviewcore/aireviewcoreediting */ import { InsertOperation, MarkerOperation, ModelDocumentFragment, ModelPosition, ModelRange, type Operation } from '@ckeditor/ckeditor5-engine'; import { type Emitter } from '@ckeditor/ckeditor5-utils'; import { type Context, ContextPlugin, type Editor } from '@ckeditor/ckeditor5-core'; import { DocumentCompare } from '@ckeditor/ckeditor5-collaboration-core'; import { type AIReviewCheckResultChange } from './model/aireviewcheckresultchange.js'; import { AIEditing } from '../aicore/aiediting.js'; export declare class AIReviewCoreEditing extends ContextPlugin { /** * @inheritDoc */ static get requires(): readonly [typeof DocumentCompare, typeof AIEditing]; /** * @inheritDoc */ static get pluginName(): "AIReviewCoreEditing"; /** * @inheritDoc */ static get isOfficialPlugin(): true; /** * @inheritDoc */ static get isPremiumPlugin(): true; /** * @inheritDoc */ constructor(context: Context | Editor); /** * Exposes the event emitter to allow listening to specific events. */ get emitter(): Emitter; /** * @inheritDoc */ afterInit(): void; /** * Returns the data (as string and flat list of container elements) and version of the current document. * * This method also applied `data-id` attributes to all elements that are direct parents of text nodes. * These attributes are used by AI API to determine that given element can be changed. * * Additionally, each element is converted from model to HTML string in the context of the entire structure * to ensure that the conversion is accurate (e.g. table cells need to be inside a table row, which needs to be inside a table). */ getDocumentData(): AIDocumentData; /** * Compares two pieces of content, calculates operations, groups them and returns diffed content * and additional data for each group. * * Each group contains: * - `operations`: list of operations that are part of the group. * - `operationsIsolated`: list of operations that are part of the group but with positions/ranges re-calculated * to allow applying them in isolation (without other operations that would affect their positions). * - `groupOffset`: how many characters were inserted in this group. * - `content`: function that returns content (as HTML string) of the entire content with all changes applied and context marked. * - `context`: function that returns part of the content (as HTML string) consider as group context, with all changes applied * for this specific context. * * Operations processing logic is simplified assuming only `Insert` and `Marker` operations. Other operations, even if present * in the calculated operations, are ignored. * * There are two modes of processing diffed content that affects the output of this method. The modes * are controlled with `asSingleGroup` parameter. * * Default mode (`asSingleGroup` is `false`): * * By default each group of operations is processed separately. This mode is used by "AI Review Mode" feature code. * * The `context` is a range within a block that includes operations from a specific group, starts after the previous * change, and ends before the next change. If there is a single group, it spans over the entire block element contents. * * For example: * Initial content:
Foo bar baz. 123 456 789.
* New content:Foo bax baz. 123 789.
* * This can be visualized as ('[]' shows removal, '{}' shows insertion): *Foo[ bar]{ bax} baz. 123[ 456] 789.
* * There are 2 separate operation groups: * - " bar" -> " bax" (marker remove operation + insert operation) * - " 456" removed (marker remove operation) * * The context of each group (marked with '()') is: * Group 1:(Foo[ bar]{ bax} baz. 123) 456 789.
* Group 2:Foo bar( baz. 123 456 789.)
* * Single group mode (`asSingleGroup` is `true`): * * A single group mode assumes that entire content block are changed as a single change. This mode * is used by "AI Translate" feature code. * * Here, the contents are diffed the same, but then based on calculated operations, a single group with one * marker remove operation (spanning all removed content) and a single insert operation (spanning all inserted content) * is created. * * For example: * Initial content:Foo bar baz. 123 456 789.
* New content:Foo bax baz. 123 789.
* * This can be visualized as ('[]' shows removal, '{}' shows insertion): *[Foo bar bax baz. 123 456 789.]{Foo bax baz. 123 789.}
* * The context and content is equal so both functions return the entire initial content. */ diffContent(contentInitial: string, contentNew: string, asSingleGroup?: boolean): Array