File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,8 @@ export interface Pen extends Rect {
206
206
207
207
// canvas 滤镜
208
208
filter ?: string ;
209
-
209
+ placeholder ?: string ; //占位符
210
+ placeholderColor ?: string ;
210
211
text ?: string ;
211
212
textWidth ?: number ;
212
213
textHeight ?: number ;
Original file line number Diff line number Diff line change @@ -996,6 +996,25 @@ function drawText(ctx: CanvasRenderingContext2D, pen: Pen) {
996
996
textBackground,
997
997
textType,
998
998
} = pen . calculative ;
999
+ if (
1000
+ pen . input &&
1001
+ ! pen . text &&
1002
+ ! ( pen . calculative . canvas . inputDiv . dataset . penId === pen . id )
1003
+ ) {
1004
+ ctx . save ( ) ;
1005
+ ctx . font = getFont ( {
1006
+ fontStyle,
1007
+ fontWeight,
1008
+ fontFamily : fontFamily ,
1009
+ fontSize,
1010
+ lineHeight,
1011
+ } ) ;
1012
+ ctx . fillStyle = pen . placeholderColor || '#c0c0c0' ;
1013
+ const rect = pen . calculative . worldTextRect ;
1014
+ ctx . fillText ( pen . placeholder || '请输入' , rect . x , rect . y + rect . height / 2 ) ;
1015
+ ctx . restore ( ) ;
1016
+ }
1017
+
999
1018
if ( text == undefined || hiddenText ) {
1000
1019
return ;
1001
1020
}
You can’t perform that action at this time.
0 commit comments