Using the TinyMCE package with the Web Component
The Official TinyMCE Web Component integrates TinyMCE into Web Component projects. This procedure creates an HTML page containing a TinyMCE editor.
Procedure
To add a TinyMCE editor to a web page using the TinyMCE Web Component:
-
Add the following meta tags to the head section of the page:
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">The second
metaelement is required for the editor to function correctly on mobile devices. For information on the viewportmetaelement, see: MDN Web Docs - Using the viewport meta tag to control layout on mobile browsers. -
Add the
tinymceandtinymce-webcomponentpackages, such as:npm install tinymce @tinymce/tinymce-webcomponent -
Bundle TinyMCE with the Web Component application using a module loader (such as Webpack).
Tiny does not recommend bundling tinymceandtinymce-webcomponentwith a module loader. Bundling these packages can be complex and error prone.To bundle TinyMCE using a module loader (such as Webpack, Rollup, or Browserify), import or require the
tinymcepackage, followed by thetinymce-webcomponentpackage, then the other required TinyMCE-related imports.Example of bundling:
/* Add the tinymce-webcomponent wrapper to the bundle */ import { Editor } from '@tinymce/tinymce-webcomponent'; /* For instructions on bundling TinyMCE, see the Bundling TinyMCE documentation. */For instructions on bundling TinyMCE, see: Bundling TinyMCE.
-
Add a
scriptelement sourcing the output file, such as:<script src="/path/to/bundle.js"></script>If a
scriptelement sourcing TinyMCE is not provided, the TinyMCE Web Component will load TinyMCE from the Tiny Cloud. -
Add a
tinymce-editorelement where the editor should appear.<tinymce-editor license-key="your-license-key"></tinymce-editor>The default TinyMCE editor will load at this location if the page is opened in a web browser.
-
Update the
license-keyoption in the editor element and include your License Key.
Next Steps
-
For information on customizing, see:
-
The TinyMCE Web Component, see: The TinyMCE Web Component Technical Reference.
-