-
Notifications
You must be signed in to change notification settings - Fork 645
Add MarkdownEditor and MarkdownViewer components
#2182
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
Conversation
…e-autocomplete-component
Fixes not having an `aria-activedescendant` initially defined
…s a combobox when no suggestions are available
…e-autocomplete-component
…own-editor-component
…own-editor-component
| import VisuallyHidden from './_VisuallyHidden' | ||
|
|
||
| interface Props extends React.HTMLProps<HTMLLabelElement> { | ||
| type BaseProps = SxProp & { |
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.
(sorry, I could be wrong): Would removing HTMLProps here throw warning for other html attributes like className or data-testid? Do we need to worry about that?
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.
It would, but those props weren't getting forwarded to the underlying element anyway - so if you passed className you'd expect it to work but it wouldn't have actually worked. In that sense, this type was actually misleading.
In addition, this is a private (internal) component and there wasn't anywhere we were using those types of props internally, so this shouldn't have any effect.
siddharthkp
left a comment
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.
Almost there, left a couple a question for clarification
siddharthkp
left a comment
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.
Feedback implemented, ship it ![]()
…own-editor-component
Closes https://github.com/github/memex/issues/10460 1
Components
MarkdownEditorMarkdownEditoris an input for writing Markdown and previewing the result. Features include:@-mentions,#-references, and emojis (:)❌ Not planned for this PR:
g-emojielement; proposal: https://github.com/github/primer/issues/1152)g-emojielement)IconButtonshould includeTooltipby default #2008)Screen Recording of Usage
Screen.Recording.2022-07-21.at.12.29.08.PM.mov
Props
react/src/drafts/MarkdownEditor/MarkdownEditor.tsx
Lines 28 to 98 in c167ff0
Sub-Components
react/src/drafts/MarkdownEditor/index.ts
Lines 9 to 34 in c167ff0
Usage Example
react/src/drafts/MarkdownEditor/MarkdownEditor.stories.tsx
Lines 251 to 284 in c167ff0
MarkdownViewerMarkdownVieweris a wrapper for displaying rendered Markdown HTML. Features:Additional Work
In addition to the two components, this PR contains many dependent changes & new functionality.
New Hooks
useUnifiedFileSelect: This hook adds an easy to use API for unifying various methods of selecting files (dragging and dropping, pasting, and clicking a button). It combines all the necessary events into a single file select eventuseIgnoreKeyboardInputWhileComposing: When listening for Enter keypresses (ie, to submit forms), it is important to filter out keypresses made while the user is inputting using IME. This is frustratingly difficult to do using browser APIs because the key press events look the same, so this hook aims to make the process much easier. For more details, see https://github.com/github/memex/issues/10800 1useDynamicTextareaHeight: Calculates the optimal height for atextareabased on the contents, automatically adjusting as the user typesuseSafeAsyncCallback: Makes it easier to manipulate state in async callbacks without memory leaks or accidentally calling outdated references.Other Changes
InlineAutocompletecomponent so they can be used by other code (this is necessary foruseDynamicTextareaHeight)useResizeObserverto allow attaching the observer to elements other than the document rootcreateSlotsto use layout effects when getting slots (reduces the number of renders)New Dependencies
fzy.js: Powers fuzzy matching in inline suggestions@github/markdown-toolbar-element: Provides Markdown formatting tools (I eventually want to remove this dependency and just build the logic into the component; I don't think this element is a great implementation for the use case)@github/paste-markdown: Markdown pasting support (pasting tables & links)Merge checklist
Footnotes