章节与块级元素对照
本頁內容尚未翻譯。
森空岛官方 Wiki JSON 将条目主体拆分为 chapterGroup(目录顺序)、widgetCommonMap(组件定义)和 documentMap(富文本文档池)三张关联表。本页详细对照章节模式、块级元素、表格与对话在 XML 与 JSON 之间的映射关系。
章节组与四种章节模式
每个 <chapters name="..."> 映射为 document.chapterGroup[] 中的一项 { title, widgets };组内每个 <chapter> 在 widgets 中占一项 { id, title, size },并在 widgetCommonMap[id] 中写入组件体:
| 章节模式 | XML 写法 | widgetCommonMap[id].type | 核心数据位置 |
|---|---|---|---|
| 通用章节(无选项卡) | <chapter size="..." name="...">blocks</chapter> | "common" | tabDataMap.default.content → documentMap[docId] |
| 通用章节(多选项卡) | <chapter ...><tab name="..." icon="...">...</tab></chapter> | "common" | tabList[] + tabDataMap[tabId].content + 可选 tabDataMap[tabId].intro |
| 简单表格章节 | <chapter ... table="true"><table><row><cell label="...">...</cell>...</row></table></chapter> | "table" | tableList[](每 2 项组成一行,项为 { label, value }) |
| 音频章节(平铺) | <chapter ... audio="true"><audios><audio ...>...</audio></audios></chapter> | "audio" | tabDataMap.default.audioList[] |
| 音频章节(多选项卡) | <chapter ... audio="true"><tab ...><audios>...</audios></tab></chapter> | "audio" | tabList[] + tabDataMap[tabId].audioList[] |
| 对话章节 | <chapter ... dialog="true">...</chapter> | "dialog" | dialogList[](其中 <text> 通过 documentId 引用 documentMap) |
通用选项卡内的 <imgIntro> 映射为 tabDataMap[tabId].intro,包含 name、type、imgUrl 与指向独立段落文档的 description(同样存于 documentMap)。
正文块级元素对照
在 <description>、通用 <chapter>、<tab>、<quote>、<li>、<td>/<th> 与 <annotation><content> 中,块级元素均进入所在文档的 blockIds 与 blockMap[blockId]:
| XML 元素 | JSON block.kind | 核心属性与字段映射 |
|---|---|---|
| 普通文本行 | "text" | text.kind = "body",align = "left"(默认),inlineElements[] |
<h1> / <h2> / <h3> | "text" | text.kind = "heading1" / "heading2" / "heading3" |
<align value="left|center|right"> | "text" | align 取自 value(作为容器可包裹多行或标题,每行分别设对齐) |
<quote> | "quote" | quote.childIds[] 指向嵌套子块 ID 列表 |
<ul> / <ol> | "list" | list.kind = "unordered" / "ordered",list.itemIds[] 引用 list.itemMap[itemId].childIds[] |
<video kind="..." id="..."/> | "externalVideo" | externalVideo.kind(skland / bilibili)与 externalVideo.videoId |
<line kind="..."/> | "horizontalLine" | horizontalLine.kind(透传字符串,常见 "1"–"5",已观察到,待确认) |
<img> | "image" | image.id、format、width、height、size、url、description |
<table>(复杂表格) | "table" | table.rowIds[]、columnIds[]、columnMap[colId].width、cellMap["rowId_colId"](含 rowSpan、colSpan、childIds、isHeader) |
复杂表格的表头与坐标映射
复杂表格在 JSON 中不使用显式的 header 枚举字段,而是把表头标记分散存储在各个单元格上(或由表头行列位置推导):
- XML 中的
header="none" | "row" | "col" | "both"会被转换为对应行列单元格的头样式标记,并在 XML 解析时校验每个<th>/<td>是否与header模式一致。 widths="w1,w2,..."按列索引写入columnMap[columnIds[i]].width;省略widths时在large(1160)、middle(754.7)、small(349.3)章节中均分计算各列宽度。cellMap的键名格式固定为<rowId>_<columnId>,每个单元格的childIds引用该格内的所有块级元素。
对话章节节点对照
<chapter dialog="true"> 内的子节点按顺序映射为 widgetCommonMap[id].dialogList[] 中的条目:
| XML 元素 | JSON 节点 type | 关键字段映射 |
|---|---|---|
<message side="me" avatar="..." name="..."> | "dialog-me" | options.avatarUrl、options.name、children[](每项为 text 或 img) |
<message side="other" avatar="..." name="..."> | "dialog-other" | options.avatarUrl、options.name、children[] |
<text>...</text> | "text"(位于消息 children) | options.documentId 指向 documentMap 中的无样式左对齐段落文档 |
<image src="..."/> | "img"(位于消息 children) | options.url(对应 XML src) |
<branches> | "branch-group" | children[] 为若干 branch-group-item |
<branch name="..."> | "branch-group-item" | options.title(对应 XML name)、children[] 为消息节点列表 |
<divider kind="...">text</divider> | "dividing-line" | options.kind、options.text |
另见
- 章节与通用选项卡:查阅
<chapters>、<chapter>、<tab>与<imgIntro> <table>复杂表格:查阅表格属性与网格规则- 对话章节:查阅对话元素与分支约束
- 行内元素与颜色映射表:查阅
inlineElements映射细节