Feat:新增自定义节点图片调整插件中删除和调整按钮内容的实例化选项

This commit is contained in:
街角小林
2025-02-10 17:38:08 +08:00
parent 361edea91a
commit 0991315422
2 changed files with 13 additions and 4 deletions

View File

@@ -492,5 +492,10 @@ export const defaultOpt = {
maxImgResizeWidthInheritTheme: false,
// 最大允许缩放的尺寸maxImgResizeWidthInheritTheme选项设置为false时生效不限制最大值可传递Infinity
maxImgResizeWidth: Infinity,
maxImgResizeHeight: Infinity
maxImgResizeHeight: Infinity,
// 自定义删除按钮和尺寸调整按钮的内容
// 默认为内置图标你可以传递一个svg字符串或者其他的html字符串
// 整体大小请使用上面的minImgResizeWidth和minImgResizeHeight选项设置
customDeleteBtnInnerHTML: '',
customResizeBtnInnerHTML: ''
}

View File

@@ -122,7 +122,11 @@ class NodeImgAdjust {
// 创建调整按钮元素
createResizeBtnEl() {
const { imgResizeBtnSize } = this.mindMap.opt
const {
imgResizeBtnSize,
customResizeBtnInnerHTML,
customDeleteBtnInnerHTML
} = this.mindMap.opt
// 容器元素
this.handleEl = document.createElement('div')
this.handleEl.style.cssText = `
@@ -134,7 +138,7 @@ class NodeImgAdjust {
this.handleEl.className = 'node-img-handle'
// 调整按钮元素
const btnEl = document.createElement('div')
btnEl.innerHTML = btnsSvg.imgAdjust
btnEl.innerHTML = customResizeBtnInnerHTML || btnsSvg.imgAdjust
btnEl.style.cssText = `
position: absolute;
right: 0;
@@ -179,7 +183,7 @@ class NodeImgAdjust {
const btnRemove = document.createElement('div')
this.handleEl.prepend(btnRemove)
btnRemove.className = 'node-image-remove'
btnRemove.innerHTML = btnsSvg.remove
btnRemove.innerHTML = customDeleteBtnInnerHTML || btnsSvg.remove
btnRemove.style.cssText = `
position: absolute;
right: 0;top:0;color:#fff;