Compare commits

..

No commits in common. "c98a5c83191fff13fc981fa1a75d215e1b1b3887" and "a26ecf3099dee000c5339fc993d6dec86575f190" have entirely different histories.

View file

@ -31,18 +31,12 @@
function getLinks(node) {
/** @type {Link[]} */
let links = [];
// a veces selecciona el documento entero y no queremos mostrar todos los enlaces
if (node.type.spec.group !== "block") return [];
let lastWasLinkMark = false;
node.descendants((node) => {
for (const mark of node.marks) {
const content = node.textContent;
// no repetir marks interrumpidas por otras marks
const lastLink = links[links.length - 1] || null;
if (
lastWasLinkMark &&
lastLink &&
("href" in lastLink
? lastLink.href === mark.attrs.href
@ -57,19 +51,14 @@
content,
href: mark.attrs.href,
});
lastWasLinkMark = true;
} else if (mark.type === schema.marks.internal_link) {
links.push({
type: "internal",
content,
id: mark.attrs.id,
});
lastWasLinkMark = true;
} else {
lastWasLinkMark = false;
}
}
if (node.marks.length == 0) lastWasLinkMark = false;
});
return links;
}
@ -78,21 +67,19 @@
</script>
<div class="linking">
<div class="links">
{#each links as link}
<a
href={"href" in link ? link.href : link.id}
target={link.type === "external" ? "_blank" : null}
>
{#if link.type === "internal"}
<InternalLinkIcon style={svgStyle} />
{:else}
<LinkIcon style={svgStyle} />
{/if}
{link.content}
</a>
{/each}
</div>
{#each links as link}
<a
href={"href" in link ? link.href : link.id}
target={link.type === "external" ? "_blank" : null}
>
{#if link.type === "internal"}
<InternalLinkIcon style={svgStyle} />
{:else}
<LinkIcon style={svgStyle} />
{/if}
{link.content}
</a>
{/each}
</div>
<style>
@ -100,11 +87,7 @@
max-width: 1280px;
width: 100%;
margin: 0 auto;
overflow-x: auto;
}
.links {
display: flex;
min-width: min-content;
}
a {
@ -118,7 +101,7 @@
line-height: 1;
text-overflow: ellipsis;
overflow: hidden;
max-width: 45vw;
max-width: 40vw;
white-space: nowrap;
}
</style>