chore: fix typo

zio/stable
patak 2023-01-18 08:01:50 +01:00
parent 9c82df0a7a
commit 40c0afb09d
2 changed files with 7 additions and 7 deletions

View File

@ -453,16 +453,16 @@ function transformCollapseMentions() {
return (node: Node, root: Node): Node | Node[] => {
if (processed || node.parent !== root || !node.children)
return node
const metions: (Node | undefined)[] = []
const mentions: (Node | undefined)[] = []
const children = node.children as Node[]
for (const child of children) {
// metion
if (isMention(child)) {
metions.push(child)
mentions.push(child)
}
// spaces in between
else if (child.type === TEXT_NODE && !child.value.trim()) {
metions.push(child)
mentions.push(child)
}
// other content, stop collapsing
else {
@ -470,17 +470,17 @@ function transformCollapseMentions() {
child.value = child.value.trimStart()
// remove <br> after mention
if (child.name === 'br')
metions.push(undefined)
mentions.push(undefined)
break
}
}
processed = true
if (metions.length === 0)
if (mentions.length === 0)
return node
return {
...node,
children: [h('mention-group', null, ...metions.filter(Boolean)), ...children.slice(metions.length)],
children: [h('mention-group', null, ...mentions.filter(Boolean)), ...children.slice(mentions.length)],
}
}
}

View File

@ -84,7 +84,7 @@ describe('content-rich', () => {
expect(formatted).toMatchSnapshot()
})
it('collapse metions', async () => {
it('collapse mentions', async () => {
const { formatted } = await render('<p><span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> content <span class="h-card"><a href="https://m.webtoo.ls/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> <span class="h-card"><a href="https://mastodon.roe.dev/@daniel" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>daniel</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@sxzz" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sxzz</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@patak" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>patak</span></a></span> content</p>', {
collapseMentionLink: true,
})