Merge pull request #3314 from dataease/pr@dev@refactor_rich-text
refactor(仪表板): 富文本组件和富文本视图支持自适应缩放
This commit is contained in:
commit
7b3b0cc6fa
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="rich-main-class" @dblclick="setEdit">
|
<div class="rich-main-class" :style="autoStyle" @dblclick="setEdit">
|
||||||
<Editor
|
<Editor
|
||||||
v-if="editShow"
|
v-if="editShow"
|
||||||
:id="tinymceId"
|
:id="tinymceId"
|
||||||
@ -39,6 +39,10 @@ export default {
|
|||||||
Editor
|
Editor
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
terminal: {
|
||||||
|
type: String,
|
||||||
|
default: 'pc'
|
||||||
|
},
|
||||||
propValue: {
|
propValue: {
|
||||||
type: String,
|
type: String,
|
||||||
require: true
|
require: true
|
||||||
@ -93,11 +97,31 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
scale(){
|
||||||
|
return Math.min(this.previewCanvasScale.scalePointWidth, this.previewCanvasScale.scalePointHeight) * this.scaleCoefficient
|
||||||
|
},
|
||||||
editStatus() {
|
editStatus() {
|
||||||
return this.editMode === 'edit' && !this.mobileLayoutStatus
|
return this.editMode === 'edit' && !this.mobileLayoutStatus
|
||||||
},
|
},
|
||||||
|
autoStyle() {
|
||||||
|
return {
|
||||||
|
height: (100 / this.scale) + '%!important',
|
||||||
|
width: (100 / this.scale) + '%!important',
|
||||||
|
left: 50 * (1 - 1 / this.scale) + '%', //放大余量 除以 2
|
||||||
|
top: 50 * (1 - 1 / this.scale) + '%',
|
||||||
|
transform: 'scale(' + this.scale + ')'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scaleCoefficient() {
|
||||||
|
if (this.terminal === 'pc' && !this.mobileLayoutStatus) {
|
||||||
|
return 1.1
|
||||||
|
} else {
|
||||||
|
return 4.5
|
||||||
|
}
|
||||||
|
},
|
||||||
...mapState([
|
...mapState([
|
||||||
'mobileLayoutStatus'
|
'mobileLayoutStatus',
|
||||||
|
'previewCanvasScale'
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -146,6 +170,7 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto!important;
|
overflow-y: auto!important;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 0px!important;
|
width: 0px!important;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="rich-main-class" @dblclick="setEdit">
|
<div class="rich-main-class" :style="autoStyle" @dblclick="setEdit">
|
||||||
<Editor
|
<Editor
|
||||||
v-if="editShow"
|
v-if="editShow"
|
||||||
:id="tinymceId"
|
:id="tinymceId"
|
||||||
@ -41,6 +41,11 @@ export default {
|
|||||||
Editor
|
Editor
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
scale: {
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
element: {
|
element: {
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
@ -102,6 +107,15 @@ export default {
|
|||||||
editStatus() {
|
editStatus() {
|
||||||
return this.editMode === 'edit' && !this.mobileLayoutStatus
|
return this.editMode === 'edit' && !this.mobileLayoutStatus
|
||||||
},
|
},
|
||||||
|
autoStyle() {
|
||||||
|
return {
|
||||||
|
height: (100 / this.scale) + '%!important',
|
||||||
|
width: (100 / this.scale) + '%!important',
|
||||||
|
left: 50 * (1 - 1 / this.scale) + '%', //放大余量 除以 2
|
||||||
|
top: 50 * (1 - 1 / this.scale) + '%',
|
||||||
|
transform: 'scale(' + this.scale + ')'
|
||||||
|
}
|
||||||
|
},
|
||||||
...mapState([
|
...mapState([
|
||||||
'mobileLayoutStatus'
|
'mobileLayoutStatus'
|
||||||
])
|
])
|
||||||
@ -167,14 +181,14 @@ export default {
|
|||||||
ed.insertContent(attachValue)
|
ed.insertContent(attachValue)
|
||||||
},
|
},
|
||||||
onClick(e) {
|
onClick(e) {
|
||||||
const edInner = tinymce.get(this.tinymceId);
|
const edInner = tinymce.get(this.tinymceId)
|
||||||
const node = tinymce.activeEditor.selection.getNode()
|
const node = tinymce.activeEditor.selection.getNode()
|
||||||
this.resetSelect(node)
|
this.resetSelect(node)
|
||||||
},
|
},
|
||||||
resetSelect(node) {
|
resetSelect(node) {
|
||||||
const edInner = tinymce.get(this.tinymceId);
|
const edInner = tinymce.get(this.tinymceId)
|
||||||
if (edInner.dom) {
|
if (edInner.dom) {
|
||||||
const nodeArray = edInner.dom.select(".base-selected")
|
const nodeArray = edInner.dom.select('.base-selected')
|
||||||
if (nodeArray) {
|
if (nodeArray) {
|
||||||
nodeArray.forEach(nodeInner => {
|
nodeArray.forEach(nodeInner => {
|
||||||
nodeInner.removeAttribute('class')
|
nodeInner.removeAttribute('class')
|
||||||
@ -185,7 +199,7 @@ export default {
|
|||||||
if (pNode && pNode.id && pNode.id.indexOf('changeText') > -1) {
|
if (pNode && pNode.id && pNode.id.indexOf('changeText') > -1) {
|
||||||
const innerId = '#' + pNode.id
|
const innerId = '#' + pNode.id
|
||||||
const domTest = edInner.dom.select(innerId)[0]
|
const domTest = edInner.dom.select(innerId)[0]
|
||||||
domTest.setAttribute("class",'base-selected')
|
domTest.setAttribute('class', 'base-selected')
|
||||||
edInner.selection.select(domTest)
|
edInner.selection.select(domTest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,11 +233,14 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto !important;
|
overflow-y: auto !important;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 0px !important;
|
width: 0px !important;
|
||||||
height: 0px !important;
|
height: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep ol {
|
::v-deep ol {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
list-style-type: decimal;
|
list-style-type: decimal;
|
||||||
@ -233,6 +250,7 @@ export default {
|
|||||||
margin-inline-end: 0px !important;
|
margin-inline-end: 0px !important;
|
||||||
padding-inline-start: 40px !important;
|
padding-inline-start: 40px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep ul {
|
::v-deep ul {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
list-style-type: disc;
|
list-style-type: disc;
|
||||||
@ -242,6 +260,7 @@ export default {
|
|||||||
margin-inline-end: 0px !important;
|
margin-inline-end: 0px !important;
|
||||||
padding-inline-start: 40px !important;
|
padding-inline-start: 40px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep li {
|
::v-deep li {
|
||||||
display: list-item !important;
|
display: list-item !important;
|
||||||
text-align: -webkit-match-parent !important;
|
text-align: -webkit-match-parent !important;
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
<de-rich-text-view
|
<de-rich-text-view
|
||||||
v-else-if="richTextViewShowFlag"
|
v-else-if="richTextViewShowFlag"
|
||||||
:ref="element.propValue.id"
|
:ref="element.propValue.id"
|
||||||
|
:scale="scale"
|
||||||
:element="element"
|
:element="element"
|
||||||
:prop-value="element.propValue.textValue"
|
:prop-value="element.propValue.textValue"
|
||||||
:active="active"
|
:active="active"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user