Closed
Description
In order to more easily maintain and iterate on the MarkdownEditor
component, we'd like to pull it back into GitHub's internal codebase. As this component never left drafts
, we should be able to do this without a breaking change.
The tricky part here is going to be figuring out what to do with the internal dependencies of the component. There are two options, and the correct choice may be different for each dependency:
- Remove it from
@primer/react
and pull it into the internal codebase along with theMarkdownEditor
- Expose it publicly from
@primer/react
so it can be used in the internal codebase and in other places
I've taken a stab at going through the dependency tree and trying to figure out what to do with each thing. Ignoring things that are internal to the component or already public:
- Internal hooks:
-
useResizeObserver
:Let's just expose this publicly by exporting it fromAlready exposed publicly.hooks/index.ts
. I think this is useful and low-risk. -
useSlots
: I think we've previously avoided making this public because it was very unstable, but we seem to have settled on a pattern that works. This would be really useful to have access to in other codebases for making reusable components - let's expose thisinfrom drafts.hooks/index.ts
as well.
-
- Internal components:
-
VisuallyHidden
: This component is private in@primer/react
, but is duplicated already in the Memex codebase.I think we should go ahead and just make it public so we can remove the duplication. Maybe we can expose it fromWe will duplicate this into the internal codebase.@primer/react/drafts
? -
InputLabel
(required byMarkdownEditor.Label
): This is private in Primer and used in the editor to reuse the styling. I don't think it makes sense to expose this so there's not really a good path here except to just duplicate the styles.
-
- Draft components:
-
MarkdownViewer
: Migrate this along withMarkdownEditor
. This is easy - it has no subdependencies that aren't public. -
InlineAutocomplete
: Migrate- This hooks in to
FormControl
, so we need to make that API public as well
- This hooks in to
-
- Utils:
-
character-coordinates
: Migrate, moving internal toInlineAutocomplete
-
- Publicly exposed draft hooks: these are public and used fairly often in other codebases.
I think we should just leave them behind and keep them publicly exposed inWe will migrate these as well:@primer/react/drafts/hooks
:-
useCombobox
-
useDynamicTextareaHeight
-
useIgnoreKeyboardActionsWhileComposing
-
useSafeAsyncCallback
-
useSyntheticChange
-
useUnifiedFileSelect
-
When done we'll also be able to remove the following dependencies:
-
fzy.js
-
@github/markdown-toolbar-element
-
@github/paste-markdown
I propose we do this in three stages:
- Expose the internal code that we want to continue sharing with the editor (
useResizeObserver
,useSlots
, andVisuallyHidden
), and cut a release of@primer/react
- Copy the to-be-migrated pieces (
MarkdownEditor
,MarkdownViewer
,InlineAutocomplete
and dependencies) from this repo into the internal GitHub repo - Delete the migrated code from
@primer/react