Skip to content

Fix Export HTML; implement ⌘F find and ⌘P print#2

Merged
sethbang merged 1 commit into
mainfrom
app/find-print-export-fixes
May 15, 2026
Merged

Fix Export HTML; implement ⌘F find and ⌘P print#2
sethbang merged 1 commit into
mainfrom
app/find-print-export-fixes

Conversation

@sethbang
Copy link
Copy Markdown
Owner

Summary

Three app-code fixes, all surfaced by manual testing this session. Independent of PR #1 (site/responsive work) — touches only Sources/Markee/.

Export Standalone HTML (⌘E) — bug fix
exportStandalone() in app.js is async (it fetches and inlines images as data URIs), so it returns a Promise. The old code used evaluateJavaScript, which can't await a Promise — it handed the Promise object back, and WKWebView can't bridge that to Swift → "JavaScript execution returned a result of an unsupported type." Switched to callAsyncJavaScript, which resolves the Promise first.

⌘P Print — new
Claimed in the README, never wired. New Print menu command running WKWebView.printOperation(with:). The system print panel's PDF ▸ Save as PDF covers print-to-PDF.

⌘F Find — new
Also claimed, never wired. macOS WKWebView has no built-in find bar (the first attempt using performTextFinderAction: crashed — unrecognized selector). Added a real in-app FindBar overlay — modeled on the existing ErrorBanner — driving WKWebView.find(_:configuration:):

  • Find-as-you-type
  • Enter / ‹ › chevrons for next & previous
  • Esc or ✕ to close
  • "Not found" indicator, wrap-around enabled

Test plan

  • make test — 24 Swift + 24 JS tests pass
  • ⌘E exports a standalone HTML file (manually verified)
  • ⌘P opens the print panel; Save as PDF works (manually verified)
  • ⌘F opens the find bar, highlights/cycles matches, no crash (manually verified)

🤖 Generated with Claude Code

Export Standalone HTML (⌘E) failed with "JavaScript execution returned a
result of an unsupported type". exportStandalone() in app.js is async, so
it returns a Promise — evaluateJavaScript can't await one and hands the
Promise object straight back, which WKWebView can't bridge. Switch to
callAsyncJavaScript, which resolves the Promise before bridging.

⌘F and ⌘P were claimed in the README but never wired up:

- ⌘P — new Print menu command running WKWebView.printOperation(with:).
  The print panel's "Save as PDF" covers print-to-PDF for free.

- ⌘F — macOS WKWebView has no built-in find bar, so add an in-app one:
  a FindBar overlay (modeled on the existing ErrorBanner) driving
  WKWebView.find(_:configuration:). Find-as-you-type, Enter / chevrons
  for next-prev, Esc or close button dismisses, "Not found" indicator,
  wrap-around enabled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
markee aeb4b2c Commit Preview URL

Branch Preview URL
May 15 2026, 10:09 AM

@sethbang sethbang merged commit 21f4198 into main May 15, 2026
4 checks passed
@sethbang sethbang deleted the app/find-print-export-fixes branch May 19, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant