@@ -6,7 +6,7 @@ import styled, { css } from "styled-components";
6
6
import { AlignCenter } from "lowcoder-design" ;
7
7
import { AlignLeft } from "lowcoder-design" ;
8
8
import { AlignRight } from "lowcoder-design" ;
9
- import { UICompBuilder } from "../generators" ;
9
+ import { UICompBuilder , withDefault } from "../generators" ;
10
10
import { NameConfig , NameConfigHidden , withExposingConfigs } from "../generators/withExposing" ;
11
11
import { markdownCompCss , TacoMarkDown } from "lowcoder-design" ;
12
12
import { styleControl } from "comps/controls/styleControl" ;
@@ -18,11 +18,15 @@ import { alignWithJustifyControl } from "comps/controls/alignControl";
18
18
import { MarginControl } from "../controls/marginControl" ;
19
19
import { PaddingControl } from "../controls/paddingControl" ;
20
20
21
- import React , { useContext } from "react" ;
21
+ import React , { useContext , useEffect } from "react" ;
22
22
import { EditorContext } from "comps/editorState" ;
23
23
import { clickEvent , eventHandlerControl } from "../controls/eventHandlerControl" ;
24
24
25
25
const EventOptions = [ clickEvent ] as const ;
26
+ import { ThemeContext } from "../utils/themeContext" ;
27
+ import { CompTypeContext } from "../utils/compTypeContext" ;
28
+ import { changeChildAction } from "lowcoder-core" ;
29
+ import { setInitialCompStyles } from "../utils/themeUtil" ;
26
30
27
31
const getStyle = ( style : TextStyleType ) => {
28
32
return css `
@@ -115,6 +119,7 @@ const typeOptions = [
115
119
value : "text" ,
116
120
} ,
117
121
] as const ;
122
+
118
123
const VerticalAlignmentOptions = [
119
124
{ label : < AlignTop /> , value : "flex-start" } ,
120
125
{ label : < AlignVerticalCenter /> , value : "center" } ,
@@ -132,13 +137,29 @@ let TextTmpComp = (function () {
132
137
type : dropdownControl ( typeOptions , "markdown" ) ,
133
138
horizontalAlignment : alignWithJustifyControl ( ) ,
134
139
verticalAlignment : dropdownControl ( VerticalAlignmentOptions , "center" ) ,
135
- style : styleControl ( TextStyle ) ,
140
+ style : styleControl ( TextStyle , 'style' ) ,
136
141
animationStyle : styleControl ( AnimationStyle ) ,
137
142
margin : MarginControl ,
138
143
padding : PaddingControl ,
139
144
} ;
140
- return new UICompBuilder ( childrenMap , ( props ) => {
145
+ return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
141
146
const value = props . text . value ;
147
+ const theme = useContext ( ThemeContext ) ;
148
+ const compType = useContext ( CompTypeContext ) ;
149
+ const compTheme = theme ?. theme ?. components ?. [ compType ] ;
150
+ const styleProps : Record < string , any > = { } ;
151
+ [ 'style' ] . forEach ( ( key : string ) => {
152
+ styleProps [ key ] = ( props as any ) [ key ] ;
153
+ } ) ;
154
+
155
+ useEffect ( ( ) => {
156
+ setInitialCompStyles ( {
157
+ dispatch,
158
+ compTheme,
159
+ styleProps,
160
+ } ) ;
161
+ } , [ ] ) ;
162
+
142
163
return (
143
164
< TextContainer
144
165
$animationStyle = { props . animationStyle }
0 commit comments