fix: md-* content

This commit is contained in:
hypercross 2026-02-26 09:47:21 +08:00
parent 76049f4ce9
commit a250762ebe
4 changed files with 16 additions and 1 deletions

View File

@ -40,7 +40,7 @@ export const Article: Component<ArticleProps> = (props) => {
}); });
return ( return (
<article ref={articleRef} class="prose prose-lg" data-src={props.src}> <article ref={articleRef} class="prose" data-src={props.src}>
<Show when={loading()}> <Show when={loading()}>
<div class="text-gray-500">...</div> <div class="text-gray-500">...</div>
</Show> </Show>

View File

@ -149,6 +149,11 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
// 从 element 的 textContent 获取骰子公式 // 从 element 的 textContent 获取骰子公式
const formula = element?.textContent?.trim() || ""; const formula = element?.textContent?.trim() || "";
// 隐藏原始文本内容
if (element) {
element.textContent = "";
}
// 使用的 key如果没有提供则使用生成的 ID // 使用的 key如果没有提供则使用生成的 ID
const effectiveKey = () => props.key; const effectiveKey = () => props.key;

View File

@ -13,6 +13,11 @@ customElement("md-link", {}, (props, { element }) => {
// 从 element 的 textContent 获取链接目标 // 从 element 的 textContent 获取链接目标
const rawLinkSrc = element?.textContent?.trim() || ""; const rawLinkSrc = element?.textContent?.trim() || "";
// 隐藏原始文本内容
if (element) {
element.textContent = "";
}
// 从父节点 article 的 data-src 获取当前 markdown 文件完整路径 // 从父节点 article 的 data-src 获取当前 markdown 文件完整路径
const articleEl = element?.closest('article[data-src]'); const articleEl = element?.closest('article[data-src]');
const articlePath = articleEl?.getAttribute('data-src') || ''; const articlePath = articleEl?.getAttribute('data-src') || '';

View File

@ -19,6 +19,11 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
// 从 element 的 textContent 获取 CSV 路径 // 从 element 的 textContent 获取 CSV 路径
const src = element?.textContent?.trim() || ''; const src = element?.textContent?.trim() || '';
// 隐藏原始文本内容
if (element) {
element.textContent = '';
}
// 从父节点 article 的 data-src 获取当前 markdown 文件完整路径 // 从父节点 article 的 data-src 获取当前 markdown 文件完整路径
const articleEl = element?.closest('article[data-src]'); const articleEl = element?.closest('article[data-src]');
const articlePath = articleEl?.getAttribute('data-src') || ''; const articlePath = articleEl?.getAttribute('data-src') || '';