@@ -6,7 +6,10 @@ import {
66import { DEFAULT_EMOJIS } from '../constants/emojis' ;
77import { DEFAULT_EMOJI_ROOT } from '../config' ;
88
9- export function parseContentWithEmoji ( content , replaceWithImage = true ) {
9+ // This method is also used to copy topic content and comment content,
10+ // the second parameter here is used to exclude custom emoji as paste
11+ // content.
12+ export function parseContentWithEmoji ( content , includeEmoji = true ) {
1013 if ( ! content ) { return '' ; }
1114
1215 // var regex = new RegExp(/xyz/, 'i');
@@ -16,10 +19,12 @@ export function parseContentWithEmoji(content, replaceWithImage = true) {
1619 let contentEmojiArray = contentWithEmoji . split ( '___emojiBoundary___' ) ;
1720
1821 return contentEmojiArray . filter ( item => item . trim ( ) ) . map ( ( item , index ) => {
19- if ( ! replaceWithImage ) { return '' ; }
20-
2122 // Handle custom emojis.
2223 if ( / h t t p s ? : \/ \/ .+ (?: j p g | p n g | g i f ) / . test ( item ) ) {
24+ // Exclude custom emoji because copy something like [mobcent_phiz=..]
25+ // is useless as paste content.
26+ if ( ! includeEmoji ) { return '' ; }
27+
2328 return (
2429 < Image
2530 key = { index }
@@ -32,6 +37,11 @@ export function parseContentWithEmoji(content, replaceWithImage = true) {
3237 //
3338 // Why use hash map here instead of array? O(1).
3439 if ( DEFAULT_EMOJIS . hasOwnProperty ( item ) ) {
40+ // Return custom emoji content directly because emoji content like [阴险]
41+ // could be pasted in text input directly which will also be read in same
42+ // format.
43+ if ( ! includeEmoji ) { return item ; }
44+
3545 return (
3646 < Image
3747 key = { index }
0 commit comments