Skip to content

feat: 模板设置-标题样式扩展到9级 (#141) - #185

Merged
FB208 merged 1 commit into
FB208:mainfrom
HUAN2022A:feat/issue-141-heading-levels-9
Aug 4, 2026
Merged

feat: 模板设置-标题样式扩展到9级 (#141)#185
FB208 merged 1 commit into
FB208:mainfrom
HUAN2022A:feat/issue-141-heading-levels-9

Conversation

@HUAN2022A

Copy link
Copy Markdown
Contributor

修改内容

解决 #141 :模板设置-标题样式从 6 级扩展到 9 级。

  • 默认配置DEFAULT_EXPORT_FORMAT(前端)与 configStore.cjs(主进程)的 headings 新增 7-9 级默认样式(宋体、小四、{tail} 编号,与原 6 级风格一致);HEADING_LEVEL_LABELS 与章节页框层级色板同步扩展到 9 项
  • Word 导出exportService.cjs):
    • getHeadingStyle / 编号级别 / 章节页框填充色的层级钳制从 6 放宽到 9
    • docx 库内置 HeadingLevel 仅支持 6 级,7-9 级改为注册自定义 Heading7-Heading9 段落样式,并显式写入 outlineLevel(大纲级别),保证 Word 导航窗格和目录能正常识别 7-9 级标题
  • 编号占位符{tailN} 上限从 6 放宽到 9(前端 outlineNumbering.ts 与导出端保持一致)
  • 预设:布局预设仅定义到 6 级,应用时 7-9 级沿用预设最深层级样式;7 个主题预设的 heading_border_cell_colors 补齐到 9 项

向后兼容

  • 已保存的旧模板(6 级)在加载时由 withExportFormatDefaults / normalizeExportFormat 按默认值自动补齐到 9 级,无需数据迁移
  • 1-6 级的导出行为与样式完全不变

测试方式

  • npx tsc --noEmit 通过;npm run build 通过;node --check 校验两个 .cjs 文件通过
  • 使用 docx@9.6.1 冒烟验证:包含自定义 Heading7-9 样式 + outlineLevel 的文档可正常打包生成,Word 打开后导航窗格正确显示 7-9 级层级

- 默认导出格式、配置存储默认值新增 7-9 级标题样式(宋体小四,{tail} 编号)
- HEADING_LEVEL_LABELS 与章节页框层级色板扩展到 9 级
- Word 导出:7-9 级使用自定义 Heading7-9 段落样式并写入大纲级别,
  保证 Word 导航窗格与目录可识别(docx 内置 HeadingLevel 仅支持 6 级)
- 标题编号 {tailN} 占位符范围从 6 级放宽到 9 级(前端与导出端一致)
- 布局预设 7-9 级沿用预设最深层级样式;主题预设层级色板补齐 9 项
- 旧模板配置(6 级)加载时自动按默认值补齐到 9 级,向后兼容

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b96a2922d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

children: [new TableCell({
children: [headingParagraph],
shading: { type: ShadingType.CLEAR, fill: frame.fills[Math.max(0, Math.min(level - 1, 5))] || 'FFFFFF' },
shading: { type: ShadingType.CLEAR, fill: frame.fills[Math.max(0, Math.min(level - 1, 8))] || 'FFFFFF' },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve level 7–9 frame colors during Word export

When a document contains level 7–9 headings with 章节页框 enabled, this lookup always falls back to white even if the user selected a color for those levels. getChapterFrameConfig() still constructs fills by mapping the six-entry DEFAULT_HEADING_BORDER_CELL_COLORS at line 48, so indexes 6–8 do not exist; extend that export-side palette to nine entries so the newly exposed colors reach the generated Word document.

Useful? React with 👍 / 👎.

Comment on lines +445 to +447
'七级标题',
'八级标题',
'九级标题',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preview the newly configurable heading levels

The new level 7–9 configurations cannot be checked in the template preview: buildExportFormatCssVars() still generates variables only for the first six headings, while ExportFormatPage renders preview examples only through h6. Consequently changing the font, size, alignment, spacing, or color on these added heading cards produces no visible preview, despite the page presenting itself as a live template preview; add preview blocks and styling support for levels 7–9.

Useful? React with 👍 / 👎.

@FB208
FB208 merged commit 4ec65b3 into FB208:main Aug 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants