forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dspace-cris-2023_02_x' into export_issue
* dspace-cris-2023_02_x: (65 commits) [DSC-397] fix issue that lead to failing e2e [DSC-1653] removed comments [DSC-1653] Defined a mixin for vertical ellipsis [DSC-1637] resolve conflicts [DSC-1601] - Added test case [DSC-1601] - Adjusted code for fixing requested [DSC-1601] - Added new implementation when bitstream is restricted [DSC-1601] - Removed old implementation [DSC-1575] Fixed labels name [CST-9683] Fix visualization order of the metrics boxes in the item page [DSC-1524] Use ngOnChanges to detect changes on input variable [DSC-1655] Configure person icon to be visible without authority [DSC-1628] change icon color in config [DSC-1524] Adjusted test for End User Agreement not shown [DSC-1524] Fixing End User Agreement not shown [DSC-1652] fix lint [DSC-1652] refactor translateService calls, change default values for timeouts [DSC-1575] Added labels required [DSC-1652] add warning and error messages to loader component [DSC-1601] Fixed issue with icon visibility in FileDownloadLinkComponent ... # Conflicts: # package.json # src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.scss # src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts
- Loading branch information
Showing
132 changed files
with
1,451 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { DOCUMENT } from '@angular/common'; | ||
import { | ||
Inject, | ||
Injectable, | ||
} from '@angular/core'; | ||
import { Observable, ReplaySubject, Subject } from 'rxjs'; | ||
import { environment } from 'src/environments/environment'; | ||
import { | ||
NativeWindowRef, | ||
NativeWindowService, | ||
} from '../services/window.service';import { MathJaxConfig, MathService } from './math.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
/** | ||
* Provide the MathService for CSR | ||
*/ | ||
export class ClientMathService extends MathService { | ||
|
||
protected isReady$: Subject<boolean>; | ||
|
||
protected mathJaxOptions = { | ||
tex: { | ||
inlineMath: [['$', '$'], ['\\(', '\\)']] | ||
}, | ||
svg: { | ||
fontCache: 'global' | ||
}, | ||
startup: { | ||
typeset: false | ||
} | ||
}; | ||
|
||
protected mathJax: MathJaxConfig = { | ||
source: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js', | ||
id: 'MathJaxScript' | ||
}; | ||
protected mathJaxFallback: MathJaxConfig = { | ||
source: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-chtml.min.js', | ||
id: 'MathJaxBackupScript' | ||
}; | ||
|
||
constructor( | ||
@Inject(DOCUMENT) private _document: Document, | ||
@Inject(NativeWindowService) protected _window: NativeWindowRef, | ||
) { | ||
super(); | ||
|
||
this.isReady$ = new ReplaySubject<boolean>(); | ||
|
||
void this.registerMathJaxAsync(this.mathJax) | ||
.then(() => this.isReady$.next(true)) | ||
.catch(_ => { | ||
void this.registerMathJaxAsync(this.mathJaxFallback) | ||
.then(() => this.isReady$.next(true)); | ||
}); | ||
} | ||
|
||
/** | ||
* Register the specified MathJax script in the document | ||
* | ||
* @param config The configuration object for the script | ||
*/ | ||
protected async registerMathJaxAsync(config: MathJaxConfig): Promise<any> { | ||
if (environment.markdown.mathjax) { | ||
return new Promise<void>((resolve, reject) => { | ||
|
||
const optionsScript: HTMLScriptElement = this._document.createElement('script'); | ||
optionsScript.type = 'text/javascript'; | ||
optionsScript.text = `MathJax = ${JSON.stringify(this.mathJaxOptions)};`; | ||
this._document.head.appendChild(optionsScript); | ||
|
||
const script: HTMLScriptElement = this._document.createElement('script'); | ||
script.id = config.id; | ||
script.type = 'text/javascript'; | ||
script.src = config.source; | ||
script.crossOrigin = 'anonymous'; | ||
script.async = true; | ||
script.onload = () => resolve(); | ||
script.onerror = error => reject(error); | ||
this._document.head.appendChild(script); | ||
}); | ||
} | ||
return Promise.resolve(); | ||
} | ||
|
||
/** | ||
* Return the status of the script registration | ||
*/ | ||
ready(): Observable<boolean> { | ||
return this.isReady$; | ||
} | ||
|
||
/** | ||
* Render the specified element using the MathJax JavaScript | ||
* | ||
* @param element The element to render with MathJax | ||
*/ | ||
render(element: HTMLElement) { | ||
if (environment.markdown.mathjax) { | ||
this._window.nativeWindow.MathJax.typesetPromise([element]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { Observable, of } from 'rxjs'; | ||
import { MathService, MathJaxConfig } from './math.service'; | ||
|
||
export class MockMathService extends MathService { | ||
protected mathJaxOptions: any = {}; | ||
protected mathJax: MathJaxConfig = { source: '', id: '' }; | ||
protected mathJaxFallback: MathJaxConfig = { source: '', id: '' }; | ||
|
||
protected registerMathJaxAsync(config: MathJaxConfig): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
ready(): Observable<boolean> { | ||
return of(true); | ||
} | ||
|
||
render(element: HTMLElement): void { | ||
return; | ||
} | ||
} | ||
|
||
describe('MathService', () => { | ||
let service: MockMathService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = new MockMathService(); | ||
spyOn(service, 'render'); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it('should be ready', (done) => { | ||
service.ready().subscribe(isReady => { | ||
expect(isReady).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should render', () => { | ||
service.render(document.createElement('div')); | ||
expect(service.render).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Observable } from 'rxjs'; | ||
|
||
export interface MathJaxConfig { | ||
source: string; | ||
id: string; | ||
} | ||
|
||
/** | ||
* This service is used to provide the MathJax library with the ability to render markdown code | ||
*/ | ||
export abstract class MathService { | ||
protected abstract mathJaxOptions: any; | ||
protected abstract mathJax: MathJaxConfig; | ||
protected abstract mathJaxFallback: MathJaxConfig; | ||
|
||
protected abstract registerMathJaxAsync(config: MathJaxConfig): Promise<any>; | ||
abstract ready(): Observable<boolean>; | ||
abstract render(element: HTMLElement): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, ReplaySubject, Subject } from 'rxjs'; | ||
import { MathJaxConfig, MathService } from './math.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
/** | ||
* Provide the MathService for SSR | ||
*/ | ||
export class ServerMathService extends MathService { | ||
|
||
protected signal: Subject<boolean>; | ||
|
||
protected mathJaxOptions = {}; | ||
|
||
protected mathJax: MathJaxConfig = { | ||
source: '', | ||
id: '' | ||
}; | ||
protected mathJaxFallback: MathJaxConfig = { | ||
source: '', | ||
id: '' | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.signal = new ReplaySubject<boolean>(); | ||
this.signal.next(true); | ||
} | ||
|
||
protected async registerMathJaxAsync(config: MathJaxConfig): Promise<any> { | ||
return Promise.resolve(); | ||
} | ||
|
||
ready(): Observable<boolean> { | ||
return this.signal; | ||
} | ||
|
||
render(element: HTMLElement) { | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.