Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bricks/vs/src/code-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ export function CodeEditorComponent({
const maxLines = _maxLines ?? Infinity;
const height = _height ?? 500;
const [expanded, setExpanded] = useState(false);
const [placeholderInstance, setPlaceholderInstance] =
useState<PlaceholderContentWidget>();
const workerId = useMemo(() => uniqueId("worker"), []);

const { t } = useTranslation(NS);
Expand Down Expand Up @@ -909,11 +911,32 @@ export function CodeEditorComponent({
editorRef.current!
);

setPlaceholderInstance(placeholderWidget);

return () => {
placeholderWidget.dispose();
};
}, [placeholder]);

useEffect(() => {
if (
placeholderInstance &&
editorRef.current &&
editorRef.current.getDomNode
) {
const node = placeholderInstance.getDomNode();
const rect = node.getBoundingClientRect();
const originWidth = editorRef.current
?.getDomNode()
?.getBoundingClientRect().width;

editorRef.current?.layout({
width: originWidth!,
height: rect.height + 25,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
}
}, [placeholderInstance]);

const handleCopyIconClick = useCallback(() => {
if (editorRef.current) {
const currentModel = editorRef.current.getModel()!;
Expand Down
2 changes: 1 addition & 1 deletion bricks/vs/src/code-editor/widget/Placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PlaceholderContentWidget implements monaco.editor.IContentWidget {
this.domNode.style.fontStyle = "italic";
this.domNode.style.color =
"rgba(var(--theme-gray-color-rgb-channel), 0.4)";
this.editor.applyFontInfo(this.domNode);
this.editor?.applyFontInfo?.(this.domNode);
}

return this.domNode;
Expand Down