diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 index 37d518928bb..e2ed8900303 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 @@ -1,5 +1,5 @@ import { registerOption } from 'pretty-text/pretty-text'; -import { buildEmojiUrl, isCustomEmoji } from 'pretty-text/emoji'; +import { registerEmoji, buildEmojiUrl, isCustomEmoji } from 'pretty-text/emoji'; import { translations } from 'pretty-text/emoji/data'; let _unicodeReplacements; @@ -29,7 +29,7 @@ function checkPrev(prev) { registerOption((siteSettings, opts, state) => { opts.features.emoji = !!siteSettings.enable_emoji; opts.emojiSet = siteSettings.emoji_set || ""; - opts.customEmoji = state.customEmoji; + _(state.customEmoji).each((url, name) => registerEmoji(name, url)); }); export function setup(helper) { diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index d9c08d7b2b5..3814fd42a09 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -56,7 +56,7 @@ module PrettyText ctx.eval("window = {}; window.devicePixelRatio = 2;") # hack to make code think stuff is retina if Rails.env.development? || Rails.env.test? - ctx.attach("console.log", proc{|l| p l }) + ctx.attach("console.log", proc { |l| p l }) end ctx_load(ctx, "#{Rails.root}/app/assets/javascripts/discourse-loader.js") @@ -154,10 +154,7 @@ module PrettyText context.eval("__optInput.mentionLookup = __mentionLookup;") custom_emoji = {} - Emoji.custom.map do |e| - context.eval("__registerEmoji('#{e.name}', '#{e.url}')") - custom_emoji[e.name] = e.url - end + Emoji.custom.map { |e| custom_emoji[e.name] = e.url } context.eval("__optInput.customEmoji = #{custom_emoji.to_json};") context.eval('__textOptions = __buildOptions(__optInput);') diff --git a/lib/pretty_text/shims.js b/lib/pretty_text/shims.js index ae4803534c3..c156fdb0cd7 100644 --- a/lib/pretty_text/shims.js +++ b/lib/pretty_text/shims.js @@ -1,7 +1,6 @@ __PrettyText = require('pretty-text/pretty-text').default; __buildOptions = require('pretty-text/pretty-text').buildOptions; __performEmojiUnescape = require('pretty-text/emoji').performEmojiUnescape; -__registerEmoji = require('pretty-text/emoji').registerEmoji; __utils = require('discourse/lib/utilities'); __setUnicode = require('pretty-text/engines/discourse-markdown/emoji').setUnicodeReplacements;