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

Allow passing custom editor creator to slate-hyperscript createEditor #4555

Merged
merged 5 commits into from
Oct 12, 2021

Conversation

bryanph
Copy link
Contributor

@bryanph bryanph commented Sep 28, 2021

Description
Just like in slate's core, I use slate-hyperscript to perform tests for my particular editor. This change makes it easier to create your own testing setup by allowing you to pass your own slate Editor instance to slate-hyperscript's createEditor. This way you can simply reuse the setup code that's in there without needing to duplicate that code in your own setup.

Issue
Fixes: (link to issue)

Example
createHyperscript would then look like this

const jsx = createHyperscript({
  creators: {
    editor: createEditor(aFunctionThatReturnsAnEditorObject)
  },
  elements: {
    block: { type: 'block' },
    inline: { type: 'inline' }
  }
})

createEditor then takes care of setting the anchor and focus properly given the JSX.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Sep 28, 2021

🦋 Changeset detected

Latest commit: 9db4e15

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-hyperscript Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bryanph bryanph force-pushed the slate-hyperscript-add-makeEditor branch from 4a2219c to 845cadf Compare September 28, 2021 14:23
…Editor()

Makes it easier to create your own testing setup
@bryanph bryanph force-pushed the slate-hyperscript-add-makeEditor branch from 845cadf to eecef4e Compare September 28, 2021 14:24
Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changeset when you get a chance, thanks!

@bryanph
Copy link
Contributor Author

bryanph commented Oct 3, 2021

@dylans done!

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

Successfully merging this pull request may close these issues.

None yet

2 participants