File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
bricks/vs/src/code-editor Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,8 @@ export function CodeEditorComponent({
380380 const maxLines = _maxLines ?? Infinity ;
381381 const height = _height ?? 500 ;
382382 const [ expanded , setExpanded ] = useState ( false ) ;
383+ const [ placeholderInstance , setPlaceholderInstance ] =
384+ useState < PlaceholderContentWidget > ( ) ;
383385 const workerId = useMemo ( ( ) => uniqueId ( "worker" ) , [ ] ) ;
384386
385387 const { t } = useTranslation ( NS ) ;
@@ -909,11 +911,32 @@ export function CodeEditorComponent({
909911 editorRef . current !
910912 ) ;
911913
914+ setPlaceholderInstance ( placeholderWidget ) ;
915+
912916 return ( ) => {
913917 placeholderWidget . dispose ( ) ;
914918 } ;
915919 } , [ placeholder ] ) ;
916920
921+ useEffect ( ( ) => {
922+ if (
923+ placeholderInstance &&
924+ editorRef . current &&
925+ editorRef . current . getDomNode
926+ ) {
927+ const node = placeholderInstance . getDomNode ( ) ;
928+ const rect = node . getBoundingClientRect ( ) ;
929+ const originWidth = editorRef . current
930+ ?. getDomNode ( )
931+ ?. getBoundingClientRect ( ) . width ;
932+
933+ editorRef . current ?. layout ( {
934+ width : originWidth ! ,
935+ height : rect . height + 25 ,
936+ } ) ;
937+ }
938+ } , [ placeholderInstance ] ) ;
939+
917940 const handleCopyIconClick = useCallback ( ( ) => {
918941 if ( editorRef . current ) {
919942 const currentModel = editorRef . current . getModel ( ) ! ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export class PlaceholderContentWidget implements monaco.editor.IContentWidget {
3939 this . domNode . style . fontStyle = "italic" ;
4040 this . domNode . style . color =
4141 "rgba(var(--theme-gray-color-rgb-channel), 0.4)" ;
42- this . editor . applyFontInfo ( this . domNode ) ;
42+ this . editor ? .applyFontInfo ?. ( this . domNode ) ;
4343 }
4444
4545 return this . domNode ;
You can’t perform that action at this time.
0 commit comments