@ckeditor/ckeditor5-ai 48.4.0 → 48.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aiactions/aiactions.d.ts +2 -2
- package/dist/aiactions/model/aiactionsinteraction.d.ts +3 -4
- package/dist/aichat/aichatcontroller.d.ts +2 -2
- package/dist/aichat/model/aichatcontext.d.ts +9 -8
- package/dist/aicore/aiconnector.d.ts +6 -6
- package/dist/aicore/aierrorreporter.d.ts +29 -1
- package/dist/aicore/aigateway.d.ts +2 -2
- package/dist/aicore/model/aicontextref.d.ts +2 -1
- package/dist/aicore/utils/geteditorconfig.d.ts +2 -0
- package/dist/aicore/utils/getoperationsfordocumentsuggestions.d.ts +4 -4
- package/dist/aicore/utils/markoperationsasai.d.ts +2 -4
- package/dist/aireviewcore/aireviewcoreediting.d.ts +2 -2
- package/dist/aireviewcore/model/aireviewcheckrun.d.ts +2 -2
- package/dist/aireviewmode/model/aireviewcustomcheckrun.d.ts +2 -2
- package/dist/aisdk/dataidassigner.d.ts +20 -0
- package/dist/aisdk/documentchanges.d.ts +165 -0
- package/dist/aisdk/documentchangesutils.d.ts +15 -0
- package/dist/aisdk/documentcompare.d.ts +171 -0
- package/dist/aisdk/documentcompareutils.d.ts +16 -0
- package/dist/aisdk/documentsnapshot.d.ts +48 -0
- package/dist/aisdk/extractselectionfromhtml.d.ts +27 -0
- package/dist/aisdk/validateoperations.d.ts +43 -0
- package/dist/aitranslate/model/aitranslatecheckrun.d.ts +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -19
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +1 -1
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +1 -1
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +1 -1
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +1 -1
- package/dist/translations/be.js +1 -1
- package/dist/translations/be.umd.js +1 -1
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +1 -1
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +1 -1
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +1 -1
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +1 -1
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +1 -1
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +1 -1
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +1 -1
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +1 -1
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +1 -1
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +1 -1
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +1 -1
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +1 -1
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +1 -1
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +1 -1
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +1 -1
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +1 -1
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +1 -1
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +1 -1
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +1 -1
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +1 -1
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +1 -1
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +1 -1
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +1 -1
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +1 -1
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +1 -1
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +1 -1
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +1 -1
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +1 -1
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +1 -1
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +1 -1
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +1 -1
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +1 -1
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +1 -1
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +1 -1
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +1 -1
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +1 -1
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +1 -1
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +1 -1
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +1 -1
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +1 -1
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +1 -1
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +1 -1
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +1 -1
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +1 -1
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +1 -1
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +1 -1
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +1 -1
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +1 -1
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +1 -1
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +1 -1
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +1 -1
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +1 -1
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +1 -1
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +1 -1
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +1 -1
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +1 -1
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +1 -1
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +1 -1
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +1 -1
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +1 -1
- package/package.json +30 -29
- package/dist/aicore/utils/tocontextrefrequestdata.d.ts +0 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/aisdk/documentcompare
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
|
|
10
|
+
import { type Operation, type ModelRange } from "@ckeditor/ckeditor5-engine";
|
|
11
|
+
import { DocumentChanges } from "./documentchanges.js";
|
|
12
|
+
import { DocumentCompareUtils } from "./documentcompareutils.js";
|
|
13
|
+
import { type DocumentCompareSnapshot } from "./documentsnapshot.js";
|
|
14
|
+
/**
|
|
15
|
+
* `DocumentCompare` provides a set of tools that allows you to process editor document data by custom external logic,
|
|
16
|
+
* evaluate the differences between original and processed data, and apply them as granular changes or tracked
|
|
17
|
+
* suggestions.
|
|
18
|
+
*
|
|
19
|
+
* Contrary to `editor.setData()`, this does not replace the whole editor
|
|
20
|
+
* data. Instead, atomic changes are evaluated and a small set of changes is applied to the document. This is especially
|
|
21
|
+
* useful when the editor also uses Track Changes, Revision History, and Real-Time Collaboration features.
|
|
22
|
+
*
|
|
23
|
+
* Use {@link #process `process()`}, to run the whole pipeline in one call - it takes document snapshot, processes the data,
|
|
24
|
+
* and applies granular changes:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* await documentCompare.process( async data => callMyService( data ) );
|
|
28
|
+
*
|
|
29
|
+
* // Or, to apply changes as suggestions:
|
|
30
|
+
* await documentCompare.process( async data => callMyService( data ), { asSuggestions: true } );
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Some integrations need to process the data in separate steps (e.g. backend processing, or when changes
|
|
34
|
+
* are not applied immediately to the content). In this case, you can capture a snapshot first and apply the result later:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const snapshot = documentCompare.makeSnapshot();
|
|
38
|
+
* const processed = await callMyService( snapshot.content );
|
|
39
|
+
*
|
|
40
|
+
* // ...
|
|
41
|
+
*
|
|
42
|
+
* const patch = documentCompare.diffSnapshot( snapshot, processed, { asSuggestions: true } );
|
|
43
|
+
* documentCompare.applyPatch( patch );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class DocumentCompare extends Plugin {
|
|
47
|
+
static get pluginName(): "DocumentCompare";
|
|
48
|
+
static get requires(): PluginDependenciesOf<[DocumentChanges, DocumentCompareUtils]>;
|
|
49
|
+
static override get isOfficialPlugin(): true;
|
|
50
|
+
static override get isPremiumPlugin(): true;
|
|
51
|
+
init(): void;
|
|
52
|
+
afterInit(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Captures the current document state as a {@link module:ai/aisdk/documentsnapshot~DocumentCompareSnapshot}.
|
|
55
|
+
*
|
|
56
|
+
* The snapshot contains all data and metadata necessary to process the data and then be able to calculate differences between
|
|
57
|
+
* the original data and the processed data.
|
|
58
|
+
*
|
|
59
|
+
* Importantly, `snapshot.content` holds data for each root (excluding `$graveyard`) serialized to HTML. The data is stamped with
|
|
60
|
+
* `data-id` attributes, assigned to structural elements of the data. During processing, make sure that these `data-id`s are retained.
|
|
61
|
+
*
|
|
62
|
+
* See also {@link module:ai/aisdk/documentsnapshot~DocumentCompareSnapshot}.
|
|
63
|
+
*
|
|
64
|
+
* @param selection Ranges to capture with the snapshot as the user's selection. Must not intersect. By default no
|
|
65
|
+
* selection is captured.
|
|
66
|
+
* @returns The captured snapshot.
|
|
67
|
+
*/
|
|
68
|
+
makeSnapshot(selection?: Iterable<ModelRange>): DocumentCompareSnapshot;
|
|
69
|
+
/**
|
|
70
|
+
* Diffs the snapshot against processed data, returning a document patch - a set of granular differences between the two states.
|
|
71
|
+
*
|
|
72
|
+
* Use `options` to set whether the patch should be calculated and applied as tracked changes or as direct changes to the document.
|
|
73
|
+
*
|
|
74
|
+
* You can apply the patch using {@link #applyPatch}.
|
|
75
|
+
*
|
|
76
|
+
* @param snapshot The captured before-state to diff against.
|
|
77
|
+
* @param data The processed data. For multi-root editor, pass an object keyed by root name.
|
|
78
|
+
* @param options How the comparison is computed.
|
|
79
|
+
* @returns The patch bringing the document from the snapshot to the processed state.
|
|
80
|
+
*/
|
|
81
|
+
diffSnapshot(snapshot: DocumentCompareSnapshot, data: string | Record<string, string>, options?: DocumentCompareDiffOptions): DocumentComparePatch;
|
|
82
|
+
/**
|
|
83
|
+
* Applies a patch to the current state of the document.
|
|
84
|
+
*
|
|
85
|
+
* As a result, all changes described by the patch are reflected in the document. Note, that this converges with all
|
|
86
|
+
* changes that happened on the document after the snapshot was made, including both local and remote edits
|
|
87
|
+
* (if real-time collaboration is enabled).
|
|
88
|
+
*
|
|
89
|
+
* Note, that the patch can be only applied to the same document as the snapshot, and only during the same editing session.
|
|
90
|
+
* Otherwise, `documentcompare-apply-session-mismatch` error is thrown.
|
|
91
|
+
*
|
|
92
|
+
* The patch is first validated against a copy of the document before anything is committed.
|
|
93
|
+
* In case if any errors or conflict resolution problems surface during this dry-run, `documentcompare-invalid-patch`
|
|
94
|
+
* error is thrown, and the editor data is left intact.
|
|
95
|
+
*
|
|
96
|
+
* The changes can be applied directly to the content or as tracked suggestions (requires
|
|
97
|
+
* {@link module:track-changes/trackchanges~TrackChanges Track changes plugin}). See also {@link #diffSnapshot}.
|
|
98
|
+
*
|
|
99
|
+
* @param patch The patch to apply, as produced by {@link #diffSnapshot}.
|
|
100
|
+
*/
|
|
101
|
+
applyPatch(patch: DocumentComparePatch): void;
|
|
102
|
+
/**
|
|
103
|
+
* Runs the whole processing pipeline in one call: snapshots the document, hands the snapshot to `callback` for
|
|
104
|
+
* external processing (e.g. an AI service), then diffs returned data and applies granular changes to the document.
|
|
105
|
+
*
|
|
106
|
+
* If diffing or applying fails, the underlying error is rethrown and can be further handled,
|
|
107
|
+
* unless `options.setDataOnError` is set, in which case the current document is instead
|
|
108
|
+
* fully replaced with the processed data, the same way as if `editor.setData()` was used.
|
|
109
|
+
* In this case, changes that happened to the document after the snapshot was taken will be overwritten.
|
|
110
|
+
*
|
|
111
|
+
* @param callback Receives the captured snapshot and returns the processed data keyed by root name.
|
|
112
|
+
* @param options Additional processing options.
|
|
113
|
+
* @returns `true` when the process finished successfully and changes were applied granularly,
|
|
114
|
+
* `false` when the full-replacement fallback was used.
|
|
115
|
+
*/
|
|
116
|
+
process(callback: (snapshot: DocumentCompareSnapshot) => Promise<Record<string, string>>, options?: DocumentCompareProcessOptions): Promise<boolean>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Describes how a comparison is computed and, once recorded on a {@link ~DocumentComparePatch patch}, how it is applied.
|
|
120
|
+
*/
|
|
121
|
+
export interface DocumentCompareDiffOptions {
|
|
122
|
+
/**
|
|
123
|
+
* Whether the operations carry track-changes suggestion markers.
|
|
124
|
+
*/
|
|
125
|
+
asSuggestions?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Options for {@link module:ai/aisdk/documentcompare~DocumentCompare#process}.
|
|
129
|
+
*/
|
|
130
|
+
export interface DocumentCompareProcessOptions extends DocumentCompareDiffOptions {
|
|
131
|
+
/**
|
|
132
|
+
* What to do when the processing fails.
|
|
133
|
+
*
|
|
134
|
+
* By default, the underlying error is rethrown.
|
|
135
|
+
*
|
|
136
|
+
* When the options is set to `true`, the whole document is instead overwritten with the processed data
|
|
137
|
+
* via `editor.setData()` and {@link module:ai/aisdk/documentcompare~DocumentCompare#process} returns `false`.
|
|
138
|
+
*
|
|
139
|
+
* Note, that the overwrite is also performed in real-time collaboration environment, and it may roll back some edits made by remote
|
|
140
|
+
* users while `callback` was processing. Opt in only when overwriting the whole document is acceptable.
|
|
141
|
+
*/
|
|
142
|
+
setDataOnError?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The result of comparing a snapshot against processed data: the operations to bring the document to the new state,
|
|
146
|
+
* together with the snapshot metadata.
|
|
147
|
+
*
|
|
148
|
+
* Can be applied via {@link module:ai/aisdk/documentcompare~DocumentCompare#applyPatch}.
|
|
149
|
+
*/
|
|
150
|
+
export interface DocumentComparePatch {
|
|
151
|
+
/**
|
|
152
|
+
* The channel of the document the snapshot was captured from, validated on apply.
|
|
153
|
+
*/
|
|
154
|
+
channelId: string;
|
|
155
|
+
/**
|
|
156
|
+
* The editing session the snapshot was captured in, validated on apply.
|
|
157
|
+
*/
|
|
158
|
+
sessionId: string;
|
|
159
|
+
/**
|
|
160
|
+
* The snapshot version the operations are anchored to (used to reconcile them on apply).
|
|
161
|
+
*/
|
|
162
|
+
version: number;
|
|
163
|
+
/**
|
|
164
|
+
* The options the patch was computed with, reused when applying it.
|
|
165
|
+
*/
|
|
166
|
+
options: DocumentCompareDiffOptions;
|
|
167
|
+
/**
|
|
168
|
+
* The operations to apply, keyed by root name (a root with no changes maps to an empty array).
|
|
169
|
+
*/
|
|
170
|
+
operations: Record<string, Array<Operation>>;
|
|
171
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/aisdk/documentcompareutils
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from "@ckeditor/ckeditor5-core";
|
|
10
|
+
export declare class DocumentCompareUtils extends Plugin {
|
|
11
|
+
static get pluginName(): "DocumentCompareUtils";
|
|
12
|
+
static override get isOfficialPlugin(): true;
|
|
13
|
+
static override get isPremiumPlugin(): true;
|
|
14
|
+
init(): void;
|
|
15
|
+
override destroy(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/aisdk/documentsnapshot
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { type AIEditorConfig } from "../aicore/utils/geteditorconfig.js";
|
|
10
|
+
/**
|
|
11
|
+
* A captured selection range as character offsets into its root's serialized HTML.
|
|
12
|
+
*/
|
|
13
|
+
export interface DocumentCompareSnapshotRange {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The captured before-state of a document plus the metadata to reconcile changes later.
|
|
19
|
+
* The snapshot is a plain object and is safe to `JSON.stringify`, send between the frontend and backend, store, parse,
|
|
20
|
+
* and later feed back into `DocumentCompare#diffSnapshot`.
|
|
21
|
+
*/
|
|
22
|
+
export interface DocumentCompareSnapshot {
|
|
23
|
+
/**
|
|
24
|
+
* The collaboration channel the snapshot was captured from.
|
|
25
|
+
*/
|
|
26
|
+
channelId: string;
|
|
27
|
+
/**
|
|
28
|
+
* The editing session the snapshot was captured in.
|
|
29
|
+
*/
|
|
30
|
+
sessionId: string;
|
|
31
|
+
/**
|
|
32
|
+
* The document version the snapshot was captured at.
|
|
33
|
+
*/
|
|
34
|
+
version: number;
|
|
35
|
+
/**
|
|
36
|
+
* Each root's content, serialized to HTML, keyed by root name (excluding `$graveyard`).
|
|
37
|
+
*/
|
|
38
|
+
content: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Each root's captured selection as character offsets into its HTML, keyed by root name (omitted if root has no selection).
|
|
41
|
+
*/
|
|
42
|
+
selection: Record<string, Array<DocumentCompareSnapshotRange>>;
|
|
43
|
+
/**
|
|
44
|
+
* The editor's feature configuration at capture time, so external processing can interpret the serialized HTML
|
|
45
|
+
* within the editor's capabilities.
|
|
46
|
+
*/
|
|
47
|
+
editorConfig: AIEditorConfig;
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/aisdk/extractselectionfromhtml
|
|
7
|
+
*/
|
|
8
|
+
import { type DocumentCompareSnapshotRange } from "./documentsnapshot.js";
|
|
9
|
+
/**
|
|
10
|
+
* The marker group used to render a captured selection into serialized HTML. Each range is added as
|
|
11
|
+
* `documentcompare-selection:<i>` and downcast (opt-in via the `includeDocumentCompareSelection` option) to the
|
|
12
|
+
* boundary elements below.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SELECTION_MARKER = "documentcompare-selection";
|
|
15
|
+
/** The boundary element names the selection markers downcast to. */
|
|
16
|
+
export declare const SELECTION_START = "documentcompare-selection-start";
|
|
17
|
+
export declare const SELECTION_END = "documentcompare-selection-end";
|
|
18
|
+
/**
|
|
19
|
+
* Strips the selection boundary elements from HTML serialized with the `includeDocumentCompareSelection` option.
|
|
20
|
+
*
|
|
21
|
+
* @param html HTML serialized with the selection boundary elements included.
|
|
22
|
+
* @returns The clean HTML together with the selection as character offsets into it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractSelectionFromHtml(html: string): {
|
|
25
|
+
content: string;
|
|
26
|
+
selection: Array<DocumentCompareSnapshotRange>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ai/aisdk/validateoperations
|
|
7
|
+
*/
|
|
8
|
+
import { type Editor } from "@ckeditor/ckeditor5-core";
|
|
9
|
+
import { type Operation } from "@ckeditor/ckeditor5-engine";
|
|
10
|
+
/**
|
|
11
|
+
* A failure found by {@link ~validateOperations} while trial-applying a patch's operations.
|
|
12
|
+
*/
|
|
13
|
+
export interface OperationValidationFailure {
|
|
14
|
+
/**
|
|
15
|
+
* What kind of failure occurred: `'unsupported'` for an operation the `DocumentCompare` API does not support,
|
|
16
|
+
* `'invalid'` for one that failed to trial-apply against a copy of the current document.
|
|
17
|
+
*/
|
|
18
|
+
reason: string;
|
|
19
|
+
/**
|
|
20
|
+
* The operation that failed.
|
|
21
|
+
*/
|
|
22
|
+
operation: Operation;
|
|
23
|
+
/**
|
|
24
|
+
* The underlying error thrown while trial-applying the operation, set when `reason` is `'invalid'`.
|
|
25
|
+
*/
|
|
26
|
+
cause?: Error;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Trial-applies `operations` on temporary copies of the document's roots, to confirm they apply cleanly before they are
|
|
30
|
+
* applied for real, so an unapplicable set is caught up front instead of failing mid-way, leaving the document corrupt.
|
|
31
|
+
*
|
|
32
|
+
* Each root (plus the graveyard, for remove/merge targets) is deep-cloned into a detached
|
|
33
|
+
* {@link module:engine/model/documentfragment~ModelDocumentFragment}, and every operation is cloned and re-rooted onto
|
|
34
|
+
* those copies and trial-applied there — `_validate()` then `_execute()`, as the real apply runs them. Marker
|
|
35
|
+
* operations are skipped: they cannot fail structurally, so there is nothing to validate. Nothing is applied to the
|
|
36
|
+
* live document.
|
|
37
|
+
*
|
|
38
|
+
* The function does not throw errors itself, instead it returns the first failure it finds (or `null` when the
|
|
39
|
+
* operations all apply cleanly), and leaves it to the caller to throw the appropriate error.
|
|
40
|
+
*
|
|
41
|
+
* @returns The first operation failure, or `null` when all operations apply cleanly.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateOperations(editor: Editor, operations: Array<Operation>): OperationValidationFailure | null;
|
|
@@ -9,7 +9,7 @@ import { type AIConnector } from "../../aicore/aiconnector.js";
|
|
|
9
9
|
import { type AIDocumentData } from "../../aireviewcore/aireviewcoreediting.js";
|
|
10
10
|
import { type AIReviewCheck } from "../../aireviewcore/model/aireviewcheck.js";
|
|
11
11
|
import { AIReviewSystemCheckRun } from "../../aireviewcore/model/aireviewsystemcheckrun.js";
|
|
12
|
-
import { type
|
|
12
|
+
import { type AIContext } from "../../aicore/model/aicontext.js";
|
|
13
13
|
/**
|
|
14
14
|
* Represents a single translate check run and its results.
|
|
15
15
|
*/
|
|
@@ -17,7 +17,7 @@ export declare class AITranslateCheckRun extends AIReviewSystemCheckRun {
|
|
|
17
17
|
/**
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
|
20
|
-
constructor(documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, title: string, params?: Array<string>, args?: Record<string, any>,
|
|
20
|
+
constructor(documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, title: string, params?: Array<string>, args?: Record<string, any>, context?: AIContext);
|
|
21
21
|
/**
|
|
22
22
|
* @inheritDoc
|
|
23
23
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,9 @@ export { AITranslate, type AITranslateConfig, type AITranslateLanguage } from ".
|
|
|
76
76
|
export { AITranslateController } from "./aitranslate/aitranslatecontroller.js";
|
|
77
77
|
export { AITranslateUI } from "./aitranslate/aitranslateui.js";
|
|
78
78
|
export { AITranslateGateway, type AITranslateRunOptions } from "./aitranslate/aitranslategateway.js";
|
|
79
|
+
export { DocumentCompare, type DocumentCompareDiffOptions, type DocumentCompareProcessOptions, type DocumentComparePatch } from "./aisdk/documentcompare.js";
|
|
80
|
+
export type { DocumentCompareSnapshot, DocumentCompareSnapshotRange } from "./aisdk/documentsnapshot.js";
|
|
81
|
+
export type { AIEditorConfig } from "./aicore/utils/geteditorconfig.js";
|
|
79
82
|
import "../theme/index-editor.css";
|
|
80
83
|
import "../theme/index-content.css";
|
|
81
84
|
import "./augmentation.js";
|