mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 21:51:41 +08:00
`discourse-common` was created in the past to share logic between the 'wizard' app and the main 'discourse' app. Since then, the wizard has been consolidated into the main app, so the separation of `discourse-common` is no longer useful. This commit moves `discourse-common/(lib|utils)/*` into `discourse/lib/*`, adds shims for the imports, and updates existing uses in core.
87 lines
2 KiB
JavaScript
Vendored
87 lines
2 KiB
JavaScript
Vendored
import { deepMerge } from "discourse/lib/object";
|
|
|
|
// the options are passed here and must be explicitly allowed with
|
|
// the const options & state below
|
|
export default function buildOptions(state) {
|
|
const {
|
|
siteSettings,
|
|
getURL,
|
|
lookupAvatar,
|
|
lookupPrimaryUserGroup,
|
|
getTopicInfo,
|
|
topicId,
|
|
postId,
|
|
forceQuoteLink,
|
|
userId,
|
|
getCurrentUser,
|
|
currentUser,
|
|
lookupAvatarByPostNumber,
|
|
lookupPrimaryUserGroupByPostNumber,
|
|
formatUsername,
|
|
emojiUnicodeReplacer,
|
|
lookupUploadUrls,
|
|
previewing,
|
|
censoredRegexp,
|
|
disableEmojis,
|
|
customEmojiTranslation,
|
|
watchedWordsReplace,
|
|
watchedWordsLink,
|
|
emojiDenyList,
|
|
featuresOverride,
|
|
markdownItRules,
|
|
additionalOptions,
|
|
hashtagTypesInPriorityOrder,
|
|
hashtagIcons,
|
|
hashtagLookup,
|
|
} = state;
|
|
|
|
let features = {};
|
|
|
|
if (state.features) {
|
|
features = deepMerge(features, state.features);
|
|
}
|
|
|
|
const options = {
|
|
sanitize: true,
|
|
getURL,
|
|
features,
|
|
lookupAvatar,
|
|
lookupPrimaryUserGroup,
|
|
getTopicInfo,
|
|
topicId,
|
|
postId,
|
|
forceQuoteLink,
|
|
userId,
|
|
getCurrentUser,
|
|
currentUser,
|
|
lookupAvatarByPostNumber,
|
|
lookupPrimaryUserGroupByPostNumber,
|
|
formatUsername,
|
|
emojiUnicodeReplacer,
|
|
lookupUploadUrls,
|
|
censoredRegexp,
|
|
customEmojiTranslation,
|
|
allowedHrefSchemes: siteSettings.allowed_href_schemes
|
|
? siteSettings.allowed_href_schemes.split("|")
|
|
: null,
|
|
allowedIframes: siteSettings.allowed_iframes
|
|
? siteSettings.allowed_iframes
|
|
.split("|")
|
|
.filter((str) => (str.match(/\//g) || []).length >= 3)
|
|
: [], // Only allow urls with at least 3 slashes. Ex: 'https://example.com/'.
|
|
markdownIt: true,
|
|
previewing,
|
|
disableEmojis,
|
|
watchedWordsReplace,
|
|
watchedWordsLink,
|
|
emojiDenyList,
|
|
featuresOverride,
|
|
markdownItRules,
|
|
additionalOptions,
|
|
hashtagTypesInPriorityOrder,
|
|
hashtagIcons,
|
|
hashtagLookup,
|
|
};
|
|
|
|
return { options, siteSettings, state };
|
|
}
|