summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Kid <kidonng@gmail.com> 2019-08-31 01:56:57 +0800
committerGravatar Federico Brigante <github@bfred.it> 2019-08-31 00:56:57 +0700
commit0ca864af6da9cac9f503e4abd0c58b60fbe1abc6 (patch)
tree54e13e05f1da1bb15bb7432b01b2e14f6e32c307
parentcd6e8e1b16a016dfea57872c922e95a5878725ab (diff)
downloadrefined-github-0ca864af6da9cac9f503e4abd0c58b60fbe1abc6.tar.gz
refined-github-0ca864af6da9cac9f503e4abd0c58b60fbe1abc6.tar.zst
refined-github-0ca864af6da9cac9f503e4abd0c58b60fbe1abc6.zip
Hide unnecessary tip on comment field (#2375)
-rw-r--r--readme.md2
-rw-r--r--source/content.ts2
-rw-r--r--source/features/clean-rich-text-editor.css6
-rw-r--r--source/features/clean-rich-text-editor.ts34
4 files changed, 39 insertions, 5 deletions
diff --git a/readme.md b/readme.md
index dff068a1..ed1f40fc 100644
--- a/readme.md
+++ b/readme.md
@@ -163,7 +163,7 @@ Thanks for contributing! πŸ¦‹πŸ™Œ
- [](# "comment-fields-keyboard-shortcuts") [Adds a shortcut to edit your last comment: <kbd>↑</kbd>.](https://github.com/sindresorhus/refined-github/pull/961) (Only works in the following comment field, if it’s empty.)
- [](# "comment-fields-keyboard-shortcuts") [Wraps selected text when pressing one of Markdown symbols instead of replacing it:](https://user-images.githubusercontent.com/37769974/59958878-39c51500-94cb-11e9-910a-061bf8ca6575.gif) `[` <code>\`</code> `'` `"` `*` `~` `_`
- [](# "minimize-upload-bar") [Reduces the upload bar to a small button.](https://user-images.githubusercontent.com/55841/59802383-3d994180-92e9-11e9-835d-60de67611c30.png)
-- [](# "clean-rich-text-editor") [Hides unnecessary buttons in the comment box toolbar](https://user-images.githubusercontent.com/1402241/53629083-a4fe8900-3c47-11e9-8211-bfe2d254ffcb.png) (each one has a keyboard shortcut).
+- [](# "clean-rich-text-editor") [Hides unnecessary comment field tooltips and toolbar items](https://user-images.githubusercontent.com/1402241/53629083-a4fe8900-3c47-11e9-8211-bfe2d254ffcb.png) (each one has a keyboard shortcut.)
- [](# "monospace-textareas") Use a monospace font for all textareas.
<!-- Refer to style guide above. Keep this message between sections. -->
diff --git a/source/content.ts b/source/content.ts
index 1dd006db..4f1a333b 100644
--- a/source/content.ts
+++ b/source/content.ts
@@ -14,7 +14,6 @@ import './features/hide-tips.css';
import './features/hide-readme-header.css';
import './features/hide-obvious-tooltips.css';
import './features/clean-discussions.css';
-import './features/clean-rich-text-editor.css';
import './features/sticky-discussion-list-toolbar.css';
// DO NOT add CSS files here if they are part of a JavaScript feature.
// Import the `.css` file from the `.tsx` instead.
@@ -137,6 +136,7 @@ import './features/linkify-symbolic-links';
import './features/hide-zero-packages';
import './features/revert-file';
import './features/hidden-review-comments-indicator';
+import './features/clean-rich-text-editor';
// Add global for easier debugging
(window as any).select = select;
diff --git a/source/features/clean-rich-text-editor.css b/source/features/clean-rich-text-editor.css
index c3bed0e8..41e956bc 100644
--- a/source/features/clean-rich-text-editor.css
+++ b/source/features/clean-rich-text-editor.css
@@ -1,6 +1,6 @@
/* Hide unnecessary comment toolbar items */
-md-mention,
-md-ref,
-markdown-toolbar > :nth-last-child(4) { /* H1, B, I */
+.rgh-clean-rich-text-editor md-mention,
+.rgh-clean-rich-text-editor md-ref,
+.rgh-clean-rich-text-editor markdown-toolbar > :nth-last-child(4) { /* H1, B, I */
display: none !important; /* Has to override `.d-inline-block` */
}
diff --git a/source/features/clean-rich-text-editor.ts b/source/features/clean-rich-text-editor.ts
new file mode 100644
index 00000000..cfcea805
--- /dev/null
+++ b/source/features/clean-rich-text-editor.ts
@@ -0,0 +1,34 @@
+import './clean-rich-text-editor.css';
+import select from 'select-dom';
+import features from '../libs/features';
+
+function hideButtons(): void {
+ document.body.classList.add('rgh-clean-rich-text-editor');
+}
+
+function hideTextareaTooltip(): void {
+ for (const textarea of select.all('.comment-form-textarea')) {
+ textarea.title = '';
+ }
+}
+
+features.add({
+ id: __featureName__,
+ description: 'Hides unnecessary comment field tooltips and toolbar items.',
+ screenshot: 'https://user-images.githubusercontent.com/1402241/53629083-a4fe8900-3c47-11e9-8211-bfe2d254ffcb.png',
+ include: [
+ features.hasRichTextEditor
+ ],
+ load: features.onAjaxedPages,
+ init: hideTextareaTooltip
+});
+
+features.add({
+ id: __featureName__,
+ description: '',
+ screenshot: '',
+ include: [
+ features.isRepo
+ ],
+ init: hideButtons
+});