@portabletext/plugin-character-pair-decorator 8.0.20 → 8.0.22
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.
- package/README.md +23 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# `@portabletext/plugin-character-pair-decorator`
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Automatically match a pair of characters and decorate the text in between
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @portabletext/plugin-character-pair-decorator
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
4
12
|
|
|
5
13
|
Import the `CharacterPairDecoratorPlugin` React component and place it inside the `EditorProvider` to automatically register the necessary Behaviors:
|
|
6
14
|
|
|
@@ -32,3 +40,17 @@ function App() {
|
|
|
32
40
|
)
|
|
33
41
|
}
|
|
34
42
|
```
|
|
43
|
+
|
|
44
|
+
## Why look up the decorator in the schema?
|
|
45
|
+
|
|
46
|
+
The `decorator` callback returns the name found in `context.schema`
|
|
47
|
+
(`context.schema.decorators.find((d) => d.name === 'italic')?.name`) instead
|
|
48
|
+
of a hardcoded `'italic'`. That lookup is what makes it schema-aware: if the
|
|
49
|
+
schema has no such decorator the callback returns `undefined` and the pairing
|
|
50
|
+
is skipped, so it never applies a decorator the schema does not declare.
|
|
51
|
+
|
|
52
|
+
The same gating follows [containers](../schema/README.md#containers-and-sub-schemas),
|
|
53
|
+
because `context.schema` is resolved at the caret: inside a code block whose
|
|
54
|
+
sub-schema declares no decorators the pairing is skipped. Read
|
|
55
|
+
`context.schema` rather than capturing the top-level schema and the plugin
|
|
56
|
+
stays correct at every nesting level.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/plugin-character-pair-decorator",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.22",
|
|
4
4
|
"description": "Automatically match a pair of characters and decorate the text in between",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portabletext",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"typescript": "5.9.3",
|
|
50
50
|
"typescript-eslint": "^8.48.0",
|
|
51
51
|
"vitest": "^4.1.8",
|
|
52
|
-
"@portabletext/editor": "^7.
|
|
52
|
+
"@portabletext/editor": "^7.7.0",
|
|
53
53
|
"@portabletext/schema": "2.2.1",
|
|
54
54
|
"racejar": "2.0.8"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^19.2",
|
|
58
|
-
"@portabletext/editor": "^7.
|
|
58
|
+
"@portabletext/editor": "^7.7.0"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=20.19 <22 || >=22.12"
|