mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Fix review warnings for dynamic CSS and ANSI regex
This commit is contained in:
parent
19a432dd94
commit
34a3f9ffcb
2 changed files with 10 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
export type ClassifiedAppServerLog = { kind: "plain"; text: string } | { kind: "error"; text: string } | null;
|
||||
|
||||
const ANSI_PATTERN = new RegExp("\\u001B\\[[0-?]*[ -/]*[@-~]", "g");
|
||||
const ESCAPE_CHARACTER = String.fromCharCode(27);
|
||||
const ANSI_PATTERN = new RegExp(`${ESCAPE_CHARACTER}\\[[0-?]*[ -/]*[@-~]`, "g");
|
||||
|
||||
export function classifyAppServerLog(message: string): ClassifiedAppServerLog {
|
||||
const normalized = stripAnsi(message).trimEnd();
|
||||
|
|
|
|||
|
|
@ -105,14 +105,20 @@ export function syncComposerHeight(composer: HTMLTextAreaElement | null): void {
|
|||
const style = getComputedStyle(composer);
|
||||
const minHeight = parseCssPixels(style.minHeight, 76);
|
||||
const maxHeight = composerMaxHeight(style.maxHeight);
|
||||
composer.setCssProps({ height: "auto" });
|
||||
setCssProps(composer, { height: "auto" });
|
||||
const nextHeight = Math.min(Math.max(composer.scrollHeight, minHeight), maxHeight);
|
||||
composer.setCssProps({
|
||||
setCssProps(composer, {
|
||||
height: `${nextHeight}px`,
|
||||
"overflow-y": composer.scrollHeight > maxHeight ? "auto" : "hidden",
|
||||
});
|
||||
}
|
||||
|
||||
function setCssProps(element: HTMLElement, props: Record<string, string>): void {
|
||||
for (const [key, value] of Object.entries(props)) {
|
||||
element.style.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
function parseCssPixels(value: string, fallback: number): number {
|
||||
const parsed = Number.parseFloat(value);
|
||||
return Number.isFinite(parsed) ? parsed : fallback;
|
||||
|
|
|
|||
Loading…
Reference in a new issue