fix(modal): enhance confirmation text handling

This commit is contained in:
Andras Bacsai
2025-08-19 00:20:53 +02:00
parent 7a6114868d
commit f02c36985f

View File

@@ -42,7 +42,11 @@
deleteText: '', deleteText: '',
password: '', password: '',
actions: @js($actions), actions: @js($actions),
confirmationText: @js(html_entity_decode($confirmationText, ENT_QUOTES, 'UTF-8')), confirmationText: (() => {
const textarea = document.createElement('textarea');
textarea.innerHTML = @js($confirmationText);
return textarea.value;
})(),
userConfirmationText: '', userConfirmationText: '',
confirmWithText: @js($confirmWithText && !$disableTwoStepConfirmation), confirmWithText: @js($confirmWithText && !$disableTwoStepConfirmation),
confirmWithPassword: @js($confirmWithPassword && !$disableTwoStepConfirmation), confirmWithPassword: @js($confirmWithPassword && !$disableTwoStepConfirmation),
@@ -257,8 +261,21 @@
<div class="mb-4"> <div class="mb-4">
<h4 class="mb-2 text-lg font-semibold">Confirm Actions</h4> <h4 class="mb-2 text-lg font-semibold">Confirm Actions</h4>
<p class="mb-2 text-sm">{{ $confirmationLabel }}</p> <p class="mb-2 text-sm">{{ $confirmationLabel }}</p>
<div class="relative mb-2"> <div class="relative mb-2" x-data="{ decodedText: confirmationText }">
<x-forms.copy-button :text="html_entity_decode($confirmationText, ENT_QUOTES, 'UTF-8')" /> <div class="relative">
<input type="text" x-model="decodedText" readonly class="input">
<button x-show="window.isSecureContext"
@click.prevent="navigator.clipboard.writeText(decodedText); $el.innerHTML = '<svg class=\'w-5 h-5 text-green-500\' fill=\'none\' stroke=\'currentColor\' viewBox=\'0 0 24 24\'><path stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M5 13l4 4L19 7\' /></svg>'; setTimeout(() => $el.innerHTML = '<svg class=\'w-5 h-5\' fill=\'none\' stroke=\'currentColor\' viewBox=\'0 0 24 24\'><path stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\' /></svg>', 1000)"
class="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-gray-400 hover:text-gray-300 transition-colors"
title="Copy to clipboard">
<svg class="w-5 h-5" fill="none" stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2"
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
</svg>
</button>
</div>
</div> </div>
<label for="userConfirmationText" <label for="userConfirmationText"