Demo:支持添加附件内容(在线Demo不开放)
This commit is contained in:
parent
979299f2e2
commit
3673c6aafe
@ -1,8 +1,8 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: "iconfont"; /* Project id 2479351 */
|
font-family: "iconfont"; /* Project id 2479351 */
|
||||||
src: url('iconfont.woff2?t=1711536835850') format('woff2'),
|
src: url('iconfont.woff2?t=1711935414521') format('woff2'),
|
||||||
url('iconfont.woff?t=1711536835850') format('woff'),
|
url('iconfont.woff?t=1711935414521') format('woff'),
|
||||||
url('iconfont.ttf?t=1711536835850') format('truetype');
|
url('iconfont.ttf?t=1711935414521') format('truetype');
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconfont {
|
.iconfont {
|
||||||
@ -13,6 +13,10 @@
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.iconfujian:before {
|
||||||
|
content: "\e88a";
|
||||||
|
}
|
||||||
|
|
||||||
.icongeshihua:before {
|
.icongeshihua:before {
|
||||||
content: "\e7a3";
|
content: "\e7a3";
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -259,6 +259,7 @@ export default {
|
|||||||
associativeLine: 'Associative line',
|
associativeLine: 'Associative line',
|
||||||
painter: 'Painter',
|
painter: 'Painter',
|
||||||
formula: 'Formula',
|
formula: 'Formula',
|
||||||
|
attachment: 'Attachment',
|
||||||
more: 'More',
|
more: 'More',
|
||||||
selectFileTip: 'Please select a file',
|
selectFileTip: 'Please select a file',
|
||||||
notSupportTip:
|
notSupportTip:
|
||||||
@ -331,5 +332,8 @@ export default {
|
|||||||
formatErrorTip: 'The JSON format is incorrect. Please check and try again',
|
formatErrorTip: 'The JSON format is incorrect. Please check and try again',
|
||||||
copyTip: 'Copied to clipboard',
|
copyTip: 'Copied to clipboard',
|
||||||
formatTip: 'Format complete'
|
formatTip: 'Format complete'
|
||||||
|
},
|
||||||
|
attachment: {
|
||||||
|
deleteAttachment: 'Delete attachment'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -256,6 +256,7 @@ export default {
|
|||||||
associativeLine: '关联线',
|
associativeLine: '关联线',
|
||||||
painter: '格式刷',
|
painter: '格式刷',
|
||||||
formula: '公式',
|
formula: '公式',
|
||||||
|
attachment: '附件',
|
||||||
more: '更多',
|
more: '更多',
|
||||||
selectFileTip: '请选择文件',
|
selectFileTip: '请选择文件',
|
||||||
notSupportTip: '你的浏览器不支持该功能,或者当前页面非https协议',
|
notSupportTip: '你的浏览器不支持该功能,或者当前页面非https协议',
|
||||||
@ -325,5 +326,8 @@ export default {
|
|||||||
formatErrorTip: 'JSON格式有误,请检查后再试',
|
formatErrorTip: 'JSON格式有误,请检查后再试',
|
||||||
copyTip: '已复制到剪贴板',
|
copyTip: '已复制到剪贴板',
|
||||||
formatTip: '格式化完成'
|
formatTip: '格式化完成'
|
||||||
|
},
|
||||||
|
attachment: {
|
||||||
|
deleteAttachment: '删除附件'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,6 +221,7 @@ export default {
|
|||||||
this.$bus.$on('expand_btn_click', this.hide)
|
this.$bus.$on('expand_btn_click', this.hide)
|
||||||
this.$bus.$on('svg_mousedown', this.onMousedown)
|
this.$bus.$on('svg_mousedown', this.onMousedown)
|
||||||
this.$bus.$on('mouseup', this.onMouseup)
|
this.$bus.$on('mouseup', this.onMouseup)
|
||||||
|
this.$bus.$on('translate', this.hide)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.$bus.$off('node_contextmenu', this.show)
|
this.$bus.$off('node_contextmenu', this.show)
|
||||||
@ -229,6 +230,7 @@ export default {
|
|||||||
this.$bus.$off('expand_btn_click', this.hide)
|
this.$bus.$off('expand_btn_click', this.hide)
|
||||||
this.$bus.$off('svg_mousedown', this.onMousedown)
|
this.$bus.$off('svg_mousedown', this.onMousedown)
|
||||||
this.$bus.$off('mouseup', this.onMouseup)
|
this.$bus.$off('mouseup', this.onMouseup)
|
||||||
|
this.$bus.$off('translate', this.hide)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['setLocalConfig']),
|
...mapMutations(['setLocalConfig']),
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
v-if="mindMap"
|
v-if="mindMap"
|
||||||
:mindMap="mindMap"
|
:mindMap="mindMap"
|
||||||
></NodeNoteContentShow>
|
></NodeNoteContentShow>
|
||||||
|
<NodeAttachment v-if="mindMap" :mindMap="mindMap"></NodeAttachment>
|
||||||
<NodeImgPreview v-if="mindMap" :mindMap="mindMap"></NodeImgPreview>
|
<NodeImgPreview v-if="mindMap" :mindMap="mindMap"></NodeImgPreview>
|
||||||
<SidebarTrigger v-if="!isZenMode"></SidebarTrigger>
|
<SidebarTrigger v-if="!isZenMode"></SidebarTrigger>
|
||||||
<Search v-if="mindMap" :mindMap="mindMap"></Search>
|
<Search v-if="mindMap" :mindMap="mindMap"></Search>
|
||||||
@ -85,6 +86,7 @@ import Scrollbar from './Scrollbar.vue'
|
|||||||
import exampleData from 'simple-mind-map/example/exampleData'
|
import exampleData from 'simple-mind-map/example/exampleData'
|
||||||
import FormulaSidebar from './FormulaSidebar.vue'
|
import FormulaSidebar from './FormulaSidebar.vue'
|
||||||
import SourceCodeEdit from './SourceCodeEdit.vue'
|
import SourceCodeEdit from './SourceCodeEdit.vue'
|
||||||
|
import NodeAttachment from './NodeAttachment.vue'
|
||||||
|
|
||||||
// 注册插件
|
// 注册插件
|
||||||
MindMap.usePlugin(MiniMap)
|
MindMap.usePlugin(MiniMap)
|
||||||
@ -137,7 +139,8 @@ export default {
|
|||||||
OutlineEdit,
|
OutlineEdit,
|
||||||
Scrollbar,
|
Scrollbar,
|
||||||
FormulaSidebar,
|
FormulaSidebar,
|
||||||
SourceCodeEdit
|
SourceCodeEdit,
|
||||||
|
NodeAttachment
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -491,7 +494,10 @@ export default {
|
|||||||
'painter_start',
|
'painter_start',
|
||||||
'painter_end',
|
'painter_end',
|
||||||
'scrollbar_change',
|
'scrollbar_change',
|
||||||
'scale'
|
'scale',
|
||||||
|
'translate',
|
||||||
|
'node_attachmentClick',
|
||||||
|
'node_attachmentContextmenu'
|
||||||
].forEach(event => {
|
].forEach(event => {
|
||||||
this.mindMap.on(event, (...args) => {
|
this.mindMap.on(event, (...args) => {
|
||||||
this.$bus.$emit(event, ...args)
|
this.$bus.$emit(event, ...args)
|
||||||
|
|||||||
133
web/src/pages/Edit/components/NodeAttachment.vue
Normal file
133
web/src/pages/Edit/components/NodeAttachment.vue
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="nodeAttachmentContextMenu"
|
||||||
|
:style="{
|
||||||
|
left: this.left + 'px',
|
||||||
|
top: this.top + 'px',
|
||||||
|
visibility: show ? 'visible' : 'hidden'
|
||||||
|
}"
|
||||||
|
@click.stop="deleteAttachment"
|
||||||
|
>
|
||||||
|
<div class="menuItem">{{ $t('attachment.deleteAttachment') }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
mindMap: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
show: false,
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
node: null,
|
||||||
|
icon: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$bus.$on('node_attachmentClick', this.onNodeAttachmentClick)
|
||||||
|
this.$bus.$on('selectAttachment', this.onSelectAttachment)
|
||||||
|
this.$bus.$on(
|
||||||
|
'node_attachmentContextmenu',
|
||||||
|
this.onNodeAttachmentContextmenu
|
||||||
|
)
|
||||||
|
this.$bus.$on('hide', this.hide)
|
||||||
|
document.body.addEventListener('click', this.hide)
|
||||||
|
this.$bus.$on('node_active', this.hide)
|
||||||
|
this.$bus.$on('scale', this.onScale)
|
||||||
|
this.$bus.$on('translate', this.onScale)
|
||||||
|
this.$bus.$on('svg_mousedown', this.hide)
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.$bus.$off('node_attachmentClick', this.onNodeAttachmentClick)
|
||||||
|
this.$bus.$off('selectAttachment', this.onSelectAttachment)
|
||||||
|
this.$bus.$off(
|
||||||
|
'node_attachmentContextmenu',
|
||||||
|
this.onNodeAttachmentContextmenu
|
||||||
|
)
|
||||||
|
this.$bus.$off('hide', this.hide)
|
||||||
|
document.body.removeEventListener('click', this.hide)
|
||||||
|
this.$bus.$off('node_active', this.hide)
|
||||||
|
this.$bus.$off('scale', this.onScale)
|
||||||
|
this.$bus.$off('translate', this.onScale)
|
||||||
|
this.$bus.$off('svg_mousedown', this.hide)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 选择附件
|
||||||
|
onSelectAttachment(activeNodes) {
|
||||||
|
// activeNodes.forEach(node => {
|
||||||
|
// node.setAttachment('/test.md', '我去')
|
||||||
|
// })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 点击附件图标,一般用来打开或下载附件
|
||||||
|
onNodeAttachmentClick(node, e, icon) {
|
||||||
|
// console.log(node.getData('attachmentUrl'))
|
||||||
|
},
|
||||||
|
|
||||||
|
// 显示删除浮层
|
||||||
|
onNodeAttachmentContextmenu(node, e, icon) {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
this.node = node
|
||||||
|
this.icon = icon
|
||||||
|
this.updatePosition()
|
||||||
|
this.show = true
|
||||||
|
},
|
||||||
|
|
||||||
|
// 更新位置
|
||||||
|
updatePosition() {
|
||||||
|
const iconSize = this.mindMap.themeConfig.iconSize
|
||||||
|
const { x, y } = this.icon.rbox()
|
||||||
|
this.left = x + iconSize
|
||||||
|
this.top = y
|
||||||
|
},
|
||||||
|
|
||||||
|
// 画布缩放事件
|
||||||
|
onScale() {
|
||||||
|
console.log(1)
|
||||||
|
if (!this.node || !this.show) return
|
||||||
|
this.updatePosition()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除附件
|
||||||
|
deleteAttachment() {
|
||||||
|
if (!this.node || !this.show) return
|
||||||
|
this.node.setAttachment('', '')
|
||||||
|
this.hide()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 隐藏浮层
|
||||||
|
hide() {
|
||||||
|
this.show = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.nodeAttachmentContextMenu {
|
||||||
|
position: fixed;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.06);
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
|
.menuItem {
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: PingFangSC-Regular, PingFang SC;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #1a1a1a;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -37,6 +37,7 @@ export default {
|
|||||||
document.body.addEventListener('click', this.hideNoteContent)
|
document.body.addEventListener('click', this.hideNoteContent)
|
||||||
this.$bus.$on('node_active', this.hideNoteContent)
|
this.$bus.$on('node_active', this.hideNoteContent)
|
||||||
this.$bus.$on('scale', this.onScale)
|
this.$bus.$on('scale', this.onScale)
|
||||||
|
this.$bus.$on('translate', this.onScale)
|
||||||
this.$bus.$on('svg_mousedown', this.hideNoteContent)
|
this.$bus.$on('svg_mousedown', this.hideNoteContent)
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -48,6 +49,7 @@ export default {
|
|||||||
document.body.removeEventListener('click', this.hideNoteContent)
|
document.body.removeEventListener('click', this.hideNoteContent)
|
||||||
this.$bus.$off('node_active', this.hideNoteContent)
|
this.$bus.$off('node_active', this.hideNoteContent)
|
||||||
this.$bus.$off('scale', this.onScale)
|
this.$bus.$off('scale', this.onScale)
|
||||||
|
this.$bus.$off('translate', this.onScale)
|
||||||
this.$bus.$off('svg_mousedown', this.hideNoteContent)
|
this.$bus.$off('svg_mousedown', this.hideNoteContent)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -97,6 +99,8 @@ export default {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
max-height: 300px;
|
max-height: 300px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.06);
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
width: 7px;
|
width: 7px;
|
||||||
|
|||||||
@ -178,6 +178,7 @@ export default {
|
|||||||
'summary',
|
'summary',
|
||||||
'associativeLine',
|
'associativeLine',
|
||||||
'formula'
|
'formula'
|
||||||
|
// 'attachment'
|
||||||
],
|
],
|
||||||
horizontalList: [],
|
horizontalList: [],
|
||||||
verticalList: [],
|
verticalList: [],
|
||||||
|
|||||||
@ -156,6 +156,17 @@
|
|||||||
<span class="icon iconfont icongongshi"></span>
|
<span class="icon iconfont icongongshi"></span>
|
||||||
<span class="text">{{ $t('toolbar.formula') }}</span>
|
<span class="text">{{ $t('toolbar.formula') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="item === 'attachment'"
|
||||||
|
class="toolbarBtn"
|
||||||
|
:class="{
|
||||||
|
disabled: activeNodes.length <= 0 || hasGeneralization
|
||||||
|
}"
|
||||||
|
@click="selectAttachmentFile"
|
||||||
|
>
|
||||||
|
<span class="icon iconfont iconfujian"></span>
|
||||||
|
<span class="text">{{ $t('toolbar.attachment') }}</span>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -258,6 +269,11 @@ export default {
|
|||||||
// 打开公式侧边栏
|
// 打开公式侧边栏
|
||||||
showFormula() {
|
showFormula() {
|
||||||
this.setActiveSidebar('formulaSidebar')
|
this.setActiveSidebar('formulaSidebar')
|
||||||
|
},
|
||||||
|
|
||||||
|
// 选择附件
|
||||||
|
selectAttachmentFile() {
|
||||||
|
this.$bus.$emit('selectAttachment', this.activeNodes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user