MCPcopy
hub / github.com/tinymce/tinymce / resetContent

Method resetContent

modules/tinymce/src/core/main/ts/api/Editor.ts:909–924  ·  view source on GitHub ↗

* Resets the editors content, undo/redo history and dirty state. If `initialContent` isn't specified, then * the editor is reset back to the initial start content. * * @method resetContent * @param {String} initialContent An optional string to use as the initial content of the editor.

(initialContent?: string)

Source from the content-addressed store, hash-verified

907 * @param {String} initialContent An optional string to use as the initial content of the editor.
908 */
909 public resetContent(initialContent?: string): void {
910 // Set the editor content
911 if (initialContent === undefined) {
912 // editor.startContent is generated by using the `raw` format, so we should set it the same way
913 EditorContent.setContent(this, this.startContent, { initial: true, format: 'raw' });
914 } else {
915 EditorContent.setContent(this, initialContent, { initial: true });
916 }
917
918 // Update the editor/undo manager state
919 this.undoManager.reset();
920 this.setDirty(false);
921
922 // Fire a node change event
923 this.nodeChanged();
924 }
925
926 /**
927 * Returns true/false if the editor is dirty or not. It will get dirty if the user has made modifications to the contents.

Calls 3

setDirtyMethod · 0.95
nodeChangedMethod · 0.95
setContentMethod · 0.80

Tested by

no test coverage detected