mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-02 00:29:30 +00:00
fix(app): normalize grid JSON smart quotes
This commit is contained in:
@@ -269,7 +269,26 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
||||
if (typeof oldVal === "boolean") {
|
||||
return value === "true" || value === "1";
|
||||
}
|
||||
return value;
|
||||
return normalizeSmartQuotedJsonInput(value);
|
||||
}
|
||||
|
||||
function normalizeSmartQuotedJsonInput(value: string): string {
|
||||
if (!/[“”]/.test(value)) return value;
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return value;
|
||||
try {
|
||||
JSON.parse(value);
|
||||
return value;
|
||||
} catch {
|
||||
// macOS smart punctuation can turn JSON delimiters into Chinese-style quotes.
|
||||
}
|
||||
const normalized = value.replace(/[“”]/g, '"');
|
||||
try {
|
||||
JSON.parse(normalized);
|
||||
return normalized;
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
function canEditColumn(columnIndex: number): boolean {
|
||||
|
||||
Reference in New Issue
Block a user