Class AutosaveEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<VaadinCKEditor>
com.wontlost.ckeditor.event.AutosaveEvent
All Implemented Interfaces:
Serializable

public class AutosaveEvent extends com.vaadin.flow.component.ComponentEvent<VaadinCKEditor>
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:
  • Constructor Details

    • AutosaveEvent

      public AutosaveEvent(VaadinCKEditor source, boolean fromClient, String content)
      Create a successful autosave event.
      Parameters:
      source - the editor component that fired the event
      fromClient - whether the event originated from the client
      content - 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 event
      fromClient - whether the event originated from the client
      content - the saved content
      success - whether the save succeeded
      errorMessage - error message (on failure)
  • Method Details

    • getContent

      public String getContent()
      Get the saved content.
      Returns:
      the HTML content
    • 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

      public String getErrorMessage()
      Get the error message.
      Returns:
      error message, or null if the save succeeded