@@ -11,7 +11,6 @@ import {
1111 ToggleButtonGroup ,
1212 Tooltip ,
1313 Typography ,
14- useTheme ,
1514} from '@mui/material' ;
1615import { T , useTranslate } from '@tolgee/react' ;
1716import {
@@ -29,7 +28,6 @@ export type TemplatePlaceholder =
2928type Props = {
3029 value : string ;
3130 onChange : ( value : string ) => void ;
32- label ?: string ;
3331 disabled ?: boolean ;
3432 readOnly ?: boolean ;
3533 placeholders ?: TemplatePlaceholder [ ] ;
@@ -40,19 +38,15 @@ type Mode = 'html' | 'preview';
4038export const HtmlTemplateEditor : React . FC < Props > = ( {
4139 value,
4240 onChange,
43- label,
4441 disabled,
4542 readOnly,
4643 placeholders = [ ] ,
4744} ) => {
4845 const { t } = useTranslate ( ) ;
49- const theme = useTheme ( ) ;
5046 const [ mode , setMode ] = useState < Mode > ( 'html' ) ;
5147 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
5248 const previewRef = useRef < HTMLDivElement > ( null ) ;
5349
54- const isDark = theme . palette . mode === 'dark' ;
55-
5650 useEffect ( ( ) => {
5751 if (
5852 mode === 'preview' &&
@@ -169,11 +163,29 @@ export const HtmlTemplateEditor: React.FC<Props> = ({
169163 < Card variant = "outlined" >
170164 < Box display = "grid" gap = { 1.5 } px = { 2 } pb = { 2 } >
171165 < Box display = "flex" justifyContent = "space-between" alignItems = "center" >
172- { label && (
173- < Typography variant = "subtitle1" fontWeight = { 600 } >
174- { label }
175- </ Typography >
176- ) }
166+ < ToggleButtonGroup size = "small" exclusive >
167+ < ToggleButton
168+ value = "bold"
169+ onClick = { ( ) => wrapOrUnwrapSelection ( 'b' ) }
170+ disabled = { disabled || readOnly }
171+ >
172+ < Bold01 width = { 16 } height = { 16 } />
173+ </ ToggleButton >
174+ < ToggleButton
175+ value = "italic"
176+ onClick = { ( ) => wrapOrUnwrapSelection ( 'i' ) }
177+ disabled = { disabled || readOnly }
178+ >
179+ < Italic01 width = { 16 } height = { 16 } />
180+ </ ToggleButton >
181+ < ToggleButton
182+ value = "underline"
183+ onClick = { ( ) => wrapOrUnwrapSelection ( 'u' ) }
184+ disabled = { disabled || readOnly }
185+ >
186+ < Underline01 width = { 16 } height = { 16 } />
187+ </ ToggleButton >
188+ </ ToggleButtonGroup >
177189 < Tabs
178190 value = { mode }
179191 onChange = { handleTabChange }
@@ -202,30 +214,6 @@ export const HtmlTemplateEditor: React.FC<Props> = ({
202214 </ Tabs >
203215 </ Box >
204216
205- < ToggleButtonGroup size = "small" exclusive >
206- < ToggleButton
207- value = "bold"
208- onClick = { ( ) => wrapOrUnwrapSelection ( 'b' ) }
209- disabled = { disabled || readOnly }
210- >
211- < Bold01 width = { 16 } height = { 16 } />
212- </ ToggleButton >
213- < ToggleButton
214- value = "italic"
215- onClick = { ( ) => wrapOrUnwrapSelection ( 'i' ) }
216- disabled = { disabled || readOnly }
217- >
218- < Italic01 width = { 16 } height = { 16 } />
219- </ ToggleButton >
220- < ToggleButton
221- value = "underline"
222- onClick = { ( ) => wrapOrUnwrapSelection ( 'u' ) }
223- disabled = { disabled || readOnly }
224- >
225- < Underline01 width = { 16 } height = { 16 } />
226- </ ToggleButton >
227- </ ToggleButtonGroup >
228-
229217 { mode === 'html' ? (
230218 < TextField
231219 inputRef = { textareaRef }
@@ -237,31 +225,19 @@ export const HtmlTemplateEditor: React.FC<Props> = ({
237225 disabled = { disabled }
238226 InputProps = { {
239227 readOnly,
240- sx : {
241- fontFamily : 'Source Code Pro, monospace' ,
242- backgroundColor : isDark
243- ? 'rgba(255,255,255,0.05)'
244- : 'background.paper' ,
245- color : isDark ? '#fff' : 'inherit' ,
246- } ,
247228 } }
248229 />
249230 ) : (
250231 < Box
251232 ref = { previewRef }
252233 contentEditable = { ! readOnly && ! disabled }
253234 suppressContentEditableWarning
235+ p = { 1 }
254236 sx = { {
255237 minHeight : 150 ,
256238 border : 1 ,
257239 borderColor : 'divider' ,
258240 borderRadius : 1 ,
259- padding : 1 ,
260- fontFamily : 'inherit' ,
261- backgroundColor : isDark
262- ? 'rgba(255,255,255,0.05)'
263- : 'background.paper' ,
264- color : isDark ? '#fff' : 'inherit' ,
265241 '&:focus' : { outline : 'none' } ,
266242 } }
267243 onInput = { ( ) => {
0 commit comments