Skip to content
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 table-input feature #3598

Merged
merged 29 commits into from
Oct 2, 2020
Merged

Add table-input feature #3598

merged 29 commits into from
Oct 2, 2020

Conversation

cheap-glitch
Copy link
Contributor

@cheap-glitch cheap-glitch commented Sep 26, 2020

Thanks for contributing! 🍄

  1. LINKED ISSUES: Closes Improve <table> input in the comment field #2875

  2. TEST URLS:

  1. SCREENSHOT:
    Peek 2020-09-26 19-53

Managed to get this done in just under 80 lines, don't know how it could be reduced but it's probably possible. A few notes/questions:

  • I couldn't find a "table" icon in the octokit, so I used the next best thing (although it's pretty close and with some slight modifications it could make a passable icon).
  • You can't get rid of the table header or the parser won't recognize the table. I chose to add the header on top of whatever size the user selected. Thoughts?
  • The cells have whitespace in them, it makes the table more visually appealing when it's empty but could prove annoying during edition?
  • I didn't use observeElement (I got started by copying and hacking collapsible-content-button which doesn't use it either). Does it even makes sense to use it here?

@cheap-glitch
Copy link
Contributor Author

cheap-glitch commented Sep 27, 2020

  • Applied most suggestions from @fregante and @sindresorhus
  • Rewrote the CSS to use Grid (getting Flexbox to make a perfect grid is a pita) but removed duplicated constraints
  • Tables are now closed to prevent successive tables from "swallowing" each other
  • Slightly improved the UI

Peek 2020-09-27 13-21

cheap-glitch and others added 2 commits September 27, 2020 14:45
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@cheap-glitch

This comment has been minimized.

@fregante
Copy link
Member

fregante commented Sep 27, 2020

You can customize the SVG directly and inline it instead of importing it. Just pass it through SVGO if you edit it with Illustrator. The plus can indeed be change to look like a table

fregante and others added 4 commits September 27, 2020 19:59
Co-authored-by: Federico <me@fregante.com>
Co-authored-by: Federico <me@fregante.com>
@cheap-glitch
Copy link
Contributor Author

Uploading a GIF for the feature demo

Peek 2020-09-29 14-34

Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Merci!

@fregante fregante changed the title Add input in editor to quickly insert GFM table Add table-input feature Oct 2, 2020
@fregante fregante merged commit cc96ac6 into refined-github:master Oct 2, 2020
@cheap-glitch cheap-glitch deleted the add-table-input branch October 7, 2020 07:14
kidonng pushed a commit to kidonng/refined-github that referenced this pull request Oct 7, 2020
Co-authored-by: Federico <me@fregante.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>

function init(): void {
delegate(document, '.rgh-table-input-cell', 'click', addTable);
delegate(document, '.rgh-table-input-cell', 'mouseenter', highlightSquares, {capture: true});
Copy link
Member

Choose a reason for hiding this comment

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

This line causes

Uncaught TypeError: event.target.closest is not a function
    at HTMLDocument.listenerFn (refined-github.js:1164)
listenerFn @ refined-github.js:1164

on every mouse enter

Copy link
Contributor Author

@cheap-glitch cheap-glitch Oct 7, 2020

Choose a reason for hiding this comment

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

Tested in latest Firefox on Arch Linux, didn't see any errors.
Edit: I see the error in Chromium, so it seems this is a browser-specific bug.

Copy link
Member

Choose a reason for hiding this comment

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

@KaKi87
Copy link

KaKi87 commented Mar 8, 2023

Hello,
Why HTML instead of Markdown ?
Thanks

@fregante
Copy link
Member

fregante commented Mar 8, 2023

#2875 (comment)

@KaKi87
Copy link

KaKi87 commented Mar 8, 2023

How about letting the user choose, then ?
Thanks

@refined-github refined-github locked and limited conversation to collaborators Mar 8, 2023
@fregante
Copy link
Member

fregante commented Mar 16, 2023

How about letting the user choose, then ?

No options allowed:

Also:

Good news, though

Markdown tables are now available natively on GitHub: https://github.com/orgs/community/discussions/40299

ko

table-input will stay here however as it's vastly superior in every way (except keyboard accessibility):

2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

Improve <table> input in the comment field
5 participants