I am facing a challenge with integrating CKEditor 5
into my Vue.js 3 application, particularly in ensuring that it is only loaded on the client-side. Due to server-side rendering limitations, I need CKEditor to be included dynamically based on the browser request, and not when Node.js initiates the app.
Within the setup() method, I have checked for IsBrowser
using the following code:
const IsBrowser = typeof window !== 'undefined';
How can I handle the import
and initialization of a component only if IsBrowser
evaluates to true?
To make CKEditor-5 function properly, I have implemented the following code:
<CKEditor v-if="IsBrowser" id="PostContent" class="ck-content" contenteditable="true" :editor="CKEditorInline" ></CKEditor>
<script>
import CKEditor from '@ckeditor/ckeditor5-vue/dist/ckeditor'
import CKEditorInline from '@ckeditor/ckeditor5-editor-inline/src/inlineeditor';
export default {
name: "ComponentCreate",
components: {
CKEditor: CKEditor.component
},
data() {
return {
CKEditorInline: CKEditorInline,
</script>