@tiptap/extension-typography 2.1.0-rc.9 → 2.1.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/src/typography.ts CHANGED
@@ -1,138 +1,138 @@
1
1
  import { Extension, textInputRule } from '@tiptap/core'
2
2
 
3
3
  export interface TypographyOptions {
4
- emDash: false,
5
- ellipsis: false,
6
- openDoubleQuote: false,
7
- closeDoubleQuote: false,
8
- openSingleQuote: false,
9
- closeSingleQuote: false,
10
- leftArrow: false,
11
- rightArrow: false,
12
- copyright: false,
13
- trademark: false,
14
- servicemark: false,
15
- registeredTrademark: false,
16
- oneHalf: false,
17
- plusMinus: false,
18
- notEqual: false,
19
- laquo: false,
20
- raquo: false,
21
- multiplication: false,
22
- superscriptTwo: false,
23
- superscriptThree: false,
24
- oneQuarter: false,
25
- threeQuarters: false,
4
+ emDash: false | string,
5
+ ellipsis: false | string,
6
+ openDoubleQuote: false | string,
7
+ closeDoubleQuote: false | string,
8
+ openSingleQuote: false | string,
9
+ closeSingleQuote: false | string,
10
+ leftArrow: false | string,
11
+ rightArrow: false | string,
12
+ copyright: false | string,
13
+ trademark: false | string,
14
+ servicemark: false | string,
15
+ registeredTrademark: false | string,
16
+ oneHalf: false | string,
17
+ plusMinus: false | string,
18
+ notEqual: false | string,
19
+ laquo: false | string,
20
+ raquo: false | string,
21
+ multiplication: false | string,
22
+ superscriptTwo: false | string,
23
+ superscriptThree: false | string,
24
+ oneQuarter: false | string,
25
+ threeQuarters: false | string,
26
26
  }
27
27
 
28
- export const emDash = textInputRule({
28
+ export const emDash = (override?: string) => textInputRule({
29
29
  find: /--$/,
30
- replace: '—',
30
+ replace: override ?? '—',
31
31
  })
32
32
 
33
- export const ellipsis = textInputRule({
33
+ export const ellipsis = (override?: string) => textInputRule({
34
34
  find: /\.\.\.$/,
35
- replace: '…',
35
+ replace: override ?? '…',
36
36
  })
37
37
 
38
- export const openDoubleQuote = textInputRule({
38
+ export const openDoubleQuote = (override?: string) => textInputRule({
39
39
  find: /(?:^|[\s{[(<'"\u2018\u201C])(")$/,
40
- replace: '“',
40
+ replace: override ?? '“',
41
41
  })
42
42
 
43
- export const closeDoubleQuote = textInputRule({
43
+ export const closeDoubleQuote = (override?: string) => textInputRule({
44
44
  find: /"$/,
45
- replace: '”',
45
+ replace: override ?? '”',
46
46
  })
47
47
 
48
- export const openSingleQuote = textInputRule({
48
+ export const openSingleQuote = (override?: string) => textInputRule({
49
49
  find: /(?:^|[\s{[(<'"\u2018\u201C])(')$/,
50
- replace: '‘',
50
+ replace: override ?? '‘',
51
51
  })
52
52
 
53
- export const closeSingleQuote = textInputRule({
53
+ export const closeSingleQuote = (override?: string) => textInputRule({
54
54
  find: /'$/,
55
- replace: '’',
55
+ replace: override ?? '’',
56
56
  })
57
57
 
58
- export const leftArrow = textInputRule({
58
+ export const leftArrow = (override?: string) => textInputRule({
59
59
  find: /<-$/,
60
- replace: '←',
60
+ replace: override ?? '←',
61
61
  })
62
62
 
63
- export const rightArrow = textInputRule({
63
+ export const rightArrow = (override?: string) => textInputRule({
64
64
  find: /->$/,
65
- replace: '→',
65
+ replace: override ?? '→',
66
66
  })
67
67
 
68
- export const copyright = textInputRule({
68
+ export const copyright = (override?: string) => textInputRule({
69
69
  find: /\(c\)$/,
70
- replace: '©',
70
+ replace: override ?? '©',
71
71
  })
72
72
 
73
- export const trademark = textInputRule({
73
+ export const trademark = (override?: string) => textInputRule({
74
74
  find: /\(tm\)$/,
75
- replace: '™',
75
+ replace: override ?? '™',
76
76
  })
77
77
 
78
- export const servicemark = textInputRule({
78
+ export const servicemark = (override?: string) => textInputRule({
79
79
  find: /\(sm\)$/,
80
- replace: '℠',
80
+ replace: override ?? '℠',
81
81
  })
82
82
 
83
- export const registeredTrademark = textInputRule({
83
+ export const registeredTrademark = (override?: string) => textInputRule({
84
84
  find: /\(r\)$/,
85
- replace: '®',
85
+ replace: override ?? '®',
86
86
  })
87
87
 
88
- export const oneHalf = textInputRule({
88
+ export const oneHalf = (override?: string) => textInputRule({
89
89
  find: /(?:^|\s)(1\/2)$/,
90
- replace: '½',
90
+ replace: override ?? '½',
91
91
  })
92
92
 
93
- export const plusMinus = textInputRule({
93
+ export const plusMinus = (override?: string) => textInputRule({
94
94
  find: /\+\/-$/,
95
- replace: '±',
95
+ replace: override ?? '±',
96
96
  })
97
97
 
98
- export const notEqual = textInputRule({
98
+ export const notEqual = (override?: string) => textInputRule({
99
99
  find: /!=$/,
100
- replace: '≠',
100
+ replace: override ?? '≠',
101
101
  })
102
102
 
103
- export const laquo = textInputRule({
103
+ export const laquo = (override?: string) => textInputRule({
104
104
  find: /<<$/,
105
- replace: '«',
105
+ replace: override ?? '«',
106
106
  })
107
107
 
108
- export const raquo = textInputRule({
108
+ export const raquo = (override?: string) => textInputRule({
109
109
  find: />>$/,
110
- replace: '»',
110
+ replace: override ?? '»',
111
111
  })
112
112
 
113
- export const multiplication = textInputRule({
113
+ export const multiplication = (override?: string) => textInputRule({
114
114
  find: /\d+\s?([*x])\s?\d+$/,
115
- replace: '×',
115
+ replace: override ?? '×',
116
116
  })
117
117
 
118
- export const superscriptTwo = textInputRule({
118
+ export const superscriptTwo = (override?: string) => textInputRule({
119
119
  find: /\^2$/,
120
- replace: '²',
120
+ replace: override ?? '²',
121
121
  })
122
122
 
123
- export const superscriptThree = textInputRule({
123
+ export const superscriptThree = (override?: string) => textInputRule({
124
124
  find: /\^3$/,
125
- replace: '³',
125
+ replace: override ?? '³',
126
126
  })
127
127
 
128
- export const oneQuarter = textInputRule({
128
+ export const oneQuarter = (override?: string) => textInputRule({
129
129
  find: /(?:^|\s)(1\/4)$/,
130
- replace: '¼',
130
+ replace: override ?? '¼',
131
131
  })
132
132
 
133
- export const threeQuarters = textInputRule({
133
+ export const threeQuarters = (override?: string) => textInputRule({
134
134
  find: /(?:^|\s)(3\/4)$/,
135
- replace: '¾',
135
+ replace: override ?? '¾',
136
136
  })
137
137
 
138
138
  export const Typography = Extension.create<TypographyOptions>({
@@ -142,91 +142,91 @@ export const Typography = Extension.create<TypographyOptions>({
142
142
  const rules = []
143
143
 
144
144
  if (this.options.emDash !== false) {
145
- rules.push(emDash)
145
+ rules.push(emDash(this.options.emDash))
146
146
  }
147
147
 
148
148
  if (this.options.ellipsis !== false) {
149
- rules.push(ellipsis)
149
+ rules.push(ellipsis(this.options.ellipsis))
150
150
  }
151
151
 
152
152
  if (this.options.openDoubleQuote !== false) {
153
- rules.push(openDoubleQuote)
153
+ rules.push(openDoubleQuote(this.options.openDoubleQuote))
154
154
  }
155
155
 
156
156
  if (this.options.closeDoubleQuote !== false) {
157
- rules.push(closeDoubleQuote)
157
+ rules.push(closeDoubleQuote(this.options.closeDoubleQuote))
158
158
  }
159
159
 
160
160
  if (this.options.openSingleQuote !== false) {
161
- rules.push(openSingleQuote)
161
+ rules.push(openSingleQuote(this.options.openSingleQuote))
162
162
  }
163
163
 
164
164
  if (this.options.closeSingleQuote !== false) {
165
- rules.push(closeSingleQuote)
165
+ rules.push(closeSingleQuote(this.options.closeSingleQuote))
166
166
  }
167
167
 
168
168
  if (this.options.leftArrow !== false) {
169
- rules.push(leftArrow)
169
+ rules.push(leftArrow(this.options.leftArrow))
170
170
  }
171
171
 
172
172
  if (this.options.rightArrow !== false) {
173
- rules.push(rightArrow)
173
+ rules.push(rightArrow(this.options.rightArrow))
174
174
  }
175
175
 
176
176
  if (this.options.copyright !== false) {
177
- rules.push(copyright)
177
+ rules.push(copyright(this.options.copyright))
178
178
  }
179
179
 
180
180
  if (this.options.trademark !== false) {
181
- rules.push(trademark)
181
+ rules.push(trademark(this.options.trademark))
182
182
  }
183
183
 
184
184
  if (this.options.servicemark !== false) {
185
- rules.push(servicemark)
185
+ rules.push(servicemark(this.options.servicemark))
186
186
  }
187
187
 
188
188
  if (this.options.registeredTrademark !== false) {
189
- rules.push(registeredTrademark)
189
+ rules.push(registeredTrademark(this.options.registeredTrademark))
190
190
  }
191
191
 
192
192
  if (this.options.oneHalf !== false) {
193
- rules.push(oneHalf)
193
+ rules.push(oneHalf(this.options.oneHalf))
194
194
  }
195
195
 
196
196
  if (this.options.plusMinus !== false) {
197
- rules.push(plusMinus)
197
+ rules.push(plusMinus(this.options.plusMinus))
198
198
  }
199
199
 
200
200
  if (this.options.notEqual !== false) {
201
- rules.push(notEqual)
201
+ rules.push(notEqual(this.options.notEqual))
202
202
  }
203
203
 
204
204
  if (this.options.laquo !== false) {
205
- rules.push(laquo)
205
+ rules.push(laquo(this.options.laquo))
206
206
  }
207
207
 
208
208
  if (this.options.raquo !== false) {
209
- rules.push(raquo)
209
+ rules.push(raquo(this.options.raquo))
210
210
  }
211
211
 
212
212
  if (this.options.multiplication !== false) {
213
- rules.push(multiplication)
213
+ rules.push(multiplication(this.options.multiplication))
214
214
  }
215
215
 
216
216
  if (this.options.superscriptTwo !== false) {
217
- rules.push(superscriptTwo)
217
+ rules.push(superscriptTwo(this.options.superscriptTwo))
218
218
  }
219
219
 
220
220
  if (this.options.superscriptThree !== false) {
221
- rules.push(superscriptThree)
221
+ rules.push(superscriptThree(this.options.superscriptThree))
222
222
  }
223
223
 
224
224
  if (this.options.oneQuarter !== false) {
225
- rules.push(oneQuarter)
225
+ rules.push(oneQuarter(this.options.oneQuarter))
226
226
  }
227
227
 
228
228
  if (this.options.threeQuarters !== false) {
229
- rules.push(threeQuarters)
229
+ rules.push(threeQuarters(this.options.threeQuarters))
230
230
  }
231
231
 
232
232
  return rules