Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix conjugated emoji in slate
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy committed Jul 24, 2018
1 parent afa19cd commit 6cd3860
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/RichText.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,25 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';

import * as sdk from './index';
import * as emojione from 'emojione';

import { SelectionRange } from "./autocomplete/Autocompleter";


export function unicodeToEmojiUri(str) {
let replaceWith, unicode, alt;
if ((!emojione.unicodeAlt) || (emojione.sprites)) {
// if we are using the shortname as the alt tag then we need a reversed array to map unicode code point to shortnames
const mappedUnicode = emojione.mapUnicodeToShort();
}

str = str.replace(emojione.regUnicode, function(unicodeChar) {
if ( (typeof unicodeChar === 'undefined') || (unicodeChar === '') || (!(unicodeChar in emojione.jsEscapeMap)) ) {
// if the unicodeChar doesnt exist just return the entire match
const mappedUnicode = emojione.mapUnicodeToShort();

// remove any zero width joiners/spaces used in conjugate emojis as the emojione URIs don't contain them
return str.replace(emojione.regUnicode, function(unicodeChar) {
if ((typeof unicodeChar === 'undefined') || (unicodeChar === '') || (!(unicodeChar in emojione.jsEscapeMap))) {
// if the unicodeChar doesn't exist just return the entire match
return unicodeChar;
} else {
// Remove variant selector VS16 (explicitly emoji) as it is unnecessary and leads to an incorrect URL below
if (unicodeChar.length == 2 && unicodeChar[1] == '\ufe0f') {
unicodeChar = unicodeChar[0];
}

// get the unicode codepoint from the actual char
unicode = emojione.jsEscapeMap[unicodeChar];
const unicode = emojione.jsEscapeMap[unicodeChar];

const short = mappedUnicode[unicode];
const fname = emojione.emojioneList[short].fname;

return emojione.imagePathSVG+unicode+'.svg'+emojione.cacheBustParam;
return emojione.imagePathSVG+fname+'.svg'+emojione.cacheBustParam;
}
});

return str;
}

0 comments on commit 6cd3860

Please sign in to comment.