fix: 2.0.1 — editors scroll again and fewer console errors (#153)
- The wrapper div @uiw/react-codemirror renders now fills its panel, so the input editor and the read-only output scroll with the wheel, touch and keyboard; the read-only output's scroll container is focusable (arrow/page keys) without becoming contenteditable. - CSP (web and Tauri) allows 'wasm-unsafe-eval' for bson's WebAssembly helper; Permissions-Policy drops browsing-topics. - Version 2.0.1 (Android versionCode 20001); CHANGELOG and docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db94730fa5
commit
46d1e53656
12 files changed
+72
-19
No files matched your search
@@ -8,6 +8,14 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
||||
|
||||
No unreleased changes at this time. Future work tracked in `docs/ROADMAP.md` under "Beyond".
|
||||
|
||||
## [2.0.1] — 2026-10-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- **The editor and the output panel scroll again.** The wrapper `@uiw/react-codemirror` renders around the editor had no height, so both editors grew to fit their content inside a clipped panel: long input or output could not be scrolled with the mouse, touch or keyboard. The wrapper now fills its panel. The read-only output's scroll container also takes keyboard focus, so the arrow and page keys scroll it, without making the output editable (which would open the on-screen keyboard on phones).
|
||||
- **Fewer console errors.** The content security policy now allows WebAssembly (`'wasm-unsafe-eval'`, which still forbids JavaScript `eval`) on the website and in the apps, so the bson library's small 64-bit math helper no longer logs a violation (it fell back to JavaScript before). `browsing-topics` was removed from the `Permissions-Policy` header, which Brave and Firefox reported as an unknown feature. The remaining messages come from inside Cloudflare's Turnstile frame, which has its own policy.
|
||||
- **Production smoke check.** After a deploy it now waits until the new version answers several times in a row and retries before failing, because a deploy takes a moment to reach every Cloudflare edge location.
|
||||
|
||||
## [2.0.0] — 2026-10-22
|
||||
|
||||
A new home, a hardened toolchain and a full audit. The web app moves to **<https://jsonprism.poli0981.dev>** on Cloudflare Workers; the old GitHub Pages address redirects there, keeping the path. Because the website now uses Cloudflare services, the Privacy Policy and Terms are at version 2.0 and **everyone is asked to accept them again** (`CONSENT_VERSION` 2).
|
||||
|
||||
+2
-2
@@ -196,11 +196,11 @@ Vite copies `public/` into `dist/`; Workers Static Assets applies `_headers` and
|
||||
|
||||
| Header | Value |
|
||||
| --- | --- |
|
||||
| `Content-Security-Policy` | `default-src 'self'`; scripts from self, `static.cloudflareinsights.com` and `challenges.cloudflare.com`; `connect-src` self + `cloudflareinsights.com`; `frame-src` Turnstile; `worker-src 'self'`; `object-src 'none'`, `base-uri 'self'`, `form-action 'self'`, `frame-ancestors 'none'`, `upgrade-insecure-requests`. `style-src` keeps `'unsafe-inline'` (CodeMirror, Radix and Sonner inject styles at runtime). |
|
||||
| `Content-Security-Policy` | `default-src 'self'`; scripts from self, `static.cloudflareinsights.com` and `challenges.cloudflare.com`, plus `'wasm-unsafe-eval'` (WebAssembly only, for bson's 64-bit math helper); `connect-src` self + `cloudflareinsights.com`; `frame-src` Turnstile; `worker-src 'self'`; `object-src 'none'`, `base-uri 'self'`, `form-action 'self'`, `frame-ancestors 'none'`, `upgrade-insecure-requests`. `style-src` keeps `'unsafe-inline'` (CodeMirror, Radix and Sonner inject styles at runtime). |
|
||||
| `Strict-Transport-Security` | `max-age=31536000`, deliberately without `includeSubDomains` |
|
||||
| `X-Content-Type-Options`, `X-Frame-Options` | `nosniff`, `DENY` |
|
||||
| `Referrer-Policy` | `strict-origin-when-cross-origin` |
|
||||
| `Permissions-Policy` | camera, microphone, geolocation, motion sensors, payment, USB and Topics all disabled |
|
||||
| `Permissions-Policy` | camera, microphone, geolocation, motion sensors, payment and USB disabled (`browsing-topics` was dropped in 2.0.1: Brave and Firefox log it as an unknown feature, and the site runs no ad code) |
|
||||
| `Cross-Origin-Opener-Policy` | `same-origin` |
|
||||
| `Cache-Control` | HTML `no-cache, no-transform`; `/assets/*` `public, max-age=31536000, immutable` (hashed file names) |
|
||||
|
||||
|
||||
+2
-1
@@ -87,10 +87,11 @@ Widening the scope requires both a capability edit and a CSP review in
|
||||
`app.security.csp` in `tauri.conf.json`:
|
||||
|
||||
```
|
||||
default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'
|
||||
default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'wasm-unsafe-eval'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'
|
||||
```
|
||||
|
||||
- 2.0.0 added `object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'`.
|
||||
- 2.0.1 added `'wasm-unsafe-eval'` to `script-src`: bson compiles a tiny WebAssembly helper for 64-bit math (it falls back to JavaScript when blocked, but every WebView logged a CSP violation).
|
||||
- No third-party origins. Cloudflare Turnstile and Web Analytics are web-only
|
||||
and compiled out of Tauri builds (`__IS_TAURI_BUILD__`), so this CSP never
|
||||
needs their hosts. The web CSP lives in `public/_headers` — see
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "jsonprism",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "jsonprism",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@codemirror/lang-json": "^6.0.2",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jsonprism",
|
||||
"private": true,
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"type": "module",
|
||||
"description": "Disperse JSON into 12 formats (six convert back) — JSONL, CSV, TSV, YAML, XML, TOML, RESX, Markdown, SQL, BSON, CBOR, MessagePack. Conversion runs locally in your browser or desktop app.",
|
||||
"author": "poli0981 <code@poli0981.dev> (https://github.com/poli0981)",
|
||||
|
||||
+5
-3
@@ -2,18 +2,20 @@
|
||||
# API responses from worker/ set their own headers.
|
||||
#
|
||||
# CSP notes:
|
||||
# - script-src: the Cloudflare Web Analytics beacon and the Turnstile widget.
|
||||
# - script-src: the Cloudflare Web Analytics beacon and the Turnstile widget;
|
||||
# 'wasm-unsafe-eval' lets bson compile its small WebAssembly helper for
|
||||
# 64-bit math (it allows WebAssembly only, not JavaScript eval).
|
||||
# - style-src 'unsafe-inline': CodeMirror, Radix and Sonner inject styles at runtime.
|
||||
# - connect-src: the analytics beacon reports to cloudflareinsights.com (or /cdn-cgi/rum).
|
||||
# - frame-src: the Turnstile challenge iframe.
|
||||
# - worker-src 'self': the conversion Web Worker.
|
||||
/*
|
||||
Content-Security-Policy: default-src 'self'; script-src 'self' https://static.cloudflareinsights.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' https://cloudflareinsights.com; frame-src https://challenges.cloudflare.com; worker-src 'self'; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
|
||||
Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval' https://static.cloudflareinsights.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' https://cloudflareinsights.com; frame-src https://challenges.cloudflare.com; worker-src 'self'; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
|
||||
Strict-Transport-Security: max-age=31536000
|
||||
X-Content-Type-Options: nosniff
|
||||
X-Frame-Options: DENY
|
||||
Referrer-Policy: strict-origin-when-cross-origin
|
||||
Permissions-Policy: accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=(), browsing-topics=()
|
||||
Permissions-Policy: accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()
|
||||
Cross-Origin-Opener-Policy: same-origin
|
||||
# HTML must revalidate so a deploy is picked up; no-transform keeps zone
|
||||
# features (Rocket Loader, Email Obfuscation) from rewriting pages and
|
||||
|
||||
Generated
+2
-2
@@ -1,6 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
@@ -1876,7 +1876,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonprism"
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "jsonprism"
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
description = "Disperse JSON into many formats."
|
||||
authors = ["poli0981 <code@poli0981.dev>"]
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
By installing and using JSONPrism, you agree to the terms below.\par
|
||||
\par
|
||||
JSONPrism is free, open-source software licensed under the Apache License 2.0:\par
|
||||
https://github.com/poli0981/jsonPrism/blob/v2.0.0/LICENSE\par
|
||||
https://github.com/poli0981/jsonPrism/blob/v2.0.1/LICENSE\par
|
||||
\par
|
||||
Your use is also governed by the following documents (version 2.0, effective 2026-10-22):\par
|
||||
\bullet\tab Terms of Service (EULA): https://github.com/poli0981/jsonPrism/blob/v2.0.0/TERMS.md\par
|
||||
\bullet\tab Privacy Policy: https://github.com/poli0981/jsonPrism/blob/v2.0.0/PRIVACY.md\par
|
||||
\bullet\tab Disclaimer: https://github.com/poli0981/jsonPrism/blob/v2.0.0/DISCLAIMER.md\par
|
||||
\bullet\tab Terms of Service (EULA): https://github.com/poli0981/jsonPrism/blob/v2.0.1/TERMS.md\par
|
||||
\bullet\tab Privacy Policy: https://github.com/poli0981/jsonPrism/blob/v2.0.1/PRIVACY.md\par
|
||||
\bullet\tab Disclaimer: https://github.com/poli0981/jsonPrism/blob/v2.0.1/DISCLAIMER.md\par
|
||||
\par
|
||||
JSONPrism is provided \ldblquote as is\rdblquote , without warranty of any kind. The desktop app converts everything on your device and makes no network requests of its own.\par
|
||||
\par
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": "default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'"
|
||||
"csp": "default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'wasm-unsafe-eval'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
@@ -78,7 +78,7 @@
|
||||
},
|
||||
"android": {
|
||||
"minSdkVersion": 31,
|
||||
"versionCode": 20000
|
||||
"versionCode": 20001
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import CodeMirror, { EditorState, EditorView, type BasicSetupOptions } from '@uiw/react-codemirror';
|
||||
import CodeMirror, {
|
||||
EditorState,
|
||||
EditorView,
|
||||
ViewPlugin,
|
||||
type BasicSetupOptions,
|
||||
} from '@uiw/react-codemirror';
|
||||
import { json } from '@codemirror/lang-json';
|
||||
import { yaml } from '@codemirror/lang-yaml';
|
||||
import { xml } from '@codemirror/lang-xml';
|
||||
@@ -108,6 +113,21 @@ const jsonlLint = linter((view) => {
|
||||
return diagnostics;
|
||||
});
|
||||
|
||||
/**
|
||||
* Read-only output isn't contenteditable (that would raise the on-screen
|
||||
* keyboard on phones), so CodeMirror never moves a cursor through it and
|
||||
* swallows the arrow keys. Make the scroll container itself focusable instead:
|
||||
* the browser then scrolls it with the arrow and page keys.
|
||||
*/
|
||||
function focusableScroller(label: string | undefined) {
|
||||
return ViewPlugin.define((view) => {
|
||||
view.scrollDOM.tabIndex = 0;
|
||||
view.scrollDOM.setAttribute('role', 'region');
|
||||
if (label) view.scrollDOM.setAttribute('aria-label', label);
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
function languageExtensions(language: EditorLanguage, readOnly: boolean) {
|
||||
switch (language) {
|
||||
case 'json':
|
||||
@@ -237,6 +257,7 @@ export function CodeEditor({
|
||||
...(ariaLabel ? { 'aria-label': ariaLabel } : {}),
|
||||
...(readOnly ? { 'aria-readonly': 'true' } : {}),
|
||||
}),
|
||||
...(readOnly ? [focusableScroller(ariaLabel)] : []),
|
||||
theme,
|
||||
];
|
||||
}, [ariaLabel, language, phrases, readOnly, resolvedTheme, wrap]);
|
||||
@@ -244,6 +265,10 @@ export function CodeEditor({
|
||||
return (
|
||||
<div className={cn('h-full overflow-hidden', className)}>
|
||||
<CodeMirror
|
||||
// The wrapper div this component renders must fill the panel too, or
|
||||
// `height="100%"` has nothing to resolve against: the editor grows to
|
||||
// its content, gets clipped, and never scrolls.
|
||||
className="h-full"
|
||||
value={value}
|
||||
readOnly={readOnly}
|
||||
editable={!readOnly}
|
||||
|
||||
@@ -113,6 +113,17 @@ describe('CodeEditor — editable', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('CodeEditor — sizing', () => {
|
||||
// Regression: the wrapper @uiw/react-codemirror renders had no height, so the
|
||||
// editor grew to its content inside an overflow-hidden panel and could not scroll.
|
||||
it.each([false, true])('fills its panel so long documents scroll (readOnly=%s)', (readOnly) => {
|
||||
const { root } = renderEditor({ value: 'x\n'.repeat(500), readOnly });
|
||||
const wrapper = root.parentElement!;
|
||||
expect(wrapper).toHaveClass('cm-theme-none', 'h-full');
|
||||
expect(wrapper.parentElement).toHaveClass('h-full', 'overflow-hidden');
|
||||
});
|
||||
});
|
||||
|
||||
describe('CodeEditor — read-only', () => {
|
||||
it('marks the content read-only and drops the editing chrome', () => {
|
||||
const { content, container } = renderEditor({
|
||||
@@ -123,6 +134,12 @@ describe('CodeEditor — read-only', () => {
|
||||
});
|
||||
expect(content).toHaveAttribute('contenteditable', 'false');
|
||||
expect(content).toHaveAttribute('aria-readonly', 'true');
|
||||
// Regression: not contenteditable, so the scroll container takes focus and
|
||||
// the browser scrolls it with the arrow and page keys.
|
||||
const scroller = container.querySelector('.cm-scroller')!;
|
||||
expect(scroller).toHaveAttribute('tabindex', '0');
|
||||
expect(scroller).toHaveAttribute('role', 'region');
|
||||
expect(scroller).toHaveAttribute('aria-label', 'YAML output (read-only)');
|
||||
expect(content).toHaveAttribute('aria-label', 'YAML output (read-only)');
|
||||
expect(container.querySelector('.cm-lineNumbers')).not.toBeNull();
|
||||
expect(container.querySelector('.cm-activeLine')).toBeNull();
|
||||
|
||||
Reference in new issue
Block a user