1
1
export class ExportManager {
2
- constructor ( layerManager ) {
2
+ constructor ( layerManager , registryManager ) {
3
3
this . layerManager = layerManager ;
4
+ this . registryManager = registryManager ;
4
5
5
6
// Define Tailwind color mappings for common colors
6
7
this . tailwindColors = {
@@ -101,7 +102,7 @@ export class ExportManager {
101
102
const rect = element . getBoundingClientRect ( ) ;
102
103
const canvas = this . layerManager . canvas . getBoundingClientRect ( ) ;
103
104
104
- // Calculate pixel positions based on container dimensions
105
+ // Calculate positions
105
106
const left = Math . round ( ( rect . left - canvas . left ) / canvas . width * this . layerManager . CONTAINER_WIDTH ) ;
106
107
const top = Math . round ( ( rect . top - canvas . top ) / canvas . height * this . layerManager . CONTAINER_HEIGHT ) ;
107
108
const width = Math . round ( rect . width / canvas . width * this . layerManager . CONTAINER_WIDTH ) ;
@@ -114,16 +115,19 @@ export class ExportManager {
114
115
// Get border radius class
115
116
const roundedClass = Array . from ( element . classList )
116
117
. find ( cls => cls . startsWith ( 'rounded-' ) ) || '' ;
118
+
119
+ // Get layer type from registry or use default 'rectangle'
120
+ const layerType = this . registryManager . getLayerType ( element . dataset . id ) || 'rectangle' ;
117
121
118
122
return `
119
- <div class="absolute ${ bgClass } ${ roundedClass } left-[${ left } px] top-[${ top } px] w-[${ width } px] h-[${ height } px]"></div>` ;
123
+ <div class="absolute ${ bgClass } ${ roundedClass } left-[${ left } px] top-[${ top } px] w-[${ width } px] h-[${ height } px]" layer=" ${ layerType } " ></div>` ;
120
124
}
121
125
122
126
exportText ( element ) {
123
127
const rect = element . getBoundingClientRect ( ) ;
124
128
const canvas = this . layerManager . canvas . getBoundingClientRect ( ) ;
125
129
126
- // Calculate pixel positions based on container dimensions
130
+ // Calculate pixel positions
127
131
const left = Math . round ( ( rect . left - canvas . left ) / canvas . width * this . layerManager . CONTAINER_WIDTH ) ;
128
132
const top = Math . round ( ( rect . top - canvas . top ) / canvas . height * this . layerManager . CONTAINER_HEIGHT ) ;
129
133
const width = Math . round ( rect . width / canvas . width * this . layerManager . CONTAINER_WIDTH ) ;
@@ -137,8 +141,11 @@ export class ExportManager {
137
141
. filter ( cls => ! [ 'layer' , 'selected' ] . includes ( cls ) )
138
142
. join ( ' ' ) ;
139
143
144
+ // Get layer type from registry
145
+ const layerType = this . registryManager . getLayerType ( element . dataset . id ) || '' ;
146
+
140
147
return `
141
- <div class="absolute ${ classes } left-[${ left } px] top-[${ top } px] w-[${ width } px] h-[${ height } px]">
148
+ <div class="absolute ${ classes } left-[${ left } px] top-[${ top } px] w-[${ width } px] h-[${ height } px]" layer=" ${ layerType } " >
142
149
${ content }
143
150
</div>` ;
144
151
}
0 commit comments