Skip to content

[Markdown editor] drag and drop api, functionality#3748

Merged
chandlerprall merged 13 commits intoelastic:feature/markdown-editorfrom
chandlerprall:feature/markdown-editor-drag-n-drop
Jul 29, 2020
Merged

[Markdown editor] drag and drop api, functionality#3748
chandlerprall merged 13 commits intoelastic:feature/markdown-editorfrom
chandlerprall:feature/markdown-editor-drag-n-drop

Conversation

@chandlerprall
Copy link
Copy Markdown
Contributor

@chandlerprall chandlerprall commented Jul 15, 2020

Summary

Adds proper drag&drop handling to the markdown editor.

  • added support to the editor for processing drop events
  • example specifies a drop handler to insert image markdown for JPGs

There is some clumsiness around the text insertion as it naively injects the markdown string at the cursor location. Next steps are to properly allow e.g. block inserts

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile

  • Checked in Safari and Firefox
    - [ ] Props have proper autodocs
  • Added documentation
    - [ ] Checked Code Sandbox works for the any docs examples
    - [ ] Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
    - [ ] A changelog entry exists and is marked appropriately

@chandlerprall chandlerprall changed the base branch from master to feature/markdown-editor July 15, 2020 16:47
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

@elizabetdev
Copy link
Copy Markdown
Contributor

Hi @chandlerprall,

What do you think of displaying the "can't accept this file / file not supported" case next to the attachment icon?

File not supported

File not supported 2

With errors

But then I was thinking what would happen if we have errors? This would create a weird interaction. The text suddenly appear in the middle of the icons and push the errors to the right... 🤔

markdown editor 11

So we could omit the errors in case there are a few.

File not supported

And once the user focus the text area the "file not supported" disappears:

markdown editor 13

What do you think?

@chandlerprall
Copy link
Copy Markdown
Contributor Author

chandlerprall commented Jul 16, 2020

I like it! Any dragndrop errors would happen apart from syntax errors, so it wouldn't suddenly be displaying both. I don't think it would provide any confusion?

Do we want to leave the message around after the drop is over? (either by moving mouse out, or by attempting the drop on the component). We would need to for that tooltip, but it feels a little off as well to just leave an error message around that the user can't dismiss.

One thing I meant to add in the original post: we can know the MIME type of the unsupported file, though not its extension. E.g. we could message "2 files unsupported: image/gif text/csv". Might be too cluttered though.

The tooltip, if we go that way, can be populated by the file handlers so listing extensions there would be okay.

@elizabetdev
Copy link
Copy Markdown
Contributor

If we click the error, retry to attach, or focus the text area the error should go away.

@chandlerprall
Copy link
Copy Markdown
Contributor Author

@miukimiu I've pushed the error display. Only issue I'm not sure how to resolve is the upload icon jumps to the right when there is an error.

message jumping

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

@elizabetdev
Copy link
Copy Markdown
Contributor

@chandlerprall I'll take a look! 👍

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

@chandlerprall chandlerprall marked this pull request as ready for review July 28, 2020 16:25
@chandlerprall
Copy link
Copy Markdown
Contributor Author

@miukimiu Safari & Firefox don't highlight as expected when dropping files:

  • Firefox highlights as green for supported files, as expected, but does not turn red for unsupported
  • Safari turns green for both supported & unsupported. It also remains green after the drop action if the file was unsupported.

@elizabetdev
Copy link
Copy Markdown
Contributor

@chandlerprall I'm taking a look.

@chandlerprall
Copy link
Copy Markdown
Contributor Author

I've merged the base markdown editor branch in, so the doc pages have moved.

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

Copy link
Copy Markdown
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick a11y test — everything seems pretty good!

Tested dragging and dropping accepted and not accepted files. Tested keyboard controls to make sure nothing was broken. (Only tested in Chromium right now.)

Only thing I would recommend that could help the experience some, is to highlight the text that was inserted. This will make finding it much easier with a screen reader (and likely for not-screen reader users as well).

@elizabetdev
Copy link
Copy Markdown
Contributor

@chandlerprall,
I've been playing around with the styles and created a PR with the changes. But there are a few browsers inconsistencies: chandlerprall#14

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

@chandlerprall
Copy link
Copy Markdown
Contributor Author

The following code that starts on line 86 of the markdown_editor_drop_zone.tsx makes the drag and drop file not accepted don't work on Safari.

I've removed that code; it means the file selection modal doesn't limit the file choices, but now all browsers react to all combinations of supported/unsupported file drops the same.

About Safari not turning red/disabled when dragging unsupported files, turns out Safari does not provide items or files for us to inspect during the drag operation, so it's impossible to determine success/failure at that point. 😞

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_3748/

Copy link
Copy Markdown
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the docs deployment in Chrome, Firefox, and Safari. Noted differences confirmed.

Comment on lines +70 to +87
const ariaLabels = {
uploadingFiles: useEuiI18n(
'euiMarkdownEditorFooter.uploadingFiles',
'Uploading files'
),
openUploadModal: useEuiI18n(
'euiMarkdownEditorFooter.openUploadModal',
'Open upload files modal'
),
showSyntaxErrors: useEuiI18n(
'euiMarkdownEditorFooter.showSyntaxErrors',
'Show errors'
),
showMarkdownHelp: useEuiI18n(
'euiMarkdownEditorFooter.showMarkdownHelp',
'Show markdown help'
),
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useEuiI18n 🙌

@chandlerprall chandlerprall merged commit b84f0dd into elastic:feature/markdown-editor Jul 29, 2020
@chandlerprall chandlerprall deleted the feature/markdown-editor-drag-n-drop branch July 29, 2020 19:35
chandlerprall added a commit that referenced this pull request Aug 12, 2020
* WIP: Add markdown_editor component

* WIP: commit auto-added i18n tokens

* Adding button toggle for previewing

* Adding toolbar component

* Adding file picker initial structure

* Adding text area component

* Buttons order

* Moving markdown editor to docs form section

* Improving file picker

* Adding dropZone component and preview styles

* Fixing height issue while resizing textarea

* Small UI fix

* Improving markdown example

* remove showdown, since it wasn't being used

* Adding code highlight

* Better coding highlight

* Replacing UglifyJsPlugin with TerserPlugin

* Adding button enter key and buttons tooltips

* More code highlight fixes

* Markdown editor plugins (#3457)

* Refactored EuiMarkdownEditor and EuiMarkdownFormat to prep for future work

* pr feedback

* [markdown] chart & tooltip plugins (#3479)

* chart & tooltip plugins

* Change tooltip markdown plugin markdown format

* Fixed error with empty tooltip tag

* [Markdown] Checkbox plugin (#3493)

* Checkbox plugin

* Better checkbox interaction formatting

* Use monospace font in markdown editor

* [EuiMarkdownEditor] Improve markdown editor font (#3525)

* Improving font family and text area font styles

* Text color and text babckground

* Adding eui font family

* euiFormControlText

* Small fix

* Refactoring some styles

* Removing unecessary padding

* Re-enable default markdown list parsing (#3531)

* [Markdown] Allow toolbar buttons to present modals to create/edit tags (#3506)

* Allow EuiMarkdownEditor's ui buttons trigger interactive modals for creating & editing tags

* export two internal markdown types that are needed externally when generating eui.d.ts

* Re-enable the default markdown list parsing/display, but keep EUI's checkbox override

* Give EuiMarkdownEditorTextArea a displayName

* Enable undo/redo for markdown editor, apart from firefox (#3582)

* Enable undo/redo for markdown editor, apart from firefox

* Add test-and-retry logic to insertText to account for ability to focus the text area before brute forcing

* Added AST & info/fail message reporting to application; added info messages to tooltip plugin and fail message to chart configuration parsing (#3602)

* Add an imperative ref to EuiMarkdownEditor (#3622)

* Add an imperative ref to EuiMarkdownEditor, exposing the textarea element and replaceNode method

* Remove textareaRef from two hook dependency arrays

* eslint errors

* Add a markdown help modal, move tooltip & checkbox plugins into src (#3636)

* Move checkbox and tooltip markdown plugins into eui src, add helpText to ui plugins

* Adding footer initial styles

* Adding error popover

* Fixing uploading files icon

* wire up errors

* modal help text

* better modal text

* blerg, react color

* toggle button for editor ast

* Ignoring ts errors and fixing sass lint errors

* Displaying always error info

* Adding checkmark button

* fix markdown test

* Added aria-label and aria-labelledby props to markdown editor

* Fix i18n token name for markdown errors title

* Reverting displaying errors

Co-authored-by: miukimiu <elizabet.oliveira@elastic.co>
Co-authored-by: Dave Snider <dave.snider@gmail.com>

* [EuiMarkdownEditor] Improving markdown format styles (#3534)

* Improving markdown format styles

* Transforming px to em

* Renaming variable

* Adding descriptions and alpha values

* hr more similar to EuiHorizontalRule

* [EuiMarkdownEditor] Better styles and class names (#3697)

* Better styles and classnames

* md footer height

* snapshot

* preventing the text area of loosing focus when clicking on an action button

* Add types to markdown editor (#3703)

* Plugin types

* Rehype / hast / unist node types

* Make typescript happy with markdown editor and dependencies

* Types for markdown AST nodes and errors

* Don't scan any .d.ts file for internationalization strings

* Adding missing types and dependency

* Fixing firefox text area margin (#3802)

* Markdown Format / Editor documentation + features (#3696)

Separates `EuiMarkdownFormat` into its own component. Adds documentation.

* [Markdown editor] drag and drop api, functionality (#3748)

* Initial markdown drag-n-drop api

* Properly insert multiple drag-and-drop results

* Update logic for markdown supported files message display

* disable upload interaction if no drop handlers are provided

* Upload error button styles

* pr feedback

* Only accept supported file types in the markdown file selection dialog

* Drag and drop animation

* small changes

* Add some cross-browser stability when dealing with unsupported drop files

Co-authored-by: miukimiu <elizabet.oliveira@elastic.co>

* Feature/markdown editor cleanup (#3830)

* Sort drag&drop file extensions when displaying

* mark markdown components as new and in beta

* Get EuiMarkdownEditor Props to render

* Update markdown's plugin prop docs based on existing writeups

* Prevent markdown plugin extensions from interacting with each other (#3842)

* Simplify the markdown editor's plugin API (#3843)

* Add a default remark->rehype node handler to simplify plugin development

* Update documentation

* Add license info around markdown tag processing; Support block-level tag insertions (#3867)

* changelog

* Improved, and proper, types for the markdown editor's usage in downstream apps (#3893)

* Fixes some ARIA issues in EuiMarkdownEditor (#3899)

* Support aria-describedby to link errors. Include file support message in upload button's aria-label

* Change markdown footer element to a div

Co-authored-by: i-a-n <ian@union.io>
Co-authored-by: Dave Snider <dave.snider@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
nyurik pushed a commit that referenced this pull request Aug 18, 2020
* WIP: Add markdown_editor component

* WIP: commit auto-added i18n tokens

* Adding button toggle for previewing

* Adding toolbar component

* Adding file picker initial structure

* Adding text area component

* Buttons order

* Moving markdown editor to docs form section

* Improving file picker

* Adding dropZone component and preview styles

* Fixing height issue while resizing textarea

* Small UI fix

* Improving markdown example

* remove showdown, since it wasn't being used

* Adding code highlight

* Better coding highlight

* Replacing UglifyJsPlugin with TerserPlugin

* Adding button enter key and buttons tooltips

* More code highlight fixes

* Markdown editor plugins (#3457)

* Refactored EuiMarkdownEditor and EuiMarkdownFormat to prep for future work

* pr feedback

* [markdown] chart & tooltip plugins (#3479)

* chart & tooltip plugins

* Change tooltip markdown plugin markdown format

* Fixed error with empty tooltip tag

* [Markdown] Checkbox plugin (#3493)

* Checkbox plugin

* Better checkbox interaction formatting

* Use monospace font in markdown editor

* [EuiMarkdownEditor] Improve markdown editor font (#3525)

* Improving font family and text area font styles

* Text color and text babckground

* Adding eui font family

* euiFormControlText

* Small fix

* Refactoring some styles

* Removing unecessary padding

* Re-enable default markdown list parsing (#3531)

* [Markdown] Allow toolbar buttons to present modals to create/edit tags (#3506)

* Allow EuiMarkdownEditor's ui buttons trigger interactive modals for creating & editing tags

* export two internal markdown types that are needed externally when generating eui.d.ts

* Re-enable the default markdown list parsing/display, but keep EUI's checkbox override

* Give EuiMarkdownEditorTextArea a displayName

* Enable undo/redo for markdown editor, apart from firefox (#3582)

* Enable undo/redo for markdown editor, apart from firefox

* Add test-and-retry logic to insertText to account for ability to focus the text area before brute forcing

* Added AST & info/fail message reporting to application; added info messages to tooltip plugin and fail message to chart configuration parsing (#3602)

* Add an imperative ref to EuiMarkdownEditor (#3622)

* Add an imperative ref to EuiMarkdownEditor, exposing the textarea element and replaceNode method

* Remove textareaRef from two hook dependency arrays

* eslint errors

* Add a markdown help modal, move tooltip & checkbox plugins into src (#3636)

* Move checkbox and tooltip markdown plugins into eui src, add helpText to ui plugins

* Adding footer initial styles

* Adding error popover

* Fixing uploading files icon

* wire up errors

* modal help text

* better modal text

* blerg, react color

* toggle button for editor ast

* Ignoring ts errors and fixing sass lint errors

* Displaying always error info

* Adding checkmark button

* fix markdown test

* Added aria-label and aria-labelledby props to markdown editor

* Fix i18n token name for markdown errors title

* Reverting displaying errors

Co-authored-by: miukimiu <elizabet.oliveira@elastic.co>
Co-authored-by: Dave Snider <dave.snider@gmail.com>

* [EuiMarkdownEditor] Improving markdown format styles (#3534)

* Improving markdown format styles

* Transforming px to em

* Renaming variable

* Adding descriptions and alpha values

* hr more similar to EuiHorizontalRule

* [EuiMarkdownEditor] Better styles and class names (#3697)

* Better styles and classnames

* md footer height

* snapshot

* preventing the text area of loosing focus when clicking on an action button

* Add types to markdown editor (#3703)

* Plugin types

* Rehype / hast / unist node types

* Make typescript happy with markdown editor and dependencies

* Types for markdown AST nodes and errors

* Don't scan any .d.ts file for internationalization strings

* Adding missing types and dependency

* Fixing firefox text area margin (#3802)

* Markdown Format / Editor documentation + features (#3696)

Separates `EuiMarkdownFormat` into its own component. Adds documentation.

* [Markdown editor] drag and drop api, functionality (#3748)

* Initial markdown drag-n-drop api

* Properly insert multiple drag-and-drop results

* Update logic for markdown supported files message display

* disable upload interaction if no drop handlers are provided

* Upload error button styles

* pr feedback

* Only accept supported file types in the markdown file selection dialog

* Drag and drop animation

* small changes

* Add some cross-browser stability when dealing with unsupported drop files

Co-authored-by: miukimiu <elizabet.oliveira@elastic.co>

* Feature/markdown editor cleanup (#3830)

* Sort drag&drop file extensions when displaying

* mark markdown components as new and in beta

* Get EuiMarkdownEditor Props to render

* Update markdown's plugin prop docs based on existing writeups

* Prevent markdown plugin extensions from interacting with each other (#3842)

* Simplify the markdown editor's plugin API (#3843)

* Add a default remark->rehype node handler to simplify plugin development

* Update documentation

* Add license info around markdown tag processing; Support block-level tag insertions (#3867)

* changelog

* Improved, and proper, types for the markdown editor's usage in downstream apps (#3893)

* Fixes some ARIA issues in EuiMarkdownEditor (#3899)

* Support aria-describedby to link errors. Include file support message in upload button's aria-label

* Change markdown footer element to a div

Co-authored-by: i-a-n <ian@union.io>
Co-authored-by: Dave Snider <dave.snider@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants