adjust code style

This commit is contained in:
Airyz 2023-01-11 13:49:10 +10:30
parent 4aeb0b193b
commit 7041aaa62b
3 changed files with 10 additions and 12 deletions

View file

@ -30,7 +30,7 @@ import PhotoIC from '../../../../public/res/ic/outlined/photo.svg';
import BulbIC from '../../../../public/res/ic/outlined/bulb.svg'; import BulbIC from '../../../../public/res/ic/outlined/bulb.svg';
import PeaceIC from '../../../../public/res/ic/outlined/peace.svg'; import PeaceIC from '../../../../public/res/ic/outlined/peace.svg';
import FlagIC from '../../../../public/res/ic/outlined/flag.svg'; import FlagIC from '../../../../public/res/ic/outlined/flag.svg';
import { GetTwemojiCDN } from '../../../util/twemojify'; import { getTwemojiCDN } from '../../../util/twemojify';
const ROW_EMOJIS_COUNT = 7; const ROW_EMOJIS_COUNT = 7;
@ -38,7 +38,7 @@ const EmojiGroup = React.memo(({ name, groupEmojis }) => {
function getEmojiBoard() { function getEmojiBoard() {
const emojiBoard = []; const emojiBoard = [];
const totalEmojis = groupEmojis.length; const totalEmojis = groupEmojis.length;
var cdn = GetTwemojiCDN() var cdn = getTwemojiCDN()
for (let r = 0; r < totalEmojis; r += ROW_EMOJIS_COUNT) { for (let r = 0; r < totalEmojis; r += ROW_EMOJIS_COUNT) {
const emojiRow = []; const emojiRow = [];
for (let c = r; c < r + ROW_EMOJIS_COUNT; c += 1) { for (let c = r; c < r + ROW_EMOJIS_COUNT; c += 1) {
@ -252,7 +252,7 @@ function EmojiBoard({ onSelect, searchRef }) {
$emojiContent.children[tabIndex].scrollIntoView(); $emojiContent.children[tabIndex].scrollIntoView();
} }
var cdn = GetTwemojiCDN() var cdn = getTwemojiCDN()
return ( return (
<div id="emoji-board" className="emoji-board"> <div id="emoji-board" className="emoji-board">

View file

@ -5,7 +5,7 @@ import './RoomViewCmdBar.scss';
import parse from 'html-react-parser'; import parse from 'html-react-parser';
import twemoji from 'twemoji'; import twemoji from 'twemoji';
import { GetTwemojiCDN, twemojify } from '../../../util/twemojify'; import { getTwemojiCDN, twemojify } from '../../../util/twemojify';
import initMatrix from '../../../client/initMatrix'; import initMatrix from '../../../client/initMatrix';
import { getEmojiForCompletion } from '../emoji-board/custom-emoji'; import { getEmojiForCompletion } from '../emoji-board/custom-emoji';
@ -60,7 +60,7 @@ function renderSuggestions({ prefix, option, suggestions }, fireCmd) {
unicode: emoji.unicode, unicode: emoji.unicode,
shortcodes: emoji.shortcodes?.toString(), shortcodes: emoji.shortcodes?.toString(),
}), }),
base: GetTwemojiCDN() base: getTwemojiCDN()
}, },
)); ));
} }

View file

@ -8,12 +8,12 @@ import { sanitizeText } from './sanitize';
const Math = lazy(() => import('../app/atoms/math/Math')); const Math = lazy(() => import('../app/atoms/math/Math'));
const CDN_LOCAL = "/public/twemoji/assets/" const CDN_LOCAL = '/public/twemoji/assets/'
const CDN_EXTERNAL = "https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/"; const CDN_EXTERNAL = 'https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/';
var use_local = false; var use_local = false;
export const GetTwemojiCDN = () => { export const getTwemojiCDN = () => {
if(window.__TAURI__ || use_local){ if(window.__TAURI__ || use_local){
return CDN_LOCAL return CDN_LOCAL
} }
@ -22,8 +22,6 @@ export const GetTwemojiCDN = () => {
} }
}; };
const mathOptions = { const mathOptions = {
replace: (node) => { replace: (node) => {
const maths = node.attribs?.['data-mx-maths']; const maths = node.attribs?.['data-mx-maths'];
@ -60,9 +58,9 @@ export function twemojify(text, opts, linkify = false, sanitize = true, maths =
} }
if(opts){ if(opts){
opts.base = GetTwemojiCDN() opts.base = getTwemojiCDN()
} else { } else {
opts = { base: GetTwemojiCDN() } opts = { base: getTwemojiCDN() }
} }
content = twemoji.parse(content, opts); content = twemoji.parse(content, opts);