Browse Source

Lazy load emoji

pull/3334/head
Chocobozzz 1 week ago
parent
commit
369e77543b
No known key found for this signature in database GPG Key ID: 583A612D890159BE
2 changed files with 9 additions and 3 deletions
  1. +7
    -3
      client/src/app/core/renderer/markdown.service.ts
  2. +2
    -0
      client/src/typings.d.ts

+ 7
- 3
client/src/app/core/renderer/markdown.service.ts View File

@@ -49,6 +49,8 @@ export class MarkdownService {
completeMarkdownIt: { rules: COMPLETE_RULES, html: true }
}

private emojiModule: any

constructor (private htmlRenderer: HtmlRendererService) {}

textMarkdownToHTML (markdown: string, withHtml = false, withEmoji = false) {
@@ -83,9 +85,11 @@ export class MarkdownService {
this.markdownParsers[ name ] = await this.createMarkdownIt(config)

if (withEmoji) {
// TODO: write types
const emoji = require('markdown-it-emoji/light')
this.markdownParsers[ name ].use(emoji)
if (!this.emojiModule) {
this.emojiModule = (await import('markdown-it-emoji/light')).default
}

this.markdownParsers[ name ].use(this.emojiModule)
}
}



+ 2
- 0
client/src/typings.d.ts View File

@@ -4,3 +4,5 @@ declare var module: NodeModule
interface NodeModule {
id: string
}

declare module 'markdown-it-emoji/light'

Loading…
Cancel
Save