ckeditor5 main.js file
📝 Ask a question
I would like to put the configuration in an external js file called main.js. But I would like the following line to be in my main .html page:
ClassicEditor.create(document.querySelector('#editor'), editorConfig);
As soon as I move the above line into the main .html file, it stops working. I was hoping to have the main config in a separate file, but the call to the editor within the main .html file because I use multiple instances of the editor on a single page.
You are close to make it work as expected.
Please export the editorConfigobject from your main.js file.
And all you have to do is:
- <script type="module" src="./ckeditor/main.js"></script>
- <script> ClassicEditor.create(document.querySelector('#editor'), editorConfig); </script>
+ <script type="module">
+ import { ClassicEditor } from 'ckeditor5';
+ import { editorConfig } from './main.js'
+
+ ClassicEditor.create( document.querySelector( '#editor' ), editorConfig );
+ </script>
Please let us know if it solves your problem.
The issue lacks the feedback we asked for two weeks. Hence, we've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.
We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).
I'm sure this will be a common requirement, I had to spend quite some time searching for this solution. Would it be a good idea to add such notes to the documentation to help others?
I also wanted to put the importmap in an external json file but it appears that this is not yet supported by browsers like Firefox, etc.