@portabletext/plugin-typography 1.0.21 → 2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/plugin-typography",
3
- "version": "1.0.21",
3
+ "version": "2.0.1",
4
4
  "description": "Automatically transform text to typographic variants",
5
5
  "keywords": [
6
6
  "portabletext",
@@ -23,14 +23,11 @@
23
23
  "exports": {
24
24
  ".": {
25
25
  "source": "./src/index.ts",
26
- "import": "./dist/index.js",
27
- "require": "./dist/index.cjs",
28
26
  "default": "./dist/index.js"
29
27
  },
30
28
  "./package.json": "./package.json"
31
29
  },
32
- "main": "./dist/index.cjs",
33
- "module": "./dist/index.js",
30
+ "main": "./dist/index.js",
34
31
  "types": "./dist/index.d.ts",
35
32
  "files": [
36
33
  "dist",
@@ -38,14 +35,14 @@
38
35
  ],
39
36
  "dependencies": {
40
37
  "react-compiler-runtime": "1.0.0",
41
- "@portabletext/plugin-input-rule": "~0.4.4"
38
+ "@portabletext/plugin-input-rule": "~0.5.1"
42
39
  },
43
40
  "devDependencies": {
44
- "@sanity/pkg-utils": "^8.1.4",
45
- "@types/react": "^19.2.0",
41
+ "@sanity/pkg-utils": "^9.0.1",
42
+ "@types/react": "^19.2.2",
46
43
  "@vitejs/plugin-react": "^5.0.4",
47
- "@vitest/browser": "^4.0.5",
48
- "@vitest/browser-playwright": "^4.0.5",
44
+ "@vitest/browser": "^4.0.6",
45
+ "@vitest/browser-playwright": "^4.0.6",
49
46
  "babel-plugin-react-compiler": "1.0.0",
50
47
  "eslint": "^9.38.0",
51
48
  "eslint-formatter-gha": "^1.6.0",
@@ -53,15 +50,18 @@
53
50
  "react": "^19.2.0",
54
51
  "typescript": "5.9.3",
55
52
  "typescript-eslint": "^8.46.1",
56
- "vitest": "^4.0.5",
57
- "@portabletext/editor": "^2.17.2",
58
- "@portabletext/schema": "^1.2.0",
59
- "racejar": "1.3.2"
53
+ "vitest": "^4.0.6",
54
+ "@portabletext/editor": "^2.18.1",
55
+ "@portabletext/schema": "^2.0.0",
56
+ "racejar": "2.0.0"
60
57
  },
61
58
  "peerDependencies": {
62
- "@portabletext/editor": "^2.17.2",
59
+ "@portabletext/editor": "^2.18.1",
63
60
  "react": "^19.1.1"
64
61
  },
62
+ "engines": {
63
+ "node": ">=20.19 <22 || >=22.12"
64
+ },
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
package/dist/index.cjs DELETED
@@ -1,235 +0,0 @@
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
@@ -1 +0,0 @@
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,CACH;AAEA,QAAIC,mBAAmB;AAEvB,eAAWC,aAAaX,YAAY;AAClC,UAAIY,4BAAkBD,SAAS,EAAEb,QAAQ,GAAG;AAC1CY,2BAAmB;AACnB;AAAA,MACF;AAEA,UAAIN,aAAaS,KAAMC,CAAAA,SAASA,KAAKC,KAAKC,OAAOC,SAASN,SAAS,CAAC,GAAG;AACrED,2BAAmB;AACnB;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAACA;AAAAA,EACV;AACF;ACjDO,MAAMQ,aAAaC,gBAAAA,wBAAwB;AAAA,EAChDC,IAAI;AAAA,EACJC,WAAWA,MAAM;AACnB,CAAC,GAKYC,eAAeH,wCAAwB;AAAA,EAClDC,IAAI;AAAA,EACJC,WAAWA,MAAM;AACnB,CAAC,GA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I,SAALE;AAAAA,EAAAA,IACrBN,MAAKK,SAAUL,MAAKK,MAAOR,KAAID,IAAK,MAAM,SACzCC,KAAIC,UAAW,QADjB,CAAA,IAAA;AAAA,IAAA,GAGMD,KAAIA;AAAAA,IAAKO,OAASJ,MAAKI,SAALG;AAAAA,EAAAA,CAC9B,GAACN,EAAA,CAAA,IAAAD,MAAAI,OAAAH,EAAA,CAAA,IAAAD,MAAAK,OAAAJ,OAAAE,MAAAA,KAAAF,EAAA,CAAA;AATL,QAAAO,uBAEIL;AASH,MAAAM;AAAA,SAAAR,EAAA,CAAA,MAAAO,wBAAAP,SAAAD,SAEMS,KAAAC,2BAAAA,IAACC,gBAAAA,iBAAA,EAAe,GAAKX,OAAcQ,OAAAA,qBAAAA,CAAoB,GAAIP,OAAAO,sBAAAP,OAAAD,OAAAC,OAAAQ,MAAAA,KAAAR,EAAA,CAAA,GAA3DQ;AAA2D;AAd7D,SAAAF,SAAA;AAAA,SASmD;AAAI;AATvD,SAAAD,QAAA;AAAA,SAKiD;AAAI;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.cts DELETED
@@ -1,246 +0,0 @@
1
- import type {EditorSchema} from '@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<true>
9
-
10
- /**
11
- * @public
12
- */
13
- export declare const closingSingleQuoteRule: InputRule<true>
14
-
15
- /**
16
- * @public
17
- */
18
- export declare const copyrightRule: InputRule<true>
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<true>
42
-
43
- /**
44
- * @public
45
- */
46
- export declare const emDashRule: InputRule<true>
47
-
48
- /**
49
- * @public
50
- */
51
- export declare const laquoRule: InputRule<true>
52
-
53
- /**
54
- * @public
55
- */
56
- export declare const leftArrowRule: InputRule<true>
57
-
58
- /**
59
- * @public
60
- */
61
- export declare const multiplicationRule: InputRule<true>
62
-
63
- /**
64
- * @public
65
- */
66
- export declare const notEqualRule: InputRule<true>
67
-
68
- /**
69
- * @public
70
- */
71
- export declare const oneHalfRule: InputRule<true>
72
-
73
- /**
74
- * @public
75
- */
76
- export declare const oneQuarterRule: InputRule<true>
77
-
78
- /**
79
- * @public
80
- */
81
- export declare const openingDoubleQuoteRule: InputRule<true>
82
-
83
- /**
84
- * @public
85
- */
86
- export declare const openingSingleQuoteRule: InputRule<true>
87
-
88
- /**
89
- * @public
90
- */
91
- export declare const plusMinusRule: InputRule<true>
92
-
93
- /**
94
- * @public
95
- */
96
- export declare const raquoRule: InputRule<true>
97
-
98
- /**
99
- * @beta
100
- */
101
- export declare const registeredTrademarkRule: InputRule<true>
102
-
103
- /**
104
- * @public
105
- */
106
- export declare const rightArrowRule: InputRule<true>
107
-
108
- /**
109
- * @public
110
- */
111
- export declare const servicemarkRule: InputRule<true>
112
-
113
- /**
114
- * @public
115
- */
116
- export declare const smartQuotesRules: Array<InputRule>
117
-
118
- /**
119
- * @public
120
- */
121
- export declare const superscriptThreeRule: InputRule<true>
122
-
123
- /**
124
- * @public
125
- */
126
- export declare const superscriptTwoRule: InputRule<true>
127
-
128
- /**
129
- * @public
130
- */
131
- export declare const threeQuartersRule: InputRule<true>
132
-
133
- /**
134
- * @public
135
- */
136
- export declare const trademarkRule: InputRule<true>
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 {}