import { BlockNoteSchema, defaultInlineContentSpecs, defaultBlockSpecs } from "@blocknote/core"; import FileLink from "./file-link"; import InlineImage from "./inline-image"; // 给指定 block spec 追加 propSchema 字段,实现原样保留 const withBasePath = (spec) => ({ ...spec, config: { ...spec.config, propSchema: { ...spec.config.propSchema, basePath: { default: "" }, }, }, }); // schema:官方默认行内内容 + 自定义 fileLink / inlineImage export const schema = BlockNoteSchema.create({ blockSpecs: { ...defaultBlockSpecs, image: withBasePath(defaultBlockSpecs.image), video: withBasePath(defaultBlockSpecs.video), audio: withBasePath(defaultBlockSpecs.audio), file: withBasePath(defaultBlockSpecs.file), }, inlineContentSpecs: { ...defaultInlineContentSpecs, fileLink: FileLink, inlineImage: InlineImage, }, }); export type FileLinkProps = { href: string; basePath: string; fileId: string; fileName: string; };