mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	| @@ -6798,7 +6798,10 @@ function updateMessage(div) { | |||||||
|     text = getRegexedString( |     text = getRegexedString( | ||||||
|         text, |         text, | ||||||
|         regexPlacement, |         regexPlacement, | ||||||
|         { characterOverride: mes.extra?.type === 'narrator' ? undefined : mes.name }, |         { | ||||||
|  |             characterOverride: mes.extra?.type === 'narrator' ? undefined : mes.name, | ||||||
|  |             isEdit: true, | ||||||
|  |         }, | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -117,7 +117,7 @@ | |||||||
|                     <input type="checkbox" name="disabled" /> |                     <input type="checkbox" name="disabled" /> | ||||||
|                     <span data-i18n="Disabled">Disabled</span> |                     <span data-i18n="Disabled">Disabled</span> | ||||||
|                 </label> |                 </label> | ||||||
|                 <label class="checkbox flex-container"> |                 <label class="checkbox flex-container" title="Run the regex script when the message belonging a to specified role(s) is edited."> | ||||||
|                     <input type="checkbox" name="run_on_edit" /> |                     <input type="checkbox" name="run_on_edit" /> | ||||||
|                     <span data-i18n="Run On Edit">Run On Edit</span> |                     <span data-i18n="Run On Edit">Run On Edit</span> | ||||||
|                 </label> |                 </label> | ||||||
|   | |||||||
| @@ -44,9 +44,9 @@ function getScopedRegex() { | |||||||
|  * @param {regex_placement} placement The placement of the string |  * @param {regex_placement} placement The placement of the string | ||||||
|  * @param {RegexParams} params The parameters to use for the regex script |  * @param {RegexParams} params The parameters to use for the regex script | ||||||
|  * @returns {string} The regexed string |  * @returns {string} The regexed string | ||||||
|  * @typedef {{characterOverride?: string, isMarkdown?: boolean, isPrompt?: boolean, depth?: number }} RegexParams The parameters to use for the regex script |  * @typedef {{characterOverride?: string, isMarkdown?: boolean, isPrompt?: boolean, isEdit?: boolean, depth?: number }} RegexParams The parameters to use for the regex script | ||||||
|  */ |  */ | ||||||
| function getRegexedString(rawString, placement, { characterOverride, isMarkdown, isPrompt, depth } = {}) { | function getRegexedString(rawString, placement, { characterOverride, isMarkdown, isPrompt, isEdit, depth } = {}) { | ||||||
|     // WTF have you passed me? |     // WTF have you passed me? | ||||||
|     if (typeof rawString !== 'string') { |     if (typeof rawString !== 'string') { | ||||||
|         console.warn('getRegexedString: rawString is not a string. Returning empty string.'); |         console.warn('getRegexedString: rawString is not a string. Returning empty string.'); | ||||||
| @@ -68,6 +68,11 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown, | |||||||
|             // Script applies to all cases when neither "only"s are true, but there's no need to do it when `isMarkdown`, the as source (chat history) should already be changed beforehand |             // Script applies to all cases when neither "only"s are true, but there's no need to do it when `isMarkdown`, the as source (chat history) should already be changed beforehand | ||||||
|             (!script.markdownOnly && !script.promptOnly && !isMarkdown) |             (!script.markdownOnly && !script.promptOnly && !isMarkdown) | ||||||
|         ) { |         ) { | ||||||
|  |             if (isEdit && !script.runOnEdit) { | ||||||
|  |                 console.debug(`getRegexedString: Skipping script ${script.scriptName} because it does not run on edit`); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             // Check if the depth is within the min/max depth |             // Check if the depth is within the min/max depth | ||||||
|             if (typeof depth === 'number' && depth >= 0) { |             if (typeof depth === 'number' && depth >= 0) { | ||||||
|                 if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= 0 && depth < script.minDepth) { |                 if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= 0 && depth < script.minDepth) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user