@@ -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,8 +18,12 @@ 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
+ import { ThemeContext } from "../utils/themeContext" ;
24
+ import { CompTypeContext } from "../utils/compTypeContext" ;
25
+ import { changeChildAction } from "lowcoder-core" ;
26
+ import { setInitialCompStyles } from "../utils/themeUtil" ;
23
27
24
28
const getStyle = ( style : TextStyleType ) => {
25
29
return css `
@@ -112,6 +116,7 @@ const typeOptions = [
112
116
value : "text" ,
113
117
} ,
114
118
] as const ;
119
+
115
120
const VerticalAlignmentOptions = [
116
121
{ label : < AlignTop /> , value : "flex-start" } ,
117
122
{ label : < AlignVerticalCenter /> , value : "center" } ,
@@ -128,13 +133,29 @@ let TextTmpComp = (function () {
128
133
type : dropdownControl ( typeOptions , "markdown" ) ,
129
134
horizontalAlignment : alignWithJustifyControl ( ) ,
130
135
verticalAlignment : dropdownControl ( VerticalAlignmentOptions , "center" ) ,
131
- style : styleControl ( TextStyle ) ,
136
+ style : styleControl ( TextStyle , 'style' ) ,
132
137
animationStyle : styleControl ( AnimationStyle ) ,
133
138
margin : MarginControl ,
134
139
padding : PaddingControl ,
135
140
} ;
136
- return new UICompBuilder ( childrenMap , ( props ) => {
141
+ return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
137
142
const value = props . text . value ;
143
+ const theme = useContext ( ThemeContext ) ;
144
+ const compType = useContext ( CompTypeContext ) ;
145
+ const compTheme = theme ?. theme ?. components ?. [ compType ] ;
146
+ const styleProps : Record < string , any > = { } ;
147
+ [ 'style' ] . forEach ( ( key : string ) => {
148
+ styleProps [ key ] = ( props as any ) [ key ] ;
149
+ } ) ;
150
+
151
+ useEffect ( ( ) => {
152
+ setInitialCompStyles ( {
153
+ dispatch,
154
+ compTheme,
155
+ styleProps,
156
+ } ) ;
157
+ } , [ ] ) ;
158
+
138
159
return (
139
160
< TextContainer
140
161
$animationStyle = { props . animationStyle }
0 commit comments