fix extension import (backend)
In firebase, typescript compiles imports into common js imports like `const StarterKit = require("@tiptap/starter-kit")` Even though StarterKit is exported from the cjs file, it gets imported as undefined. But it magically works if we import * If you're reading this in the future, consider replacing StarterKit with the entire list of extensions.
This commit is contained in:
parent
db22da3e2c
commit
f354c9e118
|
@ -8,6 +8,7 @@
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@tiptap/starter-kit": "^2.0.0-beta.190",
|
||||||
"lodash": "4.17.21"
|
"lodash": "4.17.21"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { MAX_TAG_LENGTH } from '../contract'
|
import { MAX_TAG_LENGTH } from '../contract'
|
||||||
import { generateText, JSONContent } from '@tiptap/core'
|
import { generateText, JSONContent, Extension } from '@tiptap/core'
|
||||||
import StarterKit from '@tiptap/starter-kit'
|
import * as StarterKit from '@tiptap/starter-kit' // needed for cjs import to work on firebase
|
||||||
|
|
||||||
export function parseTags(text: string) {
|
export function parseTags(text: string) {
|
||||||
const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
|
const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
|
||||||
|
@ -31,5 +31,7 @@ export function parseWordsAsTags(text: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function richTextToString(text: JSONContent | string) {
|
export function richTextToString(text: JSONContent | string) {
|
||||||
return typeof text === 'string' ? text : generateText(text, [StarterKit])
|
return typeof text === 'string'
|
||||||
|
? text
|
||||||
|
: generateText(text, [StarterKit as unknown as Extension])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user