refactor: reuse function 'escapehtml' from utils
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { CodeXml } from 'lucide-vue-next'
|
import { CodeXml } from 'lucide-vue-next'
|
||||||
import { createApp, h } from 'vue'
|
import { createApp, h } from 'vue'
|
||||||
|
import { escapeHTML } from '@/utils'
|
||||||
|
|
||||||
export class Markdown {
|
export class Markdown {
|
||||||
constructor({ data, api, readOnly, config }) {
|
constructor({ data, api, readOnly, config }) {
|
||||||
@@ -301,7 +302,7 @@ export class Markdown {
|
|||||||
_parseInlineMarkdown(text) {
|
_parseInlineMarkdown(text) {
|
||||||
if (!text) return ''
|
if (!text) return ''
|
||||||
|
|
||||||
let html = this._escapeHtml(text)
|
let html = escapeHTML(text)
|
||||||
|
|
||||||
html = html.replace(/`([^`]+)`/g, '<code class="inline-code">$1</code>')
|
html = html.replace(/`([^`]+)`/g, '<code class="inline-code">$1</code>')
|
||||||
|
|
||||||
@@ -316,15 +317,6 @@ export class Markdown {
|
|||||||
return html
|
return html
|
||||||
}
|
}
|
||||||
|
|
||||||
_escapeHtml(text) {
|
|
||||||
return text
|
|
||||||
.replace(/&/g, '&')
|
|
||||||
.replace(/</g, '<')
|
|
||||||
.replace(/>/g, '>')
|
|
||||||
.replace(/"/g, '"')
|
|
||||||
.replace(/'/g, ''')
|
|
||||||
}
|
|
||||||
|
|
||||||
_togglePlaceholder() {
|
_togglePlaceholder() {
|
||||||
const blocks = document.querySelectorAll(
|
const blocks = document.querySelectorAll(
|
||||||
'.cdx-block.ce-paragraph[data-placeholder]'
|
'.cdx-block.ce-paragraph[data-placeholder]'
|
||||||
|
|||||||
Reference in New Issue
Block a user