You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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:
slate-dom
package in the monoreposrc/utils
fromslate-react
toslate-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.plugin/react-editor
to the new package and rename toplugin/dom-editor
. There is a part of theonChange
implementation that would still need to be implemented byslate-react
. Thereact-editor
plugin could now call thedom-editor
plugin for most of its implementation and fill in anything remaining that is React specificComponents would stay in
slate-react
, although there may be some places where logic could be refactored and made suitable for theslate-dom
package. e.g. portions of the event handling code inEditable
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.
The text was updated successfully, but these errors were encountered: