File tree Expand file tree Collapse file tree 4 files changed +21
-22
lines changed Expand file tree Collapse file tree 4 files changed +21
-22
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " html2sketch" ,
3
- "version" : " 0.1.14 " ,
3
+ "version" : " 0.1.15 " ,
4
4
"author" : " arvinxx" ,
5
5
"description" : " parser HTML to Design Model" ,
6
6
"repository" : {
Original file line number Diff line number Diff line change @@ -83,10 +83,8 @@ export const nodeToSketchLayers = (node: Element): AnyLayer[] => {
83
83
// 添加后继续执行,不终止
84
84
const shape = transferToShape ( node ) ;
85
85
86
- if ( shape ) {
87
- console . info ( '[nodeToSketchLayers]转换为 Rectangle: ' , shape ) ;
88
- layers . push ( shape ) ;
89
- }
86
+ console . info ( '[nodeToSketchLayers]转换为 Rectangle: ' , shape ) ;
87
+ layers . push ( shape ) ;
90
88
}
91
89
92
90
// 判断一下是否有伪类
Original file line number Diff line number Diff line change @@ -13,27 +13,28 @@ export const isExistPseudoText = (node: Element) =>
13
13
export const isExistPseudoShape = ( node : Element ) =>
14
14
! ! ( pseudoShape ( node , 'after' ) || pseudoShape ( node , 'before' ) ) ;
15
15
16
+ /**
17
+ * 判断是否是不可见的样式
18
+ * @param shape
19
+ */
16
20
export const isVisibleShape = ( shape : Rectangle ) => {
17
- const isInvalidFills =
18
- shape . style . fills . length === 0 ||
19
- shape . style . fills . every ( ( fill ) => fill . opacity . toString ( ) === '0' ) ;
20
- const isInvalidBorders =
21
- shape . style . borders . length === 0 ||
22
- shape . style . borders . every (
23
- ( border ) => border . opacity === 0 || border . thickness === 0
24
- ) ;
25
-
26
- console . log (
27
- shape . name ,
28
- 'isInvalidFills' ,
29
- isInvalidFills ,
30
- 'isInvalidBorders' ,
31
- isInvalidBorders
32
- ) ;
33
21
const isInvisible = shape . style . opacity === 0 ;
34
22
23
+ // 透明度为 0 也返回不可见
35
24
if ( isInvisible ) return false ;
36
25
26
+ // 没任何样式的话,就返回不可见
27
+ const hasNoStyle =
28
+ shape . style . fills . length === 0 && shape . style . borders . length === 0 ;
29
+ if ( hasNoStyle ) return false ;
30
+
31
+ const isInvalidFills = shape . style . fills . every (
32
+ ( fill ) => fill . opacity . toString ( ) === '0'
33
+ ) ;
34
+ const isInvalidBorders = shape . style . borders . every (
35
+ ( border ) => border . opacity === 0 || border . thickness === 0
36
+ ) ;
37
+
37
38
if ( isInvalidFills && isInvalidBorders ) {
38
39
return false ;
39
40
}
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ const transferToShape = (node: Element): Group | Rectangle => {
237
237
break ;
238
238
}
239
239
}
240
- if ( isVisibleShape ( rect ) ) return rect ;
240
+ return rect ;
241
241
} ;
242
242
243
243
export default transferToShape ;
You can’t perform that action at this time.
0 commit comments