Feat:实例销毁时删除文本编辑框的元素
This commit is contained in:
parent
8bbbc082c7
commit
13a1f989c3
@ -587,10 +587,7 @@ class MindMap {
|
|||||||
this.emit('beforeDestroy')
|
this.emit('beforeDestroy')
|
||||||
// 清除节点编辑框
|
// 清除节点编辑框
|
||||||
this.renderer.textEdit.hideEditTextBox()
|
this.renderer.textEdit.hideEditTextBox()
|
||||||
// 清除关联线文字编辑框
|
this.renderer.textEdit.removeTextEditEl()
|
||||||
if (this.associativeLine) {
|
|
||||||
this.associativeLine.hideEditTextBox()
|
|
||||||
}
|
|
||||||
// 移除插件
|
// 移除插件
|
||||||
;[...MindMap.pluginList].forEach(plugin => {
|
;[...MindMap.pluginList].forEach(plugin => {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -280,6 +280,17 @@ export default class TextEdit {
|
|||||||
this.cacheEditingText = ''
|
this.cacheEditingText = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除文本编辑元素
|
||||||
|
removeTextEditEl() {
|
||||||
|
if (this.mindMap.richText) {
|
||||||
|
this.mindMap.richText.removeTextEditEl()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.textEditNode) return
|
||||||
|
const targetNode = this.mindMap.opt.customInnerElsAppendTo || document.body
|
||||||
|
targetNode.removeChild(this.textEditNode)
|
||||||
|
}
|
||||||
|
|
||||||
// 获取当前正在编辑的内容
|
// 获取当前正在编辑的内容
|
||||||
getEditText() {
|
getEditText() {
|
||||||
return getStrWithBrFromHtml(this.textEditNode.innerHTML)
|
return getStrWithBrFromHtml(this.textEditNode.innerHTML)
|
||||||
|
|||||||
@ -68,6 +68,7 @@ class AssociativeLine {
|
|||||||
this.onNodeDragging = this.onNodeDragging.bind(this)
|
this.onNodeDragging = this.onNodeDragging.bind(this)
|
||||||
this.onNodeDragend = this.onNodeDragend.bind(this)
|
this.onNodeDragend = this.onNodeDragend.bind(this)
|
||||||
this.onControlPointMouseup = this.onControlPointMouseup.bind(this)
|
this.onControlPointMouseup = this.onControlPointMouseup.bind(this)
|
||||||
|
this.onBeforeDestroy = this.onBeforeDestroy.bind(this)
|
||||||
|
|
||||||
// 节点树渲染完毕后渲染连接线
|
// 节点树渲染完毕后渲染连接线
|
||||||
this.mindMap.on('node_tree_render_end', this.renderAllLines)
|
this.mindMap.on('node_tree_render_end', this.renderAllLines)
|
||||||
@ -90,6 +91,8 @@ class AssociativeLine {
|
|||||||
this.mindMap.on('mouseup', this.onControlPointMouseup)
|
this.mindMap.on('mouseup', this.onControlPointMouseup)
|
||||||
// 缩放事件
|
// 缩放事件
|
||||||
this.mindMap.on('scale', this.onScale)
|
this.mindMap.on('scale', this.onScale)
|
||||||
|
// 实例销毁事件
|
||||||
|
this.mindMap.on('beforeDestroy', this.onBeforeDestroy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解绑事件
|
// 解绑事件
|
||||||
@ -106,6 +109,13 @@ class AssociativeLine {
|
|||||||
this.mindMap.off('node_dragend', this.onNodeDragend)
|
this.mindMap.off('node_dragend', this.onNodeDragend)
|
||||||
this.mindMap.off('mouseup', this.onControlPointMouseup)
|
this.mindMap.off('mouseup', this.onControlPointMouseup)
|
||||||
this.mindMap.off('scale', this.onScale)
|
this.mindMap.off('scale', this.onScale)
|
||||||
|
this.mindMap.off('beforeDestroy', this.onBeforeDestroy)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实例销毁时清除关联线文字编辑框
|
||||||
|
onBeforeDestroy() {
|
||||||
|
this.hideEditTextBox()
|
||||||
|
this.removeTextEditEl()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 画布点击事件
|
// 画布点击事件
|
||||||
|
|||||||
@ -286,6 +286,13 @@ class RichText {
|
|||||||
this.cacheEditingText = ''
|
this.cacheEditingText = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除文本编辑框元素
|
||||||
|
removeTextEditEl() {
|
||||||
|
if (!this.textEditNode) return
|
||||||
|
const targetNode = this.mindMap.opt.customInnerElsAppendTo || document.body
|
||||||
|
targetNode.removeChild(this.textEditNode)
|
||||||
|
}
|
||||||
|
|
||||||
// 获取编辑区域的背景填充
|
// 获取编辑区域的背景填充
|
||||||
getBackground(node) {
|
getBackground(node) {
|
||||||
const gradientStyle = node.style.merge('gradientStyle')
|
const gradientStyle = node.style.merge('gradientStyle')
|
||||||
|
|||||||
@ -82,6 +82,13 @@ function showEditTextBox(g) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除文本编辑框元素
|
||||||
|
function removeTextEditEl() {
|
||||||
|
if (!this.textEditNode) return
|
||||||
|
const targetNode = this.mindMap.opt.customInnerElsAppendTo || document.body
|
||||||
|
targetNode.removeChild(this.textEditNode)
|
||||||
|
}
|
||||||
|
|
||||||
// 处理画布缩放
|
// 处理画布缩放
|
||||||
function onScale() {
|
function onScale() {
|
||||||
this.hideEditTextBox()
|
this.hideEditTextBox()
|
||||||
@ -178,6 +185,7 @@ export default {
|
|||||||
styleText,
|
styleText,
|
||||||
onScale,
|
onScale,
|
||||||
showEditTextBox,
|
showEditTextBox,
|
||||||
|
removeTextEditEl,
|
||||||
hideEditTextBox,
|
hideEditTextBox,
|
||||||
updateTextEditBoxPos,
|
updateTextEditBoxPos,
|
||||||
renderText,
|
renderText,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user