mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-26 19:53:59 -05:00
Insert short code instead of native emoji (#397)
This commit is contained in:
parent
1ba4859489
commit
1cf5a3d375
2 changed files with 7 additions and 7 deletions
|
@ -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()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -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>`
|
||||||
|
|
Loading…
Reference in a new issue