ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.33k stars 3.68k forks source link

ckeditor5 main.js file #16771

Open cnaught opened 1 month ago

cnaught commented 1 month ago

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

pszczesniak commented 1 month ago

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.

CKEditorBot commented 3 weeks ago

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.