Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add markown compatible help icon in comment textarea

kimsible3c176894bae9
diff --git a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html
index c9b0a9c63a..ec8da02e27 100644
--- a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html
+++ b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html
@@ -3,6 +3,20 @@
<img [src]="getAvatarUrl()" alt="Avatar" />
<div class="form-group">
+ <my-help class="markdown-guide" helpType="custom" iconName="markdown" i18n-title title="Markdown compatible">
+ <ng-template ptTemplate="customHtml">
+ <div i18n>
+ Markdown compatible that supports:
+
+ <ul>
+ <li>Emphasis: <strong>**bold**</strong>, <i>_italic_</i></li>
+ <li>Links</li>
+ <li>Break lines</li>
+ <li>Lists</li>
+ </ul>
+ </div>
+ </ng-template>
+ </my-help>
<textarea i18n-placeholder placeholder="Add comment..." myAutoResize
[readonly]="(user === null) ? true : false"
(click)="openVisitorModal($event)"
diff --git a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.scss b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.scss
index d8f851baff..814417f04c 100644
--- a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.scss
+++ b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.scss
@@ -19,11 +19,49 @@ form {
.form-group {
flex-grow: 1;
margin: 0;
+ position: relative;
+
+ $peertube-textarea-height: 60px;
+ $markdown-icon-height: 18px;
+ $markdown-icon-width: 30px;
+
+ .markdown-guide {
+ position: absolute;
+ top: 5px;
+ left: 4px;
+
+ @media screen and (max-width: 600px) {
+ left: 0;
+ }
+
+ ::ng-deep .help-tooltip-button {
+ my-global-icon {
+ height: $markdown-icon-height;
+ width: $markdown-icon-width;
+
+ svg {
+ opacity: 0.5;
+ }
+ }
+
+ &:focus, &:active, &:hover {
+ my-global-icon svg {
+ opacity: 1;
+ }
+ }
+ }
+ }
textarea {
- @include peertube-textarea(100%, 60px);
+ @include peertube-textarea(100%, $peertube-textarea-height);
@include button-focus(pvar(--mainColorLightest));
+ text-indent: $markdown-icon-width;
+
+ @media screen and (max-width: 600px) {
+ text-indent: $markdown-icon-width + 5px;
+ }
+
&:focus::placeholder {
opacity: 0;
}
diff --git a/client/src/app/shared/shared-icons/global-icon.component.ts b/client/src/app/shared/shared-icons/global-icon.component.ts
index ffd217cc78..99efcd599b 100644
--- a/client/src/app/shared/shared-icons/global-icon.component.ts
+++ b/client/src/app/shared/shared-icons/global-icon.component.ts
@@ -4,6 +4,7 @@ import { HooksService } from '@app/core/plugins/hooks.service'
const icons = {
// misc icons
'npm': require('!!raw-loader?!../../../assets/images/misc/npm.svg').default,
+ 'markdown': require('!!raw-loader?!../../../assets/images/misc/markdown.svg').default,
'language': require('!!raw-loader?!../../../assets/images/misc/language.svg').default,
'video-lang': require('!!raw-loader?!../../../assets/images/misc/video-lang.svg').default,
'support': require('!!raw-loader?!../../../assets/images/misc/support.svg').default,
diff --git a/client/src/app/shared/shared-main/misc/help.component.html b/client/src/app/shared/shared-main/misc/help.component.html
index 9a6d3e48e7..b2d58a828d 100644
--- a/client/src/app/shared/shared-main/misc/help.component.html
+++ b/client/src/app/shared/shared-main/misc/help.component.html
@@ -26,8 +26,8 @@
role="button"
class="help-tooltip-button"
container="body"
- title="Get help"
- i18n-title
+ [title]="title"
+ tabindex=0
popoverClass="help-popover"
[attr.aria-pressed]="isPopoverOpened"
[ngbPopover]="tooltipTemplate"
@@ -36,5 +36,5 @@
(onHidden)="onPopoverHidden()"
(onShown)="onPopoverShown()"
>
- <my-global-icon iconName="help"></my-global-icon>
+ <my-global-icon [iconName]="iconName"></my-global-icon>
</span>
diff --git a/client/src/app/shared/shared-main/misc/help.component.scss b/client/src/app/shared/shared-main/misc/help.component.scss
index 1e7fb4fc62..ccc91ffab4 100644
--- a/client/src/app/shared/shared-main/misc/help.component.scss
+++ b/client/src/app/shared/shared-main/misc/help.component.scss
@@ -5,14 +5,17 @@
cursor: pointer;
border: none;
+ margin: 5px;
+
my-global-icon {
width: 17px;
position: relative;
top: -1px;
- margin: 5px;
@include apply-svg-color(pvar(--greyForegroundColor))
}
+
+ @include disable-outline;
}
::ng-deep {
diff --git a/client/src/app/shared/shared-main/misc/help.component.ts b/client/src/app/shared/shared-main/misc/help.component.ts
index ebc965a889..bcbb464f3c 100644
--- a/client/src/app/shared/shared-main/misc/help.component.ts
+++ b/client/src/app/shared/shared-main/misc/help.component.ts
@@ -1,5 +1,6 @@
import { AfterContentInit, Component, ContentChildren, Input, OnChanges, OnInit, QueryList, TemplateRef } from '@angular/core'
import { MarkdownService } from '@app/core'
+import { GlobalIconName } from '@app/shared/shared-icons'
import { PeerTubeTemplateDirective } from '../angular'
@Component({
@@ -11,6 +12,8 @@ import { PeerTubeTemplateDirective } from '../angular'
export class HelpComponent implements OnInit, OnChanges, AfterContentInit {
@Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom'
@Input() tooltipPlacement = 'right auto'
+ @Input() iconName: GlobalIconName = 'help'
+ @Input() title = $localize`Get help`
@ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective<'preHtml' | 'customHtml' | 'postHtml'>>
diff --git a/client/src/assets/images/misc/markdown.svg b/client/src/assets/images/misc/markdown.svg
new file mode 100644
index 0000000000..ee0f153035
--- /dev/null
+++ b/client/src/assets/images/misc/markdown.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="40" height="24" viewBox="0 0 208 128"><rect width="198" height="118" x="5" y="5" ry="10" stroke="#000" stroke-width="10" fill="none"/><path d="M30 98V30h20l20 25 20-25h20v68H90V59L70 84 50 59v39zm125 0l-30-33h20V30h20v35h20z"/></svg>