Insert short code instead of native emoji (#397)

This commit is contained in:
mrdrogdrog 2020-08-09 10:15:58 +02:00 committed by GitHub
parent 1ba4859489
commit 1cf5a3d375
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -1646,7 +1646,7 @@ describe('test addEmoji with native emoji', () => {
const { cursor, firstLine, multiline, multilineOffset } = buildRanges() const { cursor, firstLine, multiline, multilineOffset } = buildRanges()
const textFirstLine = testContent.split('\n')[0] const textFirstLine = testContent.split('\n')[0]
const emoji = Mock.of<EmojiData>({ const emoji = Mock.of<EmojiData>({
native: '👍' colons: ':+1:'
}) })
it('just cursor', done => { it('just cursor', done => {
Mock.extend(editor).with({ Mock.extend(editor).with({
@ -1661,7 +1661,7 @@ describe('test addEmoji with native emoji', () => {
), ),
getLine: (): string => (textFirstLine), getLine: (): string => (textFirstLine),
replaceRange: (replacement: string | string[]) => { replaceRange: (replacement: string | string[]) => {
expect(replacement).toEqual('👍') expect(replacement).toEqual(':+1:')
done() done()
} }
}) })
@ -1683,7 +1683,7 @@ describe('test addEmoji with native emoji', () => {
replaceRange: (replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position) => { replaceRange: (replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position) => {
expect(from).toEqual(firstLine.from) expect(from).toEqual(firstLine.from)
expect(to).toEqual(firstLine.to) expect(to).toEqual(firstLine.to)
expect(replacement).toEqual('👍') expect(replacement).toEqual(':+1:')
done() done()
} }
}) })
@ -1705,7 +1705,7 @@ describe('test addEmoji with native emoji', () => {
replaceRange: (replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position) => { replaceRange: (replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position) => {
expect(from).toEqual(multiline.from) expect(from).toEqual(multiline.from)
expect(to).toEqual(multiline.to) expect(to).toEqual(multiline.to)
expect(replacement).toEqual('👍') expect(replacement).toEqual(':+1:')
done() done()
} }
}) })
@ -1727,7 +1727,7 @@ describe('test addEmoji with native emoji', () => {
replaceRange: (replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position) => { replaceRange: (replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position) => {
expect(from).toEqual(multilineOffset.from) expect(from).toEqual(multilineOffset.from)
expect(to).toEqual(multilineOffset.to) expect(to).toEqual(multilineOffset.to)
expect(replacement).toEqual('👍') expect(replacement).toEqual(':+1:')
done() done()
} }
}) })

View file

@ -25,8 +25,8 @@ export const addTable = (editor: Editor): void => changeLines(editor, line => `$
export const addEmoji = (emoji: EmojiData, editor: Editor): void => { export const addEmoji = (emoji: EmojiData, editor: Editor): void => {
let replacement = '' let replacement = ''
if ((emoji as BaseEmoji).native) { if ((emoji as BaseEmoji).colons) {
replacement = (emoji as BaseEmoji).native replacement = (emoji as BaseEmoji).colons
} else if ((emoji as CustomEmoji).imageUrl) { } else if ((emoji as CustomEmoji).imageUrl) {
// noinspection CheckTagEmptyBody // noinspection CheckTagEmptyBody
replacement = `<i class="fa ${(emoji as CustomEmoji).name}"></i>` replacement = `<i class="fa ${(emoji as CustomEmoji).name}"></i>`