Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 1.22 KB

File metadata and controls

36 lines (25 loc) · 1.22 KB

Save the content from the editor

To retrieve content from the editor, either process the content with a form handler or use the getContent API.

If you use a form handler, once the <form> is submitted, {productname} {productmajorversion} will POST the content in the same way as a normal HTML <textarea>, including the HTML elements and inline CSS of the editor content. The host’s form handler can process the submitted content in the same way as content from a regular <textarea>.

Get and set content programmatically

Use the getContent and setContent APIs to read and write editor content from JavaScript.

Example: retrieve editor content as HTML

const editor = tinymce.activeEditor;
const html = editor.getContent();
console.log(html);

To retrieve the content as plain text instead of HTML:

const editor = tinymce.activeEditor;
const text = editor.getContent({ format: 'text' });
console.log(text);

Example: set editor content

const editor = tinymce.activeEditor;
editor.setContent('<p>New content</p>');