chore: better Prettier config for easier reviews
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { Emoji as EmojiMart } from 'emoji-mart'
|
||||
import { Emoji as EmojiMart } from "emoji-mart"
|
||||
|
||||
import { EMOJI_SET } from './emojiPlugin'
|
||||
import { EMOJI_SET } from "./emojiPlugin"
|
||||
|
||||
export interface EmojiProps {
|
||||
value: string
|
||||
|
@ -1,13 +1,13 @@
|
||||
import 'emoji-mart/css/emoji-mart.css'
|
||||
import type { EmojiData } from 'emoji-mart'
|
||||
import { Picker } from 'emoji-mart'
|
||||
import { useTheme } from 'next-themes'
|
||||
import "emoji-mart/css/emoji-mart.css"
|
||||
import type { EmojiData } from "emoji-mart"
|
||||
import { Picker } from "emoji-mart"
|
||||
import { useTheme } from "next-themes"
|
||||
|
||||
import { EMOJI_SET } from '../emojiPlugin'
|
||||
import { EMOJI_SET } from "../emojiPlugin"
|
||||
|
||||
export type EmojiPickerOnClick = (
|
||||
emoji: EmojiData,
|
||||
event: React.MouseEvent<HTMLElement, MouseEvent>
|
||||
event: React.MouseEvent<HTMLElement, MouseEvent>,
|
||||
) => void
|
||||
|
||||
export interface EmojiPickerProps {
|
||||
@ -20,7 +20,7 @@ export const EmojiPicker: React.FC<EmojiPickerProps> = (props) => {
|
||||
return (
|
||||
<Picker
|
||||
set={EMOJI_SET}
|
||||
theme={theme as 'light' | 'dark' | 'auto'}
|
||||
theme={theme as "light" | "dark" | "auto"}
|
||||
onClick={props.onClick}
|
||||
showPreview={false}
|
||||
showSkinTones={false}
|
||||
|
@ -1 +1 @@
|
||||
export * from './EmojiPicker'
|
||||
export * from "./EmojiPicker"
|
||||
|
@ -1,21 +1,21 @@
|
||||
import { visit } from 'unist-util-visit'
|
||||
import type { Plugin, Transformer } from 'unified'
|
||||
import type { Literal, Parent } from 'unist'
|
||||
import type { ElementContent } from 'hast'
|
||||
import type { EmojiSet } from 'emoji-mart'
|
||||
import { visit } from "unist-util-visit"
|
||||
import type { Plugin, Transformer } from "unified"
|
||||
import type { Literal, Parent } from "unist"
|
||||
import type { ElementContent } from "hast"
|
||||
import type { EmojiSet } from "emoji-mart"
|
||||
|
||||
import { emojiRegex } from './isStringWithOnlyOneEmoji'
|
||||
import { emojiRegex } from "./isStringWithOnlyOneEmoji"
|
||||
|
||||
export const EMOJI_SET: EmojiSet = 'twitter'
|
||||
export const EMOJI_SET: EmojiSet = "twitter"
|
||||
|
||||
const extractText = (
|
||||
string: string,
|
||||
start: number,
|
||||
end: number
|
||||
end: number,
|
||||
): ElementContent => {
|
||||
return {
|
||||
type: 'text',
|
||||
value: string.slice(start, end)
|
||||
type: "text",
|
||||
value: string.slice(start, end),
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,9 +23,9 @@ export const emojiPlugin: Plugin<[], Literal<string>> = () => {
|
||||
const transformer: Transformer<Literal<string>> = (tree) => {
|
||||
visit<Literal<string>, string>(
|
||||
tree,
|
||||
'text',
|
||||
"text",
|
||||
(node, position, parent: Parent<ElementContent> | null) => {
|
||||
if (typeof node.value !== 'string') {
|
||||
if (typeof node.value !== "string") {
|
||||
return
|
||||
}
|
||||
position = position ?? 0
|
||||
@ -38,15 +38,15 @@ export const emojiPlugin: Plugin<[], Literal<string>> = () => {
|
||||
definition.push(extractText(node.value, lastIndex, match.index))
|
||||
}
|
||||
definition.push({
|
||||
type: 'element',
|
||||
tagName: 'emoji',
|
||||
type: "element",
|
||||
tagName: "emoji",
|
||||
properties: { value },
|
||||
children: []
|
||||
children: [],
|
||||
})
|
||||
lastIndex = match.index + value.length
|
||||
if (lastIndex !== node.value.length) {
|
||||
definition.push(
|
||||
extractText(node.value, lastIndex, node.value.length)
|
||||
extractText(node.value, lastIndex, node.value.length),
|
||||
)
|
||||
}
|
||||
if (parent != null) {
|
||||
@ -56,7 +56,7 @@ export const emojiPlugin: Plugin<[], Literal<string>> = () => {
|
||||
parent.children = parent.children.concat(last)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
return transformer
|
||||
|
@ -1,4 +1,4 @@
|
||||
export * from './Emoji'
|
||||
export * from './EmojiPicker'
|
||||
export * from './emojiPlugin'
|
||||
export * from './isStringWithOnlyOneEmoji'
|
||||
export * from "./Emoji"
|
||||
export * from "./EmojiPicker"
|
||||
export * from "./emojiPlugin"
|
||||
export * from "./isStringWithOnlyOneEmoji"
|
||||
|
Reference in New Issue
Block a user