@@ -106,6 +106,12 @@ class DocumentationWindowController: NSWindowController {
106106 }
107107}
108108
109+ private extension DocumentationWindowController {
110+ @objc func openDocumentationInBrowser( ) {
111+ NSWorkspace . shared. open ( documentation. url)
112+ }
113+ }
114+
109115// MARK:- DocumentationViewDelegate
110116extension DocumentationWindowController : DocumentationViewDelegate {
111117 func selectFileToOpen( _ parameters: OpenPanelParameters , completionHandler: @escaping ( [ URL ] ? ) -> Void ) {
@@ -149,6 +155,7 @@ extension DocumentationWindowController: DocumentationViewDelegate {
149155extension NSToolbarItem . Identifier {
150156 static let historyNavigation : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " HistoryNavigation " )
151157 static let contentSearch : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " ContentSearch " )
158+ static let openInBrowser : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " OpenInBrowser " )
152159
153160 // Sub items
154161 static let navigateBack : NSToolbarItem . Identifier = NSToolbarItem . Identifier ( " NavigateBack " )
@@ -162,12 +169,13 @@ extension DocumentationWindowController: NSToolbarDelegate {
162169 . historyNavigation,
163170 . space,
164171 . flexibleSpace,
172+ . openInBrowser,
165173 . contentSearch
166174 ]
167175 }
168176
169177 func toolbarDefaultItemIdentifiers( _ toolbar: NSToolbar ) -> [ NSToolbarItem . Identifier ] {
170- return [ . historyNavigation, . flexibleSpace, . contentSearch]
178+ return [ . historyNavigation, . flexibleSpace, . openInBrowser , . contentSearch]
171179 }
172180
173181 func toolbar( _ toolbar: NSToolbar , itemForItemIdentifier itemIdentifier: NSToolbarItem . Identifier , willBeInsertedIntoToolbar flag: Bool ) -> NSToolbarItem ? {
@@ -178,22 +186,31 @@ extension DocumentationWindowController: NSToolbarDelegate {
178186 backItem. toolTip = backItem. label
179187 backItem. isBordered = true
180188 backItem. image = NSImage ( systemSymbolName: " chevron.backward " ,
181- accessibilityDescription: NSLocalizedString ( " Navigate back " , comment: " Navigate back " ) )
189+ accessibilityDescription: NSLocalizedString ( " Navigate back " , comment: " " ) )
182190 backItem. autovalidates = true
183191
184192 let forwardItem = NSToolbarItem ( itemIdentifier: . navigateForward)
185193 forwardItem. label = NSLocalizedString ( " Forward " , comment: " Navigate forward " )
186194 forwardItem. toolTip = forwardItem. label
187195 forwardItem. isBordered = true
188196 forwardItem. image = NSImage ( systemSymbolName: " chevron.forward " ,
189- accessibilityDescription: NSLocalizedString ( " Navigate forward " , comment: " Navigate forward " ) )
197+ accessibilityDescription: NSLocalizedString ( " Navigate forward " , comment: " " ) )
190198 forwardItem. autovalidates = true
191199
192200 let item = NSToolbarItemGroup ( itemIdentifier: itemIdentifier)
193201 item. label = NSLocalizedString ( " Back / Forward " , comment: " History navigation " )
194202 item. isNavigational = true
195203 item. subitems = [ backItem, forwardItem]
196204 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
197214 case . contentSearch:
198215 let item = NSSearchToolbarItem ( itemIdentifier: itemIdentifier)
199216 item. searchField. recentsAutosaveName = NSSearchField . RecentsAutosaveName ( " content-search-term " )
@@ -222,6 +239,9 @@ extension DocumentationWindowController: NSToolbarDelegate {
222239 break
223240 }
224241 }
242+ case . openInBrowser:
243+ item. target = self
244+ item. action = #selector( openDocumentationInBrowser)
225245 case . contentSearch:
226246 let searchItem = item as! NSSearchToolbarItem
227247 searchItem. searchField. delegate = documentationViewController
@@ -245,6 +265,9 @@ extension DocumentationWindowController: NSToolbarDelegate {
245265 subitem. target = nil
246266 subitem. action = nil
247267 }
268+ case . openInBrowser:
269+ item. target = nil
270+ item. action = nil
248271 case . contentSearch:
249272 contentSearchField = nil
250273
0 commit comments