2018-11-22 01:28:48 -05:00
|
|
|
__PrettyText = require("pretty-text/pretty-text").default;
|
|
|
|
__buildOptions = require("pretty-text/pretty-text").buildOptions;
|
|
|
|
__performEmojiUnescape = require("pretty-text/emoji").performEmojiUnescape;
|
2019-08-07 05:38:58 -04:00
|
|
|
__buildReplacementsList = require("pretty-text/emoji").buildReplacementsList;
|
2019-03-21 04:11:33 -04:00
|
|
|
__performEmojiEscape = require("pretty-text/emoji").performEmojiEscape;
|
2020-05-27 14:11:52 -04:00
|
|
|
__resetTranslationTree = require("pretty-text/engines/discourse-markdown/emoji")
|
|
|
|
.resetTranslationTree;
|
2016-06-14 14:31:51 -04:00
|
|
|
|
2020-05-13 16:23:41 -04:00
|
|
|
I18n = {
|
|
|
|
t(a, b) {
|
|
|
|
return __helpers.t(a, b);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
define("I18n", ["exports"], function(exports) {
|
|
|
|
exports.default = I18n;
|
|
|
|
});
|
|
|
|
|
2018-11-22 01:28:48 -05:00
|
|
|
__utils = require("discourse/lib/utilities");
|
2017-06-28 13:47:22 -04:00
|
|
|
|
|
|
|
__emojiUnicodeReplacer = null;
|
|
|
|
|
|
|
|
__setUnicode = function(replacements) {
|
2019-08-07 05:38:58 -04:00
|
|
|
let unicodeRegexp = new RegExp(__buildReplacementsList(replacements), "g");
|
2017-06-28 13:47:22 -04:00
|
|
|
|
|
|
|
__emojiUnicodeReplacer = function(text) {
|
|
|
|
unicodeRegexp.lastIndex = 0;
|
|
|
|
let m;
|
|
|
|
while ((m = unicodeRegexp.exec(text)) !== null) {
|
|
|
|
let replacement = ":" + replacements[m[0]] + ":";
|
2018-11-22 01:28:48 -05:00
|
|
|
const before = text.charAt(m.index - 1);
|
2017-06-28 13:47:22 -04:00
|
|
|
if (!/\B/.test(before)) {
|
|
|
|
replacement = "\u200b" + replacement;
|
|
|
|
}
|
|
|
|
text = text.replace(m[0], replacement);
|
|
|
|
}
|
2018-10-07 22:32:25 -04:00
|
|
|
|
|
|
|
// fixes Safari VARIATION SELECTOR-16 issue with some emojis
|
|
|
|
// https://meta.discourse.org/t/emojis-selected-on-ios-displaying-additional-rectangles/86132
|
2018-11-22 01:28:48 -05:00
|
|
|
text = text.replace(/\ufe0f/g, "");
|
2018-10-07 22:32:25 -04:00
|
|
|
|
2017-06-28 13:47:22 -04:00
|
|
|
return text;
|
|
|
|
};
|
|
|
|
};
|
2016-06-14 14:31:51 -04:00
|
|
|
|
|
|
|
__paths = {};
|
|
|
|
|
|
|
|
function __getURLNoCDN(url) {
|
|
|
|
if (!url) return url;
|
|
|
|
|
|
|
|
// if it's a non relative URL, return it.
|
2018-11-22 01:28:48 -05:00
|
|
|
if (url !== "/" && !/^\/[^\/]/.test(url)) {
|
|
|
|
return url;
|
|
|
|
}
|
2016-06-14 14:31:51 -04:00
|
|
|
|
2018-11-22 01:28:48 -05:00
|
|
|
if (url.indexOf(__paths.baseUri) !== -1) {
|
|
|
|
return url;
|
|
|
|
}
|
2016-06-14 14:31:51 -04:00
|
|
|
if (url[0] !== "/") url = "/" + url;
|
|
|
|
|
|
|
|
return __paths.baseUri + url;
|
|
|
|
}
|
|
|
|
|
|
|
|
function __getURL(url) {
|
|
|
|
url = __getURLNoCDN(url);
|
|
|
|
// only relative urls
|
|
|
|
if (__paths.CDN && /^\\\/[^\\\/]/.test(url)) {
|
|
|
|
url = __paths.CDN + url;
|
|
|
|
} else if (__paths.S3CDN) {
|
|
|
|
url = url.replace(__paths.S3BaseUrl, __paths.S3CDN);
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2019-05-28 21:00:25 -04:00
|
|
|
function __lookupUploadUrls(urls) {
|
|
|
|
return __helpers.lookup_upload_urls(urls);
|
2017-08-22 11:46:15 -04:00
|
|
|
}
|
|
|
|
|
2016-06-14 14:31:51 -04:00
|
|
|
function __getTopicInfo(i) {
|
|
|
|
return __helpers.get_topic_info(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
function __categoryLookup(c) {
|
|
|
|
return __helpers.category_tag_hashtag_lookup(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
function __lookupAvatar(p) {
|
2018-11-22 01:28:48 -05:00
|
|
|
return __utils.avatarImg(
|
|
|
|
{ size: "tiny", avatarTemplate: __helpers.avatar_template(p) },
|
|
|
|
__getURL
|
|
|
|
);
|
2016-06-14 14:31:51 -04:00
|
|
|
}
|
|
|
|
|
2018-03-13 13:07:51 -04:00
|
|
|
function __formatUsername(username) {
|
|
|
|
return __helpers.format_username(username);
|
2017-11-20 16:28:03 -05:00
|
|
|
}
|
|
|
|
|
2018-03-13 13:07:51 -04:00
|
|
|
function __lookupPrimaryUserGroup(username) {
|
|
|
|
return __helpers.lookup_primary_user_group(username);
|
2017-11-03 09:51:40 -04:00
|
|
|
}
|
|
|
|
|
2016-07-07 03:52:56 -04:00
|
|
|
function __getCurrentUser(userId) {
|
|
|
|
return __helpers.get_current_user(userId);
|
|
|
|
}
|