🗒️slate node
type
status
date
slug
summary
tags
category
icon
password
Blocking
Blocked by
top
URL
Sub-item
Parent item
Text Node
文本节点,例如
{ text: 'hello' } 必须有 text 属性。可以自定义属性,例如加粗的文本可表示为 { text: 'hello', bold: true } ,其他属性可自行扩展。注意,文本节点是底层节点,所以没有子节点,没有
children 属性。Element Node
元素节点,例如
{ type: 'header1', children: [ { text: 'hello' } ] } 必须有两个属性 type 和 children 属性。还可以自定义属性,例如居中对齐可表示为 { type: 'header1', textAlign: 'center', children: [ { text: 'hello' } ] } ,其他属性自行扩展。Inline Element
元素默认是 block 显示,即占满一整行。但有些元素需要变为 inline 显示,如
<img> <a> 等。需要通过slate 插件来修改
isInline 把一个元素改为 inline。Void Element
有些元素需要定义为 void 类型(即没有子节点),例如
<img> <video> 等。需要通过slate 插件来修改
isVoid 把一个元素改为 void 。注意,void 类型虽然在语义上没有子节点,但 slate.js 规定,它必须有一个
children 属性,其中只有一个空字符串。例如图片元素: