-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Improve markdown textarea for indentation and lists #31406
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
I wonder if we can add a test for this stuff. I assume basic textarea interaction should be possible with happy-dom, but I'm not sure whether that implementation is complete. Worth a try. Another option may be to test it in playwright, but I don't consider our playwright tests in a usable state yet, but it's been something I wanted to take a look eventually. |
I could do it later, by unit test. |
I mean, in a separate PR in the future. This PR would also help other features like "image file drag" |
Ok, but be prepared to run into happy-dom bugs 😆. If a unit test can do it, it would be great, much faster and much less overhead than playwright. |
So let's merge this as-is? |
Can you describe a bit what this does? I'm not familiar to this GitHub functionality. |
web_src/js/features/comp/Paste.js
Outdated
// when pasting links over selected text, turn it into [text](link), except when shift key is held | ||
const {value, selectionStart, selectionEnd, _shiftDown} = textarea; | ||
if (_shiftDown) return; | ||
function handleClipboardText(textarea, e, text, isShiftDown) { |
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.
function handleClipboardText(textarea, e, text, isShiftDown) { | |
function handleClipboardText(textarea, e, text, {isShiftDown} = {}) { |
Better to have options argument, also easier to read at caller site.
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.
I do not think it's worth to have an option here. It is not optional.
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.
Could remove the = {}
to make it required, but I guess current 4 args is borderline acceptable. Still I prefer options arg because it's immediately clear what it does at the call site. Your variant is a boolean trap.
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.
- I do not see any difference between
handleClipboardText(el, text, e, isShiftDown)
vshandleClipboardText(el, text, e, {isShiftDown})
for callers.{}
doesn't help readability. - I am just removing the legacy
el._shiftDown
, and it doesn't really cause "boolean trap" because it only uses variables, notrue/false
trick.
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.
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.
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.
Ah yes, if you still have the variable name at caller site, that's fine.
Added some comments, and most review suggestions are applied 358cd19 |
Ah I understand, yes those are some nice features. |
c204d2b
to
8024d10
Compare
* origin/main: (21 commits) Fix deprecated Dockerfile ENV format (go-gitea#31450) README Badge maintenance (go-gitea#31441) Improve markdown textarea for indentation and lists (go-gitea#31406) Split common-global.js into separate files (go-gitea#31438) Fix the link for .git-blame-ignore-revs bypass (go-gitea#31432) Bump htmx to 2.0.0 (go-gitea#31413) Fix the wrong line number in the diff view page when expanded twice. (go-gitea#31431) Fix labels and projects menu overflow on issue page (go-gitea#31435) [Fix] Account Linking UpdateMigrationsByType (go-gitea#31428) Fix markdown math brackets render problem (go-gitea#31420) Reduce `air` verbosity (go-gitea#31417) Fix new issue/pr avatar (go-gitea#31419) Increase max length of org team names from 30 to 255 characters (go-gitea#31410) [skip ci] Updated translations via Crowdin Refactor names (go-gitea#31405) Update JS dependencies, remove `eslint-plugin-jquery` (go-gitea#31402) Switch to upstream of `gorilla/feeds` (go-gitea#31400) Fix rendered wiki page link (go-gitea#31398) Refactor repo unit "disabled" check (go-gitea#31389) Refactor route path normalization (go-gitea#31381) ...
* giteaofficial/main: Refactor image diff (go-gitea#31444) [skip ci] Updated translations via Crowdin Support relative paths to videos from Wiki pages (go-gitea#31061) Fix deprecated Dockerfile ENV format (go-gitea#31450) README Badge maintenance (go-gitea#31441) Improve markdown textarea for indentation and lists (go-gitea#31406) Split common-global.js into separate files (go-gitea#31438)
Almost works like GitHub