Repository navigation
Add collapsible content button - #1804
Conversation
| const pos = commentField.selectionStart; | ||
| const currentVal = commentField.value; | ||
| const before = currentVal.substring(0, pos); | ||
| const after = currentVal.substring(pos); |
There was a problem hiding this comment.
We prefer slice over substring.
|
Thanks for the feedback and helpful tips! It also helped me realize I needed to make a couple extra changes that weren't pointed out (e.g. adding the "insert summary" button to all |
This reverts commit 2128a1b.
|
@doms Let's apply the latest suggested changes and merge this soon ^_^ |
|
@bfred-it Sorry for the lack of updates, I've been super busy! I took some time to try implementing an idempotent |
You can skip that for this PR, it'd mean (re-)writing and publishing 2 unrelated modules. The current code already works in here. |
|
I believe renaming the feature was the last suggested change that needed to be done! 😄 |
fregante
left a comment
There was a problem hiding this comment.
This is good to go for me. Please review one last time
| newlinesToPrepend = '\n'.repeat(2 - whitespaceAtStart.length); | ||
| } | ||
|
|
||
| if (after.match(/\S/) && whitespaceAtEnd.length < 2) { |
There was a problem hiding this comment.
Wow, this is a really cool way to dynamically determine the amount of whitespace to lead/trail with!
There was a problem hiding this comment.
I wish it wasn't so wordy. Thanks to GitHub's code at least I didn't have to reinvent the wheel.
|
This looks great. Thanks for working on it, @doms :) |


What
closes #1670
Notes
Still learning how to web dev, and using this PR as a learning opportunity. Looking forward to feedback!
I wasn't sure what icon to use for the toolbar button for inserting a summary, so I used the
infojust for representation, but can change it to something else if needed.I might be overthinking it, but I'm not sure how to properly insert the
detailsblock into the textarea without it being formatted into a block of text. 🤔This:
gets formatted as a block of text when I use string interpolation, or if I try to insert as innerHTML, it comes out like so:
[object HTMLDetailsElement]I'm also getting a console error:
Uncaught DOMException: Failed to construct 'CustomElement': The result must not have attributesBut I've tried to follow the format of existing features as much as possible and am not sure what I am doing wrong..