Change is not triggered by setting [value] ?


If I set initial value and then overide that value with a button click. An undo action does not become present how could I programmatically set value of rich text editor and after each setting have it saved as a step for undoing?

        <ejs-richtexteditor

         #toolsRTE
         id="alltoolRTE"
         [showCharCount]="true"
         [quickToolbarSettings]="quickToolbarSettings"
         (toolbarClick)="toolbarClick($event)"
         [toolbarSettings]="tools"
         [(value)]="richtextData"
       >
       
       </ejs-richtexteditor>


 public submitClick = (): void => {

    this.richtextData="asd"
  };




















2 Replies

JB Jonas Blazinskas January 24, 2024 04:18 PM UTC

found this to sort of do the trick:

    this.defaultRTE.formatter.saveData();


problem is that even tho initial data gets saved the undo arrow does not highlight until you start typing







VJ Vinitha Jeyakumar Syncfusion Team January 25, 2024 10:00 AM UTC

Hi Jonas Blazinskas,

Your requirement can be achieved by using the enableUndo function along with saveData. Please check the code and sample below,

Code snippet:
public BtnClick(): void {
    if (this.rteObj.formatter.getUndoRedoStack().length === 0) {
      this.rteObj.formatter.saveData();
    }
    this.richtextData = 'RichTextEditor';
    this.rteObj.formatter.saveData();
    (this.rteObj as any).formatter.enableUndo(this.rteObj);
  }



Regards,
Vinitha

Loader.
Up arrow icon