fix: properly pass checkbox id to markdown renderer
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
39ccdd7a51
commit
8c866401b0
|
@ -222,7 +222,7 @@ export default defineComponent({
|
||||||
return checkboxes[n]
|
return checkboxes[n]
|
||||||
},
|
},
|
||||||
renderPreview() {
|
renderPreview() {
|
||||||
setupMarkdownRenderer()
|
setupMarkdownRenderer(this.checkboxId)
|
||||||
|
|
||||||
this.preview = DOMPurify.sanitize(marked(this.text), {ADD_ATTR: ['target']})
|
this.preview = DOMPurify.sanitize(marked(this.text), {ADD_ATTR: ['target']})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {marked} from 'marked'
|
import {marked} from 'marked'
|
||||||
import hljs from 'highlight.js/lib/common'
|
import hljs from 'highlight.js/lib/common'
|
||||||
|
|
||||||
export function setupMarkdownRenderer() {
|
export function setupMarkdownRenderer(checkboxId: string) {
|
||||||
const renderer = new marked.Renderer()
|
const renderer = new marked.Renderer()
|
||||||
const linkRenderer = renderer.link
|
const linkRenderer = renderer.link
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export function setupMarkdownRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkboxNum++
|
checkboxNum++
|
||||||
return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${this.checkboxId}"/>`
|
return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${checkboxId}"/>`
|
||||||
},
|
},
|
||||||
link: (href, title, text) => {
|
link: (href, title, text) => {
|
||||||
const isLocal = href.startsWith(`${location.protocol}//${location.hostname}`)
|
const isLocal = href.startsWith(`${location.protocol}//${location.hostname}`)
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {useStore} from '@/store'
|
||||||
import {setupMarkdownRenderer} from '@/helpers/markdownRenderer'
|
import {setupMarkdownRenderer} from '@/helpers/markdownRenderer'
|
||||||
import {marked} from 'marked'
|
import {marked} from 'marked'
|
||||||
import DOMPurify from 'dompurify'
|
import DOMPurify from 'dompurify'
|
||||||
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
listId: {
|
listId: {
|
||||||
|
@ -37,7 +38,7 @@ const htmlDescription = computed(() => {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
setupMarkdownRenderer()
|
setupMarkdownRenderer(createRandomID())
|
||||||
return DOMPurify.sanitize(marked(description), {ADD_ATTR: ['target']})
|
return DOMPurify.sanitize(marked(description), {ADD_ATTR: ['target']})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
Reference in New Issue