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
setHTMLCodepushes an undo entry; callingclearHistory()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 disabledReset the editor when switching to a different record in a single-page app:
function openRecord(html) {
editor1.setHTMLCode(html);
editor1.clearHistory();
}Related
- editor.setHTMLCode(html)— load content (pairs naturally with clearing history).
- editor.commitBookmark()— finalize the current undo entry so the next edit starts a new one.
- All editor methods— the full JavaScript API surface.