Skip to content

feat: solve the problem of numbers changing after li tag indentation#469

Open
wuyiping0628 wants to merge 1 commit into
devfrom
wyp/indentation-0513
Open

feat: solve the problem of numbers changing after li tag indentation#469
wuyiping0628 wants to merge 1 commit into
devfrom
wyp/indentation-0513

Conversation

@wuyiping0628
Copy link
Copy Markdown
Collaborator

@wuyiping0628 wuyiping0628 commented May 13, 2026

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Style
    • Updated ordered list indentation marker styling for nested items, standardizing numbering format across indent levels 1-9.

Review Change Stack

@github-actions github-actions Bot added the enhancement New feature or request label May 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Walkthrough

The PR updates CSS rules in the Quill editor stylesheet to manage ordered-list indentation markers. Rules for li.ql-indent-1 through li.ql-indent-9 now target the .ql-ui:before pseudo-element and apply counter(list-<n>, decimal) content with !important priority for consistent marker rendering.

Changes

Ordered-list marker styling

Layer / File(s) Summary
Ordered-list marker counter styling
packages/fluent-editor/src/assets/editor.scss
CSS rules for li.ql-indent-1 through li.ql-indent-9 updated to set the :before pseudo-element under .ql-ui to render decimal counter-based content with !important priority.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Lists stand tall, indented just right,
Counters tick down, decimal bright,
Nine levels deep, markers align,
With !important touch, they purely shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing a bug where ordered list numbers change incorrectly after list item indentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wyp/indentation-0513

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/fluent-editor/src/assets/editor.scss (1)

128-258: ⚡ Quick win

Reduce code duplication using SCSS loops.

The nine rules for li.ql-indent-{1-9} .ql-ui:before (lines 128-130, 144-146, 160-162, 176-178, 192-194, 208-210, 224-226, 240-242, 256-258) are nearly identical and could be generated using an SCSS @for loop to improve maintainability.

♻️ Refactor using SCSS loop
-    li.ql-indent-1 .ql-ui:before {
-      content: counter(list-1, decimal) '. ' !important;
-    }
-
     li.ordered.ql-indent-1 {
       counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
     }

     li.ordered.ql-indent-2 {
       counter-increment: list-2;
     }

     li.ordered.ql-indent-2::before {
       content: counter(list-2, lower-roman) '. ';
     }

-    li.ql-indent-2 .ql-ui:before {
-      content: counter(list-2, decimal) '. ' !important;
-    }
-
     li.ordered.ql-indent-2 {
       counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9;
     }

-    li.ordered.ql-indent-3 {
-      counter-increment: list-3;
-    }
-
-    li.ordered.ql-indent-3::before {
-      content: counter(list-3, decimal) '. ';
-    }
-
-    li.ql-indent-3 .ql-ui:before {
-      content: counter(list-3, decimal) '. ' !important;
-    }
-
-    li.ordered.ql-indent-3 {
-      counter-reset: list-4 list-5 list-6 list-7 list-8 list-9;
-    }
-
-    li.ordered.ql-indent-4 {
-      counter-increment: list-4;
-    }
-
-    li.ordered.ql-indent-4::before {
-      content: counter(list-4, lower-alpha) '. ';
-    }
-
-    li.ql-indent-4 .ql-ui:before {
-      content: counter(list-4, decimal) '. ' !important;
-    }
-
-    li.ordered.ql-indent-4 {
-      counter-reset: list-5 list-6 list-7 list-8 list-9;
-    }
-
-    li.ordered.ql-indent-5 {
-      counter-increment: list-5;
-    }
-
-    li.ordered.ql-indent-5::before {
-      content: counter(list-5, lower-roman) '. ';
-    }
-
-    li.ql-indent-5 .ql-ui:before {
-      content: counter(list-5, decimal) '. ' !important;
-    }
-
-    li.ordered.ql-indent-5 {
-      counter-reset: list-6 list-7 list-8 list-9;
-    }
-
-    li.ordered.ql-indent-6 {
-      counter-increment: list-6;
-    }
-
-    li.ordered.ql-indent-6::before {
-      content: counter(list-6, decimal) '. ';
-    }
-
-    li.ql-indent-6 .ql-ui:before {
-      content: counter(list-6, decimal) '. ' !important;
-    }
-
-    li.ordered.ql-indent-6 {
-      counter-reset: list-7 list-8 list-9;
-    }
-
-    li.ordered.ql-indent-7 {
-      counter-increment: list-7;
-    }
-
-    li.ordered.ql-indent-7::before {
-      content: counter(list-7, lower-alpha) '. ';
-    }
-
-    li.ql-indent-7 .ql-ui:before {
-      content: counter(list-7, decimal) '. ' !important;
-    }
-
-    li.ordered.ql-indent-7 {
-      counter-reset: list-8 list-9;
-    }
-
-    li.ordered.ql-indent-8 {
-      counter-increment: list-8;
-    }
-
-    li.ordered.ql-indent-8::before {
-      content: counter(list-8, lower-roman) '. ';
-    }
-
-    li.ql-indent-8 .ql-ui:before {
-      content: counter(list-8, decimal) '. ' !important;
-    }
-
-    li.ordered.ql-indent-8 {
-      counter-reset: list-9;
-    }
-
-    li.ordered.ql-indent-9 {
-      counter-increment: list-9;
-    }
-
-    li.ordered.ql-indent-9::before {
-      content: counter(list-9, decimal) '. ';
-    }
-
-    li.ql-indent-9 .ql-ui:before {
-      content: counter(list-9, decimal) '. ' !important;
-    }
+    // Generate .ql-ui:before rules for indent levels 1-9
+    `@for` $i from 1 through 9 {
+      li.ql-indent-#{$i} .ql-ui:before {
+        content: counter(list-#{$i}, decimal) '. ' !important;
+      }
+    }
+
+    // Keep existing counter-increment and counter-reset rules
+    `@for` $i from 3 through 9 {
+      li.ordered.ql-indent-#{$i} {
+        counter-increment: list-#{$i};
+      }
+
+      li.ordered.ql-indent-#{$i}::before {
+        `@if` $i == 3 or $i == 6 or $i == 9 {
+          content: counter(list-#{$i}, decimal) '. ';
+        } `@else` if $i == 4 or $i == 7 {
+          content: counter(list-#{$i}, lower-alpha) '. ';
+        } `@else` {
+          content: counter(list-#{$i}, lower-roman) '. ';
+        }
+      }
+
+      li.ordered.ql-indent-#{$i} {
+        $reset-list: ();
+        `@for` $j from ($i + 1) through 9 {
+          $reset-list: append($reset-list, list-#{$j}, space);
+        }
+        counter-reset: $reset-list;
+      }
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/fluent-editor/src/assets/editor.scss` around lines 128 - 258, There
are nine near-identical rules for the selector pattern "li.ql-indent-{1..9}
.ql-ui:before" that can be replaced by an SCSS loop; remove the duplicated
explicit rules and add a single `@for` loop that iterates 1 through 9 and
generates "li.ql-indent-#{$i} .ql-ui:before" with content using
counter(list-#{$i}, decimal) '. ' !important so each indent level still
references the corresponding list counter; update the stylesheet in
packages/fluent-editor/src/assets/editor.scss by replacing the nine duplicated
blocks with this loop to reduce duplication and improve maintainability.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/fluent-editor/src/assets/editor.scss`:
- Around line 128-130: The change forces all nested list counters to decimal
(e.g., li.ql-indent-1 .ql-ui:before) which removes the original varied styles
(lower-alpha, lower-roman) and harms visual hierarchy; restore the original
counter styles per indent level instead of using decimal for all indents
(reapply the previous counter(...) values for li.ql-indent-1, li.ql-indent-2,
li.ql-indent-4, li.ql-indent-5, li.ql-indent-7, li.ql-indent-8) or implement a
mapping from indent level to counter style and use that in the .ql-ui:before
rules, and apply the same fix to the other modified blocks mentioned (lines
around 144-146, 160-162, 176-178, 192-194, 208-210, 224-226, 240-242, 256-258)
so numbering styles preserve nesting distinctions.
- Around line 128-130: The new rules like "li.ql-indent-1 .ql-ui:before" are
causing dual markers and overbroad matching (affecting bullets) and overwrite
the original ordered styles ("li.ordered.ql-indent-1::before"); remove or
refactor those ".ql-ui:before" rules so they don't conflict: either delete the
nine "li.ql-indent-{1-9} .ql-ui:before" selectors if the existing
"li.ordered.ql-indent-{n}::before" rules already render correctly, or replace
them with a single SCSS mixin that only applies to ordered lists (guarded by the
".ordered" class) and preserves the alternating formats (lower-alpha,
lower-roman, decimal) instead of forcing decimal and using !important.

---

Nitpick comments:
In `@packages/fluent-editor/src/assets/editor.scss`:
- Around line 128-258: There are nine near-identical rules for the selector
pattern "li.ql-indent-{1..9} .ql-ui:before" that can be replaced by an SCSS
loop; remove the duplicated explicit rules and add a single `@for` loop that
iterates 1 through 9 and generates "li.ql-indent-#{$i} .ql-ui:before" with
content using counter(list-#{$i}, decimal) '. ' !important so each indent level
still references the corresponding list counter; update the stylesheet in
packages/fluent-editor/src/assets/editor.scss by replacing the nine duplicated
blocks with this loop to reduce duplication and improve maintainability.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 812286df-c4f2-48ac-8a3a-274d3afe0595

📥 Commits

Reviewing files that changed from the base of the PR and between c7f8992 and e0c8165.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/assets/editor.scss

Comment on lines +128 to +130
li.ql-indent-1 .ql-ui:before {
content: counter(list-1, decimal) '. ' !important;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚖️ Poor tradeoff

Consider the impact of forcing all indent levels to decimal numbering.

The new rules override the original varied counter styles with uniform decimal numbering:

  • Original indent-1: lower-alpha (a, b, c) → Now: decimal (1, 2, 3)
  • Original indent-2: lower-roman (i, ii, iii) → Now: decimal (1, 2, 3)
  • Original indent-4: lower-alpha → Now: decimal
  • Original indent-5: lower-roman → Now: decimal
  • Original indent-7: lower-alpha → Now: decimal
  • Original indent-8: lower-roman → Now: decimal

While this change solves the stated problem of "numbers changing after indentation," it eliminates the visual hierarchy that different numbering styles provide in deeply nested lists. Users may find it harder to distinguish nesting levels when all levels use the same decimal format.

If the varied styles are intentionally being removed, consider documenting this behavior change and its UX implications. If the original varied styles should be preserved while fixing the indentation bug, the root cause may require a different solution.

Also applies to: 144-146, 160-162, 176-178, 192-194, 208-210, 224-226, 240-242, 256-258

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/fluent-editor/src/assets/editor.scss` around lines 128 - 130, The
change forces all nested list counters to decimal (e.g., li.ql-indent-1
.ql-ui:before) which removes the original varied styles (lower-alpha,
lower-roman) and harms visual hierarchy; restore the original counter styles per
indent level instead of using decimal for all indents (reapply the previous
counter(...) values for li.ql-indent-1, li.ql-indent-2, li.ql-indent-4,
li.ql-indent-5, li.ql-indent-7, li.ql-indent-8) or implement a mapping from
indent level to counter style and use that in the .ql-ui:before rules, and apply
the same fix to the other modified blocks mentioned (lines around 144-146,
160-162, 176-178, 192-194, 208-210, 224-226, 240-242, 256-258) so numbering
styles preserve nesting distinctions.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify when .ql-ui elements are used and whether they coexist with li::before markers

# Search for .ql-ui usage in JavaScript/TypeScript files
echo "=== Searching for .ql-ui element creation and usage ==="
rg -n -C3 --type=ts --type=js 'ql-ui' -g '!*.scss' -g '!*.css'

# Check if there's logic that conditionally uses .ql-ui vs li::before
echo -e "\n=== Checking for list rendering logic ==="
rg -n -C5 --type=ts --type=js 'ordered.*indent|indent.*ordered' -g '!*.scss'

# Look for bullet list handling with indent classes
echo -e "\n=== Checking bullet list + indent interaction ==="
rg -n -C3 --type=ts --type=js 'bullet.*ql-indent|ql-indent.*bullet'

Repository: opentiny/tiny-editor

Length of output: 3138


🏁 Script executed:

cat -n packages/fluent-editor/src/assets/editor.scss | head -280

Repository: opentiny/tiny-editor

Length of output: 7290


🏁 Script executed:

rg -n "li\.ordered\.ql-indent|li\.ql-indent" packages/fluent-editor/src/assets/editor.scss

Repository: opentiny/tiny-editor

Length of output: 1345


Remove or refactor the new li.ql-indent-{1-9} .ql-ui:before rules to avoid dual marker rendering and selector scope conflicts.

The new rules at lines 128–258 introduce two critical problems:

  1. Dual marker rendering: Both li.ordered.ql-indent-1::before (line 124) and li.ql-indent-1 .ql-ui:before (line 128) target the same list item. Since they render on different DOM elements (the <li> itself vs. its .ql-ui child span), both markers will display simultaneously if the .ql-ui element is present.

  2. Selector scope too broad: The new selector li.ql-indent-1 matches any <li> with that class, including unordered lists. From the DOM evidence, both <li class="ordered"> and <li class="bullet"> contain .ql-ui children, meaning bullet lists will incorrectly display decimal counters via the new rules with !important, overriding any intended styling.

Additionally, all nine new rules use uniform decimal formatting, discarding the original visual hierarchy of alternating formats (lower-alpha, lower-roman, decimal). Consider either removing these new rules if the original li.ordered.ql-indent-n::before approach is now working, or replace them with a single SCSS mixin to reduce duplication and improve maintainability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/fluent-editor/src/assets/editor.scss` around lines 128 - 130, The
new rules like "li.ql-indent-1 .ql-ui:before" are causing dual markers and
overbroad matching (affecting bullets) and overwrite the original ordered styles
("li.ordered.ql-indent-1::before"); remove or refactor those ".ql-ui:before"
rules so they don't conflict: either delete the nine "li.ql-indent-{1-9}
.ql-ui:before" selectors if the existing "li.ordered.ql-indent-{n}::before"
rules already render correctly, or replace them with a single SCSS mixin that
only applies to ordered lists (guarded by the ".ordered" class) and preserves
the alternating formats (lower-alpha, lower-roman, decimal) instead of forcing
decimal and using !important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant