aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-19 16:26:32 +0100
committerChocobozzz <me@florianbigard.com>2020-11-19 16:26:32 +0100
commit369e77543b0e2cd24f2353dcf6a715fca350556c (patch)
tree81734ec144291db445b73d2478e6396f77991167 /client/src
parentb355b394083aa4ea67a17e5c60e1d3e40f2defd9 (diff)
downloadPeerTube-369e77543b0e2cd24f2353dcf6a715fca350556c.tar.gz
PeerTube-369e77543b0e2cd24f2353dcf6a715fca350556c.tar.zst
PeerTube-369e77543b0e2cd24f2353dcf6a715fca350556c.zip
Lazy load emoji
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/core/renderer/markdown.service.ts10
-rw-r--r--client/src/typings.d.ts2
2 files changed, 9 insertions, 3 deletions
diff --git a/client/src/app/core/renderer/markdown.service.ts b/client/src/app/core/renderer/markdown.service.ts
index 0fde3f99d..edddb0a66 100644
--- a/client/src/app/core/renderer/markdown.service.ts
+++ b/client/src/app/core/renderer/markdown.service.ts
@@ -49,6 +49,8 @@ export class MarkdownService {
49 completeMarkdownIt: { rules: COMPLETE_RULES, html: true } 49 completeMarkdownIt: { rules: COMPLETE_RULES, html: true }
50 } 50 }
51 51
52 private emojiModule: any
53
52 constructor (private htmlRenderer: HtmlRendererService) {} 54 constructor (private htmlRenderer: HtmlRendererService) {}
53 55
54 textMarkdownToHTML (markdown: string, withHtml = false, withEmoji = false) { 56 textMarkdownToHTML (markdown: string, withHtml = false, withEmoji = false) {
@@ -83,9 +85,11 @@ export class MarkdownService {
83 this.markdownParsers[ name ] = await this.createMarkdownIt(config) 85 this.markdownParsers[ name ] = await this.createMarkdownIt(config)
84 86
85 if (withEmoji) { 87 if (withEmoji) {
86 // TODO: write types 88 if (!this.emojiModule) {
87 const emoji = require('markdown-it-emoji/light') 89 this.emojiModule = (await import('markdown-it-emoji/light')).default
88 this.markdownParsers[ name ].use(emoji) 90 }
91
92 this.markdownParsers[ name ].use(this.emojiModule)
89 } 93 }
90 } 94 }
91 95
diff --git a/client/src/typings.d.ts b/client/src/typings.d.ts
index ef6c9f2f5..24473aede 100644
--- a/client/src/typings.d.ts
+++ b/client/src/typings.d.ts
@@ -4,3 +4,5 @@ declare var module: NodeModule
4interface NodeModule { 4interface NodeModule {
5 id: string 5 id: string
6} 6}
7
8declare module 'markdown-it-emoji/light'