Using TinyMCE from the Tiny Cloud CDN with the Svelte framework
The Official TinyMCE Svelte component integrates TinyMCE into Svelte applications. This procedure creates a basic Svelte application containing a TinyMCE editor.
For examples of the TinyMCE integration, visit the tinymce-svelte storybook.
Prerequisites
This procedure requires Node.js (and npm).
Procedure
-
Use the Vite package to create a new Svelte project named
tinymce-svelte-demo
, such as:npm create vite@5 tinymce-svelte-demo -- --template svelte
-
Change to the newly created directory.
cd tinymce-svelte-demo
-
Install the
tinymce-svelte
editor component, such as:npm install @tinymce/tinymce-svelte
-
Open
src/App.svelte
and replace the contents with:<script> import Editor from '@tinymce/tinymce-svelte'; let conf = { height: 500, menubar: false, plugins: [ 'advlist', 'autolink', 'lists', 'link', 'image', 'charmap', 'anchor', 'searchreplace', 'visualblocks', 'code', 'fullscreen', 'insertdatetime', 'media', 'table', 'preview', 'help', 'wordcount' ], toolbar: 'undo redo | blocks | ' + 'bold italic forecolor | alignleft aligncenter ' + 'alignright alignjustify | bullist numlist outdent indent | ' + 'removeformat | help', } </script> <main> <h1>Hello Tiny</h1> <Editor apiKey='your-tiny-cloud-api-key' channel='6' value='<p>This is the initial content of the editor.</p>' {conf} /> </main>
-
Test the application using the Node.js development server.
-
To start the development server, in the project’s root directory, run:
npm run dev
-
To stop the development server, select on the command line or command prompt and press Ctrl+C.
-
Next Steps
-
For examples of the TinyMCE integration, see: the tinymce-svelte storybook.
-
For information on customizing, see: