FIX: custom emojis leaking over multisites

This commit is contained in:
Régis Hanol 2016-11-17 19:35:39 +01:00
parent 82bdfb9832
commit a0f1090d79
3 changed files with 4 additions and 8 deletions

View File

@ -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) {

View File

@ -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);')

View File

@ -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;