@@ -106,6 +106,12 @@ class DocumentationWindowController: NSWindowController {
106
106
}
107
107
}
108
108
109
+ private extension DocumentationWindowController {
110
+ @objc func openDocumentationInBrowser( ) {
111
+ NSWorkspace . shared. open ( documentation. url)
112
+ }
113
+ }
114
+
109
115
// MARK:- DocumentationViewDelegate
110
116
extension DocumentationWindowController : DocumentationViewDelegate {
111
117
func selectFileToOpen( _ parameters: OpenPanelParameters , completionHandler: @escaping ( [ URL ] ? ) -> Void ) {
@@ -149,6 +155,7 @@ extension DocumentationWindowController: DocumentationViewDelegate {
149
155
extension NSToolbarItem . Identifier {
150
156
static let historyNavigation : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " HistoryNavigation " )
151
157
static let contentSearch : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " ContentSearch " )
158
+ static let openInBrowser : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " OpenInBrowser " )
152
159
153
160
// Sub items
154
161
static let navigateBack : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " NavigateBack " )
@@ -162,12 +169,13 @@ extension DocumentationWindowController: NSToolbarDelegate {
162
169
. historyNavigation,
163
170
. space,
164
171
. flexibleSpace,
172
+ . openInBrowser,
165
173
. contentSearch
166
174
]
167
175
}
168
176
169
177
func toolbarDefaultItemIdentifiers( _ toolbar: NSToolbar ) -> [ NSToolbarItem . Identifier ] {
170
- return [ . historyNavigation, . flexibleSpace, . contentSearch]
178
+ return [ . historyNavigation, . flexibleSpace, . openInBrowser , . contentSearch]
171
179
}
172
180
173
181
func toolbar( _ toolbar: NSToolbar , itemForItemIdentifier itemIdentifier: NSToolbarItem . Identifier , willBeInsertedIntoToolbar flag: Bool ) -> NSToolbarItem ? {
@@ -178,22 +186,31 @@ extension DocumentationWindowController: NSToolbarDelegate {
178
186
backItem. toolTip = backItem. label
179
187
backItem. isBordered = true
180
188
backItem. image = NSImage ( systemSymbolName: " chevron.backward " ,
181
- accessibilityDescription: NSLocalizedString ( " Navigate back " , comment: " Navigate back " ) )
189
+ accessibilityDescription: NSLocalizedString ( " Navigate back " , comment: " " ) )
182
190
backItem. autovalidates = true
183
191
184
192
let forwardItem = NSToolbarItem ( itemIdentifier: . navigateForward)
185
193
forwardItem. label = NSLocalizedString ( " Forward " , comment: " Navigate forward " )
186
194
forwardItem. toolTip = forwardItem. label
187
195
forwardItem. isBordered = true
188
196
forwardItem. image = NSImage ( systemSymbolName: " chevron.forward " ,
189
- accessibilityDescription: NSLocalizedString ( " Navigate forward " , comment: " Navigate forward " ) )
197
+ accessibilityDescription: NSLocalizedString ( " Navigate forward " , comment: " " ) )
190
198
forwardItem. autovalidates = true
191
199
192
200
let item = NSToolbarItemGroup ( itemIdentifier: itemIdentifier)
193
201
item. label = NSLocalizedString ( " Back / Forward " , comment: " History navigation " )
194
202
item. isNavigational = true
195
203
item. subitems = [ backItem, forwardItem]
196
204
return item
205
+ case . openInBrowser:
206
+ let item = NSToolbarItem ( itemIdentifier: itemIdentifier)
207
+ item. label = NSLocalizedString ( " Open in Browser " , comment: " Open current page in default system browser " )
208
+ item. toolTip = item. label
209
+ item. isBordered = true
210
+ item. image = NSImage ( systemSymbolName: " safari " ,
211
+ accessibilityDescription: NSLocalizedString ( " Open current page in default system browser " , comment: " " ) )
212
+ item. autovalidates = true
213
+ return item
197
214
case . contentSearch:
198
215
let item = NSSearchToolbarItem ( itemIdentifier: itemIdentifier)
199
216
item. searchField. recentsAutosaveName = NSSearchField . RecentsAutosaveName ( " content-search-term " )
@@ -222,6 +239,9 @@ extension DocumentationWindowController: NSToolbarDelegate {
222
239
break
223
240
}
224
241
}
242
+ case . openInBrowser:
243
+ item. target = self
244
+ item. action = #selector( openDocumentationInBrowser)
225
245
case . contentSearch:
226
246
let searchItem = item as! NSSearchToolbarItem
227
247
searchItem. searchField. delegate = documentationViewController
@@ -245,6 +265,9 @@ extension DocumentationWindowController: NSToolbarDelegate {
245
265
subitem. target = nil
246
266
subitem. action = nil
247
267
}
268
+ case . openInBrowser:
269
+ item. target = nil
270
+ item. action = nil
248
271
case . contentSearch:
249
272
contentSearchField = nil
250
273
0 commit comments