Add custom quotes
This commit is contained in:
@@ -735,4 +735,10 @@ export const languageEnglish = {
|
|||||||
strictJsonSchema: "Strict Schema",
|
strictJsonSchema: "Strict Schema",
|
||||||
extractJson: "Extract JSON",
|
extractJson: "Extract JSON",
|
||||||
reloadSession: "Newer version of save data is found. reloading the session...",
|
reloadSession: "Newer version of save data is found. reloading the session...",
|
||||||
|
fixMarkdownNewline: "Fix Markdown Newline",
|
||||||
|
customQuotes: "Custom Quotes",
|
||||||
|
leadingSingleQuote: "Leading Single Quote",
|
||||||
|
leadingDoubleQuote: "Leading Double Quote",
|
||||||
|
trailingSingleQuote: "Trailing Single Quote",
|
||||||
|
trailingDoubleQuote: "Trailing Double Quote",
|
||||||
}
|
}
|
||||||
@@ -315,6 +315,24 @@
|
|||||||
<Check bind:check={$DataBase.unformatQuotes} name={language.unformatQuotes}/>
|
<Check bind:check={$DataBase.unformatQuotes} name={language.unformatQuotes}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center mt-2">
|
||||||
|
<Check bind:check={$DataBase.customQuotes} name={language.customQuotes}/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if $DataBase.customQuotes}
|
||||||
|
<span class="text-textcolor mt-4">{language.leadingSingleQuote}</span>
|
||||||
|
<TextInput bind:value={$DataBase.customQuotesData[0]} />
|
||||||
|
|
||||||
|
<span class="text-textcolor mt-4">{language.trailingSingleQuote}</span>
|
||||||
|
<TextInput bind:value={$DataBase.customQuotesData[1]} />
|
||||||
|
|
||||||
|
<span class="text-textcolor mt-4">{language.leadingDoubleQuote}</span>
|
||||||
|
<TextInput bind:value={$DataBase.customQuotesData[2]} />
|
||||||
|
|
||||||
|
<span class="text-textcolor mt-4">{language.trailingDoubleQuote}</span>
|
||||||
|
<TextInput bind:value={$DataBase.customQuotesData[3]} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="flex items-center mt-2">
|
<div class="flex items-center mt-2">
|
||||||
<Check bind:check={$DataBase.betaMobileGUI} name={language.betaMobileGUI}/>
|
<Check bind:check={$DataBase.betaMobileGUI} name={language.betaMobileGUI}/>
|
||||||
<Help key="betaMobileGUI"/>
|
<Help key="betaMobileGUI"/>
|
||||||
|
|||||||
@@ -76,15 +76,20 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
|
|||||||
|
|
||||||
function renderMarkdown(md:markdownit, data:string){
|
function renderMarkdown(md:markdownit, data:string){
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
|
let quotes = ['“', '”', '‘', '’']
|
||||||
|
if(db?.customQuotes){
|
||||||
|
quotes = db.customQuotesData ?? quotes
|
||||||
|
}
|
||||||
|
|
||||||
let text = md.render(data.replace(/“|”/g, '"').replace(/‘|’/g, "'"))
|
let text = md.render(data.replace(/“|”/g, '"').replace(/‘|’/g, "'"))
|
||||||
|
|
||||||
if(db?.unformatQuotes){
|
if(db?.unformatQuotes){
|
||||||
text = text.replace(/\uE9b0/gu, '“').replace(/\uE9b1/gu, '”')
|
text = text.replace(/\uE9b0/gu, quotes[0]).replace(/\uE9b1/gu, quotes[1])
|
||||||
text = text.replace(/\uE9b2/gu, '‘').replace(/\uE9b3/gu, '’')
|
text = text.replace(/\uE9b2/gu, quotes[2]).replace(/\uE9b3/gu, quotes[3])
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
text = text.replace(/\uE9b0/gu, '<mark risu-mark="quote2">“').replace(/\uE9b1/gu, '”</mark>')
|
text = text.replace(/\uE9b0/gu, '<mark risu-mark="quote2">' + quotes[0]).replace(/\uE9b1/gu, quotes[1] + '</mark>')
|
||||||
text = text.replace(/\uE9b2/gu, '<mark risu-mark="quote1">‘').replace(/\uE9b3/gu, '’</mark>')
|
text = text.replace(/\uE9b2/gu, '<mark risu-mark="quote1">' + quotes[2]).replace(/\uE9b3/gu, quotes[3] + '</mark>')
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|||||||
@@ -440,6 +440,8 @@ export function setDatabase(data:Database){
|
|||||||
messages: 0,
|
messages: 0,
|
||||||
imports: 0
|
imports: 0
|
||||||
}
|
}
|
||||||
|
data.customQuotes ??= false
|
||||||
|
data.customQuotesData ??= ['“','”','‘','’']
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
DataBase.set(data)
|
DataBase.set(data)
|
||||||
}
|
}
|
||||||
@@ -743,6 +745,8 @@ export interface Database{
|
|||||||
messages: number
|
messages: number
|
||||||
imports: number
|
imports: number
|
||||||
}
|
}
|
||||||
|
customQuotes:boolean
|
||||||
|
customQuotesData?:[string, string, string, string]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface customscript{
|
export interface customscript{
|
||||||
|
|||||||
Reference in New Issue
Block a user