A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.
C++
fix(mongodb): disable smart quotes in Insert Document editor
Tobi0c5644df935a
diff --git a/macos/Core/Extensions/NSTextView+PlainText.swift b/macos/Core/Extensions/NSTextView+PlainText.swiftnew file mode 100644index 0000000..a6e7a58--- /dev/null+++ b/macos/Core/Extensions/NSTextView+PlainText.swift@@ -0,0 +1,22 @@+// NSTextView+PlainText.swift+// Gridex+//+// Helpers for code-style text input.++import AppKit++extension NSTextView {+ /// Turn off every auto-substitution macOS applies by default. Essential for+ /// code/JSON/SQL editors — smart quotes silently corrupt strings, and+ /// spell/grammar underlines are pure noise on syntactic text.+ func disableAutoSubstitutions() {+ isAutomaticQuoteSubstitutionEnabled = false+ isAutomaticDashSubstitutionEnabled = false+ isAutomaticTextReplacementEnabled = false+ isAutomaticSpellingCorrectionEnabled = false+ isContinuousSpellCheckingEnabled = false+ isGrammarCheckingEnabled = false+ isAutomaticDataDetectionEnabled = false+ isAutomaticLinkDetectionEnabled = false+ }+}diff --git a/macos/Presentation/Views/MongoDB/MongoDocumentEditorSheet.swift b/macos/Presentation/Views/MongoDB/MongoDocumentEditorSheet.swiftindex 7ad0d56..255ca4d 100644--- a/macos/Presentation/Views/MongoDB/MongoDocumentEditorSheet.swift+++ b/macos/Presentation/Views/MongoDB/MongoDocumentEditorSheet.swift@@ -4,6 +4,7 @@// JSON document editor for inserting MongoDB documents.import SwiftUI+import AppKitstruct MongoDocumentEditorSheet: View {let collectionName: String@@ -41,16 +42,11 @@ struct MongoDocumentEditorSheet: View {Divider()- // JSON editor- ScrollView {- TextEditor(text: $jsonText)- .font(.system(size: 12, design: .monospaced))- .frame(minHeight: 280)- .padding(8)- .scrollContentBackground(.hidden)- .background(Color(nsColor: .textBackgroundColor))- }- .frame(minHeight: 300)+ // macOS smart quotes silently replace `"` with `"`/`"`, which then fail+ // JSONSerialization — force a plain-text NSTextView here.+ PlainJSONTextEditor(text: $jsonText)+ .frame(minHeight: 300)+ .background(Color(nsColor: .textBackgroundColor))if let errorMessage {Divider()@@ -154,3 +150,45 @@ struct MongoDocumentEditorSheet: View {}}}++// MARK: - Plain-text JSON editor++private struct PlainJSONTextEditor: NSViewRepresentable {+ @Binding var text: String++ final class Coordinator: NSObject, NSTextViewDelegate {+ let binding: Binding<String>+ init(_ binding: Binding<String>) { self.binding = binding }+ func textDidChange(_ notification: Notification) {+ guard let tv = notification.object as? NSTextView else { return }+ binding.wrappedValue = tv.string+ }+ }++ func makeCoordinator() -> Coordinator { Coordinator($text) }++ func makeNSView(context: Context) -> NSScrollView {+ let scroll = NSTextView.scrollableTextView()+ // `NSTextView.scrollableTextView()` is documented to always produce an+ // NSTextView document view — a failure here would be a system-level bug.+ let textView = scroll.documentView as! NSTextView++ textView.font = .monospacedSystemFont(ofSize: 12, weight: .regular)+ textView.textContainerInset = NSSize(width: 8, height: 8)+ textView.disableAutoSubstitutions()+ // NSTextView defaults undo to off; SwiftUI's TextEditor enabled it, so keep parity.+ textView.allowsUndo = true+ textView.delegate = context.coordinator+ textView.string = text++ scroll.hasVerticalScroller = true+ scroll.drawsBackground = false+ return scroll+ }++ func updateNSView(_ scroll: NSScrollView, context: Context) {+ guard let textView = scroll.documentView as? NSTextView,+ textView.string != text else { return }+ textView.string = text+ }+}diff --git a/macos/Presentation/Views/QueryEditor/SQLTextView.swift b/macos/Presentation/Views/QueryEditor/SQLTextView.swiftindex 83301f4..fe1a4e5 100644--- a/macos/Presentation/Views/QueryEditor/SQLTextView.swift+++ b/macos/Presentation/Views/QueryEditor/SQLTextView.swift@@ -28,11 +28,7 @@ final class SQLTextView: NSTextView {private func commonInit() {font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)textContainerInset = NSSize(width: 12, height: 8)- isAutomaticQuoteSubstitutionEnabled = false- isAutomaticDashSubstitutionEnabled = false- isAutomaticTextReplacementEnabled = false- isAutomaticSpellingCorrectionEnabled = false- isContinuousSpellCheckingEnabled = false+ disableAutoSubstitutions()}override func keyDown(with event: NSEvent) {diff --git a/macos/Resources/Info.plist b/macos/Resources/Info.plistindex 5d66407..1269d51 100644--- a/macos/Resources/Info.plist+++ b/macos/Resources/Info.plist@@ -32,9 +32,9 @@<key>CFBundlePackageType</key><string>APPL</string><key>CFBundleShortVersionString</key>- <string>0.0.9</string>+ <string>0.0.10</string><key>CFBundleVersion</key>- <string>9</string>+ <string>10</string><key>LSMinimumSystemVersion</key><string>14.0</string><key>NSAppTransportSecurity</key>diff --git a/scripts/publish.sh b/scripts/publish.shindex 244863a..9cc3994 100755--- a/scripts/publish.sh+++ b/scripts/publish.sh@@ -2,9 +2,10 @@# publish.sh — Generate Sparkle appcast and upload release artifacts to Cloudflare R2.## Usage:-# ./scripts/publish.sh # Publishes everything in dist/*.dmg-# DRY_RUN=1 ./scripts/publish.sh # Generates appcast locally, skips upload-# SKIP_APPCAST=1 ./scripts/publish.sh # Uploads existing artifacts, no appcast regen+# ./scripts/publish.sh # Upload only the current version's DMG + appcast+# UPLOAD_ALL=1 ./scripts/publish.sh # Re-upload every DMG in dist/ (bucket resync)+# DRY_RUN=1 ./scripts/publish.sh # Generate appcast locally, skip upload+# SKIP_APPCAST=1 ./scripts/publish.sh # Upload existing artifacts, no appcast regen## Env:# R2_BUCKET Cloudflare R2 bucket name (default: gridex-downloads)@@ -12,6 +13,7 @@# FEED_BASE_URL Public URL where the DMGs are served (default: https://cdn.gridex.app/macos)# DRY_RUN 1 = generate appcast locally, skip R2 upload# SKIP_APPCAST 1 = skip appcast regeneration (re-upload only)+# UPLOAD_ALL 1 = upload every dist/*.dmg, not just the current version## Requirements:# • generate_appcast from Sparkle (found automatically under .build/artifacts)@@ -21,7 +23,7 @@# Flow:# 1. Find generate_appcast in SPM artifacts# 2. Run generate_appcast against dist/ → signs each DMG with EdDSA, emits appcast.xml-# 3. Upload every .dmg + appcast.xml to R2 under $R2_BUCKET/$R2_PREFIX/+# 3. Upload the current version's DMG (or everything if UPLOAD_ALL=1) + appcast.xmlset -euo pipefail@@ -34,13 +36,23 @@ R2_PREFIX="${R2_PREFIX:-macos}"FEED_BASE_URL="${FEED_BASE_URL:-https://cdn.gridex.app/macos}"DRY_RUN="${DRY_RUN:-0}"SKIP_APPCAST="${SKIP_APPCAST:-0}"+UPLOAD_ALL="${UPLOAD_ALL:-0}"++# Current version drives the default "new DMG only" upload path.+CURRENT_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$PROJECT_DIR/macos/Resources/Info.plist" 2>/dev/null || true)+if [ -z "$CURRENT_VERSION" ]; then+ echo "✗ Could not read CFBundleShortVersionString from Info.plist"+ exit 1+fiecho "═══════════════════════════════════════════"echo " Publish to Cloudflare R2"echo " Bucket: $R2_BUCKET"echo " Prefix: $R2_PREFIX"echo " Feed: $FEED_BASE_URL"+echo " Version: $CURRENT_VERSION"[ "$DRY_RUN" = "1" ] && echo " Mode: DRY RUN (no upload)"+[ "$UPLOAD_ALL" = "1" ] && echo " Mode: UPLOAD ALL (re-syncing every DMG)"echo "═══════════════════════════════════════════"if [ ! -d "$DIST_DIR" ] || [ -z "$(ls -A "$DIST_DIR"/*.dmg 2>/dev/null)" ]; then@@ -78,10 +90,29 @@ if ! command -v wrangler >/dev/null 2>&1; thenexit 1fi-# 3. Upload DMGs+# 3. Collect DMGs to upload — by default just the current version; the appcast+# still references every historical build from $FEED_BASE_URL, but those+# DMGs were already uploaded in previous publish runs. Pass UPLOAD_ALL=1 to+# resync the full bucket (e.g. after a bucket wipe or prefix migration).+if [ "$UPLOAD_ALL" = "1" ]; then+ candidate_dmgs=( "$DIST_DIR"/*.dmg )+else+ candidate_dmgs=( "$DIST_DIR/Gridex-${CURRENT_VERSION}-"*.dmg )+fi+dmgs_to_upload=()+for dmg in "${candidate_dmgs[@]}"; do+ [ -f "$dmg" ] && dmgs_to_upload+=("$dmg")+done+if [ ${#dmgs_to_upload[@]} -eq 0 ]; then+ echo "✗ No DMG found for version $CURRENT_VERSION in $DIST_DIR"+ echo " Expected: $DIST_DIR/Gridex-${CURRENT_VERSION}-*.dmg"+ echo " Run ./scripts/release.sh or ./scripts/release-all.sh first,"+ echo " or pass UPLOAD_ALL=1 to upload every existing DMG."+ exit 1+fi+echo "→ Uploading DMGs to R2..."-for dmg in "$DIST_DIR"/*.dmg; do- [ -f "$dmg" ] || continue+for dmg in "${dmgs_to_upload[@]}"; doname=$(basename "$dmg")echo " ↑ $name"wrangler r2 object put "$R2_BUCKET/$R2_PREFIX/$name" \