Conversation
WalkthroughThe parser now exposes Changes
Sequence Diagram(s)sequenceDiagram
participant UI as ClassNamesContainer (component)
participant Parser as parser.buildCssObjectFromContent
participant Serializer as objectCssToString
participant Store as Persistence/Storage
UI->>Parser: save(content) -> buildCssObjectFromContent(content)
Note right of Parser: parseList → cssObject\ninclude at-rules (arrays if dupes)
Parser-->>UI: cssObject
UI->>Serializer: objectCssToString(cssObject)
Note left of Serializer: extract top-level directives\nprepend topString
Serializer-->>UI: cssText
UI->>Store: persist(cssText)
Store-->>UI: confirm
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/settings/styles/src/components/classNamesContainer/index.vue`:
- Around line 462-465: The current logic in classNamesContainer that computes
rawValue/braceIdx/key/value re-parses item.style.value and splits on the first
'{', which misclassifies blockless at-rules containing '{' inside quoted URLs or
data URIs; instead, stop reparsing the raw rule: use item.style.value verbatim
(rawValue) for display/processing or, if structured data is needed, use the
parser-produced metadata (e.g., any at-rule fields produced in parser.ts) rather
than slicing on '{'. Concretely, remove the braceIdx/indexOf('{') branching that
sets key and value and either assign key = rawValue (or use
item.style.name/params if the parser exposes them) and keep value empty, or
consume the structured at-rule properties from the parser output so the
component never attempts to reparse the raw text.
- Around line 455-470: The current atrule handling in parseList merges later
occurrences into cssObject[key], which collapses multiple same-key at-rule
blocks and breaks source order; change the logic so each atrule occurrence gets
its own ordered slot instead of being merged — e.g., stop aggregating by key and
instead push an ordered entry (such as { key, value } or store values as
successive items in an array of entries like cssEntries) when item.type ===
'atrule' (use the existing variables item, rawValue, key, value), and update the
serializer (packages/utils/src/utils/index.ts where serialization reads
cssObject) to iterate these ordered entries so identical at-rule preludes remain
separate and round-trip in source order.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7a29d3b6-7f4c-4e71-be6b-5261c82612bc
📒 Files selected for processing (2)
packages/settings/styles/src/components/classNamesContainer/index.vuepackages/utils/src/utils/index.ts
English | 简体中文
PR
fix #1776
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
背景:
在v2.10版本中新增支持css 对象格式,系统将输入的全局 CSS 代码字符串解析并存储为 JSON 对象(
cssObject)。保存时通过parser将 CSS 字符串转化格式并在必要时将其转化回字符串(objectCssToString)。问题:
转换为
styleObject的过程中没把包含@keyframes、@media的在内的大部分 at-rules 囊括在内,直接导致这些代码在保存刷新后丢失。见 #1776解决方法:
转化时增加对at-rules的支持,保存为 key,value格式
已处理的特殊场景:
验证环境:https://hexqi.github.io/tiny-engine/?type=app&id=1&tenant=1&pageid=88
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes