mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-22 02:47:46 +08:00
添加方法支持自定义新建节点的样式
This commit is contained in:
parent
4f2d4f8e36
commit
57fde3d0f2
@ -307,7 +307,7 @@ export const defaultOpt = {
|
||||
/*
|
||||
{
|
||||
// 返回要添加的DOM元素详细
|
||||
create: (node) => {
|
||||
create: (node) => {
|
||||
return {
|
||||
el, // DOM节点
|
||||
width: 20, // 宽高
|
||||
@ -316,7 +316,7 @@ export const defaultOpt = {
|
||||
},
|
||||
// 处理生成的@svgdotjs/svg.js库的ForeignObject节点实例,可以设置其在节点内的位置
|
||||
handle: ({ content, element, node }) => {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -518,5 +518,9 @@ export const defaultOpt = {
|
||||
// 默认为内置图标,你可以传递一个svg字符串,或者其他的html字符串
|
||||
// 整体大小请使用上面的minImgResizeWidth和minImgResizeHeight选项设置
|
||||
customDeleteBtnInnerHTML: '',
|
||||
customResizeBtnInnerHTML: ''
|
||||
customResizeBtnInnerHTML: '',
|
||||
|
||||
// NewAdd
|
||||
customNewNodeParams: null,
|
||||
|
||||
}
|
||||
|
||||
@ -871,14 +871,23 @@ class Render {
|
||||
if (alreadyIsRichText && params.resetRichText) {
|
||||
delete params.resetRichText
|
||||
}
|
||||
let nodeData = {
|
||||
text: text,
|
||||
uid: createUid(),
|
||||
// ...this.mindMap.opt.customNewNodeParams,
|
||||
...params,
|
||||
...(appointData || {})
|
||||
}
|
||||
if ( typeof this.mindMap.opt.customNewNodeParams === 'function'){
|
||||
const return_value = this.mindMap.opt.customNewNodeParams()
|
||||
nodeData = {
|
||||
...nodeData,
|
||||
...return_value
|
||||
}
|
||||
}
|
||||
const newNode = {
|
||||
inserting,
|
||||
data: {
|
||||
text: text,
|
||||
uid: createUid(),
|
||||
...params,
|
||||
...(appointData || {})
|
||||
},
|
||||
data: nodeData,
|
||||
children: [...createUidForAppointNodes(appointChildren, createNewId)]
|
||||
}
|
||||
createNewId = true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user