Merge branch 'feature' of https://github.com/wanglin2/mind-map into feature

This commit is contained in:
wanglin2 2025-02-10 20:52:29 +08:00
commit 3128a546e0
13 changed files with 144 additions and 34 deletions

View File

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

View File

@ -253,7 +253,9 @@ const transformToXmind = async (data, name) => {
}
// 标签
if (node.data.tag !== undefined) {
newData.labels = node.data.tag || []
newData.labels = (node.data.tag || []).map(item => {
return typeof item === 'object' && item !== null ? item.text : item
})
}
// 图片
handleNodeImageToXmind(node, newNode, waitLoadImageList, imageList)

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;

View File

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 2479351 */
src: url('iconfont.woff2?t=1737722825571') format('woff2'),
url('iconfont.woff?t=1737722825571') format('woff'),
url('iconfont.ttf?t=1737722825571') format('truetype');
src: url('iconfont.woff2?t=1739152990179') format('woff2'),
url('iconfont.woff?t=1739152990179') format('woff'),
url('iconfont.ttf?t=1739152990179') format('truetype');
}
.iconfont {
@ -13,6 +13,14 @@
-moz-osx-font-smoothing: grayscale;
}
.iconprinting:before {
content: "\ea28";
}
.iconwenjianjia:before {
content: "\e614";
}
.iconcontentleft:before {
content: "\e8c9";
}

View File

@ -217,7 +217,9 @@ export default {
},
outline: {
title: 'Outline',
nodeDefaultText: 'Branch node'
nodeDefaultText: 'Branch node',
print: 'Print',
fullscreen: 'Fullscreen'
},
scale: {
zoomIn: 'Zoom in',

View File

@ -213,7 +213,9 @@ export default {
},
outline: {
title: '大纲',
nodeDefaultText: '分支节点'
nodeDefaultText: '分支节点',
print: '打印',
fullscreen: '全屏'
},
scale: {
zoomIn: '放大',

View File

@ -78,7 +78,8 @@ export default {
belowNode: '顯示在節點下方',
confirm: '確定',
cancel: '取消',
changeRichTextTip: '該操作會清空所有曆史修改記錄,並且修改思維導圖數據,是否繼續?',
changeRichTextTip:
'該操作會清空所有曆史修改記錄,並且修改思維導圖數據,是否繼續?',
changeRichTextTip2: '是否切換爲富文本模式?',
changeRichTextTip3: '是否切換爲非富文本模式?',
enableDragImport: '是否允許直接拖拽文件到頁面進行導入',
@ -214,7 +215,9 @@ export default {
},
outline: {
title: '大綱',
nodeDefaultText: '分支節點'
nodeDefaultText: '分支節點',
print: '打印',
fullscreen: '全屏'
},
scale: {
zoomIn: '放大',
@ -268,7 +271,7 @@ export default {
bottom: '下',
left: '左',
right: '右',
tag: '標簽',
tag: '標簽'
},
theme: {
title: '主題',

View File

@ -5,10 +5,26 @@
ref="outlineEditContainer"
v-if="isOutlineEdit"
>
<div class="closeBtn" @click="onClose">
<span class="icon iconfont iconguanbi"></span>
<div class="btnList">
<el-tooltip
class="item"
effect="dark"
:content="$t('outline.print')"
placement="top"
>
<div class="btn" @click="onPrint">
<span class="icon iconfont iconprinting"></span>
</div>
</el-tooltip>
<div class="btn" @click="onClose">
<span class="icon iconfont iconguanbi"></span>
</div>
</div>
<div class="outlineEditBox" ref="outlineEditBox">
<div
class="outlineEditBox"
id="fullScreenOutlineEditBox"
ref="outlineEditBox"
>
<div class="outlineEdit">
<el-tree
ref="tree"
@ -58,6 +74,7 @@ import {
handleInputPasteText
} from 'simple-mind-map/src/utils'
import { storeData } from '@/api'
import { printOutline } from '@/utils'
//
export default {
@ -225,6 +242,11 @@ export default {
return Math.random()
},
//
onPrint() {
printOutline(this.$refs.outlineEditBox)
},
//
onClose() {
this.setIsOutlineEdit(false)
@ -274,28 +296,36 @@ export default {
top: 0;
width: 100%;
height: 100%;
z-index: 9999;
z-index: 1999;
background-color: #fff;
overflow: hidden;
&.isDark {
background-color: #262a2e;
.closeBtn {
.icon {
color: #fff;
.btnList {
.btn {
.icon {
color: #fff;
}
}
}
}
.closeBtn {
.btnList {
position: absolute;
right: 40px;
top: 20px;
cursor: pointer;
display: flex;
align-items: center;
.icon {
font-size: 28px;
.btn {
cursor: pointer;
margin-left: 12px;
.icon {
font-size: 28px;
}
}
}

View File

@ -1,16 +1,36 @@
<template>
<Sidebar ref="sidebar" :title="$t('outline.title')">
<div
class="changeBtn"
:class="{ isDark: isDark }"
@click="onChangeToOutlineEdit"
>
<span class="icon iconfont iconquanping1"></span>
<div class="btnList">
<el-tooltip
class="item"
effect="dark"
:content="$t('outline.print')"
placement="top"
>
<div class="btn" @click="onPrint">
<span class="icon iconfont iconprinting"></span>
</div>
</el-tooltip>
<el-tooltip
class="item"
effect="dark"
:content="$t('outline.fullscreen')"
placement="top"
>
<div
class="btn"
:class="{ isDark: isDark }"
@click="onChangeToOutlineEdit"
>
<span class="icon iconfont iconquanping1"></span>
</div>
</el-tooltip>
</div>
<Outline
:mindMap="mindMap"
v-if="activeSidebar === 'outline'"
@scrollTo="onScrollTo"
ref="outlineRef"
></Outline>
</Sidebar>
</template>
@ -19,6 +39,7 @@
import Sidebar from './Sidebar'
import { mapState, mapMutations } from 'vuex'
import Outline from './Outline.vue'
import { printOutline } from '@/utils'
//
export default {
@ -62,20 +83,31 @@ export default {
if (y > top + height) {
container.scrollTo(0, y - height / 2)
}
},
//
onPrint() {
printOutline(this.$refs.outlineRef.$el)
}
}
}
</script>
<style lang="less" scoped>
.changeBtn {
.btnList {
position: absolute;
right: 50px;
top: 12px;
cursor: pointer;
display: flex;
align-items: center;
&.isDark {
color: #fff;
.btn {
cursor: pointer;
margin-left: 12px;
&.isDark {
color: #fff;
}
}
}
</style>

View File

@ -74,3 +74,25 @@ export const setImgToClipboard = img => {
navigator.clipboard.write(data)
}
}
// 打印大纲
export const printOutline = el => {
const printContent = el.outerHTML
const iframe = document.createElement('iframe')
iframe.setAttribute('style', 'position: absolute; width: 0; height: 0;')
document.body.appendChild(iframe)
const iframeDoc = iframe.contentWindow.document
// 将当前页面的所有样式添加到iframe中
const styleList = document.querySelectorAll('style')
Array.from(styleList).forEach(el => {
iframeDoc.write(el.outerHTML)
})
// 设置打印展示方式 - 纵向展示
iframeDoc.write('<style media="print">@page {size: portrait;}</style>')
// 写入内容
iframeDoc.write('<div>' + printContent + '</div>')
setTimeout(function() {
iframe.contentWindow?.print()
document.body.removeChild(iframe)
}, 500)
}