TrackChangesAdapter (track-changes)
@ckeditor/ckeditor5-track-changes/src/trackchanges
Track changes adapter.
The track changes adapter is an object that communicates asynchronously with the data source to fetch or save the suggestion data. It is used internally by the track changes feature whenever a suggestion is loaded, created or deleted.
The adapter is optional. You might need to provide it if you are features/collaboration/track-changes/track-changes-integration using the track changes feature without real-time collaboration.
To set the adapter, overwrite the TrackChanges#adapter
property.
Filtering
Methods
-
addSuggestion( suggestionData ) → Promise<SuggestionData>
module:track-changes/trackchanges~TrackChangesAdapter#addSuggestion
Called each time a new suggestion is created.
The method should save the suggestion data in the database and return a promise that should be resolved when the save is completed.
If the promise resolves with an object with the
createdAt
property, this suggestion property will be updated in the suggestion in the editor. This lets you update the suggestion data with server-side information.The
suggestionData
object does not expect theauthorId
property. For security reasons, the author of the suggestion should be set on the server side.If
suggestionData.originalSuggestionId
is set, the new suggestion should have theauthorId
property set to the same as the suggestion withoriginalSuggestionId
. This happens when one user splits another user's suggestion, creating a new suggestion as a result. See Track changes integration guide.Note: Failure to properly handle this property will result in editor crash in some scenarios.
In any other case, use the current (local) user to set
authorId
.The
suggestionData
object does not expect thecreatedAt
property either. You should use the server-side time generator to ensure that all users see the same date.It is recommended to stringify
suggestionData.attributes
value to JSON and save it as a string in your database, and then to parse the strings when loading suggestions.Parameters
suggestionData : AddSuggestionInput
Returns
Promise<SuggestionData>
-
getSuggestion( id ) → Promise<SuggestionData>
module:track-changes/trackchanges~TrackChangesAdapter#getSuggestion
Called each time the suggestion data is needed.
The method should return a promise that resolves with the suggestion data object.
Parameters
id : string
The ID of the suggestion to get.
Returns
Promise<SuggestionData>
-
updateSuggestion( id, suggestionData ) → Promise<void>
module:track-changes/trackchanges~TrackChangesAdapter#updateSuggestion
Called each time the suggestion properties change.
The method should update the suggestion properties in the database and return a promise that should be resolved when the save is completed.
Keep in mind that the
data
parameter only contains those properties of a suggestion which changed.Parameters
id : string
suggestionData : UpdateSuggestionInput
Returns
Promise<void>
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.