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

Split out slate-dom package from slate-react #5731

Closed
bmingles opened this issue Sep 26, 2024 · 1 comment · Fixed by #5734
Closed

Split out slate-dom package from slate-react #5731

bmingles opened this issue Sep 26, 2024 · 1 comment · Fixed by #5734

Comments

@bmingles
Copy link
Contributor

Problem
It looks like the slate-react package contains a fair amount of non-react code. Conceptually it's more like a combination of DOM + React specific features. It would be nice if the DOM only utils lived in a package that didn't have a dependency on React at all. This could make it easier for non-React web libraries to build on top of slate without re-inventing the DOM parts.

Solution
A high level proposed solution would be to:

  • Create a new slate-dom package in the monorepo
  • Move src/utils from slate-react to slate-dom. There are a very few things that would need to stay such as some React constants, but for the most part there are very few React dependencies in this folder.
  • Move most of plugin/react-editor to the new package and rename to plugin/dom-editor. There is a part of the onChange implementation that would still need to be implemented by slate-react. The react-editor plugin could now call the dom-editor plugin for most of its implementation and fill in anything remaining that is React specific
  • commonTypes to be split into React vs DOM specific concerns and live in respective package

Components would stay in slate-react, although there may be some places where logic could be refactored and made suitable for the slate-dom package. e.g. portions of the event handling code in Editable for onInputChange and onSelectionChange. There are likely some other places as well, but the above bulleted list could be a good starting point to make it easier for library authors.

I'd be interested in submitting a PR for this, but I wanted to get a general sense if this would be a welcome improvement, or if it is fundamentally flawed somehow in relation to goals of Slate.

@bmingles
Copy link
Contributor Author

@dylans very happy to see this. When should the npm publish of the new package happen?

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

Successfully merging a pull request may close this issue.

1 participant