Demo:节点右键菜单新增添加待办按钮

This commit is contained in:
街角小林
2024-10-22 17:32:46 +08:00
parent c097d20748
commit 4a7485c58e
7 changed files with 49 additions and 11 deletions

View File

@@ -113,7 +113,9 @@ export default {
copySuccess: 'Copy success',
copyFail: 'Copy fail',
number: 'Number child nodes',
expandNodeChild: 'Expand all sub nodes'
expandNodeChild: 'Expand all sub nodes',
addToDo: 'Add toDo',
removeToDo: 'Remove toDo'
},
count: {
words: 'Words',

View File

@@ -113,7 +113,9 @@ export default {
copySuccess: '复制成功',
copyFail: '复制失败',
number: '编号其子节点',
expandNodeChild: '展开所有下级节点'
expandNodeChild: '展开所有下级节点',
addToDo: '添加待办',
removeToDo: '删除待办'
},
count: {
words: '字数',

View File

@@ -113,7 +113,9 @@ export default {
copySuccess: '複製成功',
copyFail: '複製失敗',
number: '將其子節點編號',
expandNodeChild: '展開所有下級節點'
expandNodeChild: '展開所有下級節點',
addToDo: '添加待辦',
removeToDo: '刪除待辦'
},
count: {
words: '字數',

View File

@@ -89,6 +89,11 @@
</div>
</div>
</div>
<div class="item" @click="setCheckbox" v-if="supportCheckbox">
<span class="name">{{
hasCheckbox ? $t('contextmenu.removeToDo') : $t('contextmenu.addToDo')
}}</span>
</div>
<div class="splitLine"></div>
<div class="item danger" @click="exec('REMOVE_NODE')">
<span class="name">{{ $t('contextmenu.deleteNode') }}</span>
@@ -244,7 +249,8 @@ export default {
...mapState({
isZenMode: state => state.localConfig.isZenMode,
isDark: state => state.localConfig.isDark,
supportNumbers: state => state.supportNumbers
supportNumbers: state => state.supportNumbers,
supportCheckbox: state => state.supportCheckbox
}),
expandList() {
return [
@@ -322,6 +328,9 @@ export default {
},
numberLevelList() {
return numberLevelList[this.$i18n.locale] || numberLevelList.zh
},
hasCheckbox() {
return !!this.node.getData('checkbox')
}
},
created() {
@@ -496,6 +505,21 @@ export default {
this.mindMap.execCommand('SET_NUMBER', [], {
[prop]: value
})
this.hide()
},
// 设置待办
setCheckbox() {
this.mindMap.execCommand(
'SET_CHECKBOX',
[],
this.hasCheckbox
? null
: {
done: false
}
)
this.hide()
},
// 复制到剪贴板

View File

@@ -74,17 +74,14 @@ import OuterFrame from 'simple-mind-map/src/plugins/OuterFrame.js'
import Themes from 'simple-mind-map-plugin-themes'
// 协同编辑插件
// import Cooperate from 'simple-mind-map/src/plugins/Cooperate.js'
// 手绘风格插件,该插件为付费插件,详情请查看开发文档
// 以下插件为付费插件,详情请查看开发文档。依次为手绘风格插件、标记插件、编号插件、Freemind软件格式导入导出插件、Excel软件格式导入导出插件、待办插件
// import HandDrawnLikeStyle from 'simple-mind-map-plugin-handdrawnlikestyle'
// 标记插件,该插件为付费插件,详情请查看开发文档
// import Notation from 'simple-mind-map-plugin-notation'
// 编号插件,该插件为付费插件,详情请查看开发文档
// import Numbers from 'simple-mind-map-plugin-numbers'
// Freemind软件格式导入导出插件该插件为付费插件详情请查看开发文档
// import Freemind from 'simple-mind-map-plugin-freemind'
// Excel软件格式导入导出插件该插件为付费插件详情请查看开发文档
// import Excel from 'simple-mind-map-plugin-excel'
// npm link simple-mind-map-plugin-excel simple-mind-map-plugin-freemind simple-mind-map-plugin-numbers simple-mind-map-plugin-notation simple-mind-map-plugin-handdrawnlikestyle simple-mind-map simple-mind-map-plugin-themes
// import Checkbox from 'simple-mind-map-plugin-checkbox'
// npm link simple-mind-map-plugin-excel simple-mind-map-plugin-freemind simple-mind-map-plugin-numbers simple-mind-map-plugin-notation simple-mind-map-plugin-handdrawnlikestyle simple-mind-map-plugin-checkbox simple-mind-map simple-mind-map-plugin-themes
import OutlineSidebar from './OutlineSidebar'
import Style from './Style'
import BaseStyle from './BaseStyle'
@@ -577,6 +574,10 @@ export default {
this.$store.commit('setSupportExcel', true)
Vue.prototype.Excel = Excel
}
if (typeof Checkbox !== 'undefined') {
this.mindMap.addPlugin(Checkbox)
this.$store.commit('setSupportCheckbox', true)
}
this.mindMap.keyCommand.addShortcut('Control+s', () => {
this.manualSave()
})

View File

@@ -33,6 +33,7 @@ const store = new Vuex.Store({
supportNumbers: false, // 是否支持编号
supportFreemind: false, // 是否支持Freemind插件
supportExcel: false, // 是否支持Excel插件
supportCheckbox: false, // 是否支持Checkbox插件
isDragOutlineTreeNode: false // 当前是否正在拖拽大纲树的节点
},
mutations: {
@@ -105,6 +106,11 @@ const store = new Vuex.Store({
state.supportExcel = data
},
// 设置是否支持Checkbox插件
setSupportCheckbox(state, data) {
state.supportCheckbox = data
},
// 设置树节点拖拽
setIsDragOutlineTreeNode(state, data) {
state.isDragOutlineTreeNode = data