样式调整
tui-editor i18n 配置
This commit is contained in:
parent
e94731590f
commit
5addb707ee
@ -19,7 +19,7 @@ watch(locale,(value)=>{
|
|||||||
if(elementUIConfig.supportLocale[value]){
|
if(elementUIConfig.supportLocale[value]){
|
||||||
elementUIConfig.locale = elementUIConfig.supportLocale[value]
|
elementUIConfig.locale = elementUIConfig.supportLocale[value]
|
||||||
} else {
|
} else {
|
||||||
elementUIConfig.locale = elementUIConfig.supportLocale["zh-Hans"]
|
elementUIConfig.locale = elementUIConfig.supportLocale["zh-CN"]
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
immediate: true
|
immediate: true
|
||||||
@ -85,7 +85,7 @@ document.body.addEventListener("click", function (event) {
|
|||||||
<router-view v-slot="{ Component, route }">
|
<router-view v-slot="{ Component, route }">
|
||||||
<component v-if="route.matched && route.matched.length > 0 && route.matched[0].children.length === 0" :is="Component"/>
|
<component v-if="route.matched && route.matched.length > 0 && route.matched[0].children.length === 0" :is="Component"/>
|
||||||
<transition v-else name="fade" mode="out-in">
|
<transition v-else name="fade" mode="out-in">
|
||||||
<div style="height: 100vh" class="overflow-auto">
|
<div style="max-height: 100vh" class="max-h-full overflow-auto">
|
||||||
<component
|
<component
|
||||||
v-if="route.meta.keepAlive != null && (route.meta.groups ? true: route.meta.keepAlive === false)"
|
v-if="route.meta.keepAlive != null && (route.meta.groups ? true: route.meta.keepAlive === false)"
|
||||||
:is="Component"
|
:is="Component"
|
||||||
@ -119,10 +119,10 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
position: relative;
|
position: static;
|
||||||
// width: 900px;
|
// width: 900px;
|
||||||
// height: 520px;
|
// height: 520px;
|
||||||
height: 100vh;
|
max-height: 100vh;
|
||||||
background-color: rgba(255, 255, 255, 0.9);
|
background-color: rgba(255, 255, 255, 0.9);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import '@toast-ui/editor/dist/toastui-editor.css';
|
import '@toast-ui/editor/dist/toastui-editor.css';
|
||||||
import {onMounted, reactive, ref} from "vue";
|
import type {Ref} from "vue";
|
||||||
|
import {onMounted, reactive, ref, watch} from "vue";
|
||||||
import Editor from "@toast-ui/editor";
|
import Editor from "@toast-ui/editor";
|
||||||
import Prism from 'prismjs'
|
import Prism from 'prismjs'
|
||||||
import codeSyntaxHighlight from '@toast-ui/editor-plugin-code-syntax-highlight'
|
import codeSyntaxHighlight from '@toast-ui/editor-plugin-code-syntax-highlight'
|
||||||
import chart from "@toast-ui/editor-plugin-chart"
|
import chart from "@toast-ui/editor-plugin-chart"
|
||||||
import tableMergedCell from "@toast-ui/editor-plugin-table-merged-cell"
|
import tableMergedCell from "@toast-ui/editor-plugin-table-merged-cell"
|
||||||
import uml from "@toast-ui/editor-plugin-uml"
|
import uml from "@toast-ui/editor-plugin-uml"
|
||||||
|
import "@toast-ui/editor/dist/i18n/zh-cn";
|
||||||
|
import {useI18n} from "vue-i18n";
|
||||||
|
|
||||||
|
|
||||||
const chartOptions = {
|
const chartOptions = {
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
@ -15,27 +19,62 @@ const chartOptions = {
|
|||||||
maxHeight: 300
|
maxHeight: 300
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const {locale} = useI18n()
|
||||||
|
|
||||||
const editorRef = ref()
|
const editorRef = ref()
|
||||||
|
|
||||||
onMounted(() => {
|
function initEditor(editorRef:Ref<any>){
|
||||||
const editor = new Editor({
|
let editor = new Editor({
|
||||||
el: editorRef.value,
|
el: editorRef.value,
|
||||||
language: 'en-US',
|
// language: 'en-US',
|
||||||
|
language: locale.value,
|
||||||
previewStyle: 'vertical',
|
previewStyle: 'vertical',
|
||||||
height: '80vh',
|
height: '85vh',
|
||||||
initialValue: "",
|
initialValue: "",
|
||||||
plugins: [[chart, chartOptions], [codeSyntaxHighlight, {highlighter: Prism}], tableMergedCell, uml]
|
plugins: [
|
||||||
});
|
[chart, chartOptions],
|
||||||
|
[codeSyntaxHighlight, {highlighter: Prism}],
|
||||||
|
tableMergedCell,
|
||||||
|
uml,
|
||||||
|
],
|
||||||
|
useCommandShortcut: true,
|
||||||
|
usageStatistics: true,
|
||||||
|
hideModeSwitch: false,
|
||||||
|
toolbarItems: [
|
||||||
|
['heading', 'bold', 'italic', 'strike'],
|
||||||
|
['hr', 'quote'],
|
||||||
|
['ul', 'ol', 'task', 'indent', 'outdent'],
|
||||||
|
['table', 'image', 'link'],
|
||||||
|
['code', 'codeblock'],
|
||||||
|
['scrollSync'],
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
// const viewer = Editor.factory({
|
||||||
|
// el: editorRef.value,
|
||||||
|
// viewer: true,
|
||||||
|
// height: '500px',
|
||||||
|
// initialValue: "",
|
||||||
|
// plugins: [[chart, chartOptions], [codeSyntaxHighlight, { highlighter: Prism }], tableMergedCell, uml]
|
||||||
|
// });
|
||||||
|
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
console.log("locale.value",locale.value)
|
||||||
|
let editor = initEditor(editorRef);
|
||||||
|
watch(locale, value => {
|
||||||
|
let markdown = editor.getMarkdown()
|
||||||
|
editor.destroy()
|
||||||
|
|
||||||
|
editor = initEditor(editorRef);
|
||||||
|
editor.setMarkdown(markdown)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// const viewer = Editor.factory({
|
|
||||||
// el: document.querySelector('#viewer'),
|
|
||||||
// viewer: true,
|
|
||||||
// height: '500px',
|
|
||||||
// initialValue: "",
|
|
||||||
// plugins: [[chart, chartOptions], [codeSyntaxHighlight, { highlighter: Prism }], tableMergedCell, uml]
|
|
||||||
// });
|
|
||||||
//
|
//
|
||||||
// const defaultOptions = reactive({
|
// const defaultOptions = reactive({
|
||||||
// minHeight: '600px',
|
// minHeight: '600px',
|
||||||
@ -60,7 +99,7 @@ const ctx = reactive({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="editorRef"/>
|
<div ref="editorRef" class="overscroll-none"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
|
|
||||||
import zhHans from "./locales/zh-Hans.json";
|
import zhCN from "./locales/zh-CN.json";
|
||||||
import en from "./locales/en.json";
|
import en from "./locales/en.json";
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
locale: "zh-Hans",
|
locale: "zh-CN",
|
||||||
fallbackLocale: "zh-Hans",
|
fallbackLocale: "zh-CN",
|
||||||
legacy: false,
|
legacy: false,
|
||||||
messages: {
|
messages: {
|
||||||
"zh-Hans": zhHans,
|
"zh-CN": zhCN,
|
||||||
en: en,
|
en: en,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
"en": "English",
|
"en": "English",
|
||||||
"zh-Hans": "简体中文",
|
"zh-CN": "简体中文",
|
||||||
"fr": "Français"
|
"fr": "Français"
|
||||||
},
|
},
|
||||||
"topbar": {
|
"topbar": {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
"en": "English",
|
"en": "English",
|
||||||
"zh-Hans": "简体中文",
|
"zh-CN": "简体中文",
|
||||||
"fr": "Français"
|
"fr": "Français"
|
||||||
},
|
},
|
||||||
"topbar": {
|
"topbar": {
|
@ -7,7 +7,7 @@ export const useGlobalConfig = defineStore("globalConfig",{
|
|||||||
ui: {
|
ui: {
|
||||||
locale: zhCn,
|
locale: zhCn,
|
||||||
supportLocale: {
|
supportLocale: {
|
||||||
"zh-Hans": zhCn,
|
"zh-CN": zhCn,
|
||||||
en
|
en
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,10 @@ const {t} = useI18n();
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<router-view/>
|
<div class="relative">
|
||||||
|
<router-view/>
|
||||||
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
Loading…
Reference in New Issue
Block a user