Editorjs for vue3
Installation
To start using the library, install it in your project:
pnpm install @dicarbene/vue-editorjs
or
yarn add @dicarbene/vue-editorjs
Usage
For Vue 3
<!-- component.vue -->
<template>
<EditorjsClient :data="dat" />
</template>
<script lang="ts" setup>
import { EditorjsClient } from '@dicarbene/vue-editorjs'
const dat = ref({})
</script>
For Nuxt 3
Define a nuxt plugin
// plugins/editorjs.client.ts
import { EditorjsClient } from '@dicarbene/vue-editorjs'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component('EditorjsClient', EditorjsClient)
})
Use EditorjsClient
component anywhere in the Vue SFC
<!-- editor.vue -->
<template>
<div>
<ClientOnly>
<EditorjsClient :data="dat" />
</ClientOnly>
</div>
</template>
<script setup lang="ts">
const dat = ref({})
</script>
Add the build transpile.
// nuxt.config.ts
import { defineNuxtConfig } from 'nuxt/config'
export default defineNuxtConfig({
...
build: {
transpile: ['@dicarbene/vue-editorjs']
}
})