Skip to content

Commit

Permalink
fix: Element editor height
Browse files Browse the repository at this point in the history
  • Loading branch information
areknawo committed Oct 12, 2023
1 parent d813d5a commit 5d9b954
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions apps/web/src/lib/editor/extensions/element-menu/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const ElementMenuEditor = lazy(async () => {

if (element) {
element.textContent = codeEditor.getValue() || "";
element.style.height = `${codeEditor.getContentHeight()}px`;
element.style.minHeight = `${codeEditor.getContentHeight()}px`;
}
});
codeEditor.onDidBlurEditorText(async () => {
Expand Down Expand Up @@ -210,26 +210,20 @@ const ElementMenuEditor = lazy(async () => {
createEffect(
on(
() => props.state.active,
(active, _, prevElement) => {
const element: HTMLElement | null =
(prevElement as HTMLElement) ||
(document.querySelector(".selected-element-tag") as HTMLElement);

if (element) {
setTimeout(() => {
if (active) {
element.style.height = `${codeEditor.getContentHeight()}px`;

return element;
} else {
element.style.height = "unset";

return null;
}
}, 0);
}

return element || null;
(active) => {
setTimeout(() => {
const element: HTMLElement | null = document.querySelector(
".selected-element-tag"
) as HTMLElement;

if (!element) return;

if (active) {
element.style.minHeight = `${codeEditor.getContentHeight()}px`;
} else {
element.style.minHeight = "unset";
}
}, 200);
}
)
);
Expand Down

0 comments on commit 5d9b954

Please sign in to comment.