Class ContentChangeEvent

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

public class ContentChangeEvent extends com.vaadin.flow.component.ComponentEvent<VaadinCKEditor>
Content change event. Fired when the editor content changes, providing the content before and after the change.

Usage example:

editor.addContentChangeListener(event -> {
    // Calculate difference
    int charDiff = event.getNewContent().length() - event.getOldContent().length();
    updateCharacterCount(charDiff);

    // Mark as unsaved
    markAsUnsaved();
});

Note: This event differs from Vaadin's ValueChangeListener:

  • ContentChangeEvent - fires on every content change (real-time)
  • ValueChangeListener - fires on blur or sync
See Also:
  • Constructor Details

    • ContentChangeEvent

      public ContentChangeEvent(VaadinCKEditor source, boolean fromClient, String oldContent, String newContent, ContentChangeEvent.ChangeSource changeSource)
      Create a content change event.
      Parameters:
      source - the editor component that fired the event
      fromClient - whether the event originated from the client
      oldContent - the content before the change
      newContent - the content after the change
      changeSource - the source of the change
  • Method Details

    • getOldContent

      public String getOldContent()
      Get the content before the change.
      Returns:
      the old content
    • getNewContent

      public String getNewContent()
      Get the content after the change.
      Returns:
      the new content
    • getChangeSource

      public ContentChangeEvent.ChangeSource getChangeSource()
      Get the source of the change.
      Returns:
      the change source type
    • hasChanged

      public boolean hasChanged()
      Check whether the content has actually changed.
      Returns:
      true if the content is different
    • getLengthDelta

      public int getLengthDelta()
      Get the content length delta.
      Returns:
      character count change (positive means increase, negative means decrease)