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

Answer architecture round 1: 2 🔴, 4 🟡; refuse a link around only nodes that take none, mark the change breaking, file code-text marks

This commit is contained in:
2026-10-14 13:37:50 +02:00
committed by Lillem4n
parent d31efaba16
commit 6842f386ae
12 changed files with 96 additions and 45 deletions
+13 -8
View File
@@ -2,15 +2,15 @@ import type { AttributeVocabulary } from './attribute-vocabulary.ts'
export type InlineNodeModel = {
attributes: AttributeVocabulary
marks: readonly string[]
markTypes: readonly string[]
textAttribute?: string
}
export const inlineNodes: Readonly<Record<string, InlineNodeModel>> = {
date: { attributes: { localId: 'string', timestamp: 'string' }, marks: ['annotation'] },
emoji: { attributes: { id: 'string', localId: 'string', shortName: 'string', text: 'string' }, marks: ['annotation'], textAttribute: 'text' },
hardBreak: { attributes: { localId: 'string', text: 'string' }, marks: [] },
inlineCard: { attributes: { data: 'json', localId: 'string', url: 'string' }, marks: ['annotation'] },
date: { attributes: { localId: 'string', timestamp: 'string' }, markTypes: ['annotation'] },
emoji: { attributes: { id: 'string', localId: 'string', shortName: 'string', text: 'string' }, markTypes: ['annotation'], textAttribute: 'text' },
hardBreak: { attributes: { localId: 'string', text: 'string' }, markTypes: [] },
inlineCard: { attributes: { data: 'json', localId: 'string', url: 'string' }, markTypes: ['annotation'] },
mediaInline: {
attributes: {
alt: 'string',
@@ -23,12 +23,17 @@ export const inlineNodes: Readonly<Record<string, InlineNodeModel>> = {
type: 'string',
width: 'number',
},
marks: ['annotation', 'border', 'dataConsumer', 'link'],
markTypes: ['annotation', 'border', 'dataConsumer', 'link'],
},
mention: { attributes: { accessLevel: 'string', id: 'string', localId: 'string', text: 'string', userType: 'string' }, marks: ['annotation'], textAttribute: 'text' },
status: { attributes: { color: 'string', localId: 'string', style: 'string', text: 'string' }, marks: ['annotation'], textAttribute: 'text' },
mention: { attributes: { accessLevel: 'string', id: 'string', localId: 'string', text: 'string', userType: 'string' }, markTypes: ['annotation'], textAttribute: 'text' },
status: { attributes: { color: 'string', localId: 'string', style: 'string', text: 'string' }, markTypes: ['annotation'], textAttribute: 'text' },
}
export function inlineNodeModel(type: string): InlineNodeModel | undefined {
return Object.hasOwn(inlineNodes, type) ? inlineNodes[type] : undefined
}
// An unknown type is no inline leaf the table holds, so the table withholds nothing from it.
export function takesMark(type: string, markType: string): boolean {
return inlineNodeModel(type)?.markTypes.includes(markType) ?? true
}