From a8d329ad7906d3518e0210bafa73dd7c1efa9d20 Mon Sep 17 00:00:00 2001 From: adevopg Date: Thu, 16 Jul 2026 13:00:22 +0000 Subject: [PATCH] =?UTF-8?q?Foro:=20enlaces=20de=20wowhead=20con=20nombre/c?= =?UTF-8?q?alidad/icono=20autom=C3=A1ticos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Al insertar un enlace de wowhead sin texto, ahora sale el NOMBRE real del ítem/ misión/etc., su color por calidad y su icono, obtenidos automáticamente de wowhead —sin escribir nada—. El script global va con renameLinks:false (para no pisar los nombres en español de la tienda), así que se marca cada enlace del foro con data-wh-rename-link="true", que sobrescribe ese ajuste solo para esos enlaces. El botón Wowhead del editor deja el texto opcional: vacío = nombre automático; con texto = se respeta el del usuario. El saneador conserva data-wh-rename-link y data-wh-icon-size. Verificado: un enlace insertado sin texto se guarda con data-wh-rename-link="true" y el href /wotlk/, listo para que tooltips.js le ponga nombre, color e icono. Co-Authored-By: Claude Opus 4.8 (1M context) --- web-next/components/ForumEditor.tsx | 11 ++++++++--- web-next/lib/forum-sanitize.ts | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/web-next/components/ForumEditor.tsx b/web-next/components/ForumEditor.tsx index f96d6ae..7dc86a4 100644 --- a/web-next/components/ForumEditor.tsx +++ b/web-next/components/ForumEditor.tsx @@ -49,7 +49,7 @@ export function ForumEditor({ tooltip: es ? 'Insertar enlace de Wowhead' : 'Insert a Wowhead link', type: es ? 'Tipo' : 'Type', id: 'ID', - text: es ? 'Texto (opcional)' : 'Text (optional)', + text: es ? 'Texto (vacío = nombre automático)' : 'Text (empty = auto name)', insert: es ? 'Insertar' : 'Insert', cancel: es ? 'Cancelar' : 'Cancel', } @@ -107,11 +107,16 @@ export function ForumEditor({ return } const type = (data.wtype || 'item') as WowheadType - const label = data.wtext.trim() || `${type}=${id}` const href = wowheadUrl(type, id, locale) const wh = wowheadData(type, id, locale) + const custom = data.wtext.trim() + // Sin texto: wowhead pone el nombre real (y color+icono) gracias a + // data-wh-rename-link; el `type=id` es solo un marcador hasta que + // corre el script. Con texto: se respeta el que escriba el usuario. + const rename = custom ? '' : ' data-wh-rename-link="true"' + const label = esc(custom || `${type}=${id}`) editor.insertContent( - `${esc(label)} `, + `${label} `, ) api.close() }, diff --git a/web-next/lib/forum-sanitize.ts b/web-next/lib/forum-sanitize.ts index b057ea3..fd48780 100644 --- a/web-next/lib/forum-sanitize.ts +++ b/web-next/lib/forum-sanitize.ts @@ -35,7 +35,10 @@ export function cleanPostHtml(html: string): string { allowedAttributes: { // data-wowhead + class dejan que los enlaces de wowhead muestren tooltip, // color por calidad e icono (los pinta el script global tooltips.js del layout). - a: ['href', 'title', 'target', 'data-wowhead', 'class'], + // data-wh-rename-link deja que wowhead ponga el NOMBRE del ítem/misión/etc. + // automáticamente (sobrescribe el renameLinks:false global, que existe para no + // pisar los nombres en español de la tienda). data-wh-icon-size ajusta el icono. + a: ['href', 'title', 'target', 'data-wowhead', 'data-wh-rename-link', 'data-wh-icon-size', 'class'], img: ['src', 'alt', 'title', 'width', 'height'], span: ['style', 'data-wowhead'], div: ['style'],