Closed
Labels
needs-triageIssue has not yet been reviewed or classified by maintainers.Issue has not yet been reviewed or classified by maintainers.
Description
At #62, @brandondrew raised the issue of incorrect numbering.
#42 fixed the numbering, but it doesn't solve the other problem: sublists commonly have a different number style.
For example, a common numbered list shall look like this, which is more readable:
1. sth
a. sth
i. sth
ii. sth
1. sth
iii.sth
iv. sth
while current presentation is:
1. sth
1. sth
1. sth
2. sth
1. sth
3. sth
4. sth
common nested styles are:
| 1st | 2nd | 3rd | 4th |
|---|---|---|---|
| 1. | a. | i. | 1. |
| 1. | 1) | a) | 1. |
| 1. | 1.1. | 1.1.1. | 1.1.1.1. |
Further more, there are multiple variants of one number style, which is useful in different scenarios. For example, a. could also be a) or (a).
If possible, consider implementing this, or provide a way to customize this behavior easily. Maybe do something like this:
function listNumberProvider(numeric: number, layer: number) {
if (layer % 3 === 2) {
return `${toAlphabet(numeric)}.`; // a.
} else if (layer % 3 === 0) {
return `${toRomeNumber(numeric)}.`; // i.
} else {
return `${numeric}.` // 1.
}
}
const editor: BlockNoteEditor = useBlockNote({
listNumberProvider: listNumberProvider
});
}Reacted by 陈杨文
Metadata
Metadata
Assignees
Labels
needs-triageIssue has not yet been reviewed or classified by maintainers.Issue has not yet been reviewed or classified by maintainers.
Activity
nicholasdavidbrown commentedon Feb 29, 2024
I'm just a user of this library, but implementing this to the core list block would make lists much more complex than they need to be for most users (I can only speak for myself). Writing a custom block using the core Blocknote ListBlock as a basis would be what I would do in the short term.
You can also just use the slash menu in any nested block too:
Just to offer some alternatives for you in the meantime.
matthewlipski commentedon Jun 11, 2024
I think this is a good suggestion! While customizing the numbering style for each nesting level is probably overkill, I agree that nested numbered lists should have distinct numbering styles.
sb8244 commentedon Jul 14, 2024
Having this in the base
NumberedListItemBlockseems very useful. Unless I'm missing something, I don't think it's super easy to implement this even in a custom block today. If there's a path towards implementing it, I'd love to know so I can take a stab at it.matthewlipski commentedon Jul 16, 2024
Yeah agreed it's not a super easy change, but definitely take a look at the
NumberedListIndexingPlugin. I think in theory you would just need to check the depth fromblockInfoand have a function which converts the regular index to/from the other formats, like roman numerals. Also had a quick look and the TipTap node doesn't care what theindexattribute is since it just stores, renders, and parses it, so doing e.g.index: "iii"shouldn't cause any issues.sb8244 commentedon Aug 3, 2024
@matthewlipski I know a lot more about BlockNote now, so was more comfortable taking this on.
I'm not sure how to actually work in the dev version of the project. I was hoping to be able to write some tests or examples to test this feature, but I think they're based on published version of blocknote and not local.
I'm more than happy to work through putting this into BlockNote proper, or if you want to use the code that is also good with me.
A few notes on the code:
depthis not calculate properly here. It should be the depth of the list entry and NOT the depth relative to the document. I think that calculation would need to change to be accurate. Impact: a numeric list started at depth will not necessarily start at 1sb8244 commentedon Aug 5, 2024
This updated version handles broken lists properly, by finding the closest parent of the same type: https://gist.github.com/sb8244/c59acf0836eda8c79852e623afe936d1
serpent213 commentedon Nov 12, 2024
Just solved the same problem. I'm using CSS to generate the actual ordering symbols (
lower-alphain this case):And extended my ListIndexingPlugin like so:
For my
AlphabeticalListItem(based onNumericalListItem) to work I had to patchcoreto exportupdateblock, though.Happy to learn about a workaround – or have that exported by default...? 🙂