Fix issue with highlighting matched string in the buffer selector

broke in f1d74bb14f9ce38cb7627a3a8778f1f4009d0c18
This commit is contained in:
Jonatan Heyman 2025-03-03 16:47:25 +01:00
parent ea16ff0c73
commit 487c274e23

View File

@ -7,6 +7,15 @@
const pathSep = window.heynote.buffer.pathSeparator const pathSep = window.heynote.buffer.pathSeparator
function escapeHTML(str) {
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}
export default { export default {
props: { props: {
headline: String, headline: String,
@ -106,8 +115,8 @@
this.items = Object.entries(this.buffers).map(([path, metadata]) => { this.items = Object.entries(this.buffers).map(([path, metadata]) => {
return { return {
"path": path, "path": path,
"name": metadata?.name || path, "name": escapeHTML(metadata?.name || path),
"folder": path.split(pathSep).slice(0, -1).join(pathSep), "folder": escapeHTML(path.split(pathSep).slice(0, -1).join(pathSep)),
"scratch": path === SCRATCH_FILE_NAME, "scratch": path === SCRATCH_FILE_NAME,
} }
}) })
@ -263,8 +272,8 @@
@click="selectItem(item)" @click="selectItem(item)"
ref="item" ref="item"
> >
<span class="name">{{ item.name }}</span> <span class="name" v-html="item.name" />
<span class="path">{{ item.folder }}</span> <span class="path" v-html="item.folder" />
<span :class="{'action-buttons':true, 'visible':actionButton > 0 && idx === selected}"> <span :class="{'action-buttons':true, 'visible':actionButton > 0 && idx === selected}">
<button <button
v-if="actionButton > 0 && idx === selected" v-if="actionButton > 0 && idx === selected"