@tiptap/extension-typography 2.0.0-beta.8 → 2.0.0-rc.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/README.md CHANGED
@@ -5,10 +5,10 @@
5
5
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
6
 
7
7
  ## Introduction
8
- tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
8
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
9
 
10
- ## Offical Documentation
11
- Documentation can be found on the [tiptap website](https://tiptap.dev).
10
+ ## Official Documentation
11
+ Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
12
 
13
13
  ## License
14
- tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
14
+ Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs ADDED
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@tiptap/core');
6
+
7
+ const emDash = core.textInputRule({
8
+ find: /--$/,
9
+ replace: '—',
10
+ });
11
+ const ellipsis = core.textInputRule({
12
+ find: /\.\.\.$/,
13
+ replace: '…',
14
+ });
15
+ const openDoubleQuote = core.textInputRule({
16
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(")$/,
17
+ replace: '“',
18
+ });
19
+ const closeDoubleQuote = core.textInputRule({
20
+ find: /"$/,
21
+ replace: '”',
22
+ });
23
+ const openSingleQuote = core.textInputRule({
24
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(')$/,
25
+ replace: '‘',
26
+ });
27
+ const closeSingleQuote = core.textInputRule({
28
+ find: /'$/,
29
+ replace: '’',
30
+ });
31
+ const leftArrow = core.textInputRule({
32
+ find: /<-$/,
33
+ replace: '←',
34
+ });
35
+ const rightArrow = core.textInputRule({
36
+ find: /->$/,
37
+ replace: '→',
38
+ });
39
+ const copyright = core.textInputRule({
40
+ find: /\(c\)$/,
41
+ replace: '©',
42
+ });
43
+ const trademark = core.textInputRule({
44
+ find: /\(tm\)$/,
45
+ replace: '™',
46
+ });
47
+ const servicemark = core.textInputRule({
48
+ find: /\(sm\)$/,
49
+ replace: '℠',
50
+ });
51
+ const registeredTrademark = core.textInputRule({
52
+ find: /\(r\)$/,
53
+ replace: '®',
54
+ });
55
+ const oneHalf = core.textInputRule({
56
+ find: /(?:^|\s)(1\/2)$/,
57
+ replace: '½',
58
+ });
59
+ const plusMinus = core.textInputRule({
60
+ find: /\+\/-$/,
61
+ replace: '±',
62
+ });
63
+ const notEqual = core.textInputRule({
64
+ find: /!=$/,
65
+ replace: '≠',
66
+ });
67
+ const laquo = core.textInputRule({
68
+ find: /<<$/,
69
+ replace: '«',
70
+ });
71
+ const raquo = core.textInputRule({
72
+ find: />>$/,
73
+ replace: '»',
74
+ });
75
+ const multiplication = core.textInputRule({
76
+ find: /\d+\s?([*x])\s?\d+$/,
77
+ replace: '×',
78
+ });
79
+ const superscriptTwo = core.textInputRule({
80
+ find: /\^2$/,
81
+ replace: '²',
82
+ });
83
+ const superscriptThree = core.textInputRule({
84
+ find: /\^3$/,
85
+ replace: '³',
86
+ });
87
+ const oneQuarter = core.textInputRule({
88
+ find: /(?:^|\s)(1\/4)$/,
89
+ replace: '¼',
90
+ });
91
+ const threeQuarters = core.textInputRule({
92
+ find: /(?:^|\s)(3\/4)$/,
93
+ replace: '¾',
94
+ });
95
+ const Typography = core.Extension.create({
96
+ name: 'typography',
97
+ addInputRules() {
98
+ const rules = [];
99
+ if (this.options.emDash !== false) {
100
+ rules.push(emDash);
101
+ }
102
+ if (this.options.ellipsis !== false) {
103
+ rules.push(ellipsis);
104
+ }
105
+ if (this.options.openDoubleQuote !== false) {
106
+ rules.push(openDoubleQuote);
107
+ }
108
+ if (this.options.closeDoubleQuote !== false) {
109
+ rules.push(closeDoubleQuote);
110
+ }
111
+ if (this.options.openSingleQuote !== false) {
112
+ rules.push(openSingleQuote);
113
+ }
114
+ if (this.options.closeSingleQuote !== false) {
115
+ rules.push(closeSingleQuote);
116
+ }
117
+ if (this.options.leftArrow !== false) {
118
+ rules.push(leftArrow);
119
+ }
120
+ if (this.options.rightArrow !== false) {
121
+ rules.push(rightArrow);
122
+ }
123
+ if (this.options.copyright !== false) {
124
+ rules.push(copyright);
125
+ }
126
+ if (this.options.trademark !== false) {
127
+ rules.push(trademark);
128
+ }
129
+ if (this.options.servicemark !== false) {
130
+ rules.push(servicemark);
131
+ }
132
+ if (this.options.registeredTrademark !== false) {
133
+ rules.push(registeredTrademark);
134
+ }
135
+ if (this.options.oneHalf !== false) {
136
+ rules.push(oneHalf);
137
+ }
138
+ if (this.options.plusMinus !== false) {
139
+ rules.push(plusMinus);
140
+ }
141
+ if (this.options.notEqual !== false) {
142
+ rules.push(notEqual);
143
+ }
144
+ if (this.options.laquo !== false) {
145
+ rules.push(laquo);
146
+ }
147
+ if (this.options.raquo !== false) {
148
+ rules.push(raquo);
149
+ }
150
+ if (this.options.multiplication !== false) {
151
+ rules.push(multiplication);
152
+ }
153
+ if (this.options.superscriptTwo !== false) {
154
+ rules.push(superscriptTwo);
155
+ }
156
+ if (this.options.superscriptThree !== false) {
157
+ rules.push(superscriptThree);
158
+ }
159
+ if (this.options.oneQuarter !== false) {
160
+ rules.push(oneQuarter);
161
+ }
162
+ if (this.options.threeQuarters !== false) {
163
+ rules.push(threeQuarters);
164
+ }
165
+ return rules;
166
+ },
167
+ });
168
+
169
+ exports.Typography = Typography;
170
+ exports.closeDoubleQuote = closeDoubleQuote;
171
+ exports.closeSingleQuote = closeSingleQuote;
172
+ exports.copyright = copyright;
173
+ exports["default"] = Typography;
174
+ exports.ellipsis = ellipsis;
175
+ exports.emDash = emDash;
176
+ exports.laquo = laquo;
177
+ exports.leftArrow = leftArrow;
178
+ exports.multiplication = multiplication;
179
+ exports.notEqual = notEqual;
180
+ exports.oneHalf = oneHalf;
181
+ exports.oneQuarter = oneQuarter;
182
+ exports.openDoubleQuote = openDoubleQuote;
183
+ exports.openSingleQuote = openSingleQuote;
184
+ exports.plusMinus = plusMinus;
185
+ exports.raquo = raquo;
186
+ exports.registeredTrademark = registeredTrademark;
187
+ exports.rightArrow = rightArrow;
188
+ exports.servicemark = servicemark;
189
+ exports.superscriptThree = superscriptThree;
190
+ exports.superscriptTwo = superscriptTwo;
191
+ exports.threeQuarters = threeQuarters;
192
+ exports.trademark = trademark;
193
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/typography.ts"],"sourcesContent":["import { Extension, textInputRule } from '@tiptap/core'\n\nexport interface TypographyOptions {\n emDash: false,\n ellipsis: false,\n openDoubleQuote: false,\n closeDoubleQuote: false,\n openSingleQuote: false,\n closeSingleQuote: false,\n leftArrow: false,\n rightArrow: false,\n copyright: false,\n trademark: false,\n servicemark: false,\n registeredTrademark: false,\n oneHalf: false,\n plusMinus: false,\n notEqual: false,\n laquo: false,\n raquo: false,\n multiplication: false,\n superscriptTwo: false,\n superscriptThree: false,\n oneQuarter: false,\n threeQuarters: false,\n}\n\nexport const emDash = textInputRule({\n find: /--$/,\n replace: '—',\n})\n\nexport const ellipsis = textInputRule({\n find: /\\.\\.\\.$/,\n replace: '…',\n})\n\nexport const openDoubleQuote = textInputRule({\n find: /(?:^|[\\s{[(<'\"\\u2018\\u201C])(\")$/,\n replace: '“',\n})\n\nexport const closeDoubleQuote = textInputRule({\n find: /\"$/,\n replace: '”',\n})\n\nexport const openSingleQuote = textInputRule({\n find: /(?:^|[\\s{[(<'\"\\u2018\\u201C])(')$/,\n replace: '‘',\n})\n\nexport const closeSingleQuote = textInputRule({\n find: /'$/,\n replace: '’',\n})\n\nexport const leftArrow = textInputRule({\n find: /<-$/,\n replace: '←',\n})\n\nexport const rightArrow = textInputRule({\n find: /->$/,\n replace: '→',\n})\n\nexport const copyright = textInputRule({\n find: /\\(c\\)$/,\n replace: '©',\n})\n\nexport const trademark = textInputRule({\n find: /\\(tm\\)$/,\n replace: '™',\n})\n\nexport const servicemark = textInputRule({\n find: /\\(sm\\)$/,\n replace: '℠',\n})\n\nexport const registeredTrademark = textInputRule({\n find: /\\(r\\)$/,\n replace: '®',\n})\n\nexport const oneHalf = textInputRule({\n find: /(?:^|\\s)(1\\/2)$/,\n replace: '½',\n})\n\nexport const plusMinus = textInputRule({\n find: /\\+\\/-$/,\n replace: '±',\n})\n\nexport const notEqual = textInputRule({\n find: /!=$/,\n replace: '≠',\n})\n\nexport const laquo = textInputRule({\n find: /<<$/,\n replace: '«',\n})\n\nexport const raquo = textInputRule({\n find: />>$/,\n replace: '»',\n})\n\nexport const multiplication = textInputRule({\n find: /\\d+\\s?([*x])\\s?\\d+$/,\n replace: '×',\n})\n\nexport const superscriptTwo = textInputRule({\n find: /\\^2$/,\n replace: '²',\n})\n\nexport const superscriptThree = textInputRule({\n find: /\\^3$/,\n replace: '³',\n})\n\nexport const oneQuarter = textInputRule({\n find: /(?:^|\\s)(1\\/4)$/,\n replace: '¼',\n})\n\nexport const threeQuarters = textInputRule({\n find: /(?:^|\\s)(3\\/4)$/,\n replace: '¾',\n})\n\nexport const Typography = Extension.create<TypographyOptions>({\n name: 'typography',\n\n addInputRules() {\n const rules = []\n\n if (this.options.emDash !== false) {\n rules.push(emDash)\n }\n\n if (this.options.ellipsis !== false) {\n rules.push(ellipsis)\n }\n\n if (this.options.openDoubleQuote !== false) {\n rules.push(openDoubleQuote)\n }\n\n if (this.options.closeDoubleQuote !== false) {\n rules.push(closeDoubleQuote)\n }\n\n if (this.options.openSingleQuote !== false) {\n rules.push(openSingleQuote)\n }\n\n if (this.options.closeSingleQuote !== false) {\n rules.push(closeSingleQuote)\n }\n\n if (this.options.leftArrow !== false) {\n rules.push(leftArrow)\n }\n\n if (this.options.rightArrow !== false) {\n rules.push(rightArrow)\n }\n\n if (this.options.copyright !== false) {\n rules.push(copyright)\n }\n\n if (this.options.trademark !== false) {\n rules.push(trademark)\n }\n\n if (this.options.servicemark !== false) {\n rules.push(servicemark)\n }\n\n if (this.options.registeredTrademark !== false) {\n rules.push(registeredTrademark)\n }\n\n if (this.options.oneHalf !== false) {\n rules.push(oneHalf)\n }\n\n if (this.options.plusMinus !== false) {\n rules.push(plusMinus)\n }\n\n if (this.options.notEqual !== false) {\n rules.push(notEqual)\n }\n\n if (this.options.laquo !== false) {\n rules.push(laquo)\n }\n\n if (this.options.raquo !== false) {\n rules.push(raquo)\n }\n\n if (this.options.multiplication !== false) {\n rules.push(multiplication)\n }\n\n if (this.options.superscriptTwo !== false) {\n rules.push(superscriptTwo)\n }\n\n if (this.options.superscriptThree !== false) {\n rules.push(superscriptThree)\n }\n\n if (this.options.oneQuarter !== false) {\n rules.push(oneQuarter)\n }\n\n if (this.options.threeQuarters !== false) {\n rules.push(threeQuarters)\n }\n\n return rules\n },\n})\n"],"names":["textInputRule","Extension"],"mappings":";;;;;;AA2BO,MAAM,MAAM,GAAGA,kBAAa,CAAC;AAClC,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,EAAC;AAEK,MAAM,QAAQ,GAAGA,kBAAa,CAAC;AACpC,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,EAAC;AAEK,MAAM,eAAe,GAAGA,kBAAa,CAAC;AAC3C,IAAA,IAAI,EAAE,kCAAkC;AACxC,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,EAAC;AAEK,MAAM,gBAAgB,GAAGA,kBAAa,CAAC;AAC5C,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,OAAO,EAAE,GAAG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AAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,KAAK,EAAE;AACrC,YAAA,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AACvB,SAAA;AAED,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,KAAK,EAAE;AACxC,YAAA,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AAC1B,SAAA;AAED,QAAA,OAAO,KAAK,CAAA;KACb;AACF,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,166 @@
1
+ import { textInputRule, Extension } from '@tiptap/core';
2
+
3
+ const emDash = textInputRule({
4
+ find: /--$/,
5
+ replace: '—',
6
+ });
7
+ const ellipsis = textInputRule({
8
+ find: /\.\.\.$/,
9
+ replace: '…',
10
+ });
11
+ const openDoubleQuote = textInputRule({
12
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(")$/,
13
+ replace: '“',
14
+ });
15
+ const closeDoubleQuote = textInputRule({
16
+ find: /"$/,
17
+ replace: '”',
18
+ });
19
+ const openSingleQuote = textInputRule({
20
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(')$/,
21
+ replace: '‘',
22
+ });
23
+ const closeSingleQuote = textInputRule({
24
+ find: /'$/,
25
+ replace: '’',
26
+ });
27
+ const leftArrow = textInputRule({
28
+ find: /<-$/,
29
+ replace: '←',
30
+ });
31
+ const rightArrow = textInputRule({
32
+ find: /->$/,
33
+ replace: '→',
34
+ });
35
+ const copyright = textInputRule({
36
+ find: /\(c\)$/,
37
+ replace: '©',
38
+ });
39
+ const trademark = textInputRule({
40
+ find: /\(tm\)$/,
41
+ replace: '™',
42
+ });
43
+ const servicemark = textInputRule({
44
+ find: /\(sm\)$/,
45
+ replace: '℠',
46
+ });
47
+ const registeredTrademark = textInputRule({
48
+ find: /\(r\)$/,
49
+ replace: '®',
50
+ });
51
+ const oneHalf = textInputRule({
52
+ find: /(?:^|\s)(1\/2)$/,
53
+ replace: '½',
54
+ });
55
+ const plusMinus = textInputRule({
56
+ find: /\+\/-$/,
57
+ replace: '±',
58
+ });
59
+ const notEqual = textInputRule({
60
+ find: /!=$/,
61
+ replace: '≠',
62
+ });
63
+ const laquo = textInputRule({
64
+ find: /<<$/,
65
+ replace: '«',
66
+ });
67
+ const raquo = textInputRule({
68
+ find: />>$/,
69
+ replace: '»',
70
+ });
71
+ const multiplication = textInputRule({
72
+ find: /\d+\s?([*x])\s?\d+$/,
73
+ replace: '×',
74
+ });
75
+ const superscriptTwo = textInputRule({
76
+ find: /\^2$/,
77
+ replace: '²',
78
+ });
79
+ const superscriptThree = textInputRule({
80
+ find: /\^3$/,
81
+ replace: '³',
82
+ });
83
+ const oneQuarter = textInputRule({
84
+ find: /(?:^|\s)(1\/4)$/,
85
+ replace: '¼',
86
+ });
87
+ const threeQuarters = textInputRule({
88
+ find: /(?:^|\s)(3\/4)$/,
89
+ replace: '¾',
90
+ });
91
+ const Typography = Extension.create({
92
+ name: 'typography',
93
+ addInputRules() {
94
+ const rules = [];
95
+ if (this.options.emDash !== false) {
96
+ rules.push(emDash);
97
+ }
98
+ if (this.options.ellipsis !== false) {
99
+ rules.push(ellipsis);
100
+ }
101
+ if (this.options.openDoubleQuote !== false) {
102
+ rules.push(openDoubleQuote);
103
+ }
104
+ if (this.options.closeDoubleQuote !== false) {
105
+ rules.push(closeDoubleQuote);
106
+ }
107
+ if (this.options.openSingleQuote !== false) {
108
+ rules.push(openSingleQuote);
109
+ }
110
+ if (this.options.closeSingleQuote !== false) {
111
+ rules.push(closeSingleQuote);
112
+ }
113
+ if (this.options.leftArrow !== false) {
114
+ rules.push(leftArrow);
115
+ }
116
+ if (this.options.rightArrow !== false) {
117
+ rules.push(rightArrow);
118
+ }
119
+ if (this.options.copyright !== false) {
120
+ rules.push(copyright);
121
+ }
122
+ if (this.options.trademark !== false) {
123
+ rules.push(trademark);
124
+ }
125
+ if (this.options.servicemark !== false) {
126
+ rules.push(servicemark);
127
+ }
128
+ if (this.options.registeredTrademark !== false) {
129
+ rules.push(registeredTrademark);
130
+ }
131
+ if (this.options.oneHalf !== false) {
132
+ rules.push(oneHalf);
133
+ }
134
+ if (this.options.plusMinus !== false) {
135
+ rules.push(plusMinus);
136
+ }
137
+ if (this.options.notEqual !== false) {
138
+ rules.push(notEqual);
139
+ }
140
+ if (this.options.laquo !== false) {
141
+ rules.push(laquo);
142
+ }
143
+ if (this.options.raquo !== false) {
144
+ rules.push(raquo);
145
+ }
146
+ if (this.options.multiplication !== false) {
147
+ rules.push(multiplication);
148
+ }
149
+ if (this.options.superscriptTwo !== false) {
150
+ rules.push(superscriptTwo);
151
+ }
152
+ if (this.options.superscriptThree !== false) {
153
+ rules.push(superscriptThree);
154
+ }
155
+ if (this.options.oneQuarter !== false) {
156
+ rules.push(oneQuarter);
157
+ }
158
+ if (this.options.threeQuarters !== false) {
159
+ rules.push(threeQuarters);
160
+ }
161
+ return rules;
162
+ },
163
+ });
164
+
165
+ export { Typography, closeDoubleQuote, closeSingleQuote, copyright, Typography as default, ellipsis, emDash, laquo, leftArrow, multiplication, notEqual, oneHalf, oneQuarter, openDoubleQuote, openSingleQuote, plusMinus, raquo, registeredTrademark, rightArrow, servicemark, superscriptThree, superscriptTwo, threeQuarters, trademark };
166
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/typography.ts"],"sourcesContent":["import { Extension, textInputRule } from '@tiptap/core'\n\nexport interface TypographyOptions {\n emDash: false,\n ellipsis: false,\n openDoubleQuote: false,\n closeDoubleQuote: false,\n openSingleQuote: false,\n closeSingleQuote: false,\n leftArrow: false,\n rightArrow: false,\n copyright: false,\n trademark: false,\n servicemark: false,\n registeredTrademark: false,\n oneHalf: false,\n plusMinus: false,\n notEqual: false,\n laquo: false,\n raquo: false,\n multiplication: false,\n superscriptTwo: false,\n superscriptThree: false,\n oneQuarter: false,\n threeQuarters: false,\n}\n\nexport const emDash = textInputRule({\n find: /--$/,\n replace: '—',\n})\n\nexport const ellipsis = textInputRule({\n find: /\\.\\.\\.$/,\n replace: '…',\n})\n\nexport const openDoubleQuote = textInputRule({\n find: /(?:^|[\\s{[(<'\"\\u2018\\u201C])(\")$/,\n replace: '“',\n})\n\nexport const closeDoubleQuote = textInputRule({\n find: /\"$/,\n replace: '”',\n})\n\nexport const openSingleQuote = textInputRule({\n find: /(?:^|[\\s{[(<'\"\\u2018\\u201C])(')$/,\n replace: '‘',\n})\n\nexport const closeSingleQuote = textInputRule({\n find: /'$/,\n replace: '’',\n})\n\nexport const leftArrow = textInputRule({\n find: /<-$/,\n replace: '←',\n})\n\nexport const rightArrow = textInputRule({\n find: /->$/,\n replace: '→',\n})\n\nexport const copyright = textInputRule({\n find: /\\(c\\)$/,\n replace: '©',\n})\n\nexport const trademark = textInputRule({\n find: /\\(tm\\)$/,\n replace: '™',\n})\n\nexport const servicemark = textInputRule({\n find: /\\(sm\\)$/,\n replace: '℠',\n})\n\nexport const registeredTrademark = textInputRule({\n find: /\\(r\\)$/,\n replace: '®',\n})\n\nexport const oneHalf = textInputRule({\n find: /(?:^|\\s)(1\\/2)$/,\n replace: '½',\n})\n\nexport const plusMinus = textInputRule({\n find: /\\+\\/-$/,\n replace: '±',\n})\n\nexport const notEqual = textInputRule({\n find: /!=$/,\n replace: '≠',\n})\n\nexport const laquo = textInputRule({\n find: /<<$/,\n replace: '«',\n})\n\nexport const raquo = textInputRule({\n find: />>$/,\n replace: '»',\n})\n\nexport const multiplication = textInputRule({\n find: /\\d+\\s?([*x])\\s?\\d+$/,\n replace: '×',\n})\n\nexport const superscriptTwo = textInputRule({\n find: /\\^2$/,\n replace: '²',\n})\n\nexport const superscriptThree = textInputRule({\n find: /\\^3$/,\n replace: '³',\n})\n\nexport const oneQuarter = textInputRule({\n find: /(?:^|\\s)(1\\/4)$/,\n replace: '¼',\n})\n\nexport const threeQuarters = textInputRule({\n find: /(?:^|\\s)(3\\/4)$/,\n replace: '¾',\n})\n\nexport const Typography = Extension.create<TypographyOptions>({\n name: 'typography',\n\n addInputRules() {\n const rules = []\n\n if (this.options.emDash !== false) {\n rules.push(emDash)\n }\n\n if (this.options.ellipsis !== false) {\n rules.push(ellipsis)\n }\n\n if (this.options.openDoubleQuote !== false) {\n rules.push(openDoubleQuote)\n }\n\n if (this.options.closeDoubleQuote !== false) {\n rules.push(closeDoubleQuote)\n }\n\n if (this.options.openSingleQuote !== false) {\n rules.push(openSingleQuote)\n }\n\n if (this.options.closeSingleQuote !== false) {\n rules.push(closeSingleQuote)\n }\n\n if (this.options.leftArrow !== false) {\n rules.push(leftArrow)\n }\n\n if (this.options.rightArrow !== false) {\n rules.push(rightArrow)\n }\n\n if (this.options.copyright !== false) {\n rules.push(copyright)\n }\n\n if (this.options.trademark !== false) {\n rules.push(trademark)\n }\n\n if (this.options.servicemark !== false) {\n rules.push(servicemark)\n }\n\n if (this.options.registeredTrademark !== false) {\n rules.push(registeredTrademark)\n }\n\n if (this.options.oneHalf !== false) {\n rules.push(oneHalf)\n }\n\n if (this.options.plusMinus !== false) {\n rules.push(plusMinus)\n }\n\n if (this.options.notEqual !== false) {\n rules.push(notEqual)\n }\n\n if (this.options.laquo !== false) {\n rules.push(laquo)\n }\n\n if (this.options.raquo !== false) {\n rules.push(raquo)\n }\n\n if (this.options.multiplication !== false) {\n rules.push(multiplication)\n }\n\n if (this.options.superscriptTwo !== false) {\n rules.push(superscriptTwo)\n }\n\n if (this.options.superscriptThree !== false) {\n rules.push(superscriptThree)\n }\n\n if (this.options.oneQuarter !== false) {\n rules.push(oneQuarter)\n }\n\n if (this.options.threeQuarters !== false) {\n rules.push(threeQuarters)\n }\n\n return rules\n },\n})\n"],"names":[],"mappings":";;AA2BO,MAAM,MAAM,GAAG,aAAa,CAAC;AAClC,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,OAAO,EAAE,GAAG;AACb,CAAA,EAAC;AAEK,MAAM,QAAQ,GAAG,aAAa,CAAC;AACpC,IAAA,IAAI,EAAE,S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E;AACzC,YAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC3B,SAAA;AAED,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,KAAK,KAAK,EAAE;AAC3C,YAAA,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;AAC7B,SAAA;AAED,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,KAAK,EAAE;AACrC,YAAA,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AACvB,SAAA;AAED,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,KAAK,EAAE;AACxC,YAAA,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AAC1B,SAAA;AAED,QAAA,OAAO,KAAK,CAAA;KACb;AACF,CAAA;;;;"}
@@ -0,0 +1,197 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-typography"] = {}, global.core));
5
+ })(this, (function (exports, core) { 'use strict';
6
+
7
+ const emDash = core.textInputRule({
8
+ find: /--$/,
9
+ replace: '—',
10
+ });
11
+ const ellipsis = core.textInputRule({
12
+ find: /\.\.\.$/,
13
+ replace: '…',
14
+ });
15
+ const openDoubleQuote = core.textInputRule({
16
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(")$/,
17
+ replace: '“',
18
+ });
19
+ const closeDoubleQuote = core.textInputRule({
20
+ find: /"$/,
21
+ replace: '”',
22
+ });
23
+ const openSingleQuote = core.textInputRule({
24
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(')$/,
25
+ replace: '‘',
26
+ });
27
+ const closeSingleQuote = core.textInputRule({
28
+ find: /'$/,
29
+ replace: '’',
30
+ });
31
+ const leftArrow = core.textInputRule({
32
+ find: /<-$/,
33
+ replace: '←',
34
+ });
35
+ const rightArrow = core.textInputRule({
36
+ find: /->$/,
37
+ replace: '→',
38
+ });
39
+ const copyright = core.textInputRule({
40
+ find: /\(c\)$/,
41
+ replace: '©',
42
+ });
43
+ const trademark = core.textInputRule({
44
+ find: /\(tm\)$/,
45
+ replace: '™',
46
+ });
47
+ const servicemark = core.textInputRule({
48
+ find: /\(sm\)$/,
49
+ replace: '℠',
50
+ });
51
+ const registeredTrademark = core.textInputRule({
52
+ find: /\(r\)$/,
53
+ replace: '®',
54
+ });
55
+ const oneHalf = core.textInputRule({
56
+ find: /(?:^|\s)(1\/2)$/,
57
+ replace: '½',
58
+ });
59
+ const plusMinus = core.textInputRule({
60
+ find: /\+\/-$/,
61
+ replace: '±',
62
+ });
63
+ const notEqual = core.textInputRule({
64
+ find: /!=$/,
65
+ replace: '≠',
66
+ });
67
+ const laquo = core.textInputRule({
68
+ find: /<<$/,
69
+ replace: '«',
70
+ });
71
+ const raquo = core.textInputRule({
72
+ find: />>$/,
73
+ replace: '»',
74
+ });
75
+ const multiplication = core.textInputRule({
76
+ find: /\d+\s?([*x])\s?\d+$/,
77
+ replace: '×',
78
+ });
79
+ const superscriptTwo = core.textInputRule({
80
+ find: /\^2$/,
81
+ replace: '²',
82
+ });
83
+ const superscriptThree = core.textInputRule({
84
+ find: /\^3$/,
85
+ replace: '³',
86
+ });
87
+ const oneQuarter = core.textInputRule({
88
+ find: /(?:^|\s)(1\/4)$/,
89
+ replace: '¼',
90
+ });
91
+ const threeQuarters = core.textInputRule({
92
+ find: /(?:^|\s)(3\/4)$/,
93
+ replace: '¾',
94
+ });
95
+ const Typography = core.Extension.create({
96
+ name: 'typography',
97
+ addInputRules() {
98
+ const rules = [];
99
+ if (this.options.emDash !== false) {
100
+ rules.push(emDash);
101
+ }
102
+ if (this.options.ellipsis !== false) {
103
+ rules.push(ellipsis);
104
+ }
105
+ if (this.options.openDoubleQuote !== false) {
106
+ rules.push(openDoubleQuote);
107
+ }
108
+ if (this.options.closeDoubleQuote !== false) {
109
+ rules.push(closeDoubleQuote);
110
+ }
111
+ if (this.options.openSingleQuote !== false) {
112
+ rules.push(openSingleQuote);
113
+ }
114
+ if (this.options.closeSingleQuote !== false) {
115
+ rules.push(closeSingleQuote);
116
+ }
117
+ if (this.options.leftArrow !== false) {
118
+ rules.push(leftArrow);
119
+ }
120
+ if (this.options.rightArrow !== false) {
121
+ rules.push(rightArrow);
122
+ }
123
+ if (this.options.copyright !== false) {
124
+ rules.push(copyright);
125
+ }
126
+ if (this.options.trademark !== false) {
127
+ rules.push(trademark);
128
+ }
129
+ if (this.options.servicemark !== false) {
130
+ rules.push(servicemark);
131
+ }
132
+ if (this.options.registeredTrademark !== false) {
133
+ rules.push(registeredTrademark);
134
+ }
135
+ if (this.options.oneHalf !== false) {
136
+ rules.push(oneHalf);
137
+ }
138
+ if (this.options.plusMinus !== false) {
139
+ rules.push(plusMinus);
140
+ }
141
+ if (this.options.notEqual !== false) {
142
+ rules.push(notEqual);
143
+ }
144
+ if (this.options.laquo !== false) {
145
+ rules.push(laquo);
146
+ }
147
+ if (this.options.raquo !== false) {
148
+ rules.push(raquo);
149
+ }
150
+ if (this.options.multiplication !== false) {
151
+ rules.push(multiplication);
152
+ }
153
+ if (this.options.superscriptTwo !== false) {
154
+ rules.push(superscriptTwo);
155
+ }
156
+ if (this.options.superscriptThree !== false) {
157
+ rules.push(superscriptThree);
158
+ }
159
+ if (this.options.oneQuarter !== false) {
160
+ rules.push(oneQuarter);
161
+ }
162
+ if (this.options.threeQuarters !== false) {
163
+ rules.push(threeQuarters);
164
+ }
165
+ return rules;
166
+ },
167
+ });
168
+
169
+ exports.Typography = Typography;
170
+ exports.closeDoubleQuote = closeDoubleQuote;
171
+ exports.closeSingleQuote = closeSingleQuote;
172
+ exports.copyright = copyright;
173
+ exports["default"] = Typography;
174
+ exports.ellipsis = ellipsis;
175
+ exports.emDash = emDash;
176
+ exports.laquo = laquo;
177
+ exports.leftArrow = leftArrow;
178
+ exports.multiplication = multiplication;
179
+ exports.notEqual = notEqual;
180
+ exports.oneHalf = oneHalf;
181
+ exports.oneQuarter = oneQuarter;
182
+ exports.openDoubleQuote = openDoubleQuote;
183
+ exports.openSingleQuote = openSingleQuote;
184
+ exports.plusMinus = plusMinus;
185
+ exports.raquo = raquo;
186
+ exports.registeredTrademark = registeredTrademark;
187
+ exports.rightArrow = rightArrow;
188
+ exports.servicemark = servicemark;
189
+ exports.superscriptThree = superscriptThree;
190
+ exports.superscriptTwo = superscriptTwo;
191
+ exports.threeQuarters = threeQuarters;
192
+ exports.trademark = trademark;
193
+
194
+ Object.defineProperty(exports, '__esModule', { value: true });
195
+
196
+ }));
197
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/typography.ts"],"sourcesContent":["import { Extension, textInputRule } from '@tiptap/core'\n\nexport interface TypographyOptions {\n emDash: false,\n ellipsis: false,\n openDoubleQuote: false,\n closeDoubleQuote: false,\n openSingleQuote: false,\n closeSingleQuote: false,\n leftArrow: false,\n rightArrow: false,\n copyright: false,\n trademark: false,\n servicemark: false,\n registeredTrademark: false,\n oneHalf: false,\n plusMinus: false,\n notEqual: false,\n laquo: false,\n raquo: false,\n multiplication: false,\n superscriptTwo: false,\n superscriptThree: false,\n oneQuarter: false,\n threeQuarters: false,\n}\n\nexport const emDash = textInputRule({\n find: /--$/,\n replace: '—',\n})\n\nexport const ellipsis = textInputRule({\n find: /\\.\\.\\.$/,\n replace: '…',\n})\n\nexport const openDoubleQuote = textInputRule({\n find: /(?:^|[\\s{[(<'\"\\u2018\\u201C])(\")$/,\n replace: '“',\n})\n\nexport const closeDoubleQuote = textInputRule({\n find: /\"$/,\n replace: '”',\n})\n\nexport const openSingleQuote = textInputRule({\n find: /(?:^|[\\s{[(<'\"\\u2018\\u201C])(')$/,\n replace: '‘',\n})\n\nexport const closeSingleQuote = textInputRule({\n find: /'$/,\n replace: '’',\n})\n\nexport const leftArrow = textInputRule({\n find: /<-$/,\n replace: '←',\n})\n\nexport const rightArrow = textInputRule({\n find: /->$/,\n replace: '→',\n})\n\nexport const copyright = textInputRule({\n find: /\\(c\\)$/,\n replace: '©',\n})\n\nexport const trademark = textInputRule({\n find: /\\(tm\\)$/,\n replace: '™',\n})\n\nexport const servicemark = textInputRule({\n find: /\\(sm\\)$/,\n replace: '℠',\n})\n\nexport const registeredTrademark = textInputRule({\n find: /\\(r\\)$/,\n replace: '®',\n})\n\nexport const oneHalf = textInputRule({\n find: /(?:^|\\s)(1\\/2)$/,\n replace: '½',\n})\n\nexport const plusMinus = textInputRule({\n find: /\\+\\/-$/,\n replace: '±',\n})\n\nexport const notEqual = textInputRule({\n find: /!=$/,\n replace: '≠',\n})\n\nexport const laquo = textInputRule({\n find: /<<$/,\n replace: '«',\n})\n\nexport const raquo = textInputRule({\n find: />>$/,\n replace: '»',\n})\n\nexport const multiplication = textInputRule({\n find: /\\d+\\s?([*x])\\s?\\d+$/,\n replace: '×',\n})\n\nexport const superscriptTwo = textInputRule({\n find: /\\^2$/,\n replace: '²',\n})\n\nexport const superscriptThree = textInputRule({\n find: /\\^3$/,\n replace: '³',\n})\n\nexport const oneQuarter = textInputRule({\n find: /(?:^|\\s)(1\\/4)$/,\n replace: '¼',\n})\n\nexport const threeQuarters = textInputRule({\n find: /(?:^|\\s)(3\\/4)$/,\n replace: '¾',\n})\n\nexport const Typography = Extension.create<TypographyOptions>({\n name: 'typography',\n\n addInputRules() {\n const rules = []\n\n if (this.options.emDash !== false) {\n rules.push(emDash)\n }\n\n if (this.options.ellipsis !== false) {\n rules.push(ellipsis)\n }\n\n if (this.options.openDoubleQuote !== false) {\n rules.push(openDoubleQuote)\n }\n\n if (this.options.closeDoubleQuote !== false) {\n rules.push(closeDoubleQuote)\n }\n\n if (this.options.openSingleQuote !== false) {\n rules.push(openSingleQuote)\n }\n\n if (this.options.closeSingleQuote !== false) {\n rules.push(closeSingleQuote)\n }\n\n if (this.options.leftArrow !== false) {\n rules.push(leftArrow)\n }\n\n if (this.options.rightArrow !== false) {\n rules.push(rightArrow)\n }\n\n if (this.options.copyright !== false) {\n rules.push(copyright)\n }\n\n if (this.options.trademark !== false) {\n rules.push(trademark)\n }\n\n if (this.options.servicemark !== false) {\n rules.push(servicemark)\n }\n\n if (this.options.registeredTrademark !== false) {\n rules.push(registeredTrademark)\n }\n\n if (this.options.oneHalf !== false) {\n rules.push(oneHalf)\n }\n\n if (this.options.plusMinus !== false) {\n rules.push(plusMinus)\n }\n\n if (this.options.notEqual !== false) {\n rules.push(notEqual)\n }\n\n if (this.options.laquo !== false) {\n rules.push(laquo)\n }\n\n if (this.options.raquo !== false) {\n rules.push(raquo)\n }\n\n if (this.options.multiplication !== false) {\n rules.push(multiplication)\n }\n\n if (this.options.superscriptTwo !== false) {\n rules.push(superscriptTwo)\n }\n\n if (this.options.superscriptThree !== false) {\n rules.push(superscriptThree)\n }\n\n if (this.options.oneQuarter !== false) {\n rules.push(oneQuarter)\n }\n\n if (this.options.threeQuarters !== false) {\n rules.push(threeQuarters)\n }\n\n return rules\n },\n})\n"],"names":["textInputRule","Extension"],"mappings":";;;;;;AA2BO,QAAM,MAAM,GAAGA,kBAAa,CAAC;EAClC,IAAA,IAAI,EAAE,KAAK;EACX,IAAA,OAAO,EAAE,GAAG;EACb,CAAA,EAAC;AAEK,QAAM,QAAQ,GAAGA,kBAAa,CAAC;EACpC,IAAA,IAAI,EAAE,SAAS;EACf,IAAA,OAAO,EAAE,GAAG;EACb,CAAA,EAAC;AAEK,QAAM,eAAe,GAAGA,kBAAa,CAAC;EAC3C,IAAA,IAAI,EAAE,kCAAkC;EACxC,IAAA,OAAO,EAAE,GAAG;EACb,CAAA,EAAC;AAEK,QAAM,gBAAgB,GAAGA,kBAAa,CAAC;EAC5C,IAAA,IAAI,EAAE,IAAI;EACV,IAAA,OAAO,EAAE,GAAG;EACb,CAAA,EAAC;AAEK,QAAM,eAAe,GAAGA,kBAAa,CAAC;EAC3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