mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-24 15:19:29 +00:00
Summary: - The PR wires the macOS Dashboard and Canvas WKWebViews to WKUIDelegate and presents NSOpenPanel for HTML file inputs. - PR surface: Other +61. Total +61 across 3 files. - Reproducibility: yes. at source level: current main renders the affected file inputs while the macOS Dashboa ... fore-fix packaged macOS app in this read-only review, but the after-fix screenshots show the real app path. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head4f477c4ed0. - Required merge gates passed before the squash merge. Prepared head SHA:4f477c4ed0Review: https://github.com/openclaw/openclaw/pull/94612#issuecomment-4743165861 Co-authored-by: bbblending <li.mingkang@xydigit.com>
33 lines
1.1 KiB
Swift
33 lines
1.1 KiB
Swift
import AppKit
|
|
import WebKit
|
|
|
|
extension CanvasWindowController {
|
|
// MARK: - WKUIDelegate
|
|
|
|
/// Bridges `<input type="file">` clicks in canvas HTML to a native `NSOpenPanel`.
|
|
/// Without a `WKUIDelegate`, WebKit silently drops the request and file-picker
|
|
/// buttons in canvas pages do nothing.
|
|
@MainActor
|
|
func webView(
|
|
_ webView: WKWebView,
|
|
runOpenPanelWith parameters: WKOpenPanelParameters,
|
|
initiatedByFrame frame: WKFrameInfo,
|
|
completionHandler: @escaping @MainActor @Sendable ([URL]?) -> Void)
|
|
{
|
|
let panel = NSOpenPanel()
|
|
panel.canChooseFiles = true
|
|
panel.canChooseDirectories = parameters.allowsDirectories
|
|
panel.allowsMultipleSelection = parameters.allowsMultipleSelection
|
|
panel.resolvesAliases = true
|
|
if let window = self.window {
|
|
panel.beginSheetModal(for: window) { response in
|
|
completionHandler(response == .OK ? panel.urls : nil)
|
|
}
|
|
return
|
|
}
|
|
panel.begin { response in
|
|
completionHandler(response == .OK ? panel.urls : nil)
|
|
}
|
|
}
|
|
}
|