Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

referenceerror window is not defined ckeditor

import React, { useState, useEffect, useRef } from 'react'

export default function MyEditor () {
  const editorRef = useRef()
  const [editorLoaded, setEditorLoaded] = useState(false)
  const { CKEditor, ClassicEditor } = editorRef.current || {}

  useEffect(() => {
    editorRef.current = {
      // CKEditor: require('@ckeditor/ckeditor5-react'), // depricated in v3
      CKEditor: require('@ckeditor/ckeditor5-react').CKEditor // v3+
      ClassicEditor: require('@ckeditor/ckeditor5-build-classic')
    }
    setEditorLoaded(true)
  }, [])

  return editorLoaded ? (
    <CKEditor
      editor={ClassicEditor}
      data='<p>Hello from CKEditor 5!</p>'
      onInit={editor => {
        // You can store the "editor" and use when it is needed.
        console.log('Editor is ready to use!', editor)
      }}
      onChange={(event, editor) => {
        const data = editor.getData()
        console.log({ event, editor, data })
      }}
    />
  ) : (
    <div>Editor loading</div>
  )
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to link a photo in expo react native 
Javascript :: js-cookie set expiration of cookie 
Javascript :: Bots latency discord js 
Javascript :: javascript pick random attribute from object 
Javascript :: command to create custom pipe in angular 6 
Javascript :: javascript getelementbyid 
Javascript :: javascript get parent element height javascript 
Javascript :: angularjs accordion access toggle 
Javascript :: jquery duplicate last table row 
Javascript :: How to get the input from a textbox javascript 
Javascript :: js check string for isogram 
Javascript :: node fs full path 
Javascript :: contenteditable paste plain text 
Javascript :: how to call a function with arguments on event listener javascript 
Javascript :: xmlhttprequest javascript 
Javascript :: how to disable keyboard calender input in material ui datepicker reactjs 
Javascript :: An external JavaScript cannot contain the <script tag 
Javascript :: insert into array js 
Javascript :: jquery google 
Javascript :: restrict the user from going to signup or login page if the user is already logged in firebase auth 
Javascript :: open cypress window 
Javascript :: javascript array push element at index 
Javascript :: angular refresh token 
Javascript :: react native button top right 
Javascript :: MVC 5 controller return json value to view 
Javascript :: javascript simulate click on element 
Javascript :: picker change event react native 
Javascript :: how to check all values of an array are equal or not in javascript 
Javascript :: get table row data jquery 
Javascript :: discord.js how to send a message to all guilds 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =