summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-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
3 files changed, 38 insertions, 4 deletions
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
+});