-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,42 @@ | ||
<template> | ||
<div class="page-container"></div> | ||
<div class="page-container"> | ||
<div ref="editorELRef"></div> | ||
<div class="innerHTML" :innerHTML="html"></div> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
// import wangeditor from 'wangeditor'; | ||
import { onMounted, ref, unref } from 'vue'; | ||
import wangeDitor from 'wangeditor'; | ||
import i18next from 'i18next'; | ||
import { useI18n } from '@/hooks/web/useI18n'; | ||
const editorELRef = ref<HTMLElement>({} as HTMLElement); | ||
const editor = ref<wangeDitor>({} as wangeDitor); | ||
const html = ref<string>(''); | ||
const { locale } = useI18n(); | ||
function init() { | ||
editor.value = new wangeDitor(unref(editorELRef)); | ||
editor.value.config.lang = locale.value === 'zh-ch' ? 'zh-ch' : 'en'; | ||
editor.value.i18next = i18next; | ||
editor.value.config.height = 500; | ||
Object.assign(editor.value.config, { | ||
onchange() { | ||
html.value = editor.value.txt.html() as string; | ||
}, | ||
}); | ||
editor.value.create(); | ||
} | ||
onMounted(() => { | ||
init(); | ||
}); | ||
</script> | ||
|
||
<style lang="scss"></style> | ||
<style lang="scss"> | ||
.innerHTML { | ||
margin-top: 20px; | ||
min-height: 50px; | ||
border: 1px solid #e3e3e3; | ||
} | ||
</style> |