Skip to content
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

Mismatch between Slate Node type and Leaf/Block types #25

Open
siliconeidolon opened this issue Jan 13, 2021 · 2 comments
Open

Mismatch between Slate Node type and Leaf/Block types #25

siliconeidolon opened this issue Jan 13, 2021 · 2 comments

Comments

@siliconeidolon
Copy link

I may be misunderstanding something here.

In my typescript project I've typed the value of my Slate editor as Array<Node> (Node type coming from Slate).
When I use serialize, the first argument for chunk is typed as BlockType or LeafType as defined in the remark-slate package. Where have these types come from and do they have equivalents from Slate itself?

image

Any guidance appreciated, thanks.

@moretti
Copy link

moretti commented Aug 23, 2021

I'm also interested on this. My current workaround is the following, because I can't even import those types from remark-slate:

import { serialize } from "remark-slate";
import type { Node } from "slate";

type Chunk = Parameters<typeof serialize>[0];

// ...

const [value, setValue] = useState<Node[]>();

useEffect(() => {
  if (!value) return;
  onChange(value.map((v) => serialize(v as Chunk)).join(""));
}, [onChange, value]);

@hanford
Copy link
Owner

hanford commented Aug 23, 2021

Ahh, didn't realize I wasn't exporting the types... Would be happy to merge any PR's that refine the types/typescript if there is any interest in contributing back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants