Feat:转换富文本节点数据的逻辑由Render类移至RichText插件本身
This commit is contained in:
parent
322975528e
commit
ade7a95f3c
@ -112,20 +112,17 @@ class Render {
|
|||||||
|
|
||||||
// 设置布局结构
|
// 设置布局结构
|
||||||
setLayout() {
|
setLayout() {
|
||||||
|
const { layout } = this.mindMap.opt
|
||||||
this.layout = new (
|
this.layout = new (
|
||||||
layouts[this.mindMap.opt.layout]
|
layouts[layout]
|
||||||
? layouts[this.mindMap.opt.layout]
|
? layouts[layout]
|
||||||
: layouts[CONSTANTS.LAYOUT.LOGICAL_STRUCTURE]
|
: layouts[CONSTANTS.LAYOUT.LOGICAL_STRUCTURE]
|
||||||
)(this, this.mindMap.opt.layout)
|
)(this, layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新设置思维导图数据
|
// 重新设置思维导图数据
|
||||||
setData(data) {
|
setData(data) {
|
||||||
if (this.hasRichTextPlugin()) {
|
this.renderTree = data || null
|
||||||
this.renderTree = data ? this.mindMap.richText.handleSetData(data) : null
|
|
||||||
} else {
|
|
||||||
this.renderTree = data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定事件
|
// 绑定事件
|
||||||
|
|||||||
@ -81,9 +81,12 @@ class RichText {
|
|||||||
this.onCompositionStart = this.onCompositionStart.bind(this)
|
this.onCompositionStart = this.onCompositionStart.bind(this)
|
||||||
this.onCompositionUpdate = this.onCompositionUpdate.bind(this)
|
this.onCompositionUpdate = this.onCompositionUpdate.bind(this)
|
||||||
this.onCompositionEnd = this.onCompositionEnd.bind(this)
|
this.onCompositionEnd = this.onCompositionEnd.bind(this)
|
||||||
|
this.handleSetData = this.handleSetData.bind(this)
|
||||||
window.addEventListener('compositionstart', this.onCompositionStart)
|
window.addEventListener('compositionstart', this.onCompositionStart)
|
||||||
window.addEventListener('compositionupdate', this.onCompositionUpdate)
|
window.addEventListener('compositionupdate', this.onCompositionUpdate)
|
||||||
window.addEventListener('compositionend', this.onCompositionEnd)
|
window.addEventListener('compositionend', this.onCompositionEnd)
|
||||||
|
this.mindMap.on('before_update_data', this.handleSetData)
|
||||||
|
this.mindMap.on('before_set_data', this.handleSetData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解绑事件
|
// 解绑事件
|
||||||
@ -91,6 +94,8 @@ class RichText {
|
|||||||
window.removeEventListener('compositionstart', this.onCompositionStart)
|
window.removeEventListener('compositionstart', this.onCompositionStart)
|
||||||
window.removeEventListener('compositionupdate', this.onCompositionUpdate)
|
window.removeEventListener('compositionupdate', this.onCompositionUpdate)
|
||||||
window.removeEventListener('compositionend', this.onCompositionEnd)
|
window.removeEventListener('compositionend', this.onCompositionEnd)
|
||||||
|
this.mindMap.off('before_update_data', this.handleSetData)
|
||||||
|
this.mindMap.off('before_set_data', this.handleSetData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入样式
|
// 插入样式
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user