@@ -92,7 +92,7 @@ export default class ProjectFactory {
9292
9393 /**
9494 * Creates a new manifest from given image url(s) and project label.
95- * @param {string|string[] } imageInput - URL or array of URLs of images to be used.
95+ * @param {string|string[] } imgUrl - URL or array of URLs of images to be used.
9696 * @param {string } projectLabel - Label for the project.
9797 * @returns {Object } - Returns the created project object.
9898 */
@@ -327,7 +327,7 @@ export default class ProjectFactory {
327327 await project . updateTools ( selectedTools )
328328 }
329329 const allCanvases = projectTPEN3Data . layers [ 0 ] . pages . map ( ( page ) => page . target )
330- const allPagesIds = projectTPEN3Data . layers [ 0 ] . pages . map ( ( page ) => page . id . replace ( / p r o j e c t \/ ( [ a - f 0 - 9 ] + ) / , `project/${ projectTPEN3Data . _id } ` ) )
330+ const allPagesIds = projectTPEN3Data . layers [ 0 ] . pages . map ( ( page ) => page . id . replace ( / p r o j e c t \/ ( [ a - f 0 - 9 ] + ) / , `project/${ projectTPEN3Data . _id } ` ) )
331331 let manifestUrl = projectTPEN3Data . manifest [ 0 ]
332332 manifestUrl = this . transformManifestUrl ( manifestUrl , protocol )
333333 const responseManifest = await fetch ( manifestUrl )
@@ -498,7 +498,7 @@ export default class ProjectFactory {
498498
499499 let newPages = [ ]
500500
501- if ( result [ layer . id ] ) {
501+ if ( result [ layer . id ] ) {
502502 newPages = await this . clonePages ( layer , copiedProject , creator , database , true )
503503 for ( const page of newPages ) {
504504 const updatedPage = new Page (
@@ -560,16 +560,16 @@ export default class ProjectFactory {
560560 const now = Date . now ( ) . toString ( ) . slice ( - 6 )
561561 const label = ProjectFactory . getLabelAsString ( manifest . label )
562562 const metadata = manifest . metadata ?? [ ]
563- const layer = Layer . build ( _id , `First Layer - ${ label } ` , manifest . items , creator )
563+ const layer = Layer . build ( _id , `First Layer - ${ label } ` , manifest . items , creator )
564564
565565 const firstPage = layer . pages [ 0 ] ?. id . split ( '/' ) . pop ( ) ?? true
566566
567567 return {
568568 _id,
569569 label,
570570 metadata,
571- manifest : [ manifest . id ] ,
572- layers : [ layer . asProjectLayer ( ) ] ,
571+ manifest : [ manifest . id ] ,
572+ layers : [ layer . asProjectLayer ( ) ] ,
573573 tools : Tools . defaultTools ,
574574 _createdAt : now ,
575575 _modifiedAt : - 1 ,
@@ -590,7 +590,7 @@ export default class ProjectFactory {
590590 return (
591591 region === "full" ||
592592 region === "square" ||
593- / ^ p c t : \d + ( \. \d + ) ? , \d + ( \. \d + ) ? , \d + ( \. \d + ) ? , \d + ( \. \d + ) ? $ / . test ( region ) ||
593+ / ^ p c t : \d + ( \. \d + ) ? , \d + ( \. \d + ) ? , \d + ( \. \d + ) ? , \d + ( \. \d + ) ? $ / . test ( region ) ||
594594 / ^ \d + , \d + , \d + , \d + $ / . test ( region )
595595 )
596596 }
@@ -781,6 +781,21 @@ export default class ProjectFactory {
781781 if ( annotationPages . length ) {
782782 canvasItems . annotations = await this . getAnnotations ( { annotations : annotationPages } )
783783 }
784+
785+ const annotationPages = [ ]
786+ await Promise . all ( project . layers . map ( layer => {
787+ return layer . pages . forEach ( page => {
788+ if ( ( page . target === canvas . id ) && page . id . startsWith ( process . env . RERUMIDPREFIX ) ) {
789+ const annotationPage = {
790+ id : page . id ,
791+ type : "AnnotationPage"
792+ }
793+ annotationPages . push ( annotationPage )
794+ }
795+ } )
796+ } )
797+ )
798+ annotationPages . length > 0 && ( canvasItems . annotations = await this . getAnnotations ( { annotations : annotationPages } ) )
784799 return canvasItems
785800 } catch ( error ) {
786801 console . error ( `Error processing layer:` , error )
0 commit comments