Feat:新增节点连线样式是否允许继承祖先的样式的实例化选项

This commit is contained in:
街角小林 2025-02-13 09:22:28 +08:00
parent 8c7d11c629
commit 86c84cba0b
2 changed files with 13 additions and 5 deletions

View File

@ -321,6 +321,8 @@ export const defaultOpt = {
} }
*/ */
addCustomContentToNode: null, addCustomContentToNode: null,
// 节点连线样式是否允许继承祖先的连线样式
enableInheritAncestorLineStyle: false,
// 【Select插件】 // 【Select插件】
// 多选节点时鼠标移动到边缘时的画布移动偏移量 // 多选节点时鼠标移动到边缘时的画布移动偏移量

View File

@ -296,7 +296,10 @@ class MindMapNode {
typeof addCustomContentToNode.create === 'function' typeof addCustomContentToNode.create === 'function'
) { ) {
this._customContentAddToNodeAdd = addCustomContentToNode.create(this) this._customContentAddToNodeAdd = addCustomContentToNode.create(this)
if (this._customContentAddToNodeAdd && this._customContentAddToNodeAdd.el) { if (
this._customContentAddToNodeAdd &&
this._customContentAddToNodeAdd.el
) {
addXmlns(this._customContentAddToNodeAdd.el) addXmlns(this._customContentAddToNodeAdd.el)
} }
} }
@ -883,15 +886,18 @@ class MindMapNode {
// 设置连线样式 // 设置连线样式
styleLine(line, childNode, enableMarker) { styleLine(line, childNode, enableMarker) {
const { enableInheritAncestorLineStyle } = this.mindMap.opt
const getName = enableInheritAncestorLineStyle
? 'getSelfInhertStyle'
: 'getSelfStyle'
const width = const width =
childNode.getSelfInhertStyle('lineWidth') || childNode[getName]('lineWidth') || childNode.getStyle('lineWidth', true)
childNode.getStyle('lineWidth', true)
const color = const color =
childNode.getSelfInhertStyle('lineColor') || childNode[getName]('lineColor') ||
this.getRainbowLineColor(childNode) || this.getRainbowLineColor(childNode) ||
childNode.getStyle('lineColor', true) childNode.getStyle('lineColor', true)
const dasharray = const dasharray =
childNode.getSelfInhertStyle('lineDasharray') || childNode[getName]('lineDasharray') ||
childNode.getStyle('lineDasharray', true) childNode.getStyle('lineDasharray', true)
this.style.line( this.style.line(
line, line,