@@ -49,23 +49,14 @@ export async function exportDevup() {
4949
5050 const typography : Record < string , ( null | DevupTypography ) [ ] > = { }
5151 await Promise . all (
52- texts . map ( async ( text ) => {
53- if ( typeof text . textStyleId !== 'string' ) return
54- const style = await figma . getStyleByIdAsync ( text . textStyleId )
55- if ( style && ids . has ( style . id ) ) {
56- const { type, name } = styleNameToTypography ( style . name )
57- if ( typography [ name ] ) {
58- if ( type === 'mobile' && typography [ name ] [ 0 ] ) {
59- return
60- }
61- if ( type === 'tablet' && typography [ name ] [ 2 ] ) {
62- return
63- }
64- if ( type === 'desktop' && typography [ name ] [ 4 ] ) {
65- return
66- }
67- }
68- const segs = text . getStyledTextSegments ( [
52+ texts
53+ . filter ( ( text ) => typeof text . textStyleId === 'string' )
54+ . map ( async ( text ) => {
55+ const style = await figma . getStyleByIdAsync ( text . textStyleId as string )
56+ if ( ! ( style && ids . has ( style . id ) ) ) return
57+ const { level , name } = styleNameToTypography ( style . name )
58+ if ( typography [ name ] && typography [ name ] [ level ] ) return
59+ for ( const seg of text . getStyledTextSegments ( [
6960 'fontName' ,
7061 'fontWeight' ,
7162 'fontSize' ,
@@ -79,21 +70,13 @@ export async function exportDevup() {
7970 'listOptions' ,
8071 'indentation' ,
8172 'hyperlink' ,
82- ] )
83- for ( const seg of segs ) {
73+ ] ) ) {
8474 if ( seg ) {
8575 const typo = textSegmentToTypography ( seg as StyledTextSegment )
86- typography [ name ] ??= [ null , null , null , null , null ]
87- if ( type === 'mobile' ) {
88- typography [ name ] [ 0 ] = typo
89- } else if ( type === 'tablet' ) {
90- typography [ name ] [ 2 ] = typo
91- } else if ( type === 'desktop' ) {
92- typography [ name ] [ 4 ] = typo
93- }
76+ typography [ name ] ??= [ null , null , null , null , null , null ]
77+ typography [ name ] [ level ] = typo
9478 }
9579 }
96- }
9780 } ) ,
9881 )
9982 if ( Object . keys ( typography ) . length > 0 ) {
0 commit comments