ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

ckeditor5 main.js file

Open cnaught opened this issue 1 year ago • 1 comments

📝 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.

cnaught avatar Jul 19 '24 20:07 cnaught

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.

pszczesniak avatar Jul 22 '24 09:07 pszczesniak

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.

CKEditorBot avatar Aug 14 '24 02:08 CKEditorBot

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).

CKEditorBot avatar Oct 01 '24 23:10 CKEditorBot

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.

Ezyweb-uk avatar Feb 12 '25 12:02 Ezyweb-uk