web/jsonview: fix extra newlines when copying json

This commit is contained in:
Tulir Asokan 2024-11-07 18:48:24 +01:00
parent 219f92c222
commit 8ca664c745
3 changed files with 12 additions and 5 deletions

View file

@ -153,7 +153,7 @@ input, textarea {
font-size: 1em; font-size: 1em;
} }
button, a.button { button, a.button, span.button {
cursor: var(--clickable-cursor); cursor: var(--clickable-cursor);
font-size: 1em; font-size: 1em;
background: none; background: none;

View file

@ -15,9 +15,13 @@ pre.json-view {
user-select: none; user-select: none;
} }
button { span.button {
padding: 0 .25rem; padding: 0 .25rem;
display: inline-flex; display: inline-flex;
&::before {
content: attr(data-symbol);
}
} }
/* If the screen is wide enough, make line-wrapped strings aligned after the object key */ /* If the screen is wide enough, make line-wrapped strings aligned after the object key */

View file

@ -82,9 +82,12 @@ function JSONValueWithKey({ data, objectKey, trailingComma, noCollapse }: JSONVi
? <span className="json-object-comma p">,</span> ? <span className="json-object-comma p">,</span>
: null : null
const collapseButton = noCollapse ? null : const collapseButton = noCollapse ? null :
<button onClick={toggleCollapsed} title={collapsed ? "Expand" : "Collapse"}> <span
{collapsed ? "+" : "-"} className="button"
</button> data-symbol={collapsed ? "+" : "-"}
onClick={toggleCollapsed}
title={collapsed ? "Expand" : "Collapse"}
/>
if (Array.isArray(data)) { if (Array.isArray(data)) {
return <> return <>
{renderedKey} {renderedKey}