2. NoteAtom 的结构说明
NoteAtom 结构
NoteAtom
笔记-原子节点信息
type
string
可选
doc
paragraph
text
highlight
link
bold
quote
note
text
string
可选
通常用在
text
类型的节点中content
array[object (NoteAtom) {5}]
可选
通常用在
block
类型的节点中type
string
可选
doc
paragraph
text
highlight
link
bold
quote
note
text
string
可选
通常用在
text
类型的节点中content
array[object (NoteAtom) {5}]
可选
通常用在
block
类型的节点中marks
array[object (NoteAtom) {5}]
可选
通常用在
inline
类型的节点中,用于描述样式attrs
object
可选
与各种节点配合使用,用于描述属性信息
marks.link
类型的节点note
类型的节点marks
array[object (NoteAtom) {5}]
可选
通常用在
inline
类型的节点中,用于描述样式type
string
可选
doc
paragraph
text
highlight
link
bold
quote
note
text
string
可选
通常用在
text
类型的节点中content
array[object (NoteAtom) {5}]
可选
通常用在
block
类型的节点中marks
array[object (NoteAtom) {5}]
可选
通常用在
inline
类型的节点中,用于描述样式attrs
object
可选
与各种节点配合使用,用于描述属性信息
marks.link
类型的节点note
类型的节点attrs
object
可选
与各种节点配合使用,用于描述属性信息
marks.link
类型的节点note
类型的节点额外字段
string
可选
说明
NoteAtom
是笔记的原子结构。一个 NoteAtom
节点,可以包含其他的NoteAtom
节点,以一个树状的结构来描述一篇笔记。NoteAtom
可以包含如下属性:属性 | 类型 | 说明 |
---|---|---|
type | string | 表示当前 atom 节点的类型,可能包含 doc(一篇笔记) paragraph(笔记中的段落) text(段落中的文本) 等类型。⚠️ 根节点的 type 必须是 doc |
text | string | 节点的文本内容 |
marks | []NoteAtom | 由多个atom 节点组成,通常用来修饰 text 文本的样式,如高亮 加粗 链接 |
attrs | map<string>string | 节点的属性 |
content | []NoteAtom | 当前节点的子节点,由多个atom 节点组成。譬如一个doc 节点包含多个 paragraph 节点, paragraph 又可以包含多个 text 节点 |
举例
{
"body": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "这是一条 API 创建的笔记"
}
]
},
{
"type": "paragraph"
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "第一段,普通文本段落"
}
]
},
{
"type": "paragraph"
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "第二段,富文本段落 "
},
{
"type": "text",
"marks": [
{
"type": "bold"
}
],
"text": "加粗"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"marks": [
{
"type": "highlight"
}
],
"text": "高亮"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"marks": [
{
"type": "link",
"attrs": {
"href": "https://baidu.com"
}
}
],
"text": "链接"
}
]
},
{
"type": "paragraph"
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "第三段,富文本段落 "
},
{
"type": "text",
"marks": [
{
"type": "link",
"attrs": {
"href": "https://bing.com"
}
},
{
"type": "highlight"
},
{
"type": "bold"
}
],
"text": "加粗并高亮的链接"
}
]
},
{
"type": "paragraph"
},
{
"type": "quote",
"content": [
{
"type": "text",
"text": "第四段,引用文本段落"
}
]
},
{
"type": "paragraph"
},
{
"type": "quote",
"content": [
{
"type": "text",
"text": "第五段,引用文本段落也可以有富文本 "
},
{
"type": "text",
"marks": [
{
"type": "link",
"attrs": {
"href": "https://bing.com"
}
},
{
"type": "highlight"
},
{
"type": "bold"
}
],
"text": "加粗并高亮的链接"
}
]
},
{
"type": "paragraph"
},
{
"type": "note",
"attrs": {
"uuid": "VPrWsE_-P0qwrFUOygGs8"
}
}
]
}
}