mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-09-19 09:27:22 +03:00
Lazy load emoji
This commit is contained in:
parent
b355b39408
commit
369e77543b
@ -49,6 +49,8 @@ export class MarkdownService {
|
|||||||
completeMarkdownIt: { rules: COMPLETE_RULES, html: true }
|
completeMarkdownIt: { rules: COMPLETE_RULES, html: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private emojiModule: any
|
||||||
|
|
||||||
constructor (private htmlRenderer: HtmlRendererService) {}
|
constructor (private htmlRenderer: HtmlRendererService) {}
|
||||||
|
|
||||||
textMarkdownToHTML (markdown: string, withHtml = false, withEmoji = false) {
|
textMarkdownToHTML (markdown: string, withHtml = false, withEmoji = false) {
|
||||||
@ -83,9 +85,11 @@ export class MarkdownService {
|
|||||||
this.markdownParsers[ name ] = await this.createMarkdownIt(config)
|
this.markdownParsers[ name ] = await this.createMarkdownIt(config)
|
||||||
|
|
||||||
if (withEmoji) {
|
if (withEmoji) {
|
||||||
// TODO: write types
|
if (!this.emojiModule) {
|
||||||
const emoji = require('markdown-it-emoji/light')
|
this.emojiModule = (await import('markdown-it-emoji/light')).default
|
||||||
this.markdownParsers[ name ].use(emoji)
|
}
|
||||||
|
|
||||||
|
this.markdownParsers[ name ].use(this.emojiModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
client/src/typings.d.ts
vendored
2
client/src/typings.d.ts
vendored
@ -4,3 +4,5 @@ declare var module: NodeModule
|
|||||||
interface NodeModule {
|
interface NodeModule {
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare module 'markdown-it-emoji/light'
|
||||||
|
Loading…
Reference in New Issue
Block a user