diff --git a/src/lib/SideBars/RegexData.svelte b/src/lib/SideBars/RegexData.svelte index 4bdc4392..4271a96b 100644 --- a/src/lib/SideBars/RegexData.svelte +++ b/src/lib/SideBars/RegexData.svelte @@ -3,6 +3,7 @@ import { language } from "src/lang"; import { alertConfirm } from "src/ts/alert"; import type { customscript } from "src/ts/storage/database"; + import Check from "../Others/Check.svelte"; export let value:customscript export let onRemove: () => void = () => {} @@ -26,10 +27,10 @@ {#if open} -
+
{language.name} - Type + Modification Type OUT: + {#if value.ableFlag} + FLAG: + + {/if} +
+ { + if(!value.flag){ + value.flag = 'g' + } + }}/> + Custom Flag +
{/if}
diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 00f8a971..6c114eb4 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -35,9 +35,6 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => { export async function ParseMarkdown(data:string, char:(character | groupChat) = null, mode:'normal'|'back' = 'normal') { if(char && char.type !== 'group'){ - if(char.customscript){ - data = processScript(char, data, 'editdisplay') - } if(char.additionalAssets){ for(const asset of char.additionalAssets){ const assetPath = await getFileSrc(asset[1]) @@ -51,6 +48,9 @@ export async function ParseMarkdown(data:string, char:(character | groupChat) = } } } + if(char){ + data = processScript(char, data, 'editdisplay') + } return DOMPurify.sanitize(convertor.makeHtml(data), { ADD_TAGS: ["iframe"], ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling"], diff --git a/src/ts/process/group.ts b/src/ts/process/group.ts index 5af16c31..00706f45 100644 --- a/src/ts/process/group.ts +++ b/src/ts/process/group.ts @@ -63,7 +63,6 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] { for (const word of words) { for (let char of chars) { const charNameChunks = getWords(findCharacterbyId(char.id).name) - console.log(charNameChunks) if (charNameChunks.includes(word)) { order.push(char); @@ -96,8 +95,11 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] { } function getWords(data:string){ - const matches = data.match(/\b\w+\b/gmi) + const matches = data.split(/\n| /g) let words:string[] = [] + if(!matches){ + return [data] + } for(const match of matches){ words.push(match.toLocaleLowerCase()) } diff --git a/src/ts/process/scripts.ts b/src/ts/process/scripts.ts index aa8084d7..827e6af6 100644 --- a/src/ts/process/scripts.ts +++ b/src/ts/process/scripts.ts @@ -58,7 +58,7 @@ export function processScriptFull(char:character|groupChat, data:string, mode:Sc const scripts = (db.globalscript ?? []).concat(char.customscript) for (const script of scripts){ if(script.type === mode){ - const reg = new RegExp(script.in,'g') + const reg = new RegExp(script.in, script.ableFlag ? script.flag : 'g') const outScript = script.out if(outScript.startsWith('@@') && reg.test(data)){ if(outScript.startsWith('@@emo ')){ diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts index 775f3baa..ac20313a 100644 --- a/src/ts/storage/database.ts +++ b/src/ts/storage/database.ts @@ -267,10 +267,12 @@ export function setDatabase(data:Database){ export interface customscript{ - comment: string; - in:string - out:string - type:string + comment: string; + in:string + out:string + type:string + flag?:string + ableFlag?:boolean }