_setBlockData(block,newData)#handles undo and callbacks
#if len(block.linkedContentBlocks) == 1: return #This will not work because block is still the old one. unlink replaces with a standalone copy but we keep the original for undo.
withsession.history.sequence("unlink block"):
duplicateBlock(blockId)
deleteBlock(blockId)#original one
callbacks._historyChanged()
#Does not work properly:
#newData = block.getUnlinkedData()
#assert newData
#_setBlockData(block, newData) #handles undo and callbacks
#deprecated
def_setBlockData(block,newData):
"""DEPRECATED. This did not work. The linked blocks were not reduced.
assertnotcopyItem.parentBlocks#parentBlock was empty until now
copyItem.parentBlocks.add(new)
copyItem.parentBlocks.add(new)
ifselfincopyItem.parentBlocks:#TODO: investigate
copyItem.parentBlocks.remove(self)
@ -167,7 +167,10 @@ class Block(object):
returnnew
defgetUnlinkedData(self):
"""Set and handled for undo/redo by the api"""
"""
Returnsanewlistwithcopiesofitems.
Setandhandledforundo/redobytheapi.
"""
newData=[]
newParentBlocks=WeakSet()
newParentBlocks.add(self)
@ -304,7 +307,7 @@ class Block(object):
definsert(self,item):
self.data.insert(self.localCursorIndex,item)#we do not need to check if appending or not. list.insert appends if the index is higher then len()
#self.localCursorIndex += 1 #we don't need to go right here because track.insert() is calling its own right() directly after insert, which triggers block.right()
item.parentBlocks.add(self)
item.parentBlocks.add(self)
defdelete(self):
"""The commented out is the immediate garbage collector which