只读模式下禁止添加历史记录、禁止响应前进后退操作

This commit is contained in:
wanglin2 2023-01-17 15:49:23 +08:00
parent 1e5dfd97e1
commit b40da53aef
2 changed files with 14 additions and 5 deletions

View File

@ -72,6 +72,9 @@ class Command {
// 添加回退数据
addHistory() {
if (this.mindMap.opt.readonly) {
return
}
let data = this.getCopyData()
this.history.push(simpleDeepClone(data))
this.activeHistoryIndex = this.history.length - 1
@ -85,6 +88,9 @@ class Command {
// 回退
back(step = 1) {
if (this.mindMap.opt.readonly) {
return
}
if (this.activeHistoryIndex - step >= 0) {
this.activeHistoryIndex -= step
this.mindMap.emit(
@ -98,6 +104,9 @@ class Command {
// 前进
forward(step = 1) {
if (this.mindMap.opt.readonly) {
return
}
let len = this.history.length
if (this.activeHistoryIndex + step <= len - 1) {
this.activeHistoryIndex += step

View File

@ -16,15 +16,15 @@ let APIList = [
'node',
'render',
'view',
'miniMap',
'doExport',
'watermark',
'keyCommand',
'keyboardNavigation',
'command',
'batchExecution',
'select',
'drag',
'batchExecution',
'keyboardNavigation',
'doExport',
'miniMap',
'watermark',
'xmind',
'utils'
]