Skip to content

fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题 - #5795

Merged
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
olwater:fix-html-layout
Jul 1, 2026
Merged

Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
olwater:fix-html-layout

Conversation

@olwater

@olwater olwater commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

在最近的更新中(如引入 DOMPurify 清理以及修改容器布局),导致管理员在后台配置的自定义富文本 HTML 出现严重显示问题:

  1. 样式丢失:DOMPurify 的默认行为过度清理了自定义 HTML 中的 class、style、id 属性以及 <style> 标签,导致自定义页面的样式完全失效。
  2. 排版受限:在 home、�bout 以及法律文档页面,外层被强加了宽度限制(如 max-w-6xl)和较宽的内边距(如 py-8、py-12)。这导致管理员自己编写的 HTML 页面无法实现全屏布局,且会产生巨大的上下多余空白。

What is changed and how it works?

  1. 放宽 DOMPurify 限制:在 HtmlContent 组件中放开对 class, style, id 等属性以及 style, iframe, �ideo 等常用标签的过滤,恢复管理员正常的自定义样式渲染能力。
  2. 释放自定义 HTML 布局空间:在 home/index.tsx、�bout/index.tsx 和 legal/legal-document.tsx 中增加判断。当系统检测到内容为自定义 HTML(isLikelyHtml)时,自动解除外层容器的宽度限制与多余内边距,将排版自由完全交还给用户。

@Calcium-Ion

Copy link
Copy Markdown
Member

确实是个问题,需要评估一下,还有建议下次pr使用模板提交

@Calcium-Ion
Calcium-Ion merged commit fda8177 into QuantumNous:main Jul 1, 2026
henrydontbbai added a commit to henrydontbbai/henry-newapi that referenced this pull request Jul 2, 2026
* feat: improve advanced custom route editor

* Bump Electron lockfile dependencies

* feat: bill doubao seedance-2.0 by output resolution and video input (QuantumNous#5300)

* feat: support doubao seedance 2.0 safety_identifier/priority and 4k billing (QuantumNous#5824)

* feat: support safety_identifier and priority for doubao video

* feat: add 4k resolution billing tier for doubao video

* chore: run `bun format` to automatically format the frontend code

* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题 (QuantumNous#5795)

* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>

* feat: support Wan2.7 i2v media mapping (QuantumNous#4984)

* feat: support Wan2.7 i2v media mapping

* fix: normalize wan2.7 i2v image inputs

* perf(web): optimize web Rsbuild and Tailwind build pipeline (QuantumNous#5786)

* fix(dev): run only default frontend in dev-web

- simplify make dev-web to install default dependencies and start web/default only.
- keep dev-web-classic as the standalone classic entry and scope its install to classic.

* chore(build): align make targets with web naming

- rename frontend make targets and variables to use the web terminology consistently.
- keep default and classic dev port overrides available under the updated names.

* fix(web): inject app styles into isolated HTML (QuantumNous#5860)

- clone loaded application style nodes into the Shadow DOM for custom HTML rendering.
- keep HTML rendering isolated while restoring layout and typography that depend on app CSS.

* fix: keep page state when switching tabs within the same route (QuantumNous#5796)

AnimatedOutlet keyed its motion container by the full pathname, so
navigating between params of the same route (e.g. the dashboard tabs
under /dashboard/$section) changed the key and remounted the route
component, discarding its in-memory state. The most visible symptom:
the dashboard time range resets to the default every time you switch
sub-tabs (Model Analytics / Flow / User Analytics).

Key the transition by the matched route id instead, so param-only
navigation re-renders in place while real page-to-page navigation
still plays the enter animation. This also preserves state across the
other $section tab pages (usage logs, models, system settings).

* 支持服务优雅关闭,避免重启回复中断和面板缓存数据丢失 (QuantumNous#4258)

* feat: add graceful shutdown with configurable timeout

* fix: flush quota dashboard cache on graceful shutdown

Persist the in-memory CacheQuotaData aggregation to the quota_data table
before process exit, so a restart no longer drops up to one DataExportInterval
window of dashboard data (issue QuantumNous#5679).

* docs: update AGENTS.md

* Make quota logging synchronous and delay startup log

---------

Co-authored-by: CaIon <[email protected]>
Co-authored-by: feitianbubu <[email protected]>
Co-authored-by: t0ng7u <[email protected]>
Co-authored-by: olwater <[email protected]>
Co-authored-by: Scott <[email protected]>
Co-authored-by: QuentinHsu <[email protected]>
Co-authored-by: henrydontbbai <[email protected]>
liulixin-lex pushed a commit to liulixin-lex/xy-api that referenced this pull request Jul 7, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
noah-wung pushed a commit to noah-wung/new-api that referenced this pull request Jul 17, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
@olwater
olwater deleted the fix-html-layout branch July 30, 2026 21:22
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
* fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题

* fix(web): isolate custom HTML rendering

---------

Co-authored-by: CaIon <[email protected]>
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