Demo:导入了富文本内容自动开启富文本模式设置

This commit is contained in:
街角小林 2025-01-21 16:31:46 +08:00
parent 9b2c9ad1d2
commit d3353d50c5
5 changed files with 28 additions and 4 deletions

View File

@ -331,7 +331,8 @@ export default {
no: 'No', no: 'No',
exportError: 'Export failed', exportError: 'Export failed',
dragTip: 'Release here to import the file', dragTip: 'Release here to import the file',
deleteNodeImgTip: 'Are you sure to delete the node image?' deleteNodeImgTip: 'Are you sure to delete the node image?',
autoOpenNodeRichTextTip: 'Detected imported rich text content, automatically enabled rich text mode'
}, },
mouseAction: { mouseAction: {
tip1: tip1:

View File

@ -323,7 +323,8 @@ export default {
no: '否', no: '否',
exportError: '导出失败', exportError: '导出失败',
dragTip: '在此释放以导入该文件', dragTip: '在此释放以导入该文件',
deleteNodeImgTip: '是否确认删除该节点图片?' deleteNodeImgTip: '是否确认删除该节点图片?',
autoOpenNodeRichTextTip: '检测到导入了富文本内容,已自动开启富文本模式'
}, },
mouseAction: { mouseAction: {
tip1: '当前:左键拖动画布,右键框选节点', tip1: '当前:左键拖动画布,右键框选节点',

View File

@ -322,7 +322,8 @@ export default {
yes: '是', yes: '是',
no: '否', no: '否',
exportError: '匯出失敗', exportError: '匯出失敗',
dragTip: '在此釋放以匯入檔案' dragTip: '在此釋放以匯入檔案',
autoOpenNodeRichTextTip: '檢測到導入了富文本內容,已自動開啓富文本模式'
}, },
mouseAction: { mouseAction: {
tip1: '目前:左鍵拖曳畫布,右鍵框選節點', tip1: '目前:左鍵拖曳畫布,右鍵框選節點',

View File

@ -654,13 +654,24 @@ export default {
// //
setData(data) { setData(data) {
this.handleShowLoading() this.handleShowLoading()
let rootNodeData = null
if (data.root) { if (data.root) {
this.mindMap.setFullData(data) this.mindMap.setFullData(data)
rootNodeData = data.root
} else { } else {
this.mindMap.setData(data) this.mindMap.setData(data)
rootNodeData = data
} }
this.mindMap.view.reset() this.mindMap.view.reset()
this.manualSave() this.manualSave()
//
if (rootNodeData.data.richText && !this.openNodeRichText) {
this.$bus.$emit('toggleOpenNodeRichText', true)
this.$notify.info({
title: this.$t('edit.tip'),
message: this.$t('edit.autoOpenNodeRichTextTip')
})
}
}, },
// //

View File

@ -417,8 +417,11 @@ export default {
}, },
created() { created() {
this.initLoacalConfig() this.initLoacalConfig()
this.$bus.$on('toggleOpenNodeRichText', this.onToggleOpenNodeRichText)
},
beforeDestroy() {
this.$bus.$off('toggleOpenNodeRichText', this.onToggleOpenNodeRichText)
}, },
beforeDestroy() {},
methods: { methods: {
...mapMutations(['setLocalConfig']), ...mapMutations(['setLocalConfig']),
@ -520,6 +523,13 @@ export default {
}) })
}, },
onToggleOpenNodeRichText(val) {
this.setLocalConfig({
openNodeRichText: val
})
this.enableNodeRichText = val
},
// //
updateLocalConfig(key, value) { updateLocalConfig(key, value) {
this.setLocalConfig({ this.setLocalConfig({