Can not select anything within WkWebView editor view of my MacCatalyst app when running on macOS 14 Sonoma.
Any selection gesture or command key fails to select anything in content editable WKWebView, so none of the Editor tools can be activated.
My application uses the nnhubbard / ZSSRichTextEditor WKWebView-based Rich Text Editor: https://github.com/nnhubbard/ZSSRichTextEditor. The app is built with Xcode 15.0 or 15.0.1.
The app is a Catalyst app that implements an editor view with a ZSSRichTextEditor WKWebView.
The problem does not occur if the the app is run in iOS or macOS 11, 12, or 13 (Catalina, Monterey, or Ventura.) The issue only occurs in macOS 14 Sonoma.
Post
Replies
Boosts
Views
Activity
Can not select anything within WkWebView editor view of my MacCatalyst app when running on macOS 14 Sonoma.
Any selection gesture or command key fails to select anything in content editable WKWebView, so none of the Editor tools can be activated.
My application uses the nnhubbard / ZSSRichTextEditor WKWebView-based Rich Text Editor: https://github.com/nnhubbard/ZSSRichTextEditor. The app is built with Xcode 15.4.
The app is a Catalyst app that implements an editor view with a ZSSRichTextEditor WKWebView.
The problem does not occur if the the app is run in macOS 11, 12, or 13 (Catalina, Monterey, or Ventura.) The issue only occurs in macOS 14 Sonoma.
The following error message is logged whenever an attempt to select any text in the WKWebView content:
0x1359ecc18 - [pageProxyID=14, webPageID=15, PID=14,932] WebPageProxy::didFailProvisionalLoadForFrame: frameID=1, isMainFrame=1, domain=NSURLErrorDomain, code=18,446,744,073,709,550,614, isMainFrame=1, willInternallyHandleFailure=0
Without the ability to select text the editor (WKWebView) is useless since no editing tool can be invoked without a selection.
An Apple Feedback report was filed: FB13344011.
An incident was filed with DTS concerning this issue. Apple Developer Technical Support's reply was "Our engineers have reviewed your request and have determined that you are experiencing a known issue for which there is no known workaround at this time."
Since DTS’ reply there has been no further response from them.
I have a UITableView that displays a Group/Note hierarchy analogous to a Finder Folder/Files hierarchy. I have implemented Drag and Drop such that if I drag a Note to the Finder Desktop an HTML file is created of the Note, and if I drag a Group to the Finder Desktop a Text file is created of the Group's title. Here is the Helper Dragging extension that I've implemented:
//
// Model+Dragging.swift
//
/*
Abstract:
Helper methods for providing and consuming drag-and-drop data.
*/
import UIKit
import MobileCoreServices
// Conditionalize Drag and Drop so it is not in iOS target.
#if targetEnvironment(macCatalyst)
extension Model {
/**
A helper function that serves as an interface to the data model,
called by the implementation of the `tableView(_ canHandle:)` method.
*/
func canHandle(_ session: UIDropSession) -> Bool {
// In order to enable dragging all text type files changed the class
// loadable objects from NSString to my custom TEXTClass.
return session.canLoadObjects(ofClass: TEXTClass.self)
}
/**
A helper function that serves as an interface to the data model, called
by the `tableView(_:itemsForBeginning:at:)` method.
*/
func dragItems(for indexPath: IndexPath) -> [UIDragItem] {
let itemProvider = NSItemProvider()
let item = self.getDisplayItem(for: indexPath.row)
if item is Note {
let note:Note = item as! Note
let html = note.noteHTML
let data = html?.data(using: .utf8)
// Drag to finder creates an html file.
itemProvider.suggestedName = note.title + ".html"
itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeData as String,
visibility: .all) { completion in
completion(data, nil)
return nil
}
} else {
let group:Group = item as! Group
let title = group.title
let data = title?.data(using: .utf8)
// Drag to finder creates a text file.
itemProvider.suggestedName = group.title + ".text"
itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeData as String,
visibility: .all) { completion in
completion(data, nil)
return nil
}
}
return [
UIDragItem(itemProvider: itemProvider)
]
}
}
#endif
I would now like to change the result of dragging a Group to the Finder. Instead of creating a Text file from the drag data, I would like to create a Folder containing the Group's Notes.
Note: I am unconcerned with the task of assembling the Group/Notes hierarchies as Folder/Files hierarchies because I already have implemented such previously as a menu export command. My concern is where and how I can communicate it to the Finder in the Drag and Drop process.
As a first step I thought I would simply create an empty folder from the drag of a Group. So far, none of my experiments have been successful. Every variation of itemProvider.registerDataRepresentation(forTypeIdentifier: or itemProvider.registerFileRepresentation(forTypeIdentifier: or registerItem(forTypeIdentifier:loadHandler: that I have tried has failed to produce anything but empty TEXT files, if they worked at all.
It is my understanding that itemProviders may provide directories instead of files, but I have been unable to find any examples of such.
My problem may be a lack of understanding of the syntax and usage of the NSItemProvider.LoadHandler completion block.
Any Swift examples on point would be greatly appreciated!