New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught Error: Cannot find transform for node Node<"unknown"> #3
Comments
Hello, and thanks for reaching me out with your issue. Does this error appears if you add a [
{
"type": "p",
"children": [
{
"text": "Das Passwort darf nicht mit dem Benutzernamen übereinstimmen"
}
]
}
] |
https://payloadcms.com/community-help/github/node-of-richtext-is-missing-type I found this article in payload cms, by default payload doesn't set any type if no type is selected. |
By default import {createElementMatcher, createElementTransform} from "slate-to-react"
const isUnknownElement = createElementMatcher(node => "type" in node === false)
const FallbackElement = createElementTransform(isUnknownElement, ({key, attributes, children}) => (
<p {...attributes} key={key}>
{children}
</p>
)) I should probably make an improvement upon this area. |
Where do I have to have insert this, would it be possible for you to create an update to your library? |
As documentation says (see the 5th example), you can use custom transforms with import type {FC} from "react"
import {SlateView, type Node} from "slate-to-react"
import {FallbackElement} from "./FallbackElement.js" // Previously created fallback element
interface Props {
nodes: Node[]
}
export const MyComponent: FC<Props> = ({nodes}) => (
<SlateView
nodes={nodes}
transforms={{elements: [FallbackElement]}}
/>
) The whole point of this library is to have bunch of utilities to create customizable Slate views. So, you can and you likely will create your own transforms to keep the look of your slate views in touch with the styles of your application.
I think I will add support for generic |
This error gets thrown when my node has no formatting.
With slate nodes that have formatting such as bold no error occurs.
Am I doing anything wrong?
I'm using it this way. slateResponse is the following arry/slate node.
[{"children":[{"text":"Das Passwort darf nicht mit dem Benutzernamen übereinstimmen"}]}]
Uncaught Error: Cannot find transform for node Node<"unknown">
i BaseError.ts:10
f NoMatcherError.ts:13
ee transformNodes.tsx:75
ne transformNodes.tsx:95
re transformNodes.tsx:113
oe transformNodes.tsx:156
se useSlateToReact.ts:19
React 3
se useSlateToReact.ts:19
ie SlateView.tsx:24
React 12
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
__require chunk-ROME4SDB.js:11
js index.js:6
__require chunk-ROME4SDB.js:11
React 2
__require chunk-ROME4SDB.js:11
js React
__require chunk-ROME4SDB.js:11
js React
__require chunk-ROME4SDB.js:11
react-dom_client.js:38
The text was updated successfully, but these errors were encountered: