forked from open-webui/open-webui
		
	fix: safari copy share link issue
This commit is contained in:
		
							parent
							
								
									424141d1da
								
							
						
					
					
						commit
						e6fad5ccb0
					
				
					 1 changed files with 30 additions and 5 deletions
				
			
		|  | @ -134,11 +134,36 @@ | ||||||
| 							<button | 							<button | ||||||
| 								class=" self-center flex items-center gap-1 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white" | 								class=" self-center flex items-center gap-1 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white" | ||||||
| 								type="button" | 								type="button" | ||||||
| 								on:pointerdown={() => { | 								on:click={async () => { | ||||||
| 									shareLocalChat(); | 									const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); | ||||||
| 								}} | 
 | ||||||
| 								on:pointerup={async () => { | 									if (isSafari) { | ||||||
| 									copyToClipboard(shareUrl); | 										// Oh, Safari, you're so special, let's give you some extra love and attention | ||||||
|  | 										console.log('isSafari'); | ||||||
|  | 
 | ||||||
|  | 										const getUrlPromise = async () => { | ||||||
|  | 											const url = await shareLocalChat(); | ||||||
|  | 											return new Blob([url], { type: 'text/plain' }); | ||||||
|  | 										}; | ||||||
|  | 
 | ||||||
|  | 										navigator.clipboard | ||||||
|  | 											.write([ | ||||||
|  | 												new ClipboardItem({ | ||||||
|  | 													'text/plain': getUrlPromise() | ||||||
|  | 												}) | ||||||
|  | 											]) | ||||||
|  | 											.then(() => { | ||||||
|  | 												console.log('Async: Copying to clipboard was successful!'); | ||||||
|  | 												return true; | ||||||
|  | 											}) | ||||||
|  | 											.catch((error) => { | ||||||
|  | 												console.error('Async: Could not copy text: ', error); | ||||||
|  | 												return false; | ||||||
|  | 											}); | ||||||
|  | 									} else { | ||||||
|  | 										copyToClipboard(await shareLocalChat()); | ||||||
|  | 									} | ||||||
|  | 
 | ||||||
| 									toast.success($i18n.t('Copied shared chat URL to clipboard!')); | 									toast.success($i18n.t('Copied shared chat URL to clipboard!')); | ||||||
| 									show = false; | 									show = false; | ||||||
| 								}} | 								}} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek