nhn / tui.editor

🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
http://ui.toast.com/tui-editor
MIT License
16.91k stars 1.72k forks source link

self is not defined (vue3 + nuxt3) #3188

Closed snowdream closed 5 months ago

snowdream commented 9 months ago

Describe the bug

I want to import tui editor into my project(vue3 + nuxt3),but failed.

errors: self is not defined

To Reproduce

  1. import
    npm install --save @toast-ui/vue-editor
  2. define componet
<template>
  <editor
    :initial-value="editorText"
    :options="defaultEditorOptions"
    height="500px"
    initial-edit-type="wysiwyg"
    preview-style="vertical"
  />
</template>

<script setup lang="ts">
import { reactive, ref, onMounted, onUnmounted, nextTick } from 'vue'

import '@toast-ui/editor/dist/toastui-editor.css'

import { Editor } from '@toast-ui/vue-editor'

const editorText = ref('This is initialValue.')

const defaultEditorOptions = reactive({
  minHeight: '200px',
  language: 'en-US',
  useCommandShortcut: true,
  usageStatistics: true,
  hideModeSwitch: false,
  toolbarItems: [
    ['heading', 'bold', 'italic', 'strike'],
    ['hr', 'quote'],
    ['ul', 'ol', 'task', 'indent', 'outdent'],
    ['table', 'image', 'link'],
    ['code', 'codeblock'],
    ['scrollSync']
  ]
})
</script>
  1. build and run

Expected behavior

It works!

Screenshots

image

Desktop (please complete the following information):

XiaoRongwen commented 5 months ago

博主解决了么

snowdream commented 5 months ago

https://github.com/snowdreamtech/vue-tui-editor