|
|
@@ -16,24 +16,24 @@ export default class EmojiPickerHelper {
|
|
|
this.editor = editor;
|
|
|
}
|
|
|
|
|
|
- setStyle = (): CSSProperties => {
|
|
|
- const offset = 20;
|
|
|
- const emojiPickerHeight = 420;
|
|
|
- const cursorPos = this.editor.cursorCoords(true);
|
|
|
- const editorPos = this.editor.getWrapperElement().getBoundingClientRect();
|
|
|
- // Emoji Picker bottom position exceed editor's bottom position
|
|
|
- if (cursorPos.bottom + emojiPickerHeight > editorPos.bottom) {
|
|
|
- return {
|
|
|
- top: editorPos.bottom - emojiPickerHeight,
|
|
|
- left: cursorPos.left + offset,
|
|
|
- position: 'fixed',
|
|
|
- };
|
|
|
- }
|
|
|
+ setStyle = (): CSSProperties => {
|
|
|
+ const offset = 20;
|
|
|
+ const emojiPickerHeight = 420;
|
|
|
+ const cursorPos = this.editor.cursorCoords(true);
|
|
|
+ const editorPos = this.editor.getWrapperElement().getBoundingClientRect();
|
|
|
+ // Emoji Picker bottom position exceed editor's bottom position
|
|
|
+ if (cursorPos.bottom + emojiPickerHeight > editorPos.bottom) {
|
|
|
return {
|
|
|
- top: cursorPos.top + offset,
|
|
|
+ top: editorPos.bottom - emojiPickerHeight,
|
|
|
left: cursorPos.left + offset,
|
|
|
position: 'fixed',
|
|
|
};
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ top: cursorPos.top + offset,
|
|
|
+ left: cursorPos.left + offset,
|
|
|
+ position: 'fixed',
|
|
|
+ };
|
|
|
};
|
|
|
|
|
|
shouldModeTurnOn = (char: string): Position | null | undefined => {
|
|
|
@@ -46,21 +46,21 @@ export default class EmojiPickerHelper {
|
|
|
if (sc.findPrevious()) {
|
|
|
return sc.pos.from;
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
shouldOpen = (startPos: Position): boolean => {
|
|
|
const currentPos = this.editor.getCursor();
|
|
|
const rangeStr = this.editor.getRange(startPos, currentPos);
|
|
|
|
|
|
return EMOJI_PATTERN.test(rangeStr);
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
getInitialSearchingText = (startPos: Position): void => {
|
|
|
const currentPos = this.editor.getCursor();
|
|
|
const rangeStr = this.editor.getRange(startPos, currentPos);
|
|
|
|
|
|
return rangeStr.slice(1); // return without the heading ':'
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
addEmoji = (emoji: { colons: string }, startPosToReplace: Position|null): void => {
|
|
|
const currentPos = this.editor.getCursor();
|