-
-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clipboard is broken on Mac Catalyst WebView #1322
Comments
Do I understand correctly that this webview inherits all the Mobile Safari bugs, and we should somehow try to detect it and enable our iOS workarounds? |
Thanks for the quick response!
This is my assumption but I'm not entirely sure, could you please point out some iOS bugs so that I can verify on Mac Catalyst?
For now I actually cannot tell from I ended up by setting a fake user agent, telling ProseMirror the browser is both iOS and older than 604. |
@cyanzhong How are you seeing this problem manifest? I ask because we use prosemirror within a WKWebView in iOS & Catalyst and haven't found any issues with the clipboard. I can copy content and it's correctly within the Mac pasteboard and so can be pasted into other places in the app or other applications. |
@igandrews I just wrote a minimal repro: import UIKit
import WebKit
class ViewController: UIViewController {
private let webView = WKWebView(frame: .zero)
override func viewDidLoad() {
super.viewDidLoad()
webView.load(URLRequest(url: URL(string: "https://prosemirror.net/")!))
view.addSubview(webView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
webView.frame = view.bounds
}
} The copied content can only be pasted into the ProseMirror editor, not anywhere else. What's your OS version? I am using macOS 12.6, building the sample using Xcode 14.1. Also, do you have a custom user agent in your app? |
@cyanzhong I do not have a custom user agent. I am also in Mac 12.6 but my Xcode version is 13.4.1. And when I copy to the clipboard (e.g. select all and copy the default prosemirror.net content) I see the pasteboard with that content and can paste elsewhere: What do you have in the pasteboard? The fact that you can paste within prosemirror would indicate something is in the clipboard (unless prosemirror uses some local/internal fallback storage I'm not aware of). Wonder if it relates to the custom clipboard format changes being discussed/made. |
@igandrews This is a great way to investigate, thanks for sharing. It turns out when I use the default UA, I have something in the clipboard: It seems there's no When I fake the UA (to enable the |
@igandrews Alright, I think I figured out. I downloaded Xcode 13.4.1 and tried again, it works just fine as you mentioned. The issue seems like a regression in the new SDK (Xcode 14), that is why you haven't seen this issue. Hope this helps. I will Ventura later today, not sure if it's still there. |
So do I understand correctly that this isn't really something ProseMirror can work around? |
@marijnh Yeah I think this is just a webkit/wkwebview issue imo. @cyanzhong I'm actually seeing the html only format in my app too and have another dev using ventura and they see that so guessing you will find the issue is still there. Seems like something bad in webkit though I didn't spend the time to track it down. Maybe you want to report it to them. For me I worked around this for now by hooking the cut and copy (after the editor view creation to ensure I'm hooking after it does) and then I later on update the pasteboard. Not ideal but it works for now. |
FYI - the recently released .NET MAUI Blazor Hybrid stuff from Microsoft uses Mac Catalyst for compiling to macOS, so you may see more of this issue. (I just came across this myself, trying exactly this.) |
Mac Catalyst is a technique introduced by Apple to bring iOS apps to Mac, it uses
UIKit
instead ofAppKit
even when running on macOS.That being said, a WKWebView on macCatalyst inherits from UIView, which behaves differently in some ways compared to the native WKWebView on Mac apps.
I tested ProseMirror on Monterey running on Mac Catalyst, and it seems copying content from the editor doesn't work (cannot paste into other places).
The root cause seems that we need to enable
brokenClipboardAPI
even whenbrowser.ios && browser.webkit_version < 604
gives us false: https://github.com/ProseMirror/prosemirror-view/blob/master/src/input.ts#L550I can help get more info regarding system versions and SDK versions if you want to fix this (e.g., whether this is fixed in Ventura), totally understand the priority since using Mac Catalyst is already a niche choice.
The text was updated successfully, but these errors were encountered: