BlockNote
约 1 分钟阅读
- TypeCellOS/BlockNoteGitHubTypeCellOS/BlockNoteTypeCellOS/BlockNote · MPLv2, TS, React · 基于 tiptap,prosemirror · UI mantine, shadcn · 原生 React - 非常好定制化和扩展 · 不支持粘贴图片 · https://github.com/TypeCellOS/BlockNote/issues/693笔记:BlockNote
- MPLv2, TS, React
- 基于 tiptap,prosemirror
- UI mantine, shadcn
- 原生 React - 非常好定制化和扩展
- 不支持粘贴图片
- TypeCellOS/BlockNote#693GitHub IssueTypeCellOS/BlockNote#693
npm add @blocknote/{core,react,shadcn}Cutome
- 媒体和图片统一作为 File 处理
- 选择文件的组件为 FilePanel
- 所有的组件可替换
Model
type Block = {
id: string;
type: string;
props: Record<string, boolean | number | string>;
content: InlineContent[] | TableContent | undefined;
children: Block[];
};
type InlineContent = Link | StyledText;
type Link = {
type: 'link';
content: StyledText[];
href: string;
};
type StyledText = {
type: 'text';
text: string;
styles: Styles;
};
type TableContent = {
type: 'tableContent';
rows: {
cells: InlineContent[][];
}[];
};
// 默认 Schema
type ParagraphBlock = {
id: string;
type: "paragraph";
props: DefaultProps;
content: InlineContent[];
children: Block[];
};
type HeadingBlock = {
id: string;
type: "heading";
props: {
level: 1 | 2 | 3 = 1;
} & DefaultProps;
content: InlineContent[];
children: Block[];
};
type BulletListItemBlock = {
id: string;
type: "bulletListItem";
props: DefaultProps;
content: InlineContent[];
children: Block[];
};
type NumberedListItemBlock = {
id: string;
type: "numberedListItem";
props: DefaultProps;
content: InlineContent[];
children: Block[];
};
type ImageBlock = {
id: string;
type: "image";
props: {
url: string = "";
caption: string = "";
width: number = 512;
} & DefaultProps;
content: undefined;
children: Block[];
};
type TableBlock = {
id: string;
type: "table";
props: DefaultProps;
content: TableContent[];
children: Block[];
};
type DefaultProps = {
backgroundColor: string = "default";
textColor: string = "default";
textAlignment: "left" | "center" | "right" | "justify" = "left";
};
type Styles = {
bold: boolean;
italic: boolean;
underline: boolean;
strikethrough: boolean;
textColor: string;
backgroundColor: string;
};关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
GitHub3 条
- TypeCellOS/BlockNotegithub.com/TypeCellOS/BlockNote
- TypeCellOS/BlockNote/packages/react/src/editor/ComponentsContext.tsxgithub.com/TypeCellOS/BlockNote/blob/main/packages/react/src/editor/ComponentsContext.tsx
- TypeCellOS/BlockNote#693github.com/TypeCellOS/BlockNote/issues/693
其他外链1 条
- www.blocknotejs.org/docs/editor-basics/document-structurewww.blocknotejs.org/docs/editor-basics/document-structure