PLT-1378 Initial version of emoji reactions (#4520)
* Refactored emoji.json to support multiple aliases and emoji categories * Added custom category to emoji.jsx and stabilized all fields * Removed conflicting aliases for :mattermost: and :ca: * fixup after store changes * Added emoji reactions * Removed reactions for an emoji when that emoji is deleted * Fixed incorrect test case * Renamed ReactionList to ReactionListView * Fixed 👍 and 👎 not showing up as possible reactions * Removed text emoticons from emoji reaction autocomplete * Changed emoji reactions to be sorted by the order that they were first created * Set a maximum number of listeners for the ReactionStore * Removed unused code from Textbox component * Fixed reaction permissions * Changed error code when trying to modify reactions for another user * Fixed merge conflicts * Properly applied theme colours to reactions * Fixed ESLint and gofmt errors * Fixed ReactionListContainer to properly update when its post prop changes * Removed unnecessary escape characters from reaction regexes * Shared reaction message pattern between CreatePost and CreateComment * Removed an unnecessary select query when saving a reaction * Changed reactions route to be under /reactions * Fixed copyright dates on newly added files * Removed debug code that prevented all unit tests from being ran * Cleaned up unnecessary code for reactions * Renamed ReactionStore.List to ReactionStore.GetForPost
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2bf0342d13
Коммит
165ad0d4f7
@@ -46,20 +46,23 @@ export default class EmoticonProvider {
|
||||
handlePretextChanged(suggestionId, pretext) {
|
||||
let hasSuggestions = false;
|
||||
|
||||
// look for partial matches among the named emojis
|
||||
const captured = (/(?:^|\s)(:([^:\s]*))$/g).exec(pretext);
|
||||
// look for the potential emoticons at the start of the text, after whitespace, and at the start of emoji reaction commands
|
||||
const captured = (/(^|\s|^\+|^-)(:([^:\s]*))$/g).exec(pretext);
|
||||
if (captured) {
|
||||
const text = captured[1];
|
||||
const partialName = captured[2];
|
||||
const prefix = captured[1];
|
||||
const text = captured[2];
|
||||
const partialName = captured[3];
|
||||
|
||||
const matched = [];
|
||||
|
||||
// check for text emoticons
|
||||
for (const emoticon of Object.keys(Emoticons.emoticonPatterns)) {
|
||||
if (Emoticons.emoticonPatterns[emoticon].test(text)) {
|
||||
SuggestionStore.addSuggestion(suggestionId, text, EmojiStore.get(emoticon), EmoticonSuggestion, text);
|
||||
// check for text emoticons if this isn't for an emoji reaction
|
||||
if (prefix !== '-' && prefix !== '+') {
|
||||
for (const emoticon of Object.keys(Emoticons.emoticonPatterns)) {
|
||||
if (Emoticons.emoticonPatterns[emoticon].test(text)) {
|
||||
SuggestionStore.addSuggestion(suggestionId, text, EmojiStore.get(emoticon), EmoticonSuggestion, text);
|
||||
|
||||
hasSuggestions = true;
|
||||
hasSuggestions = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,11 +79,14 @@ export default class EmoticonProvider {
|
||||
|
||||
// sort the emoticons so that emoticons starting with the entered text come first
|
||||
matched.sort((a, b) => {
|
||||
const aPrefix = a.name.startsWith(partialName);
|
||||
const bPrefix = b.name.startsWith(partialName);
|
||||
const aName = a.name || a.aliases[0];
|
||||
const bName = b.name || b.aliases[0];
|
||||
|
||||
const aPrefix = aName.startsWith(partialName);
|
||||
const bPrefix = bName.startsWith(partialName);
|
||||
|
||||
if (aPrefix === bPrefix) {
|
||||
return a.name.localeCompare(b.name);
|
||||
return aName.localeCompare(bName);
|
||||
} else if (aPrefix) {
|
||||
return -1;
|
||||
}
|
||||
@@ -88,7 +94,7 @@ export default class EmoticonProvider {
|
||||
return 1;
|
||||
});
|
||||
|
||||
const terms = matched.map((emoticon) => ':' + emoticon.name + ':');
|
||||
const terms = matched.map((emoticon) => ':' + (emoticon.name || emoticon.aliases[0]) + ':');
|
||||
|
||||
SuggestionStore.clearSuggestions(suggestionId);
|
||||
if (terms.length > 0) {
|
||||
|
||||
Ссылка в новой задаче
Block a user