-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use consistent module layout and naming #97
Conversation
I based this loosely on what react-redux does, where To get a feel for this change, mostly just look at the changes to |
I don't think changing the naming of the portal registry should affect anyone. We don't have that documented as public interface. Mostly, folks should just be calling |
476c6bc
to
d6c85df
Compare
I actually have a little more to clean up here. Hmm. I am just getting hung up on the React |
d6c85df
to
b62437a
Compare
Okay, this should be ready to go now. |
Move every module in the contexts directory to the components directory. Name each one with a consistent suffix "Context" suffix. From each one, export the context and the context value interface. For every context module, ensure there is a corresponding module with a component that wraps the provider. These modules do not have any suffix. Move the useLayoutGroupEffect hook into the hooks directory. Fix all of the remaining references to the old "deferred layout effects" naming. Export only a single EditorProps type that is the type of the props for the ProseMirror and Editor components. Hooks do not export their types. Make all of the exports in the barrel module consistent. Rename PortalRegistry to NodeViews.
b62437a
to
b519d9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of the export naming changes especially -- makes it a lot easier to read the index.js file when getting oriented in what features are available to import!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be a blocking sentiment, just a slight modification to consider:
It feels a little weird to me that the contexts are in their own files in the components directory. I think I could get behind putting all of the Contexts, split out as they are now, in a contexts directory, and even maybe putting all of the context definitions inside their corresponding component definition files. But contexts are more than just components, and are also used by hooks, which is why it feels a little weird to have them live alongside components.
Anyway, the other comment is more important I think, this one is just something I wanted to throw out there.
I was a bit on the fence, myself, but I've grown to like it. They aren't components, but their |
Until APIs stabilize and users demonstrate a need for more control, remove the layout group and low-level editor exports.
@@ -6,7 +6,7 @@ import { Plugin, PluginKey } from "prosemirror-state"; | |||
*/ | |||
export const ROOT_NODE_KEY = Symbol("@nytimes/react-prosemirror/root-node-key"); | |||
|
|||
export type NodeKey = string | typeof ROOT_NODE_KEY; | |||
export type NodeKey = string | symbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was necessary because React doesn't want to let us make an interface type that's indexable by a unique symbol. With this change, our interface can be this:
export interface NodeViewsContextValue {
[key: NodeKey]: NodeViewRegistration[];
}
If you're unconvinced by the Context argument, I really don't mind moving them back to a |
Hahaha ok, I appreciate that; I am indeed unconvinced. |
f7c30f1
to
20f93b0
Compare
Okay. Contexts are back where you want them! |
I think the readme formatting needs to be adjusted |
Where are you seeing an issue? I just glanced at the rendered markdown and don't see it. |
Oh. Prettier! |
20f93b0
to
7d2beff
Compare
Okay. We're all green. |
@smoores-dev let me know if you find anything else! |
Move every module in the contexts directory to the components directory. Name each one with a consistent suffix "Context" suffix. From each one, export the context and the context value interface.
For every context module, ensure there is a corresponding module with a component that wraps the provider. These modules do not have any suffix.
Move the useLayoutGroupEffect hook into the hooks directory. Fix all of the remaining references to the old "deferred layout effects" naming.
Export only a single EditorProps type that is the type of the props for the ProseMirror and Editor components. Hooks do not export their types.
Make all of the exports in the barrel module consistent.
Rename PortalRegistry to NodeViews.