2018-11-22 14:28:48 +08:00
|
|
|
__PrettyText = require("pretty-text/pretty-text").default;
|
|
|
|
__buildOptions = require("pretty-text/pretty-text").buildOptions;
|
|
|
|
__performEmojiUnescape = require("pretty-text/emoji").performEmojiUnescape;
|
2021-04-22 14:43:06 +08:00
|
|
|
__emojiReplacementRegex = require("pretty-text/emoji").emojiReplacementRegex;
|
2019-03-21 16:11:33 +08:00
|
|
|
__performEmojiEscape = require("pretty-text/emoji").performEmojiEscape;
|
2022-07-06 16:37:54 +08:00
|
|
|
__resetTranslationTree =
|
|
|
|
require("pretty-text/engines/discourse-markdown/emoji").resetTranslationTree;
|
2016-06-15 02:31:51 +08:00
|
|
|
|
2020-05-14 04:23:41 +08:00
|
|
|
I18n = {
|
|
|
|
t(a, b) {
|
|
|
|
return __helpers.t(a, b);
|
2020-09-15 22:59:41 +08:00
|
|
|
},
|
2020-05-14 04:23:41 +08:00
|
|
|
};
|
|
|
|
|
2020-09-15 22:59:41 +08:00
|
|
|
define("I18n", ["exports"], function (exports) {
|
2020-05-14 04:23:41 +08:00
|
|
|
exports.default = I18n;
|
|
|
|
});
|
|
|
|
|
2020-08-20 04:11:36 +08:00
|
|
|
// Formatting doesn't currently need any helper context
|
2020-09-15 22:59:41 +08:00
|
|
|
define("discourse-common/lib/helpers", ["exports"], function (exports) {
|
|
|
|
exports.helperContext = function () {
|
2020-08-20 04:11:36 +08:00
|
|
|
return {};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2018-11-22 14:28:48 +08:00
|
|
|
__utils = require("discourse/lib/utilities");
|
2017-06-29 01:47:22 +08:00
|
|
|
|
|
|
|
__emojiUnicodeReplacer = null;
|
|
|
|
|
2020-09-15 22:59:41 +08:00
|
|
|
__setUnicode = function (replacements) {
|
2021-04-22 14:43:06 +08:00
|
|
|
const regexp = new RegExp(__emojiReplacementRegex, "g");
|
2017-06-29 01:47:22 +08:00
|
|
|
|
2020-09-15 22:59:41 +08:00
|
|
|
__emojiUnicodeReplacer = function (text) {
|
2021-04-22 14:43:06 +08:00
|
|
|
regexp.lastIndex = 0;
|
|
|
|
|
2017-06-29 01:47:22 +08:00
|
|
|
let m;
|
2021-04-22 14:43:06 +08:00
|
|
|
while ((m = regexp.exec(text)) !== null) {
|
|
|
|
let match = m[0];
|
|
|
|
|
|
|
|
let replacement = replacements[match];
|
|
|
|
|
|
|
|
if (!replacement) {
|
|
|
|
// if we can't find replacement for an emoji match
|
|
|
|
// attempts to look for the same without trailing variation selector
|
|
|
|
match = match.replace(/\ufe0f$/g, "");
|
|
|
|
replacement = replacements[match];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!replacement) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
replacement = ":" + replacement + ":";
|
2018-11-22 14:28:48 +08:00
|
|
|
const before = text.charAt(m.index - 1);
|
2017-06-29 01:47:22 +08:00
|
|
|
if (!/\B/.test(before)) {
|
|
|
|
replacement = "\u200b" + replacement;
|
|
|
|
}
|
2021-04-22 14:43:06 +08:00
|
|
|
text = text.replace(match, replacement);
|
2017-06-29 01:47:22 +08:00
|
|
|
}
|
2018-10-08 10:32:25 +08: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 14:28:48 +08:00
|
|
|
text = text.replace(/\ufe0f/g, "");
|
2018-10-08 10:32:25 +08:00
|
|
|
|
2017-06-29 01:47:22 +08:00
|
|
|
return text;
|
|
|
|
};
|
|
|
|
};
|
2016-06-15 02:31:51 +08:00
|
|
|
|
|
|
|
__paths = {};
|
|
|
|
|
|
|
|
function __getURLNoCDN(url) {
|
2021-04-22 14:43:06 +08:00
|
|
|
if (!url) {
|
|
|
|
return url;
|
|
|
|
}
|
2016-06-15 02:31:51 +08:00
|
|
|
|
|
|
|
// if it's a non relative URL, return it.
|
2018-11-22 14:28:48 +08:00
|
|
|
if (url !== "/" && !/^\/[^\/]/.test(url)) {
|
|
|
|
return url;
|
|
|
|
}
|
2016-06-15 02:31:51 +08:00
|
|
|
|
2022-07-18 02:48:36 +08:00
|
|
|
if (url.includes(__paths.baseUri)) {
|
2018-11-22 14:28:48 +08:00
|
|
|
return url;
|
|
|
|
}
|
2021-04-22 14:43:06 +08:00
|
|
|
if (url[0] !== "/") {
|
|
|
|
url = "/" + url;
|
|
|
|
}
|
2016-06-15 02:31:51 +08:00
|
|
|
|
|
|
|
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-29 09:00:25 +08:00
|
|
|
function __lookupUploadUrls(urls) {
|
|
|
|
return __helpers.lookup_upload_urls(urls);
|
2017-08-22 23:46:15 +08:00
|
|
|
}
|
|
|
|
|
2016-06-15 02:31:51 +08: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 14:28:48 +08:00
|
|
|
return __utils.avatarImg(
|
|
|
|
{ size: "tiny", avatarTemplate: __helpers.avatar_template(p) },
|
|
|
|
__getURL
|
|
|
|
);
|
2016-06-15 02:31:51 +08:00
|
|
|
}
|
|
|
|
|
2018-03-14 01:07:51 +08:00
|
|
|
function __formatUsername(username) {
|
|
|
|
return __helpers.format_username(username);
|
2017-11-21 05:28:03 +08:00
|
|
|
}
|
|
|
|
|
2018-03-14 01:07:51 +08:00
|
|
|
function __lookupPrimaryUserGroup(username) {
|
|
|
|
return __helpers.lookup_primary_user_group(username);
|
2017-11-03 21:51:40 +08:00
|
|
|
}
|
|
|
|
|
2016-07-07 15:52:56 +08:00
|
|
|
function __getCurrentUser(userId) {
|
|
|
|
return __helpers.get_current_user(userId);
|
|
|
|
}
|