3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 15:42:58 +01:00

Answer architecture round 1: the portable writer builds the linked image through externalMedia, the properties generate the image shapes, linkDefinition sits beside linkMark, the changelog drops a refusal no release met, and items 99 and 100 file the inline linked image and the caption reading

This commit is contained in:
2026-10-11 12:27:55 +02:00
committed by Lillem4n
parent aa73e7d673
commit 5f2c5083e9
9 changed files with 46 additions and 19 deletions
@@ -8,6 +8,7 @@ import { flavourClaims, taskMarker } from './conventions.ts'
import { inlineLeaves, isBlockNodeType, oneLine, portableLink, reduceInline, writableHref } from './inline-reduction.ts'
import { inlineNodeModel } from '../../adf/inline-nodes.ts'
import { languageSlot } from '../code-language.ts'
import { linkDefinition } from '../mark-spellings.ts'
import { largestNesting } from '../../nesting.ts'
import { splitTaskList } from './task-list.ts'
import { toEditorNormal } from './editor-normal.ts'
@@ -350,8 +351,7 @@ function reduceMedia(media: AdfNode, reduction: Reduction): Result<AdfNode[]> {
if (attrs['type'] !== 'external' || typeof url !== 'string') return paragraphOfNode(media, reduction)
const held = attrs['alt']
const alt = typeof held === 'string' ? oneLine(held).trim() : ''
const image = externalMedia(alt, writableHref(url))
const mark = nodeMarks(media).find((held) => held.type === 'link')
const link = mark === undefined ? undefined : portableLink(mark, 'paragraph')
return success([centeredImage([link === undefined ? image : { ...image, marks: [link] }])])
return success([centeredImage([externalMedia(alt, writableHref(url), link === undefined ? undefined : linkDefinition(nodeAttrs(link)))])])
}