Auto-fit Beat Prompt node height
This commit is contained in:
@@ -44,10 +44,6 @@ function injectCSS() {
|
||||
.dh3bp-root {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: auto;
|
||||
pointer-events: auto;
|
||||
color: #e8e8e8;
|
||||
font: 12px/1.35 "Segoe UI", sans-serif;
|
||||
@@ -80,7 +76,6 @@ function injectCSS() {
|
||||
}
|
||||
.dh3bp-list {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
@@ -306,6 +301,18 @@ function stopCanvasKeyboard(event) {
|
||||
if (isInteractiveTarget(event.target)) event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
function fitNodeHeight(node) {
|
||||
const root = node?._dh3bpUI?.root;
|
||||
if (!root) return;
|
||||
requestAnimationFrame(() => {
|
||||
const contentHeight = Math.ceil(root.scrollHeight || 0);
|
||||
const nextHeight = Math.max(DEFAULT_H, contentHeight + 6);
|
||||
if (Math.abs((node.size?.[1] || 0) - nextHeight) < 2) return;
|
||||
node.size[1] = nextHeight;
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
});
|
||||
}
|
||||
|
||||
function renderUI(node) {
|
||||
const ui = node._dh3bpUI;
|
||||
if (!ui) return;
|
||||
@@ -474,6 +481,7 @@ function renderUI(node) {
|
||||
updateTextareaHeight(textarea);
|
||||
});
|
||||
|
||||
fitNodeHeight(node);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user