Ye
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 54s

This commit is contained in:
2026-10-12 01:05:46 +02:00
parent f3bf48ae54
commit 50828af674
7 changed files with 103 additions and 20 deletions

View File

@@ -13,16 +13,30 @@ const componentCache = {
display: {}
}
// Retorna null si el widget no està registrat (evita cridar
// defineAsyncComponent(undefined), que llençaria un TypeError i rebentaria
// tot el muntatge de notes).
const GetWidget = (type, name) => {
const loader = widget_map[type] && widget_map[type][name];
if (!loader) {
console.warn(`[Marker] Unknown widget "${name}" of type "${type}"; skipping.`);
return null;
}
if (!componentCache[type][name]) {
componentCache[type][name] = defineAsyncComponent(
widget_map[type][name]
)
componentCache[type][name] = defineAsyncComponent(loader)
}
return componentCache[type][name]
}
// Escapa valors per inserir-los de forma segura dins d'un atribut HTML.
const escapeAttr = (value) => String(value ?? "")
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
const marker = new Marked();
@@ -45,7 +59,7 @@ const extension = {
},
renderer(token) {
return `<div class="vue-component-display" data-component="${token.name}" data-content="${token.text}"></div>`;
return `<div class="vue-component-display" data-component="${escapeAttr(token.name)}" data-content="${escapeAttr(token.text)}"></div>`;
},
};
@@ -70,7 +84,7 @@ const inlineExtension = {
},
renderer(token) {
return `<span class="vue-component-inline" data-component="${token.name}" data-content="${token.text}"></span>`;
return `<span class="vue-component-inline" data-component="${escapeAttr(token.name)}" data-content="${escapeAttr(token.text)}"></span>`;
},
};
@@ -94,7 +108,7 @@ const linkExtension = {
},
renderer(token) {
return `<span class="vue-link" data-href="${token.link}">Link</span>`;
return `<span class="vue-link" data-href="${escapeAttr(token.link)}">Link</span>`;
},
};