2323import com .vaadin .flow .component .dependency .CssImport ;
2424import com .vaadin .flow .component .dependency .NpmPackage ;
2525import com .vaadin .flow .component .react .ReactAdapterComponent ;
26+ import com .vaadin .flow .function .SerializableConsumer ;
2627
2728/**
2829 * Base class for Markdown based Components.
@@ -47,13 +48,16 @@ public class BaseMarkdownComponent extends ReactAdapterComponent implements HasS
4748 */
4849 public enum DataColorMode {DARK ,LIGTH ,AUTO };
4950
51+ private String content ;
52+
5053 /**
5154 * Base constructor that receives the content of the markdown component.
5255 *
5356 * @param content content to be used in the Markdown component
5457 */
5558 public BaseMarkdownComponent (String content ) {
5659 setContent (content );
60+ this .addContentChangeListener (c ->this .content = c );
5761 }
5862
5963 /**
@@ -62,7 +66,7 @@ public BaseMarkdownComponent(String content) {
6266 * @return the content of the Markdown component
6367 */
6468 public String getContent () {
65- return getState ( " content" , String . class ) ;
69+ return content ;
6670 }
6771
6872 /**
@@ -71,9 +75,19 @@ public String getContent() {
7175 * @param content retrieved from the state of the component
7276 */
7377 public void setContent (String content ) {
78+ this .content = content ;
7479 setState ("content" , content );
7580 }
7681
82+ /**
83+ * Adds the specified listener for the content change event.
84+ *
85+ * @param listener the listener callback for receiving content changes
86+ */
87+ public void addContentChangeListener (SerializableConsumer <String > listener ) {
88+ addStateChangeListener ("content" , String .class , listener );
89+ }
90+
7791 /**
7892 * Sets the color mode of the Markdown component.
7993 *
0 commit comments