-
Notifications
You must be signed in to change notification settings - Fork 536
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
Add MarkdownEditor
and MarkdownViewer
components
#2182
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
@@ -3,25 +3,41 @@ import {Box} from '.' | |||
import {SxProp} from './sx' | |||
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.
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
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
MarkdownEditor
MarkdownEditor
is an input for writing Markdown and previewing the result. Features include:@
-mentions,#
-references, and emojis (:
)❌ Not planned for this PR:
g-emoji
element; proposal: https://github.com/github/primer/issues/1152)g-emoji
element)IconButton
should includeTooltip
by 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
MarkdownViewer
MarkdownViewer
is 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 atextarea
based 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
InlineAutocomplete
component so they can be used by other code (this is necessary foruseDynamicTextareaHeight
)useResizeObserver
to allow attaching the observer to elements other than the document rootcreateSlots
to 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
Link only accessible to GitHub employees ↩ ↩2