mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
Add Emoji/FA Autocompletion (#387)
added emoji/fork-awesome autocompletion added autocompletion e2e test Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
c8c5569426
commit
c15f0d9900
13 changed files with 279 additions and 38 deletions
|
@ -1,5 +1,6 @@
|
|||
import { Editor } from 'codemirror'
|
||||
import { BaseEmoji, CustomEmoji, EmojiData } from 'emoji-mart'
|
||||
import { EmojiData } from 'emoji-mart'
|
||||
import { getEmojiShortCode } from '../../../../utils/emoji'
|
||||
|
||||
export const makeSelectionBold = (editor: Editor): void => wrapTextWith(editor, '**')
|
||||
export const makeSelectionItalic = (editor: Editor): void => wrapTextWith(editor, '*')
|
||||
|
@ -24,14 +25,7 @@ export const addComment = (editor: Editor): void => changeLines(editor, line =>
|
|||
export const addTable = (editor: Editor): void => changeLines(editor, line => `${line}\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |`)
|
||||
|
||||
export const addEmoji = (emoji: EmojiData, editor: Editor): void => {
|
||||
let replacement = ''
|
||||
if ((emoji as BaseEmoji).colons) {
|
||||
replacement = (emoji as BaseEmoji).colons
|
||||
} else if ((emoji as CustomEmoji).imageUrl) {
|
||||
// noinspection CheckTagEmptyBody
|
||||
replacement = `<i class="fa ${(emoji as CustomEmoji).name}"></i>`
|
||||
}
|
||||
insertAtCursor(editor, replacement)
|
||||
insertAtCursor(editor, getEmojiShortCode(emoji))
|
||||
}
|
||||
|
||||
export const wrapTextWith = (editor: Editor, symbol: string, endSymbol?: string): void => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue