We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not really an issue, but for those using nuxt 3:
Create file named "vue-editor.client.vue" in "./components/" (file name can be anything, but remember ".client.vue"). You can paste this inside of it:
<script lang="ts"> import EditorJS from "@editorjs/editorjs"; interface Props { holder: string; config: Object; initialized: Function; } export default defineNuxtComponent({ name: "vue-editor-js", props: { holder: { type: String, default: () => "vue-editor-js", require: true, }, config: { type: Object, default: () => ({}), require: true, }, initialized: { type: Function, default: () => {}, }, }, setup: (props, context) => { const state = reactive({ editor: null }); function initEditor(props: Props) { destroyEditor(); state.editor = new EditorJS({ holder: props.holder || "vue-editor-js", ...props.config, }); props.initialized(state.editor); } function destroyEditor() { if (state.editor) { state.editor.destory(); state.editor = null; } } onMounted((_: void) => initEditor(props)); return { props, state }; }, }); </script>
OR
<script lang="ts" setup> import EditorJS from "@editorjs/editorjs"; const editorProps = defineProps({ holder: { type: String, default: () => "vue-editor-js", require: true, }, config: { type: Object, default: () => ({}), require: true, }, initialized: { type: Function, default: () => {}, }, }); const state = reactive({ editor: null }); const destroyEditor = () => { if (state.editor) { state.editor.destory(); state.editor = null; } }; const initEditor = () => { destroyEditor(); state.editor = new EditorJS({ holder: editorProps.holder || "vue-editor-js", ...editorProps.config, }); editorProps.initialized(state.editor); }; onMounted((_: void) => initEditor()); </script>
<template> <div :id="holder"></div> </template>
Inside "app.vue" you should add following:
<script lang="ts" setup> onMounted(() => { const VueEditor = () => import("../components/nuxt-editor.client.vue"); }); </script>
<template> <ClientOnly> <vue-editor /> </ClientOnly> </template>
Or if you want easiest way:
Inside ./components/vue-editor.client.vue:
<script lang="ts" setup> import EditorJS from "@editorjs/editorjs"; // @ts-ignore import Header from "@editorjs/header"; onMounted(() => { new EditorJS({ holder: "vue-editor-js", autofocus: true, tools: { header: { class: Header, config: { placeholder: "Enter a header", levels: [1, 2, 3, 4, 5, 6], defaultLevel: 3, }, }, }, }); }); </script>
<template> <div id="vue-editor-js"></div> </template>
inside app.vue:
The text was updated successfully, but these errors were encountered:
Here's another approach on how to implement it:
In components i have a file called editorjs.vue
components
editorjs.vue
<template> <div ref="editorDom" /> </template> <script lang="ts" setup> // import import EditorJS from "@editorjs/editorjs"; // variables const editor = ref<EditorJS>(); const editorDom = ref<HTMLElement>(); onMounted(() => { editor.value = new EditorJS({ holder: editorDom.value }); }); </script>
I can then use it anywhere like that:
<editorjs />
Sorry, something went wrong.
Here's another approach on how to implement it: In components i have a file called editorjs.vue <template> <div ref="editorDom" /> </template> <script lang="ts" setup> // import import EditorJS from "@editorjs/editorjs"; // variables const editor = ref<EditorJS>(); const editorDom = ref<HTMLElement>(); onMounted(() => { editor.value = new EditorJS({ holder: editorDom.value }); }); </script> I can then use it anywhere like that: <editorjs />
Thank you! This worked for me!
No branches or pull requests
Not really an issue, but for those using nuxt 3:
Create file named "vue-editor.client.vue" in "./components/" (file name can be anything, but remember ".client.vue").
You can paste this inside of it:
OR
Inside "app.vue" you should add following:
Or if you want easiest way:
Inside ./components/vue-editor.client.vue:
inside app.vue:
The text was updated successfully, but these errors were encountered: