Merge pull request #2288 from dataease/pr@dev@refactor_rich-text

refactor: 丰富富文本插件
This commit is contained in:
王嘉豪 2022-05-20 20:30:57 +08:00 committed by GitHub
commit 47163af09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 21 deletions

View File

@ -5,7 +5,6 @@
* For commercial licenses see https://www.tiny.cloud/ * For commercial licenses see https://www.tiny.cloud/
*/ */
table { table {
border-collapse: collapse; border-collapse: collapse;
} }

View File

@ -1,19 +1,20 @@
<template> <template>
<div v-if="editStatus" class="rich-main-class"> <div class="rich-main-class" @dblclick="setEdit">
<Editor <Editor
v-show="canEdit" v-if="editShow"
:id="tinymceId" :id="tinymceId"
v-model="myValue" v-model="myValue"
style="width: 100%;height: 100%" style="width: 100%;height: 100%"
:init="init" :init="init"
:disabled="disabled" :disabled="!canEdit"
@onClick="onClick" @onClick="onClick"
/> />
<div v-show="!canEdit" style="width: 100%;height: 100%" @dblclick="setEdit" v-html="myValue" /> <!-- <div v-show="!canEdit" style="width: 100%;height: 100%" @dblclick="setEdit" v-html="myValue" />-->
</div>
<div v-else class="rich-main-class">
<div v-html="myValue" />
</div> </div>
<!-- <div v-else class="rich-main-class">-->
<!-- <Editor :id="tinymceId"/>-->
<!-- <div v-html="myValue" />-->
<!-- </div>-->
</template> </template>
@ -32,6 +33,10 @@ import 'tinymce/plugins/charmap' // 特殊字符
import 'tinymce/plugins/media' // import 'tinymce/plugins/media' //
import 'tinymce/plugins/wordcount'// import 'tinymce/plugins/wordcount'//
import 'tinymce/plugins/table'// import 'tinymce/plugins/table'//
import 'tinymce/plugins/contextmenu'// contextmenu
import 'tinymce/plugins/directionality'
import 'tinymce/plugins/nonbreaking'
import 'tinymce/plugins/pagebreak'
import { mapState } from 'vuex' import { mapState } from 'vuex'
// const fonts = [ // const fonts = [
@ -93,6 +98,7 @@ export default {
}, },
data() { data() {
return { return {
editShow: true,
canEdit: false, canEdit: false,
// //
tinymceId: 'tinymce', tinymceId: 'tinymce',
@ -104,9 +110,13 @@ export default {
language: 'zh_CN', language: 'zh_CN',
skin_url: '/tinymce/skins/ui/oxide', // skin_url: '/tinymce/skins/ui/oxide', //
content_css: '/tinymce/skins/content/default/content.css', content_css: '/tinymce/skins/content/default/content.css',
plugins: 'advlist autolink link image lists charmap media wordcount table', // plugins: 'advlist autolink link image lists charmap media wordcount table contextmenu directionality pagebreak', //
// //
toolbar: 'undo redo | fontsizeselect | bold italic forecolor backcolor| alignleft aligncenter alignright | lists image media table link', // toolbar: 'undo redo | fontsizeselect fontselect | bold italic forecolor backcolor underline strikethrough | alignleft aligncenter alignright | lists image media table link | bullist numlist ',
toolbar: 'undo redo |fontsizeselect forecolor backcolor bold italic underline strikethrough link | ' +
'alignleft aligncenter alignright | bullist numlist |' +
' blockquote subscript superscript removeformat | table image media | fullscreen ' +
'| bdmap indent2em lineheight formatpainter axupimgs',
toolbar_location: '/', toolbar_location: '/',
fontsize_formats: '12px 14px 16px 18px 20px 22px 24px 28px 32px 36px 48px 56px 72px', // fontsize_formats: '12px 14px 16px 18px 20px 22px 24px 28px 32px 36px 48px 56px 72px', //
menubar: false, menubar: false,
@ -128,7 +138,11 @@ export default {
// //
active(val) { active(val) {
if (!val) { if (!val) {
this.editShow = false
this.canEdit = false this.canEdit = false
this.$nextTick(() => {
this.editShow = true
})
} }
}, },
// //
@ -148,8 +162,10 @@ export default {
this.$emit('onClick', e, tinymce) this.$emit('onClick', e, tinymce)
}, },
setEdit() { setEdit() {
this.canEdit = true if (this.editStatus) {
this.element.editing = true this.canEdit = true
this.element.editing = true
}
} }
} }
} }
@ -165,5 +181,27 @@ export default {
width: 0px!important; width: 0px!important;
height: 0px!important; height: 0px!important;
} }
::v-deep ol {
display: block!important;
list-style-type: decimal;
margin-block-start: 1em!important;
margin-block-end: 1em!important;
margin-inline-start: 0px!important;
margin-inline-end: 0px!important;
padding-inline-start: 40px!important;
}
::v-deep ul {
display: block!important;
list-style-type: disc;
margin-block-start: 1em!important;
margin-block-end: 1em!important;
margin-inline-start: 0px!important;
margin-inline-end: 0px!important;
padding-inline-start: 40px!important;
}
::v-deep li {
display: list-item!important;
text-align: -webkit-match-parent!important;
}
</style> </style>

View File

@ -266,14 +266,7 @@ const list = [
hyperlinks: HYPERLINKS, hyperlinks: HYPERLINKS,
style: { style: {
width: 400, width: 400,
height: 100, height: 100
fontSize: 22,
fontWeight: 400,
lineHeight: '',
letterSpacing: 0,
textAlign: 'center',
color: '#000000',
verticalAlign: 'middle'
}, },
x: 1, x: 1,
y: 1, y: 1,

View File

@ -690,7 +690,13 @@ export default {
this.$store.commit('refreshSnapshot') this.$store.commit('refreshSnapshot')
this.$store.commit('setComponentData', []) this.$store.commit('setComponentData', [])
this.$store.commit('setCanvasStyle', DEFAULT_COMMON_CANVAS_STYLE_STRING) this.$store.commit('setCanvasStyle', DEFAULT_COMMON_CANVAS_STYLE_STRING)
this.$store.dispatch('panel/setPanelInfo', data) this.$store.dispatch('panel/setPanelInfo', {
id: data.id,
name: data.name,
privileges: data.privileges,
sourcePanelName: data.sourcePanelName,
status: data.status
})
bus.$emit('PanelSwitchComponent', { name: 'PanelEdit' }) bus.$emit('PanelSwitchComponent', { name: 'PanelEdit' })
}, },
link(data) { link(data) {