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