perf(json-editor): unify admin JSON editing experience (#6421)

* perf(json-editor): improve JSON editing experience

- integrate Yace for syntax highlighting, history, indentation, auto-closing, and smart line breaks.
- add copy support, cursor location feedback, and synchronized content and line-number scrolling.
- extract JSON editor utilities and cover key interactions with unit tests.

* perf(system-settings): improve JSON configuration editing

- replace raw JSON textareas with the shared editor for highlighting, validation, copy, and formatting.
- preserve field-specific examples and make placeholders visible through the transparent editor layer.
- remove duplicate formatting controls while keeping existing form validation and save behavior.

* perf(json-editor): standardize JSON inputs across admin settings

- replace pure JSON textareas with the shared editor across system settings and channel workflows.
- preserve form focus, validation, placeholders, and visual or JSON editing modes.
- add happy-dom component coverage for form bindings, controlled updates, and formatting.

* fix(json-code-editor): address accessibility review findings

- Drop the unconditional aria-label that overrode every field's
  label-derived accessible name; add an optional ariaLabel prop and
  set it at call sites without an associated label
- Associate standalone Labels via htmlFor/id in channel-affinity views
- Hide the highlight mirror and line-number layers from the
  accessibility tree (aria-hidden)
- Give the line-number gutter an opaque background so horizontally
  scrolled code no longer slides under it
- Degrade to no scroll sync instead of destroying the editor when the
  line-number layer is not found
This commit is contained in:
QuentinHsu
2026-07-25 19:10:28 +08:00
committed by GitHub
parent 18b0b7631a
commit eb4a1bd193
28 changed files with 1089 additions and 419 deletions
@@ -26,6 +26,7 @@ import {
sideDrawerFormClassName,
sideDrawerHeaderClassName,
} from '@/components/drawer-layout'
import { JsonCodeEditor } from '@/components/json-code-editor'
import {
Accordion,
AccordionContent,
@@ -50,7 +51,6 @@ import {
SheetTitle,
} from '@/components/ui/sheet'
import { Switch } from '@/components/ui/switch'
import { Textarea } from '@/components/ui/textarea'
import {
SettingsForm,
@@ -215,7 +215,13 @@ export const GroupRatioForm = memo(function GroupRatioForm({
<FormItem>
<FormLabel>{t('Group ratios')}</FormLabel>
<FormControl>
<Textarea rows={8} {...field} />
<JsonCodeEditor
value={field.value}
onChange={field.onChange}
name={field.name}
onBlur={field.onBlur}
textareaRef={field.ref}
/>
</FormControl>
<FormDescription>
{t(
@@ -234,7 +240,14 @@ export const GroupRatioForm = memo(function GroupRatioForm({
<FormItem>
<FormLabel>{t('Top-up group ratios')}</FormLabel>
<FormControl>
<Textarea rows={6} {...field} />
<JsonCodeEditor
value={field.value}
onChange={field.onChange}
name={field.name}
onBlur={field.onBlur}
textareaRef={field.ref}
heightClassName='h-40 min-h-40 max-h-40'
/>
</FormControl>
<FormDescription>
{t(
@@ -254,7 +267,14 @@ export const GroupRatioForm = memo(function GroupRatioForm({
<FormItem>
<FormLabel>{t('Selectable groups')}</FormLabel>
<FormControl>
<Textarea rows={6} {...field} />
<JsonCodeEditor
value={field.value}
onChange={field.onChange}
name={field.name}
onBlur={field.onBlur}
textareaRef={field.ref}
heightClassName='h-40 min-h-40 max-h-40'
/>
</FormControl>
<FormDescription>
{t(
@@ -273,7 +293,13 @@ export const GroupRatioForm = memo(function GroupRatioForm({
<FormItem>
<FormLabel>{t('Inter-group overrides')}</FormLabel>
<FormControl>
<Textarea rows={8} {...field} />
<JsonCodeEditor
value={field.value}
onChange={field.onChange}
name={field.name}
onBlur={field.onBlur}
textareaRef={field.ref}
/>
</FormControl>
<FormDescription>
{t('Nested JSON: source group →')}{' '}
@@ -294,7 +320,14 @@ export const GroupRatioForm = memo(function GroupRatioForm({
<FormItem>
<FormLabel>{t('Auto assignment order')}</FormLabel>
<FormControl>
<Textarea rows={6} {...field} />
<JsonCodeEditor
value={field.value}
onChange={field.onChange}
name={field.name}
onBlur={field.onBlur}
textareaRef={field.ref}
heightClassName='h-40 min-h-40 max-h-40'
/>
</FormControl>
<FormDescription>
{t(
@@ -313,7 +346,13 @@ export const GroupRatioForm = memo(function GroupRatioForm({
<FormItem>
<FormLabel>{t('Special usable group rules')}</FormLabel>
<FormControl>
<Textarea rows={8} {...field} />
<JsonCodeEditor
value={field.value}
onChange={field.onChange}
name={field.name}
onBlur={field.onBlur}
textareaRef={field.ref}
/>
</FormControl>
<FormDescription>
{t(