3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 22:55:44 +01:00

Keep the generated documents' cards free of a link mark

This commit is contained in:
2026-11-04 20:17:40 +01:00
committed by Lillem4n
parent a27a4453c2
commit 977729621c
2 changed files with 5 additions and 6 deletions
+4 -1
View File
@@ -123,8 +123,11 @@ const autolinkTextNode = fc
.record({ href: fc.tuple(fc.constantFrom('ab:', 'http://'), textOf(0)).map(([scheme, rest]) => `${scheme}${rest}`), marks })
.map(({ href, marks: held }): AdfNode => ({ marks: [...held.filter((outer) => outer.type !== 'link'), { attrs: { href }, type: 'link' }], text: href, type: 'text' }))
// Atlassian's schema gives a card no link mark, which every writer refuses.
const cardMarks = marks.map((held) => held.filter(({ type }) => type !== 'link'))
const inlineArbitraries = Object.entries(inlineNodes).map(([type, model]) =>
occasionallyEmpty(fc.record({ attrs: attributes(model.attributes), marks }).map((held): AdfNode => ({ ...held, type }))),
occasionallyEmpty(fc.record({ attrs: attributes(model.attributes), marks: type === 'inlineCard' ? cardMarks : marks }).map((held): AdfNode => ({ ...held, type }))),
)
function weighted(arbitraries: readonly Arbitrary<AdfNode>[], weight: number): { arbitrary: Arbitrary<AdfNode>; weight: number }[] {