-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add emoji picker in editor (#221)
* feat: add vietnamese * feat: add emoji picker in editor * fix failing checks * move emoji button before upload button * move script to body index.html * Update web/index.html Co-authored-by: boojack <[email protected]>
- Loading branch information
Showing
6 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { forwardRef, useEffect } from "react"; | ||
import Picker, { IEmojiPickerProps } from "emoji-picker-react"; | ||
|
||
export type EmojiPickerElement = HTMLDivElement; | ||
|
||
interface Props { | ||
isShowEmojiPicker: boolean; | ||
onEmojiClick: IEmojiPickerProps["onEmojiClick"]; | ||
handleChangeIsShowEmojiPicker: (status: boolean) => void; | ||
} | ||
|
||
export const EmojiPicker = forwardRef<EmojiPickerElement, Props>((props: Props, ref) => { | ||
const { isShowEmojiPicker, onEmojiClick, handleChangeIsShowEmojiPicker } = props; | ||
|
||
useEffect(() => { | ||
if (isShowEmojiPicker) { | ||
const handleClickOutside = (event: MouseEvent) => { | ||
const emojiWrapper = document.querySelector(".emoji-picker-react"); | ||
const isContains = emojiWrapper?.contains(event.target as Node); | ||
if (!isContains) { | ||
handleChangeIsShowEmojiPicker(false); | ||
} | ||
}; | ||
document.addEventListener("mousedown", handleClickOutside); | ||
return () => { | ||
// Unbind the event listener on clean up | ||
document.removeEventListener("mousedown", handleClickOutside); | ||
}; | ||
} | ||
}, [isShowEmojiPicker]); | ||
|
||
return ( | ||
<div className="emoji-picker" ref={ref}> | ||
<Picker onEmojiClick={onEmojiClick} /> | ||
</div> | ||
); | ||
}); | ||
|
||
EmojiPicker.displayName = "EmojiPicker"; | ||
|
||
export default EmojiPicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,4 +62,12 @@ | |
} | ||
} | ||
} | ||
|
||
.emoji-picker-react { | ||
@apply absolute; | ||
|
||
li.emoji::before { | ||
@apply hidden; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters