Skip to content

Commit cb20081

Browse files
authored
Remove the "Copy Link with Highlight" and "Writing Tools" EPUB editing actions (#532)
1 parent dbc07cc commit cb20081

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ All notable changes to this project will be documented in this file. Take a look
3030

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

33+
#### Navigator
34+
35+
* [#509](https://github.com/readium/swift-toolkit/issues/509) Removed the "Copy Link with Highlight" and "Writing Tools" EPUB editing actions on newer devices.
36+
3337
#### OPDS
3438

3539
* Fixed a data race in the OPDS 1 parser.

Sources/Navigator/Toolkit/WebView.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ final class WebView: WKWebView {
1717

1818
let config = WKWebViewConfiguration()
1919
config.mediaTypesRequiringUserActionForPlayback = .all
20+
21+
// Disable the Apple Intelligence Writing tools in the web views.
22+
// See https://github.com/readium/swift-toolkit/issues/509#issuecomment-2577780749
23+
#if compiler(>=6.0)
24+
if #available(iOS 18.0, *) {
25+
config.writingToolsBehavior = .none
26+
}
27+
#endif
28+
2029
super.init(frame: .zero, configuration: config)
2130

2231
#if DEBUG && swift(>=5.8)
@@ -38,6 +47,15 @@ final class WebView: WKWebView {
3847
isUserInteractionEnabled = true
3948
}
4049

50+
override func buildMenu(with builder: any UIMenuBuilder) {
51+
editingActions.buildMenu(with: builder)
52+
53+
// Don't call super as it is the only way to remove the
54+
// "Copy Link with Highlight" menu item.
55+
// See https://github.com/readium/swift-toolkit/issues/509
56+
// super.buildMenu(with: builder)
57+
}
58+
4159
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
4260
super.canPerformAction(action, withSender: sender)
4361
&& editingActions.canPerformAction(action)

0 commit comments

Comments
 (0)