Skip to content

Commit

Permalink
fix(core): correctly reset PTE list counts (#7286)
Browse files Browse the repository at this point in the history
I was reading the docs on [`counter-reset`](https://developer.mozilla.org/en-US/docs/Web/CSS/counter-reset#description) when this paragraph suddenly stood out:

> After creating a counter using `counter-reset`, you can adjust its value by
> using the `counter-set` property. This is counterintuitive because, despite
> its name, the `counter-reset` property is used for creating and initializing
> counters, while the `counter-set` property is used for resetting the value
> of an existing counter.

This made me realise that we probably used `content-reset` somewhere,
incorrectly, where we actually meant to use `counter-set`.

Before this change, counters on each list level would not reset at all across a
PTE document. Now, the counters reset properly.

Before:

```
1. This
  a. is
    i. nested
      1. list
This is a paragraph
      2. This
    ii. is
  b. another nested
2. list
```

After:

```
1. This
  a. is
    i. nested
      1. list
This is a paragraph
      1. This
    i. is
  a. another nested
1. list
```
  • Loading branch information
christianhg committed Aug 2, 2024
1 parent e32932c commit acbc351
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const EditableWrapper = styled(Card)<{$isFullscreen: boolean; $readOnly?:
/* Reset the list count if the element is not a numbered list item */
& > :not(.pt-list-item-number) {
counter-reset: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')};
counter-set: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')};
}
${TEXT_LEVELS.slice(1).map((l) => {
Expand Down

0 comments on commit acbc351

Please sign in to comment.