表情包回显

This commit is contained in:
namezlx 2023-10-29 10:13:29 +08:00
parent 803a374906
commit 9a425358c6
3 changed files with 3032 additions and 4 deletions

13
package-lock.json generated
View File

@ -6959,7 +6959,8 @@
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -7376,7 +7377,8 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -7432,6 +7434,7 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -7475,12 +7478,14 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"optional": true
},
"yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"optional": true
}
}
},

3003
src/common/util/emoji.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ import marked, { getTocContent, cleanToc, getMathExpressions, resetMathExpressio
import 'code-prettify';
import dompurify from 'dompurify';
// import { getEmoji } from '../forge/Main/emoji';
import {emojiList} from '../common/util/emoji'
import axios from 'axios';
import { renderToString } from 'katex'
@ -61,6 +62,25 @@ export default ({
// rs = rs.replace(matchStr[i],getEmoji(matchStr[i]));
// }
// }
if(rs){
for(let i = 0;i<emojiList.length;i++){
if(rs.indexOf(emojiList[i].code)>=0){
const reg = '/\\'+emojiList[i].code+'/g'
switch(emojiList[i].index){
case 1:
rs = rs.replace(eval(reg), `<img style="width:24px;" src="https://testforum.trustie.net/editormd/emoji/${emojiList[i].name}.png"/>`)
case 2:
rs = rs.replace(eval(reg), `<img style="width:24px;" src="https://twemoji.maxcdn.com/36x36/${emojiList[i].name}.png"/>`)
case 3:
rs = rs.replace(eval(reg), `<i class="fa fa-emoji fa-${emojiList[i].name}"></i>`)
case 4:
rs = rs.replace(eval(reg), `<i class="${emojiList[i].name}"></i>`)
}
}
}
}
if(owner && projectsId && issues && issues.length>0){
let matchQuote = str.match(quoteRegex);
if(matchQuote && matchQuote.length>0){