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

Unable to create custom hyperscript shorthands? ([email protected]) #5599

Open
beorn opened this issue Feb 2, 2024 · 1 comment
Open

Unable to create custom hyperscript shorthands? ([email protected]) #5599

beorn opened this issue Feb 2, 2024 · 1 comment
Labels

Comments

@beorn
Copy link
Contributor

beorn commented Feb 2, 2024

Using I don't seem to be able to create any custom elements (or HyperscriptShorthands). The documentation is "sparse" :) and the way I think it's supposed to work, the types seem broken:

import { createHyperscript } from "slate-hyperscript"

const h = createHyperscript({
  elements: {
    p: { type: "paragraph" },
    item: { type: "item" },
    text: {}
  }
})

h(
  "editor",
  {},
  h("cursor"),
  h("item", {}, h("p", {}, "p1")),
)

This results in the attached TS2345 error from TS for the h("item") and h("p") tags.

Screenshot 2024-02-01 at 16 44 53
@beorn beorn added the bug label Feb 2, 2024
@dylans
Copy link
Collaborator

dylans commented Feb 8, 2024

I think the tests have perhaps the best examples for using slate-hyperscript, e.g. https://github.com/ianstormtaylor/slate/blob/main/packages/slate/test/operations/set_node/remove-undefined.tsx

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

No branches or pull requests

2 participants