Add disable quote formating option

This commit is contained in:
kwaroran
2024-08-24 15:57:57 +09:00
parent 628b17510d
commit d38a9f3d85
6 changed files with 26 additions and 9 deletions

View File

@@ -685,4 +685,5 @@ export const languageEnglish = {
claudeCachingExperimental: "Claude Caching", claudeCachingExperimental: "Claude Caching",
openClose: "Open/Close", openClose: "Open/Close",
hideApiKeys: "Hide API Keys", hideApiKeys: "Hide API Keys",
unformatQuotes: "Disable Quote Formatting",
} }

View File

@@ -152,11 +152,11 @@
<span class="ml-2">Italic Bold Text</span> <span class="ml-2">Italic Bold Text</span>
</div> </div>
<div class="flex items-center mt-2"> <div class="flex items-center mt-2">
<ColorInput bind:value={$DataBase.customTextTheme.FontColorQuote1} on:input={updateTextTheme} /> <ColorInput nullable bind:value={$DataBase.customTextTheme.FontColorQuote1} on:input={updateTextTheme} />
<span class="ml-2">Single Quote Text</span> <span class="ml-2">Single Quote Text</span>
</div> </div>
<div class="flex items-center mt-2"> <div class="flex items-center mt-2">
<ColorInput bind:value={$DataBase.customTextTheme.FontColorQuote2} on:input={updateTextTheme} /> <ColorInput nullable bind:value={$DataBase.customTextTheme.FontColorQuote2} on:input={updateTextTheme} />
<span class="ml-2">Double Quote Text</span> <span class="ml-2">Double Quote Text</span>
</div> </div>
{/if} {/if}
@@ -314,6 +314,10 @@
<Check bind:check={$DataBase.hideApiKey} name={language.hideApiKeys}/> <Check bind:check={$DataBase.hideApiKey} name={language.hideApiKeys}/>
</div> </div>
<div class="flex items-center mt-2">
<Check bind:check={$DataBase.unformatQuotes} name={language.unformatQuotes}/>
</div>
{#if $DataBase.useExperimental} {#if $DataBase.useExperimental}
<div class="flex items-center mt-2"> <div class="flex items-center mt-2">
<Check bind:check={$DataBase.useChatSticker} name={language.useChatSticker}/> <Check bind:check={$DataBase.useChatSticker} name={language.useChatSticker}/>

View File

@@ -1,11 +1,13 @@
<script lang="ts"> <script lang="ts">
import ColorPicker from 'svelte-awesome-color-picker'; import ColorPicker from 'svelte-awesome-color-picker';
export let value = '#000000'; export let value = '#000000';
export let nullable = false;
</script> </script>
<div class="cl rounded-full bg-white"> <div class="cl rounded-full bg-white">
<ColorPicker <ColorPicker
label="" bind:hex={value} on:input label="" bind:hex={value} on:input
nullable={nullable}
/> />
</div> </div>

View File

@@ -230,8 +230,8 @@ export function updateTextTheme(){
root.style.setProperty('--FontColorItalic', db.customTextTheme.FontColorItalic); root.style.setProperty('--FontColorItalic', db.customTextTheme.FontColorItalic);
root.style.setProperty('--FontColorBold', db.customTextTheme.FontColorBold); root.style.setProperty('--FontColorBold', db.customTextTheme.FontColorBold);
root.style.setProperty('--FontColorItalicBold', db.customTextTheme.FontColorItalicBold); root.style.setProperty('--FontColorItalicBold', db.customTextTheme.FontColorItalicBold);
root.style.setProperty('--FontColorQuote1', db.customTextTheme.FontColorQuote1); root.style.setProperty('--FontColorQuote1', db.customTextTheme.FontColorQuote1 ?? '#8BE9FD');
root.style.setProperty('--FontColorQuote2', db.customTextTheme.FontColorQuote2); root.style.setProperty('--FontColorQuote2', db.customTextTheme.FontColorQuote2 ?? '#FFB86C');
break break
} }
} }

View File

@@ -79,11 +79,19 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
function renderMarkdown(md:markdownit, data:string){ function renderMarkdown(md:markdownit, data:string){
return md.render(data.replace(/“|”/g, '"').replace(/|/g, "'")) const db = get(DataBase)
.replace(/\uE9b0/gu, '<mark risu-mark="quote2">') let text = md.render(data.replace(/“|”/g, '"').replace(/|/g, "'"))
.replace(/\uE9b1/gu, '</mark>')
.replace(/\uE9b2/gu, '<mark risu-mark="quote1">') if(db?.unformatQuotes){
.replace(/\uE9b3/gu, '</mark>') text = text.replace(/\uE9b0/gu, '').replace(/\uE9b1/gu, '')
text = text.replace(/\uE9b2/gu, '').replace(/\uE9b3/gu, '')
}
else{
text = text.replace(/\uE9b0/gu, '<mark risu-mark="quote2">').replace(/\uE9b1/gu, '</mark>')
text = text.replace(/\uE9b2/gu, '<mark risu-mark="quote1">').replace(/\uE9b3/gu, '</mark>')
}
return text
} }
async function renderHighlightableMarkdown(data:string) { async function renderHighlightableMarkdown(data:string) {

View File

@@ -429,6 +429,7 @@ export function setDatabase(data:Database){
timeout: 30 timeout: 30
} }
data.hideApiKey ??= true data.hideApiKey ??= true
data.unformatQuotes ??= false
changeLanguage(data.language) changeLanguage(data.language)
DataBase.set(data) DataBase.set(data)
@@ -712,6 +713,7 @@ export interface Database{
useLegacyGUI: boolean useLegacyGUI: boolean
claudeCachingExperimental: boolean claudeCachingExperimental: boolean
hideApiKey: boolean hideApiKey: boolean
unformatQuotes: boolean
} }
export interface customscript{ export interface customscript{