File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,31 @@ struct UniversalDropHandler {
175175 }
176176 }
177177 handled = true
178+ } else if provider. hasItemConformingToTypeIdentifier ( UTType . url. identifier) || provider. hasItemConformingToTypeIdentifier ( " public.url " ) {
179+ let typeIdentifier = provider. hasItemConformingToTypeIdentifier ( UTType . url. identifier) ? UTType . url. identifier : " public.url "
180+ provider. loadItem ( forTypeIdentifier: typeIdentifier, options: nil ) { item, error in
181+ if let error = error {
182+ print ( " Error loading URL: \( error) " )
183+ return
184+ }
185+ var url : URL ?
186+ if let urlObject = item as? URL {
187+ url = urlObject
188+ } else if let data = item as? Data {
189+ url = URL ( dataRepresentation: data, relativeTo: nil )
190+ print ( " Converted data to URL: \( String ( describing: url) ) " )
191+ } else if let str = item as? String , let urlFromString = URL ( string: str) {
192+ url = urlFromString
193+ }
194+ if let url = url {
195+ let browserTab = BrowserTab ( title: url. absoluteString, url: url. absoluteString, browser: " default " )
196+ DispatchQueue . main. async {
197+ contextManager. addItem ( . browserTab( browserTab) , to: contextManager. contexts [ contextIndex] . id)
198+ print ( " Added browser tab: \( browserTab. title) " )
199+ }
200+ }
201+ }
202+ handled = true
178203 }
179204 }
180205 print ( " Drop handling complete. Handled: \( handled) " )
You can’t perform that action at this time.
0 commit comments