stevengharris/MarkupEditor

Pasteboard alert on iOS 16

sdtaheri opened this issue · 7 comments

Hello,

Is there a way to disable the paste alerts that are thrown at initialization?

I know I can disable the alert in the app settings as of iOS 16.1, but I really prefer it to not be there in the first place. I can't ask all my users to go there.

Simulator Screen Shot - iPhone 14 Pro - 2022-12-09 at 17 48 10

I don't know but will look into it.

Thanks. These are the changes:
https://sarunw.com/posts/uipasteboard-privacy-change-ios16/

Here is the culprit in code. It reads the data and string everytime and causes the alert to pop up continuously.

//...
        } else if pasteboard.contains(pasteboardTypes: ["public.html"]) {
            if let data = pasteboard.data(forPasteboardType: "public.html"), String(data: data, encoding: .utf8) != nil {
                // We have HTML, which we will have to sanitize before pasting
                return .Html
            }
        } else if pasteboard.string != nil {
            // We have a string that we can paste
            return .Text
        }
//...

It hits the aforementioned block of code when checking canPerformAction for Paste and Paste and Match Style menus in MarkupWKWebView.swift. I believe fetching the pasteboard value should only be done when those menus are explicitly performed.

Thanks for the details. I was out of town but will take a look this week. I was not sensitized to it because I am primarily using it on a Mac and using Ctrl-C/Ctrl-V.

Thanks again for raising the issue and for the debugging to locate the problem!

@stevengharris Thank you for resolving it this fast.

haemi commented

I still get this all the time when selecting text... am I missing something?

It shouldn't be happening if you are using main. Does it happen in SwiftUIDemo?