@portabletext/plugin-list-index 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +10 -1
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -22,8 +22,17 @@ Typical use: custom text-block renders (`defineTextBlock`) that need to render n
22
22
 
23
23
  ```tsx
24
24
  function TextBlock(props: TextBlockRenderProps) {
25
+ // The 1-based position within the list, or `undefined` for a block that
26
+ // is not a list item. Render it as the marker for ordered lists.
25
27
  const listIndex = useListIndex(props.path)
26
- return <div {...props.attributes}>{props.children}</div>
28
+ return (
29
+ <div {...props.attributes}>
30
+ {listIndex !== undefined ? (
31
+ <span contentEditable={false}>{listIndex}. </span>
32
+ ) : null}
33
+ {props.children}
34
+ </div>
35
+ )
27
36
  }
28
37
 
29
38
  defineTextBlock({type: '*', render: (props) => <TextBlock {...props} />})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/plugin-list-index",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A helper plugin for calculating list indices for flat blocks based on listItem and level",
5
5
  "keywords": [
6
6
  "portabletext",
@@ -46,13 +46,13 @@
46
46
  "typescript-eslint": "^8.48.0",
47
47
  "vitest": "^4.1.8",
48
48
  "vitest-browser-react": "^2.2.0",
49
- "@portabletext/editor": "^7.4.0",
50
- "@portabletext/test": "^1.0.3",
51
- "@portabletext/schema": "^2.2.0"
49
+ "@portabletext/editor": "^7.5.1",
50
+ "@portabletext/schema": "^2.2.0",
51
+ "@portabletext/test": "^1.0.3"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "^19.2",
55
- "@portabletext/editor": "^7.4.0"
55
+ "@portabletext/editor": "^7.5.1"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=20.19 <22 || >=22.12"