fix undo-redo
This commit is contained in:
@@ -55,14 +55,16 @@ export default class Item {
|
||||
/**
|
||||
* Copy the effect of struct
|
||||
*/
|
||||
_copy () {
|
||||
_copy (undeleteChildren, copyPosition) {
|
||||
let struct = new this.constructor()
|
||||
struct._origin = this._left
|
||||
struct._left = this._left
|
||||
struct._right = this
|
||||
struct._right_origin = this
|
||||
struct._parent = this._parent
|
||||
struct._parentSub = this._parentSub
|
||||
if (copyPosition) {
|
||||
struct._origin = this._left
|
||||
struct._left = this._left
|
||||
struct._right = this
|
||||
struct._right_origin = this
|
||||
struct._parent = this._parent
|
||||
struct._parentSub = this._parentSub
|
||||
}
|
||||
return struct
|
||||
}
|
||||
get _lastId () {
|
||||
|
||||
@@ -6,8 +6,8 @@ export default class ItemJSON extends Item {
|
||||
super()
|
||||
this._content = null
|
||||
}
|
||||
_copy () {
|
||||
let struct = super._copy()
|
||||
_copy (undeleteChildren, copyPosition) {
|
||||
let struct = super._copy(undeleteChildren, copyPosition)
|
||||
struct._content = this._content
|
||||
return struct
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ export default class ItemString extends Item {
|
||||
super()
|
||||
this._content = null
|
||||
}
|
||||
_copy () {
|
||||
let struct = super._copy()
|
||||
_copy (undeleteChildren, copyPosition) {
|
||||
let struct = super._copy(undeleteChildren, copyPosition)
|
||||
struct._content = this._content
|
||||
return struct
|
||||
}
|
||||
|
||||
@@ -79,15 +79,16 @@ export default class Type extends Item {
|
||||
type = type._parent
|
||||
}
|
||||
}
|
||||
_copy (undeleteChildren) {
|
||||
let copy = super._copy()
|
||||
_copy (undeleteChildren, copyPosition) {
|
||||
let copy = super._copy(undeleteChildren, copyPosition)
|
||||
let map = new Map()
|
||||
copy._map = map
|
||||
for (let [key, value] of this._map) {
|
||||
if (undeleteChildren.has(value) || !value.deleted) {
|
||||
let _item = value._copy(undeleteChildren)
|
||||
let _item = value._copy(undeleteChildren, false)
|
||||
_item._parent = copy
|
||||
map.set(key, value._copy(undeleteChildren))
|
||||
_item._parentSub = key
|
||||
map.set(key, _item)
|
||||
}
|
||||
}
|
||||
let prevUndeleted = null
|
||||
@@ -95,7 +96,7 @@ export default class Type extends Item {
|
||||
let item = this._start
|
||||
while (item !== null) {
|
||||
if (undeleteChildren.has(item) || !item.deleted) {
|
||||
let _item = item._copy(undeleteChildren)
|
||||
let _item = item._copy(undeleteChildren, false)
|
||||
_item._left = prevUndeleted
|
||||
_item._origin = prevUndeleted
|
||||
_item._right = null
|
||||
|
||||
Reference in New Issue
Block a user