update vditor style
This commit is contained in:
1 parent
15631b6b6a
commit
bb00cb66a3
10 files changed
+190
-171
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-menu class="h-full" router :default-active="$route.name">
|
<el-menu class="h-full" :default-active="$route.name" @select="onSelect">
|
||||||
<el-menu-item index="article-index" @select="onSelect">
|
<el-menu-item index="article-index">
|
||||||
<el-icon class="mr-2">
|
<el-icon class="mr-2">
|
||||||
<document />
|
<document />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -35,6 +35,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onSelect(val: string) {
|
onSelect(val: string) {
|
||||||
|
console.log('val', val);
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: val
|
name: val
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default {
|
|||||||
TopHeader,
|
TopHeader,
|
||||||
Sidebar
|
Sidebar
|
||||||
},
|
},
|
||||||
name: 'LayoutEditor'
|
name: 'LayoutContent'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<top-header />
|
||||||
|
</el-header>
|
||||||
|
<el-container>
|
||||||
|
<el-main>
|
||||||
|
<router-view />
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</el-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import Sidebar from '@/components/content/Sidebar.vue';
|
||||||
|
import { TopHeader } from '@/components/common/index';
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
TopHeader,
|
||||||
|
Sidebar
|
||||||
|
},
|
||||||
|
name: 'LayoutEditor'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
#app {
|
||||||
|
height: initial;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.el-main {
|
||||||
|
display: initial;
|
||||||
|
flex: initial;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<template>
|
|
||||||
<breadcrumb />
|
|
||||||
<div id="vditor" class="vditor" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import Vditor from 'vditor';
|
|
||||||
import { Breadcrumb } from '@/components/common/index';
|
|
||||||
import { defaultOptions } from '@/settings/editor';
|
|
||||||
import 'vditor/src/assets/scss/index.scss';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
Breadcrumb
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
vditor: null
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.initVditor();
|
|
||||||
},
|
|
||||||
computed: {},
|
|
||||||
methods: {
|
|
||||||
initVditor() {
|
|
||||||
const options = {
|
|
||||||
width: this.isMobile ? '100%' : '80%',
|
|
||||||
height: '0',
|
|
||||||
tab: '\t',
|
|
||||||
mode: 'ir',
|
|
||||||
icon: 'material',
|
|
||||||
debugger: false,
|
|
||||||
after: () => {
|
|
||||||
this.vditor.setValue('');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.vditor = new Vditor('vditor', {
|
|
||||||
...defaultOptions,
|
|
||||||
...options
|
|
||||||
});
|
|
||||||
// this.vditor.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.vditor {
|
|
||||||
margin: 50px auto;
|
|
||||||
height: calc(100vh - 200px);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="24">
|
|
||||||
<div class="px-4 pt-4">
|
|
||||||
<el-card shadow="hover">
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div id="vditor" class="vditor" />
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import Vditor from 'vditor';
|
|
||||||
import { Breadcrumb } from '@/components/common/index';
|
|
||||||
import { defaultOptions } from '@/settings/editor';
|
|
||||||
import 'vditor/src/assets/scss/index.scss';
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { ArticleService } from '@/services';
|
|
||||||
import { IArticle, IArticleDetailResponse } from '@/services/article/types';
|
|
||||||
|
|
||||||
interface IData {
|
|
||||||
id: string | string[];
|
|
||||||
vditor: null | Vditor;
|
|
||||||
item: null | IArticle;
|
|
||||||
loading: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
components: {
|
|
||||||
Breadcrumb
|
|
||||||
},
|
|
||||||
data(): IData {
|
|
||||||
return {
|
|
||||||
id: this.$route.params.id,
|
|
||||||
vditor: null,
|
|
||||||
item: null,
|
|
||||||
loading: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
async mounted() {
|
|
||||||
ArticleService.get(this.id).then(({ data: data }: { data: IArticleDetailResponse }): void => {
|
|
||||||
console.log('data', data);
|
|
||||||
this.item = data;
|
|
||||||
this.loading = false;
|
|
||||||
if (this.vditor && this.item) {
|
|
||||||
this.vditor.setValue(this.item.content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.initVditor();
|
|
||||||
},
|
|
||||||
computed: {},
|
|
||||||
methods: {
|
|
||||||
initVditor() {
|
|
||||||
const options = {
|
|
||||||
width: '100%',
|
|
||||||
height: '0',
|
|
||||||
tab: '\t',
|
|
||||||
mode: 'ir',
|
|
||||||
icon: 'material',
|
|
||||||
debugger: false,
|
|
||||||
after: () => {
|
|
||||||
if (this.vditor?.getValue) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.item?.content) {
|
|
||||||
this.vditor?.setValue(this.item.content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.vditor = new Vditor('vditor', {
|
|
||||||
...defaultOptions,
|
|
||||||
...options
|
|
||||||
});
|
|
||||||
// this.vditor.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.vditor {
|
|
||||||
// margin: 50px auto;
|
|
||||||
height: calc(100vh - 200px);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<template>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="16" :offset="4">
|
||||||
|
<div class="px-4 pt-4">
|
||||||
|
<div id="vditor" class="vditor" />
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import Vditor from 'vditor';
|
||||||
|
import { Breadcrumb } from '@/components/common/index';
|
||||||
|
import { defaultOptions } from '@/settings/editor';
|
||||||
|
import 'vditor/src/assets/scss/index.scss';
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
import { ArticleService } from '@/services';
|
||||||
|
import { IArticle, IArticleDetailResponse } from '@/services/article/types';
|
||||||
|
|
||||||
|
interface IData {
|
||||||
|
id: string | string[];
|
||||||
|
vditor: null | Vditor;
|
||||||
|
item: null | IArticle;
|
||||||
|
loading: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
components: {
|
||||||
|
Breadcrumb
|
||||||
|
},
|
||||||
|
data(): IData {
|
||||||
|
return {
|
||||||
|
id: this.$route.params.id,
|
||||||
|
vditor: null,
|
||||||
|
item: null,
|
||||||
|
loading: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
async mounted() {
|
||||||
|
ArticleService.get(this.id).then(({ data: data }: { data: IArticleDetailResponse }): void => {
|
||||||
|
console.log('data', data);
|
||||||
|
this.item = data;
|
||||||
|
this.loading = false;
|
||||||
|
if (this.vditor && this.item) {
|
||||||
|
this.vditor.setValue(this.item.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.initVditor();
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {
|
||||||
|
initVditor() {
|
||||||
|
const options = {
|
||||||
|
width: '100%',
|
||||||
|
height: '0',
|
||||||
|
tab: '\t',
|
||||||
|
mode: 'ir',
|
||||||
|
icon: 'material',
|
||||||
|
debugger: false,
|
||||||
|
after: () => {
|
||||||
|
if (this.vditor?.getValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.item?.content) {
|
||||||
|
this.vditor?.setValue(this.item.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.vditor = new Vditor('vditor', {
|
||||||
|
...defaultOptions,
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
// this.vditor.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.vditor {
|
||||||
|
box-shadow: 0 1px 7px #ddd;
|
||||||
|
border: none;
|
||||||
|
margin-bottom: 100px;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vditor-toolbar {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
border-bottom: none;
|
||||||
|
position: fixed;
|
||||||
|
padding-left: 0 !important;
|
||||||
|
top: 65px;
|
||||||
|
z-index: 1000;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vditor-toolbar--pin {
|
||||||
|
// position: fixed;
|
||||||
|
top: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vditor-ir pre.vditor-reset {
|
||||||
|
padding-top: 80px !important;
|
||||||
|
padding-bottom: 80px !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -24,14 +24,6 @@ export default {
|
|||||||
},
|
},
|
||||||
component: () => import('@/pages/content/article/Index.vue')
|
component: () => import('@/pages/content/article/Index.vue')
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'article/:id',
|
|
||||||
name: 'article-edit',
|
|
||||||
meta: {
|
|
||||||
title: t('common.nav.article')
|
|
||||||
},
|
|
||||||
component: () => import('@/pages/content/article/Detail.vue')
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'platform',
|
path: 'platform',
|
||||||
name: 'platform-index',
|
name: 'platform-index',
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { t } from '../i18n';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
path: '/editor',
|
||||||
|
name: 'editor',
|
||||||
|
meta: {
|
||||||
|
title: t('common.nav.editor')
|
||||||
|
},
|
||||||
|
component: () => import('@/layouts/Editor.vue'),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'article/:id',
|
||||||
|
name: 'article-edit',
|
||||||
|
meta: {
|
||||||
|
title: t('common.nav.article')
|
||||||
|
},
|
||||||
|
component: () => import('@/pages/editor/article/Detail.vue')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
+3
-1
@@ -1,5 +1,6 @@
|
|||||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
||||||
import content from './content';
|
import content from './content';
|
||||||
|
import editor from './editor';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
@@ -7,7 +8,8 @@ const routes = [
|
|||||||
name: 'home',
|
name: 'home',
|
||||||
component: () => import('@/pages/Home.vue')
|
component: () => import('@/pages/Home.vue')
|
||||||
},
|
},
|
||||||
content
|
content,
|
||||||
|
editor
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
|||||||
+17
-17
@@ -1,23 +1,23 @@
|
|||||||
import { Constants } from 'vditor/src/ts/constants'
|
import { Constants } from 'vditor/src/ts/constants';
|
||||||
export const defaultOptions = {
|
export const defaultOptions = {
|
||||||
after: undefined,
|
after: undefined,
|
||||||
cache: {
|
cache: {
|
||||||
enable: true,
|
enable: true
|
||||||
},
|
},
|
||||||
cdn: Constants.CDN,
|
cdn: Constants.CDN,
|
||||||
classes: {
|
classes: {
|
||||||
preview: '',
|
preview: ''
|
||||||
},
|
},
|
||||||
comment: {
|
comment: {
|
||||||
enable: false,
|
enable: false
|
||||||
},
|
},
|
||||||
counter: {
|
counter: {
|
||||||
enable: true,
|
enable: true,
|
||||||
type: 'markdown',
|
type: 'markdown'
|
||||||
},
|
},
|
||||||
debugger: false,
|
debugger: false,
|
||||||
fullscreen: {
|
fullscreen: {
|
||||||
index: 90,
|
index: 90
|
||||||
},
|
},
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
hint: {
|
hint: {
|
||||||
@@ -30,18 +30,18 @@ export const defaultOptions = {
|
|||||||
heart: '❤️',
|
heart: '❤️',
|
||||||
rocket: '🚀️',
|
rocket: '🚀️',
|
||||||
smile: '😄',
|
smile: '😄',
|
||||||
tada: '🎉️',
|
tada: '🎉️'
|
||||||
},
|
},
|
||||||
emojiPath: `${Constants.CDN}/dist/images/emoji`,
|
emojiPath: `${Constants.CDN}/dist/images/emoji`,
|
||||||
extend: [],
|
extend: [],
|
||||||
parse: true,
|
parse: true
|
||||||
},
|
},
|
||||||
icon: 'ant',
|
icon: 'ant',
|
||||||
lang: 'zh_CN',
|
lang: 'zh_CN',
|
||||||
mode: 'ir',
|
mode: 'ir',
|
||||||
outline: {
|
outline: {
|
||||||
enable: false,
|
enable: false,
|
||||||
position: 'left',
|
position: 'left'
|
||||||
},
|
},
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
preview: {
|
preview: {
|
||||||
@@ -52,11 +52,11 @@ export const defaultOptions = {
|
|||||||
math: Constants.MATH_OPTIONS,
|
math: Constants.MATH_OPTIONS,
|
||||||
maxWidth: 800,
|
maxWidth: 800,
|
||||||
mode: 'both',
|
mode: 'both',
|
||||||
theme: Constants.THEME_OPTIONS,
|
theme: Constants.THEME_OPTIONS
|
||||||
},
|
},
|
||||||
resize: {
|
resize: {
|
||||||
enable: false,
|
enable: false,
|
||||||
position: 'bottom',
|
position: 'bottom'
|
||||||
},
|
},
|
||||||
theme: 'classic',
|
theme: 'classic',
|
||||||
toolbar: [
|
toolbar: [
|
||||||
@@ -91,12 +91,12 @@ export const defaultOptions = {
|
|||||||
'content-theme',
|
'content-theme',
|
||||||
{
|
{
|
||||||
name: 'more',
|
name: 'more',
|
||||||
toolbar: ['both', 'outline', 'export', 'preview'],
|
toolbar: ['both', 'outline', 'export', 'preview']
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
hide: false,
|
hide: false,
|
||||||
pin: true,
|
pin: false
|
||||||
},
|
},
|
||||||
typewriterMode: false,
|
typewriterMode: false,
|
||||||
undoDelay: 800,
|
undoDelay: 800,
|
||||||
@@ -108,8 +108,8 @@ export const defaultOptions = {
|
|||||||
max: 10 * 1024 * 1024,
|
max: 10 * 1024 * 1024,
|
||||||
multiple: true,
|
multiple: true,
|
||||||
url: '',
|
url: '',
|
||||||
withCredentials: false,
|
withCredentials: false
|
||||||
},
|
},
|
||||||
value: '',
|
value: '',
|
||||||
width: 'auto',
|
width: 'auto'
|
||||||
}
|
};
|
||||||
Reference in new issue
Block a user