Documentation

editor.clearHistory()

Empties both the undo and redo stacks. The document content is untouched — only the recorded history is cleared. Call it after you load a fresh document programmatically so the user cannot undo their way back past the content you just set.

Syntax

editor.clearHistory()

Parameters

None.

Returns

Nothing (undefined).

Behavior notes

  • Content is not affected. Clearing history removes undo/redo records only; whatever is in the editor stays exactly as it is.
  • Toolbar state refreshes. After the stacks are emptied the editor re-evaluates its selection state, so the Undo and Redo toolbar buttons correctly show as disabled.
  • Pair it with a programmatic load. Setting content with setHTMLCode pushes an undo entry; calling clearHistory() right after makes that loaded state the clean starting point.

Example usage

Load a document and make it the baseline the user cannot undo past:

var editor1 = new RichTextEditor("#div_editor1");
editor1.setHTMLCode(loadedDocumentHtml);
editor1.clearHistory();   // fresh start; Undo is now disabled

Reset the editor when switching to a different record in a single-page app:

function openRecord(html) {
    editor1.setHTMLCode(html);
    editor1.clearHistory();
}

Related