I'm trying to use EditorJs in NuxtJs project.
Medium has an article on https://medium.com/code4mk-org/editorjs-vue-a78110c3fff8.
It works, but if I reload the page I get a "window not defined" error because the code is trying to run on the server side.
There is a package called https://github.com/ChangJoo-Park/vue-editor-js that works for NuxtJs, but it has an issue with image upload.
//I try change
import EditorJS from '@editorjs/editorjs'
//to
const EditorJS = require('@editorjs/editorjs')
It's works, but i got error on load tools
// ImageTool = require('@editorjs/image') // got error
Perhaps there is another way?
Here is an example of how I used it in a Nuxt.js project:
Using with Nuxt.js (2.15.x)
Tested with
editor.js 2.22.x
andnuxt 2.15.x
. You will obviously have to expand for your needs but this is the basics.Install modules
Install all your modules:
npm i --save @editorjs/editorjs @editorjs/header
Create plugin
1. Create the following in your Nuxt project
plugins/editor.js
2. Edit your
nuxt.config.js
plugins
block to include it:3. Create component
components/Editor.vue
4. Create component to display editor results in
components/Blog.vue
4. Example using in
pages/index.vue