From 63029148b0c1fc4f222be67b6e3f4a3ca7e9a949 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 21 Jun 2024 18:44:14 -0400 Subject: [PATCH 1/2] Add functionality to copy Lepiter Page programatically or later through UI with custom page action. --- src/Lepiter-Core/LePage.class.st | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Lepiter-Core/LePage.class.st b/src/Lepiter-Core/LePage.class.st index 5c6973cbe..a0895d9ef 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\t' } +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 From 007d3fd78f2649aae9c996a6ae2d978663229ebf Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 21 Jun 2024 18:49:00 -0400 Subject: [PATCH 2/2] Removing typo in method protocol. --- src/Lepiter-Core/LePage.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Lepiter-Core/LePage.class.st b/src/Lepiter-Core/LePage.class.st index a0895d9ef..5feb3590f 100644 --- a/src/Lepiter-Core/LePage.class.st +++ b/src/Lepiter-Core/LePage.class.st @@ -228,7 +228,7 @@ LePage >> databaseKey [ ^ type databaseKey ] -{ #category : #'api - editing\t' } +{ #category : #'api - editing' } LePage >> duplicatePageWithNewName: aTitleString inDatabase: aDatabase [ | newPage uuidMapping |