mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-19 22:39:43 +00:00
Update Confirm component to support allowHtml prompt option
This commit is contained in:
parent
874e9e1856
commit
7c0d9efe91
6 changed files with 28 additions and 6 deletions
|
|
@ -196,6 +196,7 @@ export default {
|
|||
requestBatchQuickEmbed() {
|
||||
const payload = {
|
||||
message: this.$strings.MessageConfirmQuickEmbed,
|
||||
allowHtml: true,
|
||||
callback: (confirmed) => {
|
||||
if (confirmed) {
|
||||
this.$axios
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ export default {
|
|||
quickEmbed() {
|
||||
const payload = {
|
||||
message: this.$strings.MessageConfirmQuickEmbed,
|
||||
allowHtml: true,
|
||||
callback: (confirmed) => {
|
||||
if (confirmed) {
|
||||
this.$axios
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
<div class="absolute top-0 left-0 right-0 w-full h-36 bg-linear-to-t from-transparent via-black-500 to-black-700 opacity-90 pointer-events-none" />
|
||||
<div ref="content" class="relative text-white" :style="{ height: modalHeight, width: modalWidth }" v-click-outside="clickedOutside">
|
||||
<div class="px-4 w-full text-sm py-6 rounded-lg bg-bg shadow-lg border border-black-300">
|
||||
<p id="confirm-prompt-message" class="text-lg mb-6 mt-2 px-1" v-html="message" />
|
||||
<p v-if="allowHtmlMessage" id="confirm-prompt-message" class="text-lg mb-6 mt-2 px-1" v-html="sanitizedMessage" />
|
||||
<p v-else id="confirm-prompt-message" class="text-lg mb-6 mt-2 px-1">{{ message }}</p>
|
||||
|
||||
<ui-checkbox v-if="checkboxLabel" v-model="checkboxValue" checkbox-bg="bg" :label="checkboxLabel" label-class="pl-2 text-base" class="mb-6 px-1" />
|
||||
|
||||
|
|
@ -52,6 +53,17 @@ export default {
|
|||
message() {
|
||||
return this.confirmPromptOptions.message || ''
|
||||
},
|
||||
allowHtmlMessage() {
|
||||
return !!this.confirmPromptOptions.allowHtml
|
||||
},
|
||||
sanitizedMessage() {
|
||||
if (!this.allowHtmlMessage) return this.message
|
||||
|
||||
return this.escapeHtml(this.message)
|
||||
.replace(/<br\s*\/?>/gi, '<br>')
|
||||
.replace(/<code>/gi, '<code>')
|
||||
.replace(/<\/code>/gi, '</code>')
|
||||
},
|
||||
callback() {
|
||||
return this.confirmPromptOptions.callback
|
||||
},
|
||||
|
|
@ -103,6 +115,14 @@ export default {
|
|||
if (this.callback) this.callback(true, this.checkboxValue)
|
||||
this.show = false
|
||||
},
|
||||
escapeHtml(value) {
|
||||
return String(value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
},
|
||||
setShow() {
|
||||
this.checkboxValue = this.checkboxDefaultValue
|
||||
this.$eventBus.$emit('showing-prompt', true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue