Fix icon picker issues
This commit is contained in:
parent
d7f7e52032
commit
0e5a7b61b0
|
@ -1,5 +0,0 @@
|
||||||
import Picker from 'emoji-mart/dist-es/components/picker/picker';
|
|
||||||
|
|
||||||
export {
|
|
||||||
Picker,
|
|
||||||
};
|
|
|
@ -1,11 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
import { IconPicker as IconPickerAsync } from '../utils/async';
|
import Picker from 'emoji-mart/dist-es/components/picker/picker';
|
||||||
import Overlay from 'react-overlays/lib/Overlay';
|
import Overlay from 'react-overlays/lib/Overlay';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import detectPassiveEvents from 'detect-passive-events';
|
import detectPassiveEvents from 'detect-passive-events';
|
||||||
import forkAwesomeIcons from '../forkawesome.json';
|
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -16,12 +15,10 @@ const messages = defineMessages({
|
||||||
search_results: { id: 'emoji_button.search_results', defaultMessage: 'Search results' },
|
search_results: { id: 'emoji_button.search_results', defaultMessage: 'Search results' },
|
||||||
});
|
});
|
||||||
|
|
||||||
let IconPicker; // load asynchronously
|
|
||||||
|
|
||||||
const backgroundImageFn = () => '';
|
const backgroundImageFn = () => '';
|
||||||
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
||||||
|
|
||||||
const categoriesSort = 'custom';
|
const categoriesSort = ['custom'];
|
||||||
|
|
||||||
@injectIntl
|
@injectIntl
|
||||||
class IconPickerMenu extends React.PureComponent {
|
class IconPickerMenu extends React.PureComponent {
|
||||||
|
@ -94,8 +91,9 @@ class IconPickerMenu extends React.PureComponent {
|
||||||
Object.values(customEmojis).forEach(category => {
|
Object.values(customEmojis).forEach(category => {
|
||||||
category.forEach(function(icon) {
|
category.forEach(function(icon) {
|
||||||
const name = icon.replace('fa fa-', '');
|
const name = icon.replace('fa fa-', '');
|
||||||
|
if (icon !== 'email' && icon !== 'memo') {
|
||||||
emojis.push({
|
emojis.push({
|
||||||
id: icon,
|
id: name,
|
||||||
name,
|
name,
|
||||||
short_names: [name],
|
short_names: [name],
|
||||||
emoticons: [],
|
emoticons: [],
|
||||||
|
@ -103,6 +101,7 @@ class IconPickerMenu extends React.PureComponent {
|
||||||
imageUrl: '',
|
imageUrl: '',
|
||||||
render: <Icon id={name} />,
|
render: <Icon id={name} />,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -116,12 +115,13 @@ class IconPickerMenu extends React.PureComponent {
|
||||||
return <div style={{ width: 299 }} />;
|
return <div style={{ width: 299 }} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let data = { compressed: true, categories: [], aliases: [], emojis: [] };
|
||||||
const title = intl.formatMessage(messages.emoji);
|
const title = intl.formatMessage(messages.emoji);
|
||||||
const { modifierOpen } = this.state;
|
const { modifierOpen } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames('font-icon-picker emoji-picker-dropdown__menu', { selecting: modifierOpen })} style={style} ref={this.setRef}>
|
<div className={classNames('font-icon-picker emoji-picker-dropdown__menu', { selecting: modifierOpen })} style={style} ref={this.setRef}>
|
||||||
<IconPicker
|
<Picker
|
||||||
perLine={8}
|
perLine={8}
|
||||||
emojiSize={22}
|
emojiSize={22}
|
||||||
include={categoriesSort}
|
include={categoriesSort}
|
||||||
|
@ -136,8 +136,8 @@ class IconPickerMenu extends React.PureComponent {
|
||||||
showPreview={false}
|
showPreview={false}
|
||||||
backgroundImageFn={backgroundImageFn}
|
backgroundImageFn={backgroundImageFn}
|
||||||
emojiTooltip
|
emojiTooltip
|
||||||
overwriteRender
|
|
||||||
noShowAnchors
|
noShowAnchors
|
||||||
|
data={data}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -156,7 +156,6 @@ class IconPickerDropdown extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
icons: forkAwesomeIcons,
|
|
||||||
active: false,
|
active: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
};
|
};
|
||||||
|
@ -168,18 +167,6 @@ class IconPickerDropdown extends React.PureComponent {
|
||||||
onShowDropdown = ({ target }) => {
|
onShowDropdown = ({ target }) => {
|
||||||
this.setState({ active: true });
|
this.setState({ active: true });
|
||||||
|
|
||||||
if (!IconPicker) {
|
|
||||||
this.setState({ loading: true });
|
|
||||||
|
|
||||||
IconPickerAsync().then(EmojiMart => {
|
|
||||||
IconPicker = EmojiMart.Picker;
|
|
||||||
|
|
||||||
this.setState({ loading: false });
|
|
||||||
}).catch(() => {
|
|
||||||
this.setState({ loading: false });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const { top } = target.getBoundingClientRect();
|
const { top } = target.getBoundingClientRect();
|
||||||
this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' });
|
this.setState({ placement: top * 2 < innerHeight ? 'bottom' : 'top' });
|
||||||
}
|
}
|
||||||
|
@ -215,7 +202,8 @@ class IconPickerDropdown extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { intl, onPickEmoji, value } = this.props;
|
const { intl, onPickEmoji, value } = this.props;
|
||||||
const title = intl.formatMessage(messages.emoji);
|
const title = intl.formatMessage(messages.emoji);
|
||||||
const { active, loading, placement, icons } = this.state;
|
const { active, loading, placement } = this.state;
|
||||||
|
let forkAwesomeIcons = require('../forkawesome.json');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='font-icon-picker-dropdown' onKeyDown={this.handleKeyDown}>
|
<div className='font-icon-picker-dropdown' onKeyDown={this.handleKeyDown}>
|
||||||
|
@ -225,7 +213,7 @@ class IconPickerDropdown extends React.PureComponent {
|
||||||
|
|
||||||
<Overlay show={active} placement={placement} target={this.findTarget}>
|
<Overlay show={active} placement={placement} target={this.findTarget}>
|
||||||
<IconPickerMenu
|
<IconPickerMenu
|
||||||
custom_emojis={icons}
|
custom_emojis={forkAwesomeIcons}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onClose={this.onHideDropdown}
|
onClose={this.onHideDropdown}
|
||||||
onPick={onPickEmoji}
|
onPick={onPickEmoji}
|
||||||
|
|
|
@ -502,13 +502,11 @@
|
||||||
"Brand Icons": [
|
"Brand Icons": [
|
||||||
"fa fa-twitter-square",
|
"fa fa-twitter-square",
|
||||||
"fa fa-facebook-square",
|
"fa fa-facebook-square",
|
||||||
"fa fa-linkedin-square",
|
|
||||||
"fa fa-github-square",
|
"fa fa-github-square",
|
||||||
"fa fa-twitter",
|
"fa fa-twitter",
|
||||||
"fa fa-facebook",
|
"fa fa-facebook",
|
||||||
"fa fa-github",
|
"fa fa-github",
|
||||||
"fa fa-pinterest",
|
"fa fa-pinterest",
|
||||||
"fa fa-pinterest-square",
|
|
||||||
"fa fa-google-plus-square",
|
"fa fa-google-plus-square",
|
||||||
"fa fa-google-plus",
|
"fa fa-google-plus",
|
||||||
"fa fa-linkedin",
|
"fa fa-linkedin",
|
||||||
|
@ -529,7 +527,6 @@
|
||||||
"fa fa-bitbucket",
|
"fa fa-bitbucket",
|
||||||
"fa fa-bitbucket-square",
|
"fa fa-bitbucket-square",
|
||||||
"fa fa-tumblr",
|
"fa fa-tumblr",
|
||||||
"fa fa-tumblr-square",
|
|
||||||
"fa fa-apple",
|
"fa fa-apple",
|
||||||
"fa fa-windows",
|
"fa fa-windows",
|
||||||
"fa fa-android",
|
"fa fa-android",
|
||||||
|
@ -551,7 +548,6 @@
|
||||||
"fa fa-yahoo",
|
"fa fa-yahoo",
|
||||||
"fa fa-google",
|
"fa fa-google",
|
||||||
"fa fa-reddit",
|
"fa fa-reddit",
|
||||||
"fa fa-reddit-square",
|
|
||||||
"fa fa-stumbleupon-circle",
|
"fa fa-stumbleupon-circle",
|
||||||
"fa fa-stumbleupon",
|
"fa fa-stumbleupon",
|
||||||
"fa fa-delicious",
|
"fa fa-delicious",
|
||||||
|
@ -602,7 +598,6 @@
|
||||||
"fa fa-simplybuilt",
|
"fa fa-simplybuilt",
|
||||||
"fa fa-skyatlas",
|
"fa fa-skyatlas",
|
||||||
"fa fa-facebook-official",
|
"fa fa-facebook-official",
|
||||||
"fa fa-pinterest-p",
|
|
||||||
"fa fa-whatsapp",
|
"fa fa-whatsapp",
|
||||||
"fa fa-medium",
|
"fa fa-medium",
|
||||||
"fa fa-medium-square",
|
"fa fa-medium-square",
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
export function IconPicker() {
|
|
||||||
return import(/* webpackChunkName: "icon_picker" */'../components/icon_picker');
|
|
||||||
}
|
|
|
@ -4475,7 +4475,7 @@ elliptic@^6.0.0:
|
||||||
|
|
||||||
"emoji-mart@https://gitlab.com/seanking2919/emoji-mart#build":
|
"emoji-mart@https://gitlab.com/seanking2919/emoji-mart#build":
|
||||||
version "2.6.3"
|
version "2.6.3"
|
||||||
resolved "https://gitlab.com/seanking2919/emoji-mart#c2d4dc6232e1cb1fd9541a12d2748015cddb14b1"
|
resolved "https://gitlab.com/seanking2919/emoji-mart#4bdefa3d3ee7eb58716adc8727f688facc557291"
|
||||||
|
|
||||||
emoji-regex@^7.0.1:
|
emoji-regex@^7.0.1:
|
||||||
version "7.0.3"
|
version "7.0.3"
|
||||||
|
|
Loading…
Reference in New Issue