Skip to content

💄 弹窗公告支持段落、链接、代码与列表的样式 - #1828

Closed
CodFrm wants to merge 1 commit into
mainfrom
fix/popup-notice-rich-text
Closed

CodFrm wants to merge 1 commit into
mainfrom
fix/popup-notice-rich-text

Conversation

@CodFrm

@CodFrm CodFrm commented Nov 5, 2026

Copy link
Copy Markdown
Member

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

N/A — Fixes mentioned issues: no issue was filed. The problem was spotted while publishing an announcement.

Description / 描述

The popup renders the announcement from ext.scriptcat.org as HTML. The admin sanitizer allows p, br, strong, em, a, ul, ol, li, pre and code. Tailwind's preflight strips the default styling of all of them, so an announcement with several paragraphs, a command and a link shows up as one dense block. The link looks like plain text, <code> has no background, and lists have no bullets.

This PR adds descendant styles to the notice container. The approach follows the [&_a]:… pattern PopupWarnings already uses for its HTML. It only uses existing tokens (text-primary, bg-background, font-mono), so light and dark themes both work:

  • adjacent blocks: [&>*+*]:mt-1.5;
  • links: text-primary, underlined;
  • inline code: bg-background, rounded, mono;
  • pre: padded block that scrolls horizontally;
  • ul/ol: bullets and numbers.

The change is in one file, src/pages/popup/App.tsx, and only touches the className. Behavior does not change.

Verification

This is a pure visual change, so I verified it by eye (per develop-testing.md § When TDD doesn't apply) and did not add a test. I built the extension with pnpm build, then rendered the notice fragment with the built chunk.css, the same DOM and classes and a 360px width, in light and dark themes. I compared two contents: the announcement currently live (paragraph with an inline link) and a sample using every allowed tag. Before the change, paragraphs, code and the link were not distinguishable. After it, each one is.

Tests: pnpm vitest run src/pages/popup/ sometimes fails with the same 17 failures in preload.test.ts and usePopupData.test.ts. The flake also happens on main without this change (1 of 3 runs on main, 2 of 3 with the change), and running usePopupData.test.ts alone did not reproduce it in 4 runs. It is pre-existing and unrelated to this className-only change.

Existing 1.5.0 users keep the old rendering. The live announcement was written to read acceptably without these styles: one paragraph with a bold link at the end.

@CodFrm CodFrm closed this Nov 5, 2026
@CodFrm
CodFrm deleted the fix/popup-notice-rich-text branch November 5, 2026 09:23
@cyfung1031

Copy link
Copy Markdown
Collaborator

@CodFrm 誤刪??

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