@portabletext/plugin-typography 0.0.1
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/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/index.cjs +235 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +246 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/package.json +84 -0
- package/src/create-decorator-guard.ts +58 -0
- package/src/disallow-in-code.feature +54 -0
- package/src/disallow-in-code.test.tsx +41 -0
- package/src/global.d.ts +4 -0
- package/src/index.ts +3 -0
- package/src/input-rule.ellipsis.feature +96 -0
- package/src/input-rule.ellipsis.test.tsx +31 -0
- package/src/input-rule.em-dash.feature +104 -0
- package/src/input-rule.em-dash.test.tsx +31 -0
- package/src/input-rule.multiplication.feature +26 -0
- package/src/input-rule.multiplication.test.tsx +31 -0
- package/src/input-rule.smart-quotes.feature +73 -0
- package/src/input-rule.smart-quotes.test.tsx +31 -0
- package/src/input-rules.typography.ts +190 -0
- package/src/plugin.typography.tsx +182 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 - 2025 Sanity.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# `@portabletext/plugin-typography`
|
|
2
|
+
|
|
3
|
+
> Automatically transform text to typographic variants
|
|
4
|
+
|
|
5
|
+
Drop-in plugin for the [Portable Text Editor](https://www.portabletext.org/) to enable a wide variety of typographic transformations:
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
Automatically handles smart undo with <kbd>Backspace</kbd> right after insertion:
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Import the `TypographyPlugin` React component and place it inside the `EditorProvider`:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import {
|
|
19
|
+
defineSchema,
|
|
20
|
+
EditorProvider,
|
|
21
|
+
PortableTextEditable,
|
|
22
|
+
} from '@portabletext/editor'
|
|
23
|
+
import {TypographyPlugin} from '@portabletext/plugin-typography'
|
|
24
|
+
|
|
25
|
+
const schemaDefinition = defineSchema({
|
|
26
|
+
// Your Schema
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<EditorProvider
|
|
32
|
+
initialConfig={{
|
|
33
|
+
schemaDefinition,
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<PortableTextEditable />
|
|
37
|
+
<TypographyPlugin /> {/* <-- plugin added */}
|
|
38
|
+
</EditorProvider>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Rules Included
|
|
44
|
+
|
|
45
|
+
The plugin includes the following typographic transformation rules:
|
|
46
|
+
|
|
47
|
+
**Default rules:**
|
|
48
|
+
|
|
49
|
+
| Name | Conversion |
|
|
50
|
+
| --------------------- | ------------- |
|
|
51
|
+
| `emDash` | `--` → `—` |
|
|
52
|
+
| `ellipsis` | `...` → `…` |
|
|
53
|
+
| `openingDoubleQuote` | `"` → `“` |
|
|
54
|
+
| `closingDoubleQuote` | `"` → `”` |
|
|
55
|
+
| `openingSingleQuote` | `'` → `‘` |
|
|
56
|
+
| `closingSingleQuote` | `'` → `’` |
|
|
57
|
+
| `leftArrow` | `<-` → `←` |
|
|
58
|
+
| `rightArrow` | `->` → `→` |
|
|
59
|
+
| `copyright` | `(c)` → `©` |
|
|
60
|
+
| `trademark` | `(tm)` → `™` |
|
|
61
|
+
| `servicemark` | `(sm)` → `℠` |
|
|
62
|
+
| `registeredTrademark` | `(r)` → `®` |
|
|
63
|
+
|
|
64
|
+
**Optional rules:**
|
|
65
|
+
|
|
66
|
+
| Name | Conversion |
|
|
67
|
+
| ------------------ | -------------------------------- |
|
|
68
|
+
| `oneHalf` | `1/2` → `½` |
|
|
69
|
+
| `plusMinus` | `+/-` → `±` |
|
|
70
|
+
| `notEqual` | `!=` → `≠` |
|
|
71
|
+
| `laquo` | `<<` → `«` |
|
|
72
|
+
| `raquo` | `>>` → `»` |
|
|
73
|
+
| `multiplication` | `*` or `x` between numbers → `×` |
|
|
74
|
+
| `superscriptTwo` | `^2` → `²` |
|
|
75
|
+
| `superscriptThree` | `^3` → `³` |
|
|
76
|
+
| `oneQuarter` | `1/4` → `¼` |
|
|
77
|
+
| `threeQuarters` | `3/4` → `¾` |
|
|
78
|
+
|
|
79
|
+
## Configuring what Rules are Enabled
|
|
80
|
+
|
|
81
|
+
Use the `rules` prop on the `TypographyPlugin` to control which rules are enabled:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
return <TypographyPlugin rules={{multiplication: 'on'}} />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`emDash`, `ellipsis`, `openingDoubleQuote`, `closingDoubleQuote`, `openingSingleQuote`, `closingSingleQuote`, `leftArrow`, `rightArrow`, `copyright`, `trademark`, `servicemark`, and `registeredTrademark` are `'on'` by default.
|
|
88
|
+
|
|
89
|
+
## Controlling when Text Transformations Run
|
|
90
|
+
|
|
91
|
+
The `TypographyPlugin` has an optional `guard` prop that accepts any type of `BehaviorGuard`. Here, you'll have access to the current `EditorSnapshot` as well as information about the current rule being matched.
|
|
92
|
+
|
|
93
|
+
Because disallowing text transformations inside code is a common use case, this plugin ships a built-in `createDecoratorGuard` function. use that to create a `guard` that disallows text transformations inside certain decorators:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import {
|
|
97
|
+
createDecoratorGuard,
|
|
98
|
+
TypographyPlugin,
|
|
99
|
+
} from '@portabletext/plugin-typography'
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<TypographyPlugin
|
|
103
|
+
guard={createDecoratorGuard({
|
|
104
|
+
decorators: ({schema}) =>
|
|
105
|
+
schema.decorators.flatMap((decorator) =>
|
|
106
|
+
decorator.name === 'code' ? [decorator.name] : [],
|
|
107
|
+
),
|
|
108
|
+
})}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Using Individual Rules with `InputRulePlugin`
|
|
114
|
+
|
|
115
|
+
All included typographic rules are exported from the plugin. To use them in your own abstraction, import them from this from plugin and use them with the `InputRulePlugin`:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import {InputRulePlugin} from '@portabletext/plugin-input-rule'
|
|
119
|
+
import {ellipsisRule, emDashRule} from '@portabletext/plugin-typography'
|
|
120
|
+
|
|
121
|
+
return <InputRulePlugin rules={[emDashRule, ellipsisRule]} />
|
|
122
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var selectors = require("@portabletext/editor/selectors"), pluginInputRule = require("@portabletext/plugin-input-rule"), jsxRuntime = require("react/jsx-runtime"), compilerRuntime = require("react/compiler-runtime");
|
|
4
|
+
function createDecoratorGuard(config) {
|
|
5
|
+
return ({
|
|
6
|
+
snapshot,
|
|
7
|
+
event
|
|
8
|
+
}) => {
|
|
9
|
+
const decorators = config.decorators({
|
|
10
|
+
schema: snapshot.context.schema
|
|
11
|
+
});
|
|
12
|
+
if (decorators.length === 0)
|
|
13
|
+
return !0;
|
|
14
|
+
const matchedSpans = event.matches.flatMap((match) => selectors.getSelectedSpans({
|
|
15
|
+
...snapshot,
|
|
16
|
+
context: {
|
|
17
|
+
...snapshot.context,
|
|
18
|
+
selection: match.selection
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
let preventInputRule = !1;
|
|
22
|
+
for (const decorator of decorators) {
|
|
23
|
+
if (selectors.isActiveDecorator(decorator)(snapshot)) {
|
|
24
|
+
preventInputRule = !0;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
if (matchedSpans.some((span) => span.node.marks?.includes(decorator))) {
|
|
28
|
+
preventInputRule = !0;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return !preventInputRule;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const emDashRule = pluginInputRule.defineTextTransformRule({
|
|
36
|
+
on: /--/,
|
|
37
|
+
transform: () => "\u2014"
|
|
38
|
+
}), ellipsisRule = pluginInputRule.defineTextTransformRule({
|
|
39
|
+
on: /\.\.\./,
|
|
40
|
+
transform: () => "\u2026"
|
|
41
|
+
}), openingDoubleQuoteRule = pluginInputRule.defineTextTransformRule({
|
|
42
|
+
on: new RegExp(`(?:^|(?<=[\\s{[(<'"\\u2018\\u201C]))"`, "g"),
|
|
43
|
+
transform: () => "\u201C"
|
|
44
|
+
}), closingDoubleQuoteRule = pluginInputRule.defineTextTransformRule({
|
|
45
|
+
on: /"/g,
|
|
46
|
+
transform: () => "\u201D"
|
|
47
|
+
}), openingSingleQuoteRule = pluginInputRule.defineTextTransformRule({
|
|
48
|
+
on: new RegExp(`(?:^|(?<=[\\s{[(<'"\\u2018\\u201C]))'`, "g"),
|
|
49
|
+
transform: () => "\u2018"
|
|
50
|
+
}), closingSingleQuoteRule = pluginInputRule.defineTextTransformRule({
|
|
51
|
+
on: /'/g,
|
|
52
|
+
transform: () => "\u2019"
|
|
53
|
+
}), smartQuotesRules = [openingDoubleQuoteRule, closingDoubleQuoteRule, openingSingleQuoteRule, closingSingleQuoteRule], leftArrowRule = pluginInputRule.defineTextTransformRule({
|
|
54
|
+
on: /<-/,
|
|
55
|
+
transform: () => "\u2190"
|
|
56
|
+
}), rightArrowRule = pluginInputRule.defineTextTransformRule({
|
|
57
|
+
on: /->/,
|
|
58
|
+
transform: () => "\u2192"
|
|
59
|
+
}), copyrightRule = pluginInputRule.defineTextTransformRule({
|
|
60
|
+
on: /\(c\)/,
|
|
61
|
+
transform: () => "\xA9"
|
|
62
|
+
}), servicemarkRule = pluginInputRule.defineTextTransformRule({
|
|
63
|
+
on: /\(sm\)/,
|
|
64
|
+
transform: () => "\u2120"
|
|
65
|
+
}), trademarkRule = pluginInputRule.defineTextTransformRule({
|
|
66
|
+
on: /\(tm\)/,
|
|
67
|
+
transform: () => "\u2122"
|
|
68
|
+
}), registeredTrademarkRule = pluginInputRule.defineTextTransformRule({
|
|
69
|
+
on: /\(r\)/,
|
|
70
|
+
transform: () => "\xAE"
|
|
71
|
+
}), oneHalfRule = pluginInputRule.defineTextTransformRule({
|
|
72
|
+
on: /(?:^|\s)(1\/2)\s/,
|
|
73
|
+
transform: () => "\xBD"
|
|
74
|
+
}), plusMinusRule = pluginInputRule.defineTextTransformRule({
|
|
75
|
+
on: /\+\/-/,
|
|
76
|
+
transform: () => "\xB1"
|
|
77
|
+
}), notEqualRule = pluginInputRule.defineTextTransformRule({
|
|
78
|
+
on: /!=/,
|
|
79
|
+
transform: () => "\u2260"
|
|
80
|
+
}), laquoRule = pluginInputRule.defineTextTransformRule({
|
|
81
|
+
on: /<</,
|
|
82
|
+
transform: () => "\xAB"
|
|
83
|
+
}), raquoRule = pluginInputRule.defineTextTransformRule({
|
|
84
|
+
on: />>/,
|
|
85
|
+
transform: () => "\xBB"
|
|
86
|
+
}), multiplicationRule = pluginInputRule.defineTextTransformRule({
|
|
87
|
+
on: /\d+\s?([*x])\s?\d+/,
|
|
88
|
+
transform: () => "\xD7"
|
|
89
|
+
}), superscriptTwoRule = pluginInputRule.defineTextTransformRule({
|
|
90
|
+
on: /\^2/,
|
|
91
|
+
transform: () => "\xB2"
|
|
92
|
+
}), superscriptThreeRule = pluginInputRule.defineTextTransformRule({
|
|
93
|
+
on: /\^3/,
|
|
94
|
+
transform: () => "\xB3"
|
|
95
|
+
}), oneQuarterRule = pluginInputRule.defineTextTransformRule({
|
|
96
|
+
on: /(?:^|\s)(1\/4)\s/,
|
|
97
|
+
transform: () => "\xBC"
|
|
98
|
+
}), threeQuartersRule = pluginInputRule.defineTextTransformRule({
|
|
99
|
+
on: /(?:^|\s)(3\/4)\s/,
|
|
100
|
+
transform: () => "\xBE"
|
|
101
|
+
}), defaultRuleConfig = [{
|
|
102
|
+
name: "emDash",
|
|
103
|
+
rule: emDashRule,
|
|
104
|
+
state: "on"
|
|
105
|
+
}, {
|
|
106
|
+
name: "ellipsis",
|
|
107
|
+
rule: ellipsisRule,
|
|
108
|
+
state: "on"
|
|
109
|
+
}, {
|
|
110
|
+
name: "openingDoubleQuote",
|
|
111
|
+
rule: openingDoubleQuoteRule,
|
|
112
|
+
state: "on"
|
|
113
|
+
}, {
|
|
114
|
+
name: "closingDoubleQuote",
|
|
115
|
+
rule: closingDoubleQuoteRule,
|
|
116
|
+
state: "on"
|
|
117
|
+
}, {
|
|
118
|
+
name: "openingSingleQuote",
|
|
119
|
+
rule: openingSingleQuoteRule,
|
|
120
|
+
state: "on"
|
|
121
|
+
}, {
|
|
122
|
+
name: "closingSingleQuote",
|
|
123
|
+
rule: closingSingleQuoteRule,
|
|
124
|
+
state: "on"
|
|
125
|
+
}, {
|
|
126
|
+
name: "leftArrow",
|
|
127
|
+
rule: leftArrowRule,
|
|
128
|
+
state: "on"
|
|
129
|
+
}, {
|
|
130
|
+
name: "rightArrow",
|
|
131
|
+
rule: rightArrowRule,
|
|
132
|
+
state: "on"
|
|
133
|
+
}, {
|
|
134
|
+
name: "copyright",
|
|
135
|
+
rule: copyrightRule,
|
|
136
|
+
state: "on"
|
|
137
|
+
}, {
|
|
138
|
+
name: "trademark",
|
|
139
|
+
rule: trademarkRule,
|
|
140
|
+
state: "on"
|
|
141
|
+
}, {
|
|
142
|
+
name: "servicemark",
|
|
143
|
+
rule: servicemarkRule,
|
|
144
|
+
state: "on"
|
|
145
|
+
}, {
|
|
146
|
+
name: "registeredTrademark",
|
|
147
|
+
rule: registeredTrademarkRule,
|
|
148
|
+
state: "on"
|
|
149
|
+
}, {
|
|
150
|
+
name: "oneHalf",
|
|
151
|
+
rule: oneHalfRule,
|
|
152
|
+
state: "off"
|
|
153
|
+
}, {
|
|
154
|
+
name: "plusMinus",
|
|
155
|
+
rule: plusMinusRule,
|
|
156
|
+
state: "off"
|
|
157
|
+
}, {
|
|
158
|
+
name: "laquo",
|
|
159
|
+
rule: laquoRule,
|
|
160
|
+
state: "off"
|
|
161
|
+
}, {
|
|
162
|
+
name: "notEqual",
|
|
163
|
+
rule: notEqualRule,
|
|
164
|
+
state: "off"
|
|
165
|
+
}, {
|
|
166
|
+
name: "raquo",
|
|
167
|
+
rule: raquoRule,
|
|
168
|
+
state: "off"
|
|
169
|
+
}, {
|
|
170
|
+
name: "multiplication",
|
|
171
|
+
rule: multiplicationRule,
|
|
172
|
+
state: "off"
|
|
173
|
+
}, {
|
|
174
|
+
name: "superscriptTwo",
|
|
175
|
+
rule: superscriptTwoRule,
|
|
176
|
+
state: "off"
|
|
177
|
+
}, {
|
|
178
|
+
name: "superscriptThree",
|
|
179
|
+
rule: superscriptThreeRule,
|
|
180
|
+
state: "off"
|
|
181
|
+
}, {
|
|
182
|
+
name: "oneQuarter",
|
|
183
|
+
rule: oneQuarterRule,
|
|
184
|
+
state: "off"
|
|
185
|
+
}, {
|
|
186
|
+
name: "threeQuarters",
|
|
187
|
+
rule: threeQuartersRule,
|
|
188
|
+
state: "off"
|
|
189
|
+
}];
|
|
190
|
+
function TypographyPlugin(props) {
|
|
191
|
+
const $ = compilerRuntime.c(6);
|
|
192
|
+
let t0;
|
|
193
|
+
$[0] !== props.guard || $[1] !== props.rules ? (t0 = defaultRuleConfig.flatMap((rule) => props.rules && props.rules[rule.name] === "on" ? {
|
|
194
|
+
...rule.rule,
|
|
195
|
+
guard: props.guard ?? _temp
|
|
196
|
+
} : props.rules && props.rules[rule.name] === "off" || rule.state === "off" ? [] : {
|
|
197
|
+
...rule.rule,
|
|
198
|
+
guard: props.guard ?? _temp2
|
|
199
|
+
}), $[0] = props.guard, $[1] = props.rules, $[2] = t0) : t0 = $[2];
|
|
200
|
+
const configuredInputRules = t0;
|
|
201
|
+
let t1;
|
|
202
|
+
return $[3] !== configuredInputRules || $[4] !== props ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(pluginInputRule.InputRulePlugin, { ...props, rules: configuredInputRules }), $[3] = configuredInputRules, $[4] = props, $[5] = t1) : t1 = $[5], t1;
|
|
203
|
+
}
|
|
204
|
+
function _temp2() {
|
|
205
|
+
return !0;
|
|
206
|
+
}
|
|
207
|
+
function _temp() {
|
|
208
|
+
return !0;
|
|
209
|
+
}
|
|
210
|
+
exports.TypographyPlugin = TypographyPlugin;
|
|
211
|
+
exports.closingDoubleQuoteRule = closingDoubleQuoteRule;
|
|
212
|
+
exports.closingSingleQuoteRule = closingSingleQuoteRule;
|
|
213
|
+
exports.copyrightRule = copyrightRule;
|
|
214
|
+
exports.createDecoratorGuard = createDecoratorGuard;
|
|
215
|
+
exports.ellipsisRule = ellipsisRule;
|
|
216
|
+
exports.emDashRule = emDashRule;
|
|
217
|
+
exports.laquoRule = laquoRule;
|
|
218
|
+
exports.leftArrowRule = leftArrowRule;
|
|
219
|
+
exports.multiplicationRule = multiplicationRule;
|
|
220
|
+
exports.notEqualRule = notEqualRule;
|
|
221
|
+
exports.oneHalfRule = oneHalfRule;
|
|
222
|
+
exports.oneQuarterRule = oneQuarterRule;
|
|
223
|
+
exports.openingDoubleQuoteRule = openingDoubleQuoteRule;
|
|
224
|
+
exports.openingSingleQuoteRule = openingSingleQuoteRule;
|
|
225
|
+
exports.plusMinusRule = plusMinusRule;
|
|
226
|
+
exports.raquoRule = raquoRule;
|
|
227
|
+
exports.registeredTrademarkRule = registeredTrademarkRule;
|
|
228
|
+
exports.rightArrowRule = rightArrowRule;
|
|
229
|
+
exports.servicemarkRule = servicemarkRule;
|
|
230
|
+
exports.smartQuotesRules = smartQuotesRules;
|
|
231
|
+
exports.superscriptThreeRule = superscriptThreeRule;
|
|
232
|
+
exports.superscriptTwoRule = superscriptTwoRule;
|
|
233
|
+
exports.threeQuartersRule = threeQuartersRule;
|
|
234
|
+
exports.trademarkRule = trademarkRule;
|
|
235
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/create-decorator-guard.ts","../src/input-rules.typography.ts","../src/plugin.typography.tsx"],"sourcesContent":["import type {EditorSchema} from '@portabletext/editor'\nimport {\n getSelectedSpans,\n isActiveDecorator,\n} from '@portabletext/editor/selectors'\nimport type {InputRuleGuard} from '@portabletext/plugin-input-rule'\n\n/**\n * @public\n * Create an `InputRuleGuard` that can prevent the rule from running inside\n * certain decorators.\n *\n * @example\n * ```tsx\n * const guard = createDecoratorGuard({\n * decorators: ({schema}) => schema.decorators.flatMap((decorator) => decorator.name === 'code' ? [decorator.name] : []),\n * })\n *\n * <TypographyPlugin guard={guard} />\n * ```\n */\nexport function createDecoratorGuard(config: {\n decorators: ({schema}: {schema: EditorSchema}) => Array<string>\n}): InputRuleGuard {\n return ({snapshot, event}) => {\n const decorators = config.decorators({schema: snapshot.context.schema})\n\n if (decorators.length === 0) {\n return true\n }\n\n const matchedSpans = event.matches.flatMap((match) =>\n getSelectedSpans({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: match.selection,\n },\n }),\n )\n\n let preventInputRule = false\n\n for (const decorator of decorators) {\n if (isActiveDecorator(decorator)(snapshot)) {\n preventInputRule = true\n break\n }\n\n if (matchedSpans.some((span) => span.node.marks?.includes(decorator))) {\n preventInputRule = true\n break\n }\n }\n\n return !preventInputRule\n }\n}\n","import {\n defineTextTransformRule,\n type InputRule,\n} from '@portabletext/plugin-input-rule'\n\n/**\n * @public\n */\nexport const emDashRule = defineTextTransformRule({\n on: /--/,\n transform: () => '—',\n})\n\n/**\n * @public\n */\nexport const ellipsisRule = defineTextTransformRule({\n on: /\\.\\.\\./,\n transform: () => '…',\n})\n\n/**\n * @public\n */\nexport const openingDoubleQuoteRule = defineTextTransformRule({\n on: /(?:^|(?<=[\\s{[(<'\"\\u2018\\u201C]))\"/g,\n transform: () => '“',\n})\n\n/**\n * @public\n */\nexport const closingDoubleQuoteRule = defineTextTransformRule({\n on: /\"/g,\n transform: () => '”',\n})\n\n/**\n * @public\n */\nexport const openingSingleQuoteRule = defineTextTransformRule({\n on: /(?:^|(?<=[\\s{[(<'\"\\u2018\\u201C]))'/g,\n transform: () => '‘',\n})\n\n/**\n * @public\n */\nexport const closingSingleQuoteRule = defineTextTransformRule({\n on: /'/g,\n transform: () => '’',\n})\n\n/**\n * @public\n */\nexport const smartQuotesRules: Array<InputRule> = [\n openingDoubleQuoteRule,\n closingDoubleQuoteRule,\n openingSingleQuoteRule,\n closingSingleQuoteRule,\n]\n\n/**\n * @public\n */\nexport const leftArrowRule = defineTextTransformRule({\n on: /<-/,\n transform: () => '←',\n})\n\n/**\n * @public\n */\nexport const rightArrowRule = defineTextTransformRule({\n on: /->/,\n transform: () => '→',\n})\n\n/**\n * @public\n */\nexport const copyrightRule = defineTextTransformRule({\n on: /\\(c\\)/,\n transform: () => '©',\n})\n\n/**\n * @public\n */\nexport const servicemarkRule = defineTextTransformRule({\n on: /\\(sm\\)/,\n transform: () => '℠',\n})\n\n/**\n * @public\n */\nexport const trademarkRule = defineTextTransformRule({\n on: /\\(tm\\)/,\n transform: () => '™',\n})\n\n/**\n * @beta\n */\nexport const registeredTrademarkRule = defineTextTransformRule({\n on: /\\(r\\)/,\n transform: () => '®',\n})\n\n/**\n * @public\n */\nexport const oneHalfRule = defineTextTransformRule({\n on: /(?:^|\\s)(1\\/2)\\s/,\n transform: () => '½',\n})\n\n/**\n * @public\n */\nexport const plusMinusRule = defineTextTransformRule({\n on: /\\+\\/-/,\n transform: () => '±',\n})\n\n/**\n * @public\n */\nexport const notEqualRule = defineTextTransformRule({\n on: /!=/,\n transform: () => '≠',\n})\n\n/**\n * @public\n */\nexport const laquoRule = defineTextTransformRule({\n on: /<</,\n transform: () => '«',\n})\n\n/**\n * @public\n */\nexport const raquoRule = defineTextTransformRule({\n on: />>/,\n transform: () => '»',\n})\n\n/**\n * @public\n */\nexport const multiplicationRule = defineTextTransformRule({\n on: /\\d+\\s?([*x])\\s?\\d+/,\n transform: () => '×',\n})\n\n/**\n * @public\n */\nexport const superscriptTwoRule = defineTextTransformRule({\n on: /\\^2/,\n transform: () => '²',\n})\n\n/**\n * @public\n */\nexport const superscriptThreeRule = defineTextTransformRule({\n on: /\\^3/,\n transform: () => '³',\n})\n\n/**\n * @public\n */\nexport const oneQuarterRule = defineTextTransformRule({\n on: /(?:^|\\s)(1\\/4)\\s/,\n transform: () => '¼',\n})\n\n/**\n * @public\n */\nexport const threeQuartersRule = defineTextTransformRule({\n on: /(?:^|\\s)(3\\/4)\\s/,\n transform: () => '¾',\n})\n","import {\n InputRulePlugin,\n type InputRule,\n type InputRuleGuard,\n} from '@portabletext/plugin-input-rule'\nimport {useMemo} from 'react'\nimport {\n closingDoubleQuoteRule,\n closingSingleQuoteRule,\n copyrightRule,\n ellipsisRule,\n emDashRule,\n laquoRule,\n leftArrowRule,\n multiplicationRule,\n notEqualRule,\n oneHalfRule,\n oneQuarterRule,\n openingDoubleQuoteRule,\n openingSingleQuoteRule,\n plusMinusRule,\n raquoRule,\n registeredTrademarkRule,\n rightArrowRule,\n servicemarkRule,\n superscriptThreeRule,\n superscriptTwoRule,\n threeQuartersRule,\n trademarkRule,\n} from './input-rules.typography'\n\n/**\n * @public\n */\nexport type TypographyPluginProps = {\n guard?: InputRuleGuard\n /**\n * Configure which rules to enable or disable. Ordinary rules like `emDash` and `ellipsis` are enabled by default.\n * Less common rules like `multiplication` are disabled by default.\n */\n rules?: {\n /**\n * @defaultValue 'on'\n */\n emDash?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n ellipsis?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n openingDoubleQuote?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n closingDoubleQuote?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n openingSingleQuote?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n closingSingleQuote?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n leftArrow?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n rightArrow?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n copyright?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n trademark?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n servicemark?: 'on' | 'off'\n /**\n * @defaultValue 'on'\n */\n registeredTrademark?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n oneHalf?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n plusMinus?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n notEqual?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n laquo?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n raquo?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n multiplication?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n superscriptTwo?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n superscriptThree?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n oneQuarter?: 'on' | 'off'\n /**\n * @defaultValue 'off'\n */\n threeQuarters?: 'on' | 'off'\n }\n}\n\ntype RuleName = keyof NonNullable<TypographyPluginProps['rules']>\n\nconst defaultRuleConfig: Array<{\n name: RuleName\n rule: InputRule\n state: 'on' | 'off'\n}> = [\n {name: 'emDash', rule: emDashRule, state: 'on'},\n {name: 'ellipsis', rule: ellipsisRule, state: 'on'},\n {name: 'openingDoubleQuote', rule: openingDoubleQuoteRule, state: 'on'},\n {name: 'closingDoubleQuote', rule: closingDoubleQuoteRule, state: 'on'},\n {name: 'openingSingleQuote', rule: openingSingleQuoteRule, state: 'on'},\n {name: 'closingSingleQuote', rule: closingSingleQuoteRule, state: 'on'},\n {name: 'leftArrow', rule: leftArrowRule, state: 'on'},\n {name: 'rightArrow', rule: rightArrowRule, state: 'on'},\n {name: 'copyright', rule: copyrightRule, state: 'on'},\n {name: 'trademark', rule: trademarkRule, state: 'on'},\n {name: 'servicemark', rule: servicemarkRule, state: 'on'},\n {name: 'registeredTrademark', rule: registeredTrademarkRule, state: 'on'},\n {name: 'oneHalf', rule: oneHalfRule, state: 'off'},\n {name: 'plusMinus', rule: plusMinusRule, state: 'off'},\n {name: 'laquo', rule: laquoRule, state: 'off'},\n {name: 'notEqual', rule: notEqualRule, state: 'off'},\n {name: 'raquo', rule: raquoRule, state: 'off'},\n {name: 'multiplication', rule: multiplicationRule, state: 'off'},\n {name: 'superscriptTwo', rule: superscriptTwoRule, state: 'off'},\n {name: 'superscriptThree', rule: superscriptThreeRule, state: 'off'},\n {name: 'oneQuarter', rule: oneQuarterRule, state: 'off'},\n {name: 'threeQuarters', rule: threeQuartersRule, state: 'off'},\n]\n\n/**\n * @public\n */\nexport function TypographyPlugin(props: TypographyPluginProps) {\n const configuredInputRules = useMemo(\n () =>\n defaultRuleConfig.flatMap((rule) =>\n props.rules && props.rules[rule.name] === 'on'\n ? {...rule.rule, guard: props.guard ?? (() => true)}\n : (props.rules && props.rules[rule.name] === 'off') ||\n rule.state === 'off'\n ? []\n : {...rule.rule, guard: props.guard ?? (() => true)},\n ),\n [props.guard, props.rules],\n )\n\n return <InputRulePlugin {...props} rules={configuredInputRules} />\n}\n"],"names":["createDecoratorGuard","config","snapshot","event","decorators","schema","context","length","matchedSpans","matches","flatMap","match","getSelectedSpans","selection","preventInputRule","decorator","isActiveDecorator","some","span","node","marks","includes","emDashRule","defineTextTransformRule","on","transform","ellipsisRule","openingDoubleQuoteRule","closingDoubleQuoteRule","openingSingleQuoteRule","closingSingleQuoteRule","smartQuotesRules","leftArrowRule","rightArrowRule","copyrightRule","servicemarkRule","trademarkRule","registeredTrademarkRule","oneHalfRule","plusMinusRule","notEqualRule","laquoRule","raquoRule","multiplicationRule","superscriptTwoRule","superscriptThreeRule","oneQuarterRule","threeQuartersRule","defaultRuleConfig","name","rule","state","TypographyPlugin","props","$","_c","t0","guard","rules","_temp","_temp2","configuredInputRules","t1","jsx","InputRulePlugin"],"mappings":";;;AAqBO,SAASA,qBAAqBC,QAElB;AACjB,SAAO,CAAC;AAAA,IAACC;AAAAA,IAAUC;AAAAA,EAAAA,MAAW;AAC5B,UAAMC,aAAaH,OAAOG,WAAW;AAAA,MAACC,QAAQH,SAASI,QAAQD;AAAAA,IAAAA,CAAO;AAEtE,QAAID,WAAWG,WAAW;AACxB,aAAO;AAGT,UAAMC,eAAeL,MAAMM,QAAQC,QAASC,WAC1CC,2BAAiB;AAAA,MACf,GAAGV;AAAAA,MACHI,SAAS;AAAA,QACP,GAAGJ,SAASI;AAAAA,QACZO,WAAWF,MAAME;AAAAA,MAAAA;AAAAA,IACnB,CACD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'@portabletext/editor'
|
|
2
|
+
import {InputRule, InputRuleGuard} from '@portabletext/plugin-input-rule'
|
|
3
|
+
import {JSX} from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const closingDoubleQuoteRule: InputRule
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const closingSingleQuoteRule: InputRule
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const copyrightRule: InputRule
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
* Create an `InputRuleGuard` that can prevent the rule from running inside
|
|
23
|
+
* certain decorators.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const guard = createDecoratorGuard({
|
|
28
|
+
* decorators: ({schema}) => schema.decorators.flatMap((decorator) => decorator.name === 'code' ? [decorator.name] : []),
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* <TypographyPlugin guard={guard} />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function createDecoratorGuard(config: {
|
|
35
|
+
decorators: ({schema}: {schema: EditorSchema}) => Array<string>
|
|
36
|
+
}): InputRuleGuard
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const ellipsisRule: InputRule
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare const emDashRule: InputRule
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare const laquoRule: InputRule
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export declare const leftArrowRule: InputRule
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare const multiplicationRule: InputRule
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export declare const notEqualRule: InputRule
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare const oneHalfRule: InputRule
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export declare const oneQuarterRule: InputRule
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare const openingDoubleQuoteRule: InputRule
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export declare const openingSingleQuoteRule: InputRule
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export declare const plusMinusRule: InputRule
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare const raquoRule: InputRule
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @beta
|
|
100
|
+
*/
|
|
101
|
+
export declare const registeredTrademarkRule: InputRule
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export declare const rightArrowRule: InputRule
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare const servicemarkRule: InputRule
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export declare const smartQuotesRules: Array<InputRule>
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export declare const superscriptThreeRule: InputRule
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export declare const superscriptTwoRule: InputRule
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export declare const threeQuartersRule: InputRule
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export declare const trademarkRule: InputRule
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare function TypographyPlugin(
|
|
142
|
+
props: TypographyPluginProps,
|
|
143
|
+
): JSX.Element
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
export declare type TypographyPluginProps = {
|
|
149
|
+
guard?: InputRuleGuard
|
|
150
|
+
/**
|
|
151
|
+
* Configure which rules to enable or disable. Ordinary rules like `emDash` and `ellipsis` are enabled by default.
|
|
152
|
+
* Less common rules like `multiplication` are disabled by default.
|
|
153
|
+
*/
|
|
154
|
+
rules?: {
|
|
155
|
+
/**
|
|
156
|
+
* @defaultValue 'on'
|
|
157
|
+
*/
|
|
158
|
+
emDash?: 'on' | 'off'
|
|
159
|
+
/**
|
|
160
|
+
* @defaultValue 'on'
|
|
161
|
+
*/
|
|
162
|
+
ellipsis?: 'on' | 'off'
|
|
163
|
+
/**
|
|
164
|
+
* @defaultValue 'on'
|
|
165
|
+
*/
|
|
166
|
+
openingDoubleQuote?: 'on' | 'off'
|
|
167
|
+
/**
|
|
168
|
+
* @defaultValue 'on'
|
|
169
|
+
*/
|
|
170
|
+
closingDoubleQuote?: 'on' | 'off'
|
|
171
|
+
/**
|
|
172
|
+
* @defaultValue 'on'
|
|
173
|
+
*/
|
|
174
|
+
openingSingleQuote?: 'on' | 'off'
|
|
175
|
+
/**
|
|
176
|
+
* @defaultValue 'on'
|
|
177
|
+
*/
|
|
178
|
+
closingSingleQuote?: 'on' | 'off'
|
|
179
|
+
/**
|
|
180
|
+
* @defaultValue 'on'
|
|
181
|
+
*/
|
|
182
|
+
leftArrow?: 'on' | 'off'
|
|
183
|
+
/**
|
|
184
|
+
* @defaultValue 'on'
|
|
185
|
+
*/
|
|
186
|
+
rightArrow?: 'on' | 'off'
|
|
187
|
+
/**
|
|
188
|
+
* @defaultValue 'on'
|
|
189
|
+
*/
|
|
190
|
+
copyright?: 'on' | 'off'
|
|
191
|
+
/**
|
|
192
|
+
* @defaultValue 'on'
|
|
193
|
+
*/
|
|
194
|
+
trademark?: 'on' | 'off'
|
|
195
|
+
/**
|
|
196
|
+
* @defaultValue 'on'
|
|
197
|
+
*/
|
|
198
|
+
servicemark?: 'on' | 'off'
|
|
199
|
+
/**
|
|
200
|
+
* @defaultValue 'on'
|
|
201
|
+
*/
|
|
202
|
+
registeredTrademark?: 'on' | 'off'
|
|
203
|
+
/**
|
|
204
|
+
* @defaultValue 'off'
|
|
205
|
+
*/
|
|
206
|
+
oneHalf?: 'on' | 'off'
|
|
207
|
+
/**
|
|
208
|
+
* @defaultValue 'off'
|
|
209
|
+
*/
|
|
210
|
+
plusMinus?: 'on' | 'off'
|
|
211
|
+
/**
|
|
212
|
+
* @defaultValue 'off'
|
|
213
|
+
*/
|
|
214
|
+
notEqual?: 'on' | 'off'
|
|
215
|
+
/**
|
|
216
|
+
* @defaultValue 'off'
|
|
217
|
+
*/
|
|
218
|
+
laquo?: 'on' | 'off'
|
|
219
|
+
/**
|
|
220
|
+
* @defaultValue 'off'
|
|
221
|
+
*/
|
|
222
|
+
raquo?: 'on' | 'off'
|
|
223
|
+
/**
|
|
224
|
+
* @defaultValue 'off'
|
|
225
|
+
*/
|
|
226
|
+
multiplication?: 'on' | 'off'
|
|
227
|
+
/**
|
|
228
|
+
* @defaultValue 'off'
|
|
229
|
+
*/
|
|
230
|
+
superscriptTwo?: 'on' | 'off'
|
|
231
|
+
/**
|
|
232
|
+
* @defaultValue 'off'
|
|
233
|
+
*/
|
|
234
|
+
superscriptThree?: 'on' | 'off'
|
|
235
|
+
/**
|
|
236
|
+
* @defaultValue 'off'
|
|
237
|
+
*/
|
|
238
|
+
oneQuarter?: 'on' | 'off'
|
|
239
|
+
/**
|
|
240
|
+
* @defaultValue 'off'
|
|
241
|
+
*/
|
|
242
|
+
threeQuarters?: 'on' | 'off'
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export {}
|