diff --git a/src/Lepiter-Core/LePage.class.st b/src/Lepiter-Core/LePage.class.st index 5c6973cbe..5feb3590f 100644 --- a/src/Lepiter-Core/LePage.class.st +++ b/src/Lepiter-Core/LePage.class.st @@ -228,6 +228,35 @@ LePage >> databaseKey [ ^ type databaseKey ] +{ #category : #'api - editing' } +LePage >> duplicatePageWithNewName: aTitleString inDatabase: aDatabase [ + + | newPage uuidMapping | + uuidMapping := Dictionary new. + newPage := LePage named: aTitleString. + aDatabase addPage: newPage. + self + deep: [ :parent | parent children children ] + do: [ :each | ] + relationDo: [ :from :to | + | attributesReloader newSnippet | + newSnippet := to class new. + uuidMapping at: to uid put: newSnippet. + attributesReloader := LeContentAttributesReloader forContent: newSnippet. + attributesReloader + updateForMappings: attributesReloader relevantAttributeMappings + fromContent: to. + (from isKindOf: LePage) + ifTrue: [ newPage addSnippet: newSnippet ] + ifFalse: [ + | parentSnippet | + parentSnippet := uuidMapping at: from uid. + parentSnippet children children isEmpty + ifTrue: [ parentSnippet addFirstSnippet: newSnippet ] + ifFalse: [ parentSnippet addSnippet: newSnippet ] ] ]. + ^ newPage +] + { #category : #history } LePage >> editHistory [ ^ editHistory