mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 04:53:06 +00:00
Merge branch 'feature-context-help-7.4' into w2p-97732_feature-context-help-service
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { Component, Input, OnInit, TemplateRef, OnDestroy, AfterViewInit, ViewChild } from '@angular/core';
|
||||
import { Component, Input, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { PlacementArray } from '@ng-bootstrap/ng-bootstrap/util/positioning';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable, of as observableOf, Subscription, BehaviorSubject, combineLatest } from 'rxjs';
|
||||
import { Observable, Subscription, BehaviorSubject, combineLatest } from 'rxjs';
|
||||
import { map, distinctUntilChanged, mergeMap } from 'rxjs/operators';
|
||||
import { PlacementDir } from './placement-dir.model';
|
||||
import content from '*.scss';
|
||||
import { ContextHelpService } from '../context-help.service';
|
||||
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { hasValueOperator } from '../empty.util';
|
||||
@@ -55,8 +54,8 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
|
||||
|
||||
tooltip: NgbTooltip;
|
||||
|
||||
@Input() set content(content : string) {
|
||||
this.content$.next(content);
|
||||
@Input() set content(translateKey: string) {
|
||||
this.content$.next(translateKey);
|
||||
}
|
||||
private content$: BehaviorSubject<string | undefined> = new BehaviorSubject(undefined);
|
||||
|
||||
@@ -72,11 +71,11 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
this.parsedContent$ = combineLatest([
|
||||
this.content$.pipe(distinctUntilChanged(), mergeMap(content => this.translateService.get(content))),
|
||||
this.content$.pipe(distinctUntilChanged(), mergeMap(translateKey => this.translateService.get(translateKey))),
|
||||
this.dontParseLinks$.pipe(distinctUntilChanged())
|
||||
]).pipe(
|
||||
map(([content, dontParseLinks]) =>
|
||||
dontParseLinks ? [content] : this.parseLinks(content))
|
||||
map(([text, dontParseLinks]) =>
|
||||
dontParseLinks ? [text] : this.parseLinks(text))
|
||||
);
|
||||
this.shouldShowIcon$ = this.contextHelpService.shouldShowIcons$();
|
||||
this.subs.always = [this.parsedContent$.subscribe(), this.shouldShowIcon$.subscribe()];
|
||||
@@ -136,7 +135,7 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
|
||||
* {href: "https://youtube.com", text: "so is this"}
|
||||
* ]
|
||||
*/
|
||||
private parseLinks(content: string): ParsedContent {
|
||||
private parseLinks(text: string): ParsedContent {
|
||||
// Implementation note: due to `matchAll` method on strings not being available for all versions,
|
||||
// separate "split" and "parse" steps are needed.
|
||||
|
||||
@@ -152,7 +151,7 @@ export class ContextHelpWrapperComponent implements OnInit, OnDestroy {
|
||||
// {href: string, text: string} objects.
|
||||
const parseRegexp = /^\[([^\]]*)\]\(([^\)]*)\)$/;
|
||||
|
||||
return content.match(splitRegexp).map((substring: string) => {
|
||||
return text.match(splitRegexp).map((substring: string) => {
|
||||
const match = substring.match(parseRegexp);
|
||||
return match === null
|
||||
? substring
|
||||
|
Reference in New Issue
Block a user