mirror of
				https://github.com/open-webui/open-webui
				synced 2025-06-26 18:26:48 +00:00 
			
		
		
		
	enh: always collapse code block
This commit is contained in:
		
							parent
							
								
									dbf051ff4e
								
							
						
					
					
						commit
						7723705707
					
				| @ -27,6 +27,7 @@ | |||||||
| 
 | 
 | ||||||
| 	export let save = false; | 	export let save = false; | ||||||
| 	export let run = true; | 	export let run = true; | ||||||
|  | 	export let collapsed = false; | ||||||
| 
 | 
 | ||||||
| 	export let token; | 	export let token; | ||||||
| 	export let lang = ''; | 	export let lang = ''; | ||||||
| @ -60,7 +61,6 @@ | |||||||
| 	let result = null; | 	let result = null; | ||||||
| 	let files = null; | 	let files = null; | ||||||
| 
 | 
 | ||||||
| 	let collapsed = false; |  | ||||||
| 	let copied = false; | 	let copied = false; | ||||||
| 	let saved = false; | 	let saved = false; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -85,6 +85,7 @@ | |||||||
| 		{#if token.raw.includes('```')} | 		{#if token.raw.includes('```')} | ||||||
| 			<CodeBlock | 			<CodeBlock | ||||||
| 				id={`${id}-${tokenIdx}`} | 				id={`${id}-${tokenIdx}`} | ||||||
|  | 				collapsed={$settings?.collapseCodeBlocks ?? false} | ||||||
| 				{token} | 				{token} | ||||||
| 				lang={token?.lang ?? ''} | 				lang={token?.lang ?? ''} | ||||||
| 				code={token?.text ?? ''} | 				code={token?.text ?? ''} | ||||||
|  | |||||||
| @ -39,6 +39,7 @@ | |||||||
| 	let chatDirection: 'LTR' | 'RTL' = 'LTR'; | 	let chatDirection: 'LTR' | 'RTL' = 'LTR'; | ||||||
| 	let ctrlEnterToSend = false; | 	let ctrlEnterToSend = false; | ||||||
| 
 | 
 | ||||||
|  | 	let collapseCodeBlocks = false; | ||||||
| 	let expandDetails = false; | 	let expandDetails = false; | ||||||
| 
 | 
 | ||||||
| 	let imageCompression = false; | 	let imageCompression = false; | ||||||
| @ -57,11 +58,16 @@ | |||||||
| 
 | 
 | ||||||
| 	let webSearch = null; | 	let webSearch = null; | ||||||
| 
 | 
 | ||||||
| 	const togglExpandDetails = () => { | 	const toggleExpandDetails = () => { | ||||||
| 		expandDetails = !expandDetails; | 		expandDetails = !expandDetails; | ||||||
| 		saveSettings({ expandDetails }); | 		saveSettings({ expandDetails }); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | 	const toggleCollapseCodeBlocks = () => { | ||||||
|  | 		collapseCodeBlocks = !collapseCodeBlocks; | ||||||
|  | 		saveSettings({ collapseCodeBlocks }); | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
| 	const toggleSplitLargeChunks = async () => { | 	const toggleSplitLargeChunks = async () => { | ||||||
| 		splitLargeChunks = !splitLargeChunks; | 		splitLargeChunks = !splitLargeChunks; | ||||||
| 		saveSettings({ splitLargeChunks: splitLargeChunks }); | 		saveSettings({ splitLargeChunks: splitLargeChunks }); | ||||||
| @ -234,6 +240,9 @@ | |||||||
| 		richTextInput = $settings.richTextInput ?? true; | 		richTextInput = $settings.richTextInput ?? true; | ||||||
| 		largeTextAsFile = $settings.largeTextAsFile ?? false; | 		largeTextAsFile = $settings.largeTextAsFile ?? false; | ||||||
| 
 | 
 | ||||||
|  | 		collapseCodeBlocks = $settings.collapseCodeBlocks ?? false; | ||||||
|  | 		expandDetails = $settings.expandDetails ?? false; | ||||||
|  | 
 | ||||||
| 		landingPageMode = $settings.landingPageMode ?? ''; | 		landingPageMode = $settings.landingPageMode ?? ''; | ||||||
| 		chatBubble = $settings.chatBubble ?? true; | 		chatBubble = $settings.chatBubble ?? true; | ||||||
| 		widescreenMode = $settings.widescreenMode ?? false; | 		widescreenMode = $settings.widescreenMode ?? false; | ||||||
| @ -577,6 +586,26 @@ | |||||||
| 				</div> | 				</div> | ||||||
| 			</div> | 			</div> | ||||||
| 
 | 
 | ||||||
|  | 			<div> | ||||||
|  | 				<div class=" py-0.5 flex w-full justify-between"> | ||||||
|  | 					<div class=" self-center text-xs">{$i18n.t('Always Collapse Code Blocks')}</div> | ||||||
|  | 
 | ||||||
|  | 					<button | ||||||
|  | 						class="p-1 px-3 text-xs flex rounded-sm transition" | ||||||
|  | 						on:click={() => { | ||||||
|  | 							toggleCollapseCodeBlocks(); | ||||||
|  | 						}} | ||||||
|  | 						type="button" | ||||||
|  | 					> | ||||||
|  | 						{#if collapseCodeBlocks === true} | ||||||
|  | 							<span class="ml-2 self-center">{$i18n.t('On')}</span> | ||||||
|  | 						{:else} | ||||||
|  | 							<span class="ml-2 self-center">{$i18n.t('Off')}</span> | ||||||
|  | 						{/if} | ||||||
|  | 					</button> | ||||||
|  | 				</div> | ||||||
|  | 			</div> | ||||||
|  | 
 | ||||||
| 			<div> | 			<div> | ||||||
| 				<div class=" py-0.5 flex w-full justify-between"> | 				<div class=" py-0.5 flex w-full justify-between"> | ||||||
| 					<div class=" self-center text-xs">{$i18n.t('Always Expand Details')}</div> | 					<div class=" self-center text-xs">{$i18n.t('Always Expand Details')}</div> | ||||||
| @ -584,7 +613,7 @@ | |||||||
| 					<button | 					<button | ||||||
| 						class="p-1 px-3 text-xs flex rounded-sm transition" | 						class="p-1 px-3 text-xs flex rounded-sm transition" | ||||||
| 						on:click={() => { | 						on:click={() => { | ||||||
| 							togglExpandDetails(); | 							toggleExpandDetails(); | ||||||
| 						}} | 						}} | ||||||
| 						type="button" | 						type="button" | ||||||
| 					> | 					> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user