Skip to content
New issue

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

hi, how to use editor.js in nuxt.js, is there an example? #1038

Closed
Yakumo-Yukari opened this issue Feb 15, 2020 · 6 comments
Closed

hi, how to use editor.js in nuxt.js, is there an example? #1038

Yakumo-Yukari opened this issue Feb 15, 2020 · 6 comments

Comments

@Yakumo-Yukari
Copy link

How to use editor.js in nuxt.js, are there any related examples?

@neSpecc
Copy link
Member

neSpecc commented Feb 15, 2020

Related #1036

@zabavnikov
Copy link

zabavnikov commented Feb 15, 2020

Hi @Yakumo-Yukari! Try this.

<template>
  <div id="codex-editor"></div>
</template>

<script>
  let EditorJS = null;

  if (process.client) {
    EditorJS = require('@editorjs/editorjs')
  }

  export default {
    mounted() {
      const editor = new EditorJS({
        /**
         * Id of Element that should contain Editor instance
         */
        holder: 'codex-editor'
      });
    }
  }
</script>

@Yakumo-Yukari
Copy link
Author

Hi @Yakumo-Yukari! Try this.

<template>
  <div id="codex-editor"></div>
</template>

<script>
  let EditorJS = null;

  if (process.client) {
    EditorJS = require('@editorjs/editorjs')
  }

  export default {
    mounted() {
      const editor = new EditorJS({
        /**
         * Id of Element that should contain Editor instance
         */
        holder: 'codex-editor'
      });
    }
  }
</script>

Thanks for the example

@gbgb66
Copy link

gbgb66 commented Apr 10, 2020

Hi @Yakumo-Yukari! Try this.

<template>
  <div id="codex-editor"></div>
</template>

<script>
  let EditorJS = null;

  if (process.client) {
    EditorJS = require('@editorjs/editorjs')
  }

  export default {
    mounted() {
      const editor = new EditorJS({
        /**
         * Id of Element that should contain Editor instance
         */
        holder: 'codex-editor'
      });
    }
  }
</script>

it's works, but how import tools?

@Yakumo-Yukari
Copy link
Author

Hi @Yakumo-Yukari! Try this.

<template>
  <div id="codex-editor"></div>
</template>

<script>
  let EditorJS = null;

  if (process.client) {
    EditorJS = require('@editorjs/editorjs')
  }

  export default {
    mounted() {
      const editor = new EditorJS({
        /**
         * Id of Element that should contain Editor instance
         */
        holder: 'codex-editor'
      });
    }
  }
</script>

it's works, but how import tools?

Thank you so much for your help.

@joffreyBerrier
Copy link

Hi, you can do better in Nuxt3 like that:

<script setup lang="ts">
  const uploadEditorJS = () => import('@editorjs/editorjs')
  let Editor = null

  onMounted(async () => {
    try {
      const editor = await uploadEditorJS()
      Editor = new editor.default({
        holder: 'editorjs',
      })
    } catch (err) {
      console.log(err)
    }
  })
</script>

<template>
  <div id="editorjs" />
</template>

🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants