Class ContentChangeEvent
java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<VaadinCKEditor>
com.wontlost.ckeditor.event.ContentChangeEvent
- All Implemented Interfaces:
Serializable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumContent change source. -
Field Summary
Fields inherited from class EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionContentChangeEvent(VaadinCKEditor source, boolean fromClient, String oldContent, String newContent, ContentChangeEvent.ChangeSource changeSource) Create a content change event. -
Method Summary
Modifier and TypeMethodDescriptionGet the source of the change.intGet the content length delta.Get the content after the change.Get the content before the change.booleanCheck whether the content has actually changed.Methods inherited from class com.vaadin.flow.component.ComponentEvent
getSource, isFromClient, unregisterListenerMethods inherited from class EventObject
toString
-
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 eventfromClient- whether the event originated from the clientoldContent- the content before the changenewContent- the content after the changechangeSource- the source of the change
-
-
Method Details
-
getOldContent
-
getNewContent
-
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)
-