Compare commits

..

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

View file

@ -31,18 +31,12 @@
function getLinks(node) { function getLinks(node) {
/** @type {Link[]} */ /** @type {Link[]} */
let links = []; 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) => { node.descendants((node) => {
for (const mark of node.marks) { for (const mark of node.marks) {
const content = node.textContent; const content = node.textContent;
// no repetir marks interrumpidas por otras marks // no repetir marks interrumpidas por otras marks
const lastLink = links[links.length - 1] || null; const lastLink = links[links.length - 1] || null;
if ( if (
lastWasLinkMark &&
lastLink && lastLink &&
("href" in lastLink ("href" in lastLink
? lastLink.href === mark.attrs.href ? lastLink.href === mark.attrs.href
@ -57,19 +51,14 @@
content, content,
href: mark.attrs.href, href: mark.attrs.href,
}); });
lastWasLinkMark = true;
} else if (mark.type === schema.marks.internal_link) { } else if (mark.type === schema.marks.internal_link) {
links.push({ links.push({
type: "internal", type: "internal",
content, content,
id: mark.attrs.id, id: mark.attrs.id,
}); });
lastWasLinkMark = true;
} else {
lastWasLinkMark = false;
} }
} }
if (node.marks.length == 0) lastWasLinkMark = false;
}); });
return links; return links;
} }
@ -78,7 +67,6 @@
</script> </script>
<div class="linking"> <div class="linking">
<div class="links">
{#each links as link} {#each links as link}
<a <a
href={"href" in link ? link.href : link.id} href={"href" in link ? link.href : link.id}
@ -93,18 +81,13 @@
</a> </a>
{/each} {/each}
</div> </div>
</div>
<style> <style>
.linking { .linking {
max-width: 1280px; max-width: 1280px;
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
overflow-x: auto;
}
.links {
display: flex; display: flex;
min-width: min-content;
} }
a { a {
@ -118,7 +101,7 @@
line-height: 1; line-height: 1;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
max-width: 45vw; max-width: 40vw;
white-space: nowrap; white-space: nowrap;
} }
</style> </style>