Class AutosaveEvent
java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<VaadinCKEditor>
com.wontlost.ckeditor.event.AutosaveEvent
- All Implemented Interfaces:
Serializable
Autosave event.
Fired when editor content is automatically saved.
Usage example:
editor.addAutosaveListener(event -> {
String content = event.getContent();
// Save to database or backend service
documentService.save(documentId, content);
if (event.isSuccess()) {
Notification.show("Auto-saved");
}
});
Autosave behavior can be configured via the Builder:
VaadinCKEditor editor = VaadinCKEditor.create()
.withPreset(CKEditorPreset.STANDARD)
.withAutosave(content -> saveToBackend(content), 3000) // 3-second delay
.build();
- See Also:
-
Field Summary
Fields inherited from class EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionAutosaveEvent(VaadinCKEditor source, boolean fromClient, String content) Create a successful autosave event.AutosaveEvent(VaadinCKEditor source, boolean fromClient, String content, boolean success, String errorMessage) Create an autosave event. -
Method Summary
Modifier and TypeMethodDescriptionGet the saved content.Get the error message.longGet the save timestamp.booleanCheck whether the save succeeded.Methods inherited from class com.vaadin.flow.component.ComponentEvent
getSource, isFromClient, unregisterListenerMethods inherited from class EventObject
toString
-
Constructor Details
-
AutosaveEvent
Create a successful autosave event.- Parameters:
source- the editor component that fired the eventfromClient- whether the event originated from the clientcontent- the saved content
-
AutosaveEvent
public AutosaveEvent(VaadinCKEditor source, boolean fromClient, String content, boolean success, String errorMessage) Create an autosave event.- Parameters:
source- the editor component that fired the eventfromClient- whether the event originated from the clientcontent- the saved contentsuccess- whether the save succeedederrorMessage- error message (on failure)
-
-
Method Details
-
getContent
-
getTimestamp
public long getTimestamp()Get the save timestamp.- Returns:
- timestamp in milliseconds
-
isSuccess
public boolean isSuccess()Check whether the save succeeded.- Returns:
- true if the save was successful
-
getErrorMessage
Get the error message.- Returns:
- error message, or null if the save succeeded
-