Merge pull request #12480 from dataease/pr@dev-v2@fix_rich-text

Pr@dev v2@fix rich text
This commit is contained in:
王嘉豪 2024-09-26 10:35:05 +08:00 committed by GitHub
commit bdf4742dca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 47 additions and 15 deletions

View File

@ -6,6 +6,7 @@
@keyup.stop @keyup.stop
@dblclick="setEdit" @dblclick="setEdit"
@click="onClick" @click="onClick"
:style="richTextStyle"
> >
<chart-error v-if="isError" :err-msg="errMsg" /> <chart-error v-if="isError" :err-msg="errMsg" />
<Editor <Editor
@ -163,7 +164,28 @@ const init = ref({
inline: true, // inline: true, //
branding: false, branding: false,
icons: 'vertical-content', icons: 'vertical-content',
vertical_align: element.value.propValue.verticalAlign vertical_align: element.value.propValue.verticalAlign,
setup: function (editor) {
//
editor.on('ObjectResizeStart', function (e) {
const { target, width, height } = e
if (target.nodeName === 'TABLE') {
//
// e.width = width / props.scale
// e.height = height / props.scale
}
})
//
editor.on('ObjectResized', function (e) {
const { target, width, height } = e
if (target.nodeName === 'TABLE') {
//
// target.style.width = `${width * props.scale}px`
// target.style.height = `${height scaleFactor}px`
}
})
}
}) })
const editStatus = computed(() => { const editStatus = computed(() => {
@ -561,6 +583,8 @@ const conditionAdaptor = (chart: Chart) => {
return res return res
} }
const richTextStyle = computed(() => [{ '--de-canvas-scale': props.scale }])
onMounted(() => { onMounted(() => {
viewInit() viewInit()
}) })
@ -583,6 +607,12 @@ defineExpose({
width: 0px !important; width: 0px !important;
height: 0px !important; height: 0px !important;
} }
::v-deep(p) {
zoom: var(--de-canvas-scale);
}
::v-deep(span) {
zoom: var(--de-canvas-scale);
}
} }
:deep(.ol) { :deep(.ol) {

View File

@ -58,18 +58,19 @@ const props = defineProps({
const { element, view, active, searchCount, scale } = toRefs(props) const { element, view, active, searchCount, scale } = toRefs(props)
const autoStyle = computed(() => { const autoStyle = computed(() => {
if (element.value.innerType === 'rich-text') { return {}
return { // if (element.value.innerType === 'rich-text') {
position: 'absolute', // return {
height: 100 / scale.value + '%!important', // position: 'absolute',
width: 100 / scale.value + '%!important', // height: 100 / scale.value + '%!important',
left: 50 * (1 - 1 / scale.value) + '%', // 2 // width: 100 / scale.value + '%!important',
top: 50 * (1 - 1 / scale.value) + '%', // 2 // left: 50 * (1 - 1 / scale.value) + '%', // 2
transform: 'scale(' + scale.value + ')' // top: 50 * (1 - 1 / scale.value) + '%', // 2
} as CSSProperties // transform: 'scale(' + scale.value + ') translateZ(0)'
} else { // } as CSSProperties
return {} // } else {
} // return {}
// }
}) })
const emits = defineEmits(['onPointClick']) const emits = defineEmits(['onPointClick'])

View File

@ -557,7 +557,7 @@ const autoStyle = computed(() => {
width: 100 / scale.value + '%!important', width: 100 / scale.value + '%!important',
left: 50 * (1 - 1 / scale.value) + '%', // 2 left: 50 * (1 - 1 / scale.value) + '%', // 2
top: 50 * (1 - 1 / scale.value) + '%', // 2 top: 50 * (1 - 1 / scale.value) + '%', // 2
transform: 'scale(' + scale.value + ')', transform: 'scale(' + scale.value + ') translateZ(0)',
opacity: element.value?.style?.opacity || 1 opacity: element.value?.style?.opacity || 1
} as CSSProperties } as CSSProperties
}) })

View File

@ -596,7 +596,7 @@ const autoStyle = computed(() => {
height: 20 * scale.value + 8 + 'px', height: 20 * scale.value + 8 + 'px',
width: 100 / scale.value + '%!important', width: 100 / scale.value + '%!important',
left: 50 * (1 - 1 / scale.value) + '%', // 2 left: 50 * (1 - 1 / scale.value) + '%', // 2
transform: 'scale(' + scale.value + ')' transform: 'scale(' + scale.value + ') translateZ(0)'
} }
}) })

View File

@ -944,6 +944,7 @@ const loadPluginCategory = data => {
</de-picture-group> </de-picture-group>
<de-rich-text-view <de-rich-text-view
v-else-if="showChartView(ChartLibraryType.RICH_TEXT)" v-else-if="showChartView(ChartLibraryType.RICH_TEXT)"
:scale="scale"
:themes="canvasStyleData.dashboard.themeColor" :themes="canvasStyleData.dashboard.themeColor"
ref="chartComponent" ref="chartComponent"
:element="element" :element="element"