import { nodeFactoryFactory } from "../composing"; import { schema } from "../schema"; import { AttachmentAttrs } from "./schema"; export function compose(attrs: { id: string; name?: string; hidePreview?: boolean; naturalSize?: { width: number; height: number }; type?: string; }) { const { id, name, hidePreview, naturalSize, type } = attrs; const factory = nodeFactoryFactory(schema.nodes.at, { id: id, fn: name, hp: hidePreview, ...(naturalSize !== undefined ? { nw: naturalSize.width, nh: naturalSize.height } : null), ...(type !== undefined ? { t: type } : null) } as AttachmentAttrs); return factory(); }