├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── src
├── code-block-prism.ts
├── index.ts
└── prism-plugin.ts
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | node_modules
3 | tsconfig.tsbuildinfo
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # :bookmark:CodeBlockPrism extension for TIPTAP Editor
2 | This extension is based on [CodeBlockLowlight](https://tiptap.dev/api/nodes/code-block-lowlight). Most of the code in this repository is taken from there.
3 | ## :cat: What for? Why not CodeBlockLowlight?
4 |
5 | Unfortunately CodeBlockLowlight is based on [LowLight](https://github.com/wooorm/lowlight) and [Highlight.js](https://github.com/highlightjs/highlight.js/),
6 | Highlight.js supports many languages but doesn't support many useful syntax. For example: **JSX, TSX, MDX.**
7 |
8 | The list of supported Prism.js languages can be found here: https://prismjs.com/#supported-languages
9 | ## ✍️ How to use it?
10 | ```js
11 | const editor = useEditor({
12 | extensions: [
13 | Document,
14 | Paragraph,
15 | Text,
16 | CodeBlock,
17 | CodeBlockPrism.configure({
18 | defaultLanguage: 'jsx',
19 | }),
20 | ],
21 | content: ``,
22 | });
23 | ```
24 | ## :hammer_and_wrench: How to style classes generated by PrismJS?
25 | You can define styles via CSS. There are already ready-made themes, for example: [OneDark](https://github.com/AGMStudio/prism-theme-one-dark/blob/master/prism-onedark.css)
26 |
27 |
28 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "extension-code-block-prism",
3 | "version": "0.0.1-alpha",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "extension-code-block-prism",
9 | "version": "0.0.1-alpha",
10 | "license": "MIT",
11 | "dependencies": {
12 | "hast-util-from-html": "1.0.0",
13 | "prismjs": "^1.29.0"
14 | },
15 | "devDependencies": {
16 | "@types/prismjs": "^1.26.0",
17 | "typescript": "^4.9.4"
18 | },
19 | "peerDependencies": {
20 | "@tiptap/core": "^2.0.0-beta.193",
21 | "@tiptap/extension-code-block": "^2.0.0-beta.193"
22 | }
23 | },
24 | "node_modules/@tiptap/core": {
25 | "version": "2.0.0-beta.209",
26 | "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.0.0-beta.209.tgz",
27 | "integrity": "sha512-DOOzfo2XKD5Qt2oEGW33/6ugwSnvpl4WbxtlKdPadLoApk6Kja3K1Eps3pihBgIGmo4tkctkCzmj8wNWS7KeWg==",
28 | "peer": true,
29 | "funding": {
30 | "type": "github",
31 | "url": "https://github.com/sponsors/ueberdosis"
32 | },
33 | "peerDependencies": {
34 | "prosemirror-commands": "^1.3.1",
35 | "prosemirror-keymap": "^1.2.0",
36 | "prosemirror-model": "^1.18.1",
37 | "prosemirror-schema-list": "^1.2.2",
38 | "prosemirror-state": "^1.4.1",
39 | "prosemirror-transform": "^1.7.0",
40 | "prosemirror-view": "^1.28.2"
41 | }
42 | },
43 | "node_modules/@tiptap/extension-code-block": {
44 | "version": "2.0.0-beta.209",
45 | "resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-2.0.0-beta.209.tgz",
46 | "integrity": "sha512-FlMud3yhAilHrcHbW4iUEagAdvpOJW1lTSiiDfbtVpyybjNJQQMa5zhSKi4blG2xBEGXZhqL0XuWDGERNsVawQ==",
47 | "peer": true,
48 | "funding": {
49 | "type": "github",
50 | "url": "https://github.com/sponsors/ueberdosis"
51 | },
52 | "peerDependencies": {
53 | "@tiptap/core": "^2.0.0-beta.193",
54 | "prosemirror-state": "^1.4.1"
55 | }
56 | },
57 | "node_modules/@types/hast": {
58 | "version": "2.3.4",
59 | "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
60 | "integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==",
61 | "dependencies": {
62 | "@types/unist": "*"
63 | }
64 | },
65 | "node_modules/@types/parse5": {
66 | "version": "6.0.3",
67 | "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
68 | "integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
69 | },
70 | "node_modules/@types/prismjs": {
71 | "version": "1.26.0",
72 | "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.0.tgz",
73 | "integrity": "sha512-ZTaqn/qSqUuAq1YwvOFQfVW1AR/oQJlLSZVustdjwI+GZ8kr0MSHBj0tsXPW1EqHubx50gtBEjbPGsdZwQwCjQ==",
74 | "dev": true
75 | },
76 | "node_modules/@types/unist": {
77 | "version": "2.0.6",
78 | "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
79 | "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
80 | },
81 | "node_modules/comma-separated-tokens": {
82 | "version": "2.0.3",
83 | "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
84 | "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",
85 | "funding": {
86 | "type": "github",
87 | "url": "https://github.com/sponsors/wooorm"
88 | }
89 | },
90 | "node_modules/entities": {
91 | "version": "4.4.0",
92 | "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz",
93 | "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==",
94 | "engines": {
95 | "node": ">=0.12"
96 | },
97 | "funding": {
98 | "url": "https://github.com/fb55/entities?sponsor=1"
99 | }
100 | },
101 | "node_modules/hast-util-from-html": {
102 | "version": "1.0.0",
103 | "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-1.0.0.tgz",
104 | "integrity": "sha512-tXYPhk28aMtDjGb4xNDaxtGKqlyZAEPGjN12jPCjczWppdLSrG/0r604a3FMvrd+9nV1HclILQiVqMnuPxN0WQ==",
105 | "dependencies": {
106 | "@types/hast": "^2.0.0",
107 | "hast-util-from-parse5": "^7.0.0",
108 | "parse5": "^7.0.0",
109 | "vfile": "^5.0.0"
110 | },
111 | "funding": {
112 | "type": "opencollective",
113 | "url": "https://opencollective.com/unified"
114 | }
115 | },
116 | "node_modules/hast-util-from-parse5": {
117 | "version": "7.1.0",
118 | "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-7.1.0.tgz",
119 | "integrity": "sha512-m8yhANIAccpU4K6+121KpPP55sSl9/samzQSQGpb0mTExcNh2WlvjtMwSWFhg6uqD4Rr6Nfa8N6TMypQM51rzQ==",
120 | "dependencies": {
121 | "@types/hast": "^2.0.0",
122 | "@types/parse5": "^6.0.0",
123 | "@types/unist": "^2.0.0",
124 | "hastscript": "^7.0.0",
125 | "property-information": "^6.0.0",
126 | "vfile": "^5.0.0",
127 | "vfile-location": "^4.0.0",
128 | "web-namespaces": "^2.0.0"
129 | },
130 | "funding": {
131 | "type": "opencollective",
132 | "url": "https://opencollective.com/unified"
133 | }
134 | },
135 | "node_modules/hast-util-parse-selector": {
136 | "version": "3.1.0",
137 | "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.0.tgz",
138 | "integrity": "sha512-AyjlI2pTAZEOeu7GeBPZhROx0RHBnydkQIXlhnFzDi0qfXTmGUWoCYZtomHbrdrheV4VFUlPcfJ6LMF5T6sQzg==",
139 | "dependencies": {
140 | "@types/hast": "^2.0.0"
141 | },
142 | "funding": {
143 | "type": "opencollective",
144 | "url": "https://opencollective.com/unified"
145 | }
146 | },
147 | "node_modules/hastscript": {
148 | "version": "7.1.0",
149 | "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.1.0.tgz",
150 | "integrity": "sha512-uBjaTTLN0MkCZxY/R2fWUOcu7FRtUVzKRO5P/RAfgsu3yFiMB1JWCO4AjeVkgHxAira1f2UecHK5WfS9QurlWA==",
151 | "dependencies": {
152 | "@types/hast": "^2.0.0",
153 | "comma-separated-tokens": "^2.0.0",
154 | "hast-util-parse-selector": "^3.0.0",
155 | "property-information": "^6.0.0",
156 | "space-separated-tokens": "^2.0.0"
157 | },
158 | "funding": {
159 | "type": "opencollective",
160 | "url": "https://opencollective.com/unified"
161 | }
162 | },
163 | "node_modules/is-buffer": {
164 | "version": "2.0.5",
165 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
166 | "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==",
167 | "funding": [
168 | {
169 | "type": "github",
170 | "url": "https://github.com/sponsors/feross"
171 | },
172 | {
173 | "type": "patreon",
174 | "url": "https://www.patreon.com/feross"
175 | },
176 | {
177 | "type": "consulting",
178 | "url": "https://feross.org/support"
179 | }
180 | ],
181 | "engines": {
182 | "node": ">=4"
183 | }
184 | },
185 | "node_modules/orderedmap": {
186 | "version": "2.1.0",
187 | "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.0.tgz",
188 | "integrity": "sha512-/pIFexOm6S70EPdznemIz3BQZoJ4VTFrhqzu0ACBqBgeLsLxq8e6Jim63ImIfwW/zAD1AlXpRMlOv3aghmo4dA==",
189 | "peer": true
190 | },
191 | "node_modules/parse5": {
192 | "version": "7.1.2",
193 | "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz",
194 | "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==",
195 | "dependencies": {
196 | "entities": "^4.4.0"
197 | },
198 | "funding": {
199 | "url": "https://github.com/inikulin/parse5?sponsor=1"
200 | }
201 | },
202 | "node_modules/prismjs": {
203 | "version": "1.29.0",
204 | "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
205 | "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==",
206 | "engines": {
207 | "node": ">=6"
208 | }
209 | },
210 | "node_modules/property-information": {
211 | "version": "6.2.0",
212 | "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz",
213 | "integrity": "sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg==",
214 | "funding": {
215 | "type": "github",
216 | "url": "https://github.com/sponsors/wooorm"
217 | }
218 | },
219 | "node_modules/prosemirror-commands": {
220 | "version": "1.5.0",
221 | "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.5.0.tgz",
222 | "integrity": "sha512-zL0Fxbj3fh71GPNHn5YdYgYGX2aU2XLecZYk2ekEF0oOD259HcXtM+96VjPVi5o3h4sGUdDfEEhGiREXW6U+4A==",
223 | "peer": true,
224 | "dependencies": {
225 | "prosemirror-model": "^1.0.0",
226 | "prosemirror-state": "^1.0.0",
227 | "prosemirror-transform": "^1.0.0"
228 | }
229 | },
230 | "node_modules/prosemirror-keymap": {
231 | "version": "1.2.0",
232 | "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.0.tgz",
233 | "integrity": "sha512-TdSfu+YyLDd54ufN/ZeD1VtBRYpgZnTPnnbY+4R08DDgs84KrIPEPbJL8t1Lm2dkljFx6xeBE26YWH3aIzkPKg==",
234 | "peer": true,
235 | "dependencies": {
236 | "prosemirror-state": "^1.0.0",
237 | "w3c-keyname": "^2.2.0"
238 | }
239 | },
240 | "node_modules/prosemirror-model": {
241 | "version": "1.18.3",
242 | "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.18.3.tgz",
243 | "integrity": "sha512-yUVejauEY3F1r7PDy4UJKEGeIU+KFc71JQl5sNvG66CLVdKXRjhWpBW6KMeduGsmGOsw85f6EGrs6QxIKOVILA==",
244 | "peer": true,
245 | "dependencies": {
246 | "orderedmap": "^2.0.0"
247 | }
248 | },
249 | "node_modules/prosemirror-schema-list": {
250 | "version": "1.2.2",
251 | "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.2.2.tgz",
252 | "integrity": "sha512-rd0pqSDp86p0MUMKG903g3I9VmElFkQpkZ2iOd3EOVg1vo5Cst51rAsoE+5IPy0LPXq64eGcCYlW1+JPNxOj2w==",
253 | "peer": true,
254 | "dependencies": {
255 | "prosemirror-model": "^1.0.0",
256 | "prosemirror-state": "^1.0.0",
257 | "prosemirror-transform": "^1.0.0"
258 | }
259 | },
260 | "node_modules/prosemirror-state": {
261 | "version": "1.4.2",
262 | "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.2.tgz",
263 | "integrity": "sha512-puuzLD2mz/oTdfgd8msFbe0A42j5eNudKAAPDB0+QJRw8cO1ygjLmhLrg9RvDpf87Dkd6D4t93qdef00KKNacQ==",
264 | "peer": true,
265 | "dependencies": {
266 | "prosemirror-model": "^1.0.0",
267 | "prosemirror-transform": "^1.0.0",
268 | "prosemirror-view": "^1.27.0"
269 | }
270 | },
271 | "node_modules/prosemirror-transform": {
272 | "version": "1.7.0",
273 | "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.7.0.tgz",
274 | "integrity": "sha512-O4T697Cqilw06Zvc3Wm+e237R6eZtJL/xGMliCi+Uo8VL6qHk6afz1qq0zNjT3eZMuYwnP8ZS0+YxX/tfcE9TQ==",
275 | "peer": true,
276 | "dependencies": {
277 | "prosemirror-model": "^1.0.0"
278 | }
279 | },
280 | "node_modules/prosemirror-view": {
281 | "version": "1.29.1",
282 | "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.29.1.tgz",
283 | "integrity": "sha512-OhujVZSDsh0l0PyHNdfaBj6DBkbhYaCfbaxmTeFrMKd/eWS+G6IC+OAbmR9IsLC8Se1HSbphMaXnsXjupHL3UQ==",
284 | "peer": true,
285 | "dependencies": {
286 | "prosemirror-model": "^1.16.0",
287 | "prosemirror-state": "^1.0.0",
288 | "prosemirror-transform": "^1.1.0"
289 | }
290 | },
291 | "node_modules/space-separated-tokens": {
292 | "version": "2.0.2",
293 | "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
294 | "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",
295 | "funding": {
296 | "type": "github",
297 | "url": "https://github.com/sponsors/wooorm"
298 | }
299 | },
300 | "node_modules/typescript": {
301 | "version": "4.9.4",
302 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
303 | "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==",
304 | "dev": true,
305 | "bin": {
306 | "tsc": "bin/tsc",
307 | "tsserver": "bin/tsserver"
308 | },
309 | "engines": {
310 | "node": ">=4.2.0"
311 | }
312 | },
313 | "node_modules/unist-util-stringify-position": {
314 | "version": "3.0.2",
315 | "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz",
316 | "integrity": "sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==",
317 | "dependencies": {
318 | "@types/unist": "^2.0.0"
319 | },
320 | "funding": {
321 | "type": "opencollective",
322 | "url": "https://opencollective.com/unified"
323 | }
324 | },
325 | "node_modules/vfile": {
326 | "version": "5.3.6",
327 | "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.6.tgz",
328 | "integrity": "sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==",
329 | "dependencies": {
330 | "@types/unist": "^2.0.0",
331 | "is-buffer": "^2.0.0",
332 | "unist-util-stringify-position": "^3.0.0",
333 | "vfile-message": "^3.0.0"
334 | },
335 | "funding": {
336 | "type": "opencollective",
337 | "url": "https://opencollective.com/unified"
338 | }
339 | },
340 | "node_modules/vfile-location": {
341 | "version": "4.0.1",
342 | "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz",
343 | "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==",
344 | "dependencies": {
345 | "@types/unist": "^2.0.0",
346 | "vfile": "^5.0.0"
347 | },
348 | "funding": {
349 | "type": "opencollective",
350 | "url": "https://opencollective.com/unified"
351 | }
352 | },
353 | "node_modules/vfile-message": {
354 | "version": "3.1.3",
355 | "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.3.tgz",
356 | "integrity": "sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==",
357 | "dependencies": {
358 | "@types/unist": "^2.0.0",
359 | "unist-util-stringify-position": "^3.0.0"
360 | },
361 | "funding": {
362 | "type": "opencollective",
363 | "url": "https://opencollective.com/unified"
364 | }
365 | },
366 | "node_modules/w3c-keyname": {
367 | "version": "2.2.6",
368 | "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.6.tgz",
369 | "integrity": "sha512-f+fciywl1SJEniZHD6H+kUO8gOnwIr7f4ijKA6+ZvJFjeGi1r4PDLl53Ayud9O/rk64RqgoQine0feoeOU0kXg==",
370 | "peer": true
371 | },
372 | "node_modules/web-namespaces": {
373 | "version": "2.0.1",
374 | "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
375 | "integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==",
376 | "funding": {
377 | "type": "github",
378 | "url": "https://github.com/sponsors/wooorm"
379 | }
380 | }
381 | },
382 | "dependencies": {
383 | "@tiptap/core": {
384 | "version": "2.0.0-beta.209",
385 | "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.0.0-beta.209.tgz",
386 | "integrity": "sha512-DOOzfo2XKD5Qt2oEGW33/6ugwSnvpl4WbxtlKdPadLoApk6Kja3K1Eps3pihBgIGmo4tkctkCzmj8wNWS7KeWg==",
387 | "peer": true,
388 | "requires": {}
389 | },
390 | "@tiptap/extension-code-block": {
391 | "version": "2.0.0-beta.209",
392 | "resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-2.0.0-beta.209.tgz",
393 | "integrity": "sha512-FlMud3yhAilHrcHbW4iUEagAdvpOJW1lTSiiDfbtVpyybjNJQQMa5zhSKi4blG2xBEGXZhqL0XuWDGERNsVawQ==",
394 | "peer": true,
395 | "requires": {}
396 | },
397 | "@types/hast": {
398 | "version": "2.3.4",
399 | "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
400 | "integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==",
401 | "requires": {
402 | "@types/unist": "*"
403 | }
404 | },
405 | "@types/parse5": {
406 | "version": "6.0.3",
407 | "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz",
408 | "integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
409 | },
410 | "@types/prismjs": {
411 | "version": "1.26.0",
412 | "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.0.tgz",
413 | "integrity": "sha512-ZTaqn/qSqUuAq1YwvOFQfVW1AR/oQJlLSZVustdjwI+GZ8kr0MSHBj0tsXPW1EqHubx50gtBEjbPGsdZwQwCjQ==",
414 | "dev": true
415 | },
416 | "@types/unist": {
417 | "version": "2.0.6",
418 | "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
419 | "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
420 | },
421 | "comma-separated-tokens": {
422 | "version": "2.0.3",
423 | "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
424 | "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="
425 | },
426 | "entities": {
427 | "version": "4.4.0",
428 | "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz",
429 | "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA=="
430 | },
431 | "hast-util-from-html": {
432 | "version": "1.0.0",
433 | "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-1.0.0.tgz",
434 | "integrity": "sha512-tXYPhk28aMtDjGb4xNDaxtGKqlyZAEPGjN12jPCjczWppdLSrG/0r604a3FMvrd+9nV1HclILQiVqMnuPxN0WQ==",
435 | "requires": {
436 | "@types/hast": "^2.0.0",
437 | "hast-util-from-parse5": "^7.0.0",
438 | "parse5": "^7.0.0",
439 | "vfile": "^5.0.0"
440 | }
441 | },
442 | "hast-util-from-parse5": {
443 | "version": "7.1.0",
444 | "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-7.1.0.tgz",
445 | "integrity": "sha512-m8yhANIAccpU4K6+121KpPP55sSl9/samzQSQGpb0mTExcNh2WlvjtMwSWFhg6uqD4Rr6Nfa8N6TMypQM51rzQ==",
446 | "requires": {
447 | "@types/hast": "^2.0.0",
448 | "@types/parse5": "^6.0.0",
449 | "@types/unist": "^2.0.0",
450 | "hastscript": "^7.0.0",
451 | "property-information": "^6.0.0",
452 | "vfile": "^5.0.0",
453 | "vfile-location": "^4.0.0",
454 | "web-namespaces": "^2.0.0"
455 | }
456 | },
457 | "hast-util-parse-selector": {
458 | "version": "3.1.0",
459 | "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.0.tgz",
460 | "integrity": "sha512-AyjlI2pTAZEOeu7GeBPZhROx0RHBnydkQIXlhnFzDi0qfXTmGUWoCYZtomHbrdrheV4VFUlPcfJ6LMF5T6sQzg==",
461 | "requires": {
462 | "@types/hast": "^2.0.0"
463 | }
464 | },
465 | "hastscript": {
466 | "version": "7.1.0",
467 | "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.1.0.tgz",
468 | "integrity": "sha512-uBjaTTLN0MkCZxY/R2fWUOcu7FRtUVzKRO5P/RAfgsu3yFiMB1JWCO4AjeVkgHxAira1f2UecHK5WfS9QurlWA==",
469 | "requires": {
470 | "@types/hast": "^2.0.0",
471 | "comma-separated-tokens": "^2.0.0",
472 | "hast-util-parse-selector": "^3.0.0",
473 | "property-information": "^6.0.0",
474 | "space-separated-tokens": "^2.0.0"
475 | }
476 | },
477 | "is-buffer": {
478 | "version": "2.0.5",
479 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
480 | "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
481 | },
482 | "orderedmap": {
483 | "version": "2.1.0",
484 | "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.0.tgz",
485 | "integrity": "sha512-/pIFexOm6S70EPdznemIz3BQZoJ4VTFrhqzu0ACBqBgeLsLxq8e6Jim63ImIfwW/zAD1AlXpRMlOv3aghmo4dA==",
486 | "peer": true
487 | },
488 | "parse5": {
489 | "version": "7.1.2",
490 | "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz",
491 | "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==",
492 | "requires": {
493 | "entities": "^4.4.0"
494 | }
495 | },
496 | "prismjs": {
497 | "version": "1.29.0",
498 | "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
499 | "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q=="
500 | },
501 | "property-information": {
502 | "version": "6.2.0",
503 | "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz",
504 | "integrity": "sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg=="
505 | },
506 | "prosemirror-commands": {
507 | "version": "1.5.0",
508 | "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.5.0.tgz",
509 | "integrity": "sha512-zL0Fxbj3fh71GPNHn5YdYgYGX2aU2XLecZYk2ekEF0oOD259HcXtM+96VjPVi5o3h4sGUdDfEEhGiREXW6U+4A==",
510 | "peer": true,
511 | "requires": {
512 | "prosemirror-model": "^1.0.0",
513 | "prosemirror-state": "^1.0.0",
514 | "prosemirror-transform": "^1.0.0"
515 | }
516 | },
517 | "prosemirror-keymap": {
518 | "version": "1.2.0",
519 | "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.0.tgz",
520 | "integrity": "sha512-TdSfu+YyLDd54ufN/ZeD1VtBRYpgZnTPnnbY+4R08DDgs84KrIPEPbJL8t1Lm2dkljFx6xeBE26YWH3aIzkPKg==",
521 | "peer": true,
522 | "requires": {
523 | "prosemirror-state": "^1.0.0",
524 | "w3c-keyname": "^2.2.0"
525 | }
526 | },
527 | "prosemirror-model": {
528 | "version": "1.18.3",
529 | "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.18.3.tgz",
530 | "integrity": "sha512-yUVejauEY3F1r7PDy4UJKEGeIU+KFc71JQl5sNvG66CLVdKXRjhWpBW6KMeduGsmGOsw85f6EGrs6QxIKOVILA==",
531 | "peer": true,
532 | "requires": {
533 | "orderedmap": "^2.0.0"
534 | }
535 | },
536 | "prosemirror-schema-list": {
537 | "version": "1.2.2",
538 | "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.2.2.tgz",
539 | "integrity": "sha512-rd0pqSDp86p0MUMKG903g3I9VmElFkQpkZ2iOd3EOVg1vo5Cst51rAsoE+5IPy0LPXq64eGcCYlW1+JPNxOj2w==",
540 | "peer": true,
541 | "requires": {
542 | "prosemirror-model": "^1.0.0",
543 | "prosemirror-state": "^1.0.0",
544 | "prosemirror-transform": "^1.0.0"
545 | }
546 | },
547 | "prosemirror-state": {
548 | "version": "1.4.2",
549 | "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.2.tgz",
550 | "integrity": "sha512-puuzLD2mz/oTdfgd8msFbe0A42j5eNudKAAPDB0+QJRw8cO1ygjLmhLrg9RvDpf87Dkd6D4t93qdef00KKNacQ==",
551 | "peer": true,
552 | "requires": {
553 | "prosemirror-model": "^1.0.0",
554 | "prosemirror-transform": "^1.0.0",
555 | "prosemirror-view": "^1.27.0"
556 | }
557 | },
558 | "prosemirror-transform": {
559 | "version": "1.7.0",
560 | "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.7.0.tgz",
561 | "integrity": "sha512-O4T697Cqilw06Zvc3Wm+e237R6eZtJL/xGMliCi+Uo8VL6qHk6afz1qq0zNjT3eZMuYwnP8ZS0+YxX/tfcE9TQ==",
562 | "peer": true,
563 | "requires": {
564 | "prosemirror-model": "^1.0.0"
565 | }
566 | },
567 | "prosemirror-view": {
568 | "version": "1.29.1",
569 | "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.29.1.tgz",
570 | "integrity": "sha512-OhujVZSDsh0l0PyHNdfaBj6DBkbhYaCfbaxmTeFrMKd/eWS+G6IC+OAbmR9IsLC8Se1HSbphMaXnsXjupHL3UQ==",
571 | "peer": true,
572 | "requires": {
573 | "prosemirror-model": "^1.16.0",
574 | "prosemirror-state": "^1.0.0",
575 | "prosemirror-transform": "^1.1.0"
576 | }
577 | },
578 | "space-separated-tokens": {
579 | "version": "2.0.2",
580 | "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
581 | "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="
582 | },
583 | "typescript": {
584 | "version": "4.9.4",
585 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
586 | "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==",
587 | "dev": true
588 | },
589 | "unist-util-stringify-position": {
590 | "version": "3.0.2",
591 | "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz",
592 | "integrity": "sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==",
593 | "requires": {
594 | "@types/unist": "^2.0.0"
595 | }
596 | },
597 | "vfile": {
598 | "version": "5.3.6",
599 | "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.6.tgz",
600 | "integrity": "sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==",
601 | "requires": {
602 | "@types/unist": "^2.0.0",
603 | "is-buffer": "^2.0.0",
604 | "unist-util-stringify-position": "^3.0.0",
605 | "vfile-message": "^3.0.0"
606 | }
607 | },
608 | "vfile-location": {
609 | "version": "4.0.1",
610 | "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-4.0.1.tgz",
611 | "integrity": "sha512-JDxPlTbZrZCQXogGheBHjbRWjESSPEak770XwWPfw5mTc1v1nWGLB/apzZxsx8a0SJVfF8HK8ql8RD308vXRUw==",
612 | "requires": {
613 | "@types/unist": "^2.0.0",
614 | "vfile": "^5.0.0"
615 | }
616 | },
617 | "vfile-message": {
618 | "version": "3.1.3",
619 | "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.3.tgz",
620 | "integrity": "sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==",
621 | "requires": {
622 | "@types/unist": "^2.0.0",
623 | "unist-util-stringify-position": "^3.0.0"
624 | }
625 | },
626 | "w3c-keyname": {
627 | "version": "2.2.6",
628 | "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.6.tgz",
629 | "integrity": "sha512-f+fciywl1SJEniZHD6H+kUO8gOnwIr7f4ijKA6+ZvJFjeGi1r4PDLl53Ayud9O/rk64RqgoQine0feoeOU0kXg==",
630 | "peer": true
631 | },
632 | "web-namespaces": {
633 | "version": "2.0.1",
634 | "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
635 | "integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ=="
636 | }
637 | }
638 | }
639 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tiptap-extension-code-block-prism",
3 | "description": "code block extension for tiptap",
4 | "version": "0.0.2e",
5 | "homepage": "https://tiptap.dev",
6 | "type": "module",
7 | "author": "DepressingUtopian",
8 | "keywords": [
9 | "tiptap",
10 | "extension",
11 | "prism js",
12 | "jsx"
13 | ],
14 | "license": "MIT",
15 | "main": "dist/index.js",
16 | "types": "dist/index.d.ts",
17 | "files": [
18 | "src",
19 | "dist"
20 | ],
21 | "exports": {
22 | ".": {
23 | "types": "./dist/index.d.ts",
24 | "import": "./dist/index.js",
25 | "require": "./dist/index.js"
26 | }
27 | },
28 | "peerDependencies": {
29 | "@tiptap/core": "^2.0.0-beta.193",
30 | "@tiptap/extension-code-block": "^2.0.0-beta.193"
31 | },
32 | "dependencies": {
33 | "hast-util-from-html": "1.0.0",
34 | "prismjs": "^1.29.0"
35 | },
36 | "repository": {
37 | "type": "git",
38 | "url": "git+https://github.com/DepressingUtopian/tiptap-extension-code-block-prism.git",
39 | "directory": "src"
40 | },
41 | "devDependencies": {
42 | "@types/prismjs": "^1.26.0",
43 | "typescript": "^4.9.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/code-block-prism.ts:
--------------------------------------------------------------------------------
1 | import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block'
2 |
3 | import { PrismPlugin } from './prism-plugin'
4 |
5 | export interface CodeBlockPrismOptions extends CodeBlockOptions {
6 | defaultLanguage: string | null | undefined,
7 | }
8 |
9 | export const CodeBlockPrism = CodeBlock.extend({
10 | addOptions() {
11 | return {
12 | ...this.parent?.(),
13 | defaultLanguage: null,
14 | }
15 | },
16 |
17 | addProseMirrorPlugins() {
18 | return [
19 | ...this.parent?.() || [],
20 | PrismPlugin({
21 | name: this.name,
22 | defaultLanguage: this.options.defaultLanguage,
23 | }),
24 | ]
25 | },
26 | })
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { CodeBlockPrism } from './code-block-prism'
2 |
3 | export * from './code-block-prism'
4 |
5 | export default CodeBlockPrism
--------------------------------------------------------------------------------
/src/prism-plugin.ts:
--------------------------------------------------------------------------------
1 | import { findChildren } from '@tiptap/core';
2 | import {
3 | Node as ProsemirrorNode,
4 | } from 'prosemirror-model';
5 | import { Plugin, PluginKey } from 'prosemirror-state';
6 | import { Decoration, DecorationSet } from 'prosemirror-view';
7 | import Prism from 'prismjs';
8 |
9 | import { fromHtml } from 'hast-util-from-html';
10 |
11 | import 'prismjs/components/prism-jsx';
12 |
13 | function parseNodes(
14 | nodes: any[],
15 | className: string[] = []
16 | ): { text: string; classes: string[] }[] {
17 | return nodes
18 | .map((node) => {
19 | const classes = [
20 | ...className,
21 | ...(node.properties ? node.properties.className : []),
22 | ];
23 |
24 | if (node.children) {
25 | return parseNodes(node.children, classes);
26 | }
27 |
28 | return {
29 | text: node.value,
30 | classes,
31 | };
32 | })
33 | .flat();
34 | }
35 |
36 | function getHighlightNodes(html: string) {
37 | return fromHtml(html, { fragment: true }).children;
38 | }
39 |
40 | function registeredLang(aliasOrLanguage: string) {
41 | const allSupportLang = Object.keys(Prism.languages).filter(
42 | (id) => typeof Prism.languages[id] === 'object'
43 | );
44 | return Boolean(allSupportLang.find((x) => x === aliasOrLanguage));
45 | }
46 |
47 | function getDecorations({
48 | doc,
49 | name,
50 | defaultLanguage,
51 | }: {
52 | doc: ProsemirrorNode;
53 | name: string;
54 | defaultLanguage: string | null | undefined;
55 | }) {
56 | const decorations: Decoration[] = [];
57 |
58 | findChildren(doc, (node) => node.type.name === name).forEach((block) => {
59 | let from = block.pos + 1;
60 | const language = block.node.attrs.language || defaultLanguage;
61 | let html: string = '';
62 |
63 | try{
64 | if(!registeredLang(language)) {
65 | import("prismjs/components/prism-"+language);
66 | }
67 | html = Prism.highlight(block.node.textContent, Prism.languages[language], language);
68 | }
69 | catch(err: any){
70 | console.error(err.message+": \""+language+"\"");
71 | html = Prism.highlight(block.node.textContent, Prism.languages.javascript, 'js');
72 | }
73 |
74 | const nodes = getHighlightNodes(html);
75 |
76 | parseNodes(nodes).forEach((node) => {
77 | const to = from + node.text.length;
78 |
79 | if (node.classes.length) {
80 | const decoration = Decoration.inline(from, to, {
81 | class: node.classes.join(' '),
82 | });
83 |
84 | decorations.push(decoration);
85 | }
86 |
87 | from = to;
88 | });
89 | });
90 |
91 | return DecorationSet.create(doc, decorations);
92 | }
93 |
94 | export function PrismPlugin({
95 | name,
96 | defaultLanguage,
97 | }: {
98 | name: string;
99 | defaultLanguage: string | null | undefined;
100 | }) {
101 | if (
102 | !defaultLanguage
103 | ) {
104 | throw Error(
105 | 'You must specify the defaultLanguage parameter'
106 | );
107 | }
108 |
109 | const prismjsPlugin: Plugin = new Plugin({
110 | key: new PluginKey('prism'),
111 |
112 | state: {
113 | init: (_, { doc }) =>
114 | getDecorations({
115 | doc,
116 | name,
117 | defaultLanguage,
118 | }),
119 | apply: (transaction, decorationSet, oldState, newState) => {
120 | const oldNodeName = oldState.selection.$head.parent.type.name;
121 | const newNodeName = newState.selection.$head.parent.type.name;
122 | const oldNodes = findChildren(
123 | oldState.doc,
124 | (node) => node.type.name === name
125 | );
126 | const newNodes = findChildren(
127 | newState.doc,
128 | (node) => node.type.name === name
129 | );
130 |
131 | if (
132 | transaction.docChanged &&
133 | // Apply decorations if:
134 | // selection includes named node,
135 | ([oldNodeName, newNodeName].includes(name) ||
136 | // OR transaction adds/removes named node,
137 | newNodes.length !== oldNodes.length ||
138 | // OR transaction has changes that completely encapsulte a node
139 | // (for example, a transaction that affects the entire document).
140 | // Such transactions can happen during collab syncing via y-prosemirror, for example.
141 | transaction.steps.some((step) => {
142 | // @ts-ignore
143 | return (
144 | // @ts-ignore
145 | step.from !== undefined &&
146 | // @ts-ignore
147 | step.to !== undefined &&
148 | oldNodes.some((node) => {
149 | // @ts-ignore
150 | return (
151 | // @ts-ignore
152 | node.pos >= step.from &&
153 | // @ts-ignore
154 | node.pos + node.node.nodeSize <= step.to
155 | );
156 | })
157 | );
158 | }))
159 | ) {
160 | return getDecorations({
161 | doc: transaction.doc,
162 | name,
163 | defaultLanguage,
164 | });
165 | }
166 |
167 | return decorationSet.map(transaction.mapping, transaction.doc);
168 | },
169 | },
170 |
171 | props: {
172 | decorations(state) {
173 | return prismjsPlugin.getState(state);
174 | },
175 | },
176 | });
177 |
178 | return prismjsPlugin;
179 | }
180 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig to read more about this file */
4 |
5 | /* Projects */
6 | "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12 |
13 | /* Language and Environment */
14 | "target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16 | // "jsx": "preserve", /* Specify what JSX code is generated. */
17 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26 |
27 | /* Modules */
28 | "module": "ES2020", /* Specify what module code is generated. */
29 | "rootDir": "./src", /* Specify the root folder within your source files. */
30 | "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38 | // "resolveJsonModule": true, /* Enable importing .json files. */
39 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */
40 |
41 | /* JavaScript Support */
42 | "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45 |
46 | /* Emit */
47 | "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48 | "declarationMap": true, /* Create sourcemaps for d.ts files. */
49 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52 | "outDir": "./dist", /* Specify an output folder for all emitted files. */
53 | // "removeComments": true, /* Disable emitting comments. */
54 | // "noEmit": true, /* Disable emitting files from a compilation. */
55 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63 | // "newLine": "crlf", /* Set the newline character for emitting files. */
64 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70 |
71 | /* Interop Constraints */
72 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77 |
78 | /* Type Checking */
79 | "strict": true, /* Enable all strict type-checking options. */
80 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98 |
99 | /* Completeness */
100 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101 | "skipLibCheck": true /* Skip type checking all .d.ts files. */
102 | }
103 | }
104 |
--------------------------------------------------------------------------------