+import { firstValueFrom } from 'rxjs'
import { ComponentRef, Injectable } from '@angular/core'
import { MarkdownService } from '@app/core'
import {
ContainerMarkupData,
EmbedMarkupData,
PlaylistMiniatureMarkupData,
- VideoFilter,
VideoMiniatureMarkupData,
VideosListMarkupData
} from '@shared/models'
VideoMiniatureMarkupComponent,
VideosListMarkupComponent
} from './peertube-custom-tags'
+import { CustomMarkupComponent } from './peertube-custom-tags/shared'
-type AngularBuilderFunction = (el: HTMLElement) => ComponentRef<any>
+type AngularBuilderFunction = (el: HTMLElement) => ComponentRef<CustomMarkupComponent>
type HTMLBuilderFunction = (el: HTMLElement) => HTMLElement
@Injectable()
private dynamicElementService: DynamicElementService,
private markdown: MarkdownService
) {
- this.customMarkdownRenderer = async (text: string) => this.buildElement(text)
+ this.customMarkdownRenderer = (text: string) => {
+ return this.buildElement(text)
+ .then(({ rootElement }) => rootElement)
+ }
}
getCustomMarkdownRenderer () {
})
}
+ const loadedPromises: Promise<boolean>[] = []
+
for (const selector of Object.keys(this.angularBuilders)) {
rootElement.querySelectorAll(selector)
.forEach((e: HTMLElement) => {
try {
const component = this.execAngularBuilder(selector, e)
+ if (component.instance.loaded) {
+ const p = firstValueFrom(component.instance.loaded)
+ loadedPromises.push(p)
+ }
+
this.dynamicElementService.injectElement(e, component)
} catch (err) {
console.error('Cannot inject component %s.', selector, err)
})
}
- return rootElement
+ return { rootElement, componentsLoaded: Promise.all(loadedPromises) }
}
private getSupportedTags () {
const component = this.dynamicElementService.createElement(ButtonMarkupComponent)
const model = {
- theme: data.theme,
+ theme: data.theme ?? 'primary',
href: data.href,
label: data.label,
- blankTarget: this.buildBoolean(data.blankTarget)
+ blankTarget: this.buildBoolean(data.blankTarget) ?? false
}
this.dynamicElementService.setModel(component, model)
categoryOneOf: this.buildArrayNumber(data.categoryOneOf) ?? [],
languageOneOf: this.buildArrayString(data.languageOneOf) ?? [],
- filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined
+ accountHandle: data.accountHandle || undefined,
+ channelHandle: data.channelHandle || undefined,
+
+ isLive: this.buildBoolean(data.isLive),
+
+ isLocal: this.buildBoolean(data.onlyLocal) ? true : undefined
}
this.dynamicElementService.setModel(component, model)
root.classList.add('peertube-container', layoutClass)
+ root.style.justifyContent = data.justifyContent || 'space-between'
+
if (data.width) {
root.setAttribute('width', data.width)
}