fix: 更新富文本

This commit is contained in:
wangjiahao 2024-06-20 16:16:36 +08:00
parent fb4903e887
commit 106cdf920b

View File

@ -29,7 +29,7 @@
<script setup lang="ts">
import { formatDataEaseBi } from '@/utils/url'
import tinymce from 'tinymce/tinymce' // tinymcehidden
import deTinymce from 'tinymce/tinymce' // tinymcehidden
import Editor from '@tinymce/tinymce-vue' //
import 'tinymce/themes/silver/theme' //
import 'tinymce/icons/default' // icon
@ -48,7 +48,7 @@ import 'tinymce/plugins/directionality'
import 'tinymce/plugins/nonbreaking'
import 'tinymce/plugins/pagebreak'
import '@npkg/tinymce-plugins/letterspacing'
import './plugins' //
import '@/custom-component/rich-text/plugins' //
import { computed, nextTick, reactive, ref, toRefs, watch, onMounted, PropType } from 'vue'
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
import eventBus from '@/utils/eventBus'
@ -153,7 +153,7 @@ watch(
() => active.value,
val => {
if (!val) {
const ed = tinymce.editors[tinymceId]
const ed = deTinymce.editors[tinymceId]
if (canEdit.value) {
element.value.propValue.textValue = ed.getContent()
}
@ -169,7 +169,7 @@ watch(
() => myValue.value,
() => {
if (canEdit.value) {
const ed = tinymce.editors[tinymceId]
const ed = deTinymce.editors[tinymceId]
element.value.propValue.textValue = ed.getContent()
}
if (initReady.value && canEdit.value) {
@ -207,7 +207,7 @@ const viewInit = () => {
fieldSelect(val)
}
})
tinymce.init({})
deTinymce.init({})
myValue.value = assignment(element.value.propValue.textValue)
}
const initCurFieldsChange = () => {
@ -250,7 +250,7 @@ const assignment = content => {
return content
}
const fieldSelect = field => {
const ed = tinymce.editors[tinymceId]
const ed = deTinymce.editors[tinymceId]
const fieldId = 'changeText-' + guid()
const value =
'<span id="' +
@ -267,12 +267,12 @@ const fieldSelect = field => {
}
const onClick = () => {
if (canEdit.value) {
const node = tinymce.activeEditor.selection.getNode()
const node = deTinymce.activeEditor.selection.getNode()
resetSelect(node)
}
}
const resetSelect = (node?) => {
const edInner = tinymce.get(tinymceId)
const edInner = deTinymce.get(tinymceId)
if (edInner?.dom) {
const nodeArray = edInner.dom.select('.base-selected')
if (nodeArray) {
@ -321,7 +321,7 @@ const setEdit = () => {
canEdit.value = true
element.value['editing'] = true
myValue.value = element.value.propValue.textValue
const ed = tinymce.editors[tinymceId]
const ed = deTinymce.editors[tinymceId]
ed.setContent(myValue.value)
reShow()
}