Skip to content

Commit

Permalink
Remove the "Copy Link with Highlight" and "Writing Tools" EPUB editin…
Browse files Browse the repository at this point in the history
…g actions
  • Loading branch information
mickael-menu committed Jan 13, 2025
1 parent dbc07cc commit 438b258
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ All notable changes to this project will be documented in this file. Take a look

* Fixed a crash using `HTTPClient.download()` when the device storage is full.

#### Navigator

* [#509](https://github.com/readium/swift-toolkit/issues/509) Removed the "Copy Link with Highlight" and "Writing Tools" EPUB editing actions on newer devices.

#### OPDS

* Fixed a data race in the OPDS 1 parser.
Expand Down
16 changes: 16 additions & 0 deletions Sources/Navigator/Toolkit/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ final class WebView: WKWebView {

let config = WKWebViewConfiguration()
config.mediaTypesRequiringUserActionForPlayback = .all

// Disable the Apple Intelligence Writing tools in the web views.
// See https://github.com/readium/swift-toolkit/issues/509#issuecomment-2577780749
if #available(iOS 18.0, *) {
config.writingToolsBehavior = .none
}

super.init(frame: .zero, configuration: config)

#if DEBUG && swift(>=5.8)
Expand All @@ -38,6 +45,15 @@ final class WebView: WKWebView {
isUserInteractionEnabled = true
}

override func buildMenu(with builder: any UIMenuBuilder) {
editingActions.buildMenu(with: builder)

// Don't call super as it is the only way to remove the
// "Copy Link with Highlight" menu item.
// See https://github.com/readium/swift-toolkit/issues/509
// super.buildMenu(with: builder)
}

override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
super.canPerformAction(action, withSender: sender)
&& editingActions.canPerformAction(action)
Expand Down

0 comments on commit 438b258

Please sign in to comment.