Fix Bug 47237 modification v2
This commit is contained in:
parent
4355f29cfc
commit
14220fe977
|
@ -571,6 +571,59 @@ const EditReply = ({comment, reply, onEditReply}) => {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pickLink = (message) => {
|
||||||
|
let arrayComment = [], offset, len;
|
||||||
|
message.replace(Common.Utils.ipStrongRe, function(subStr) {
|
||||||
|
let result = /[\.,\?\+;:=!\(\)]+$/.exec(subStr);
|
||||||
|
if (result)
|
||||||
|
subStr = subStr.substring(0, result.index);
|
||||||
|
offset = arguments[arguments.length-2];
|
||||||
|
arrayComment.push({start: offset, end: subStr.length+offset, str: '<a onclick="window.open(href).focus()" href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
if (message.length<1000 || message.search(/\S{255,}/)<0)
|
||||||
|
message.replace(Common.Utils.hostnameStrongRe, function(subStr) {
|
||||||
|
let result = /[\.,\?\+;:=!\(\)]+$/.exec(subStr);
|
||||||
|
if (result)
|
||||||
|
subStr = subStr.substring(0, result.index);
|
||||||
|
let ref = (! /(((^https?)|(^ftp)):\/\/)/i.test(subStr) ) ? ('http://' + subStr) : subStr;
|
||||||
|
offset = arguments[arguments.length-2];
|
||||||
|
len = subStr.length;
|
||||||
|
let elem = arrayComment.find(function(item){
|
||||||
|
return ( (offset>=item.start) && (offset<item.end) ||
|
||||||
|
(offset<=item.start) && (offset+len>item.start));
|
||||||
|
});
|
||||||
|
if (!elem)
|
||||||
|
arrayComment.push({start: offset, end: len+offset, str: '<a onclick="window.open(href).focus()" href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
message.replace(Common.Utils.emailStrongRe, function(subStr) {
|
||||||
|
let ref = (! /((^mailto:)\/\/)/i.test(subStr) ) ? ('mailto:' + subStr) : subStr;
|
||||||
|
offset = arguments[arguments.length-2];
|
||||||
|
len = subStr.length;
|
||||||
|
let elem = arrayComment.find(function(item){
|
||||||
|
return ( (offset>=item.start) && (offset<item.end) ||
|
||||||
|
(offset<=item.start) && (offset+len>item.start));
|
||||||
|
});
|
||||||
|
if (!elem)
|
||||||
|
arrayComment.push({start: offset, end: len+offset, str: '<a onclick="window.open(href).focus()" href="' + ref + '">' + subStr + '</a>'});
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
arrayComment = arrayComment.sort(function(item){ return item.start; });
|
||||||
|
let str_res = (arrayComment.length>0) ? ( Common.Utils.String.htmlEncode(message.substring(0, arrayComment[0].start)) + arrayComment[0].str) : Common.Utils.String.htmlEncode(message);
|
||||||
|
for (var i=1; i<arrayComment.length; i++) {
|
||||||
|
str_res += (Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, arrayComment[i].start)) + arrayComment[i].str);
|
||||||
|
}
|
||||||
|
if (arrayComment.length>0) {
|
||||||
|
str_res += Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, message.length));
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_res;
|
||||||
|
}
|
||||||
|
|
||||||
// View comments
|
// View comments
|
||||||
const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment}) => {
|
const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -615,7 +668,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
||||||
</div>
|
</div>
|
||||||
<div slot='footer'>
|
<div slot='footer'>
|
||||||
{comment.quote && <div className='comment-quote'>{sliceQuote(comment.quote)}</div>}
|
{comment.quote && <div className='comment-quote'>{sliceQuote(comment.quote)}</div>}
|
||||||
<div className='comment-text'><pre>{comment.comment}</pre></div>
|
<div className='comment-text' dangerouslySetInnerHTML={{__html: pickLink(comment.comment)}}></div>
|
||||||
{comment.replies.length > 0 &&
|
{comment.replies.length > 0 &&
|
||||||
<ul className='reply-list'>
|
<ul className='reply-list'>
|
||||||
{comment.replies.map((reply, indexReply) => {
|
{comment.replies.map((reply, indexReply) => {
|
||||||
|
@ -645,7 +698,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div slot='footer'>
|
<div slot='footer'>
|
||||||
<div className='reply-text'><pre>{reply.reply}</pre></div>
|
<div className='reply-text' dangerouslySetInnerHTML={{__html: pickLink(reply.reply)}}></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -670,6 +723,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
|
||||||
|
|
||||||
const _ViewComments = inject('storeComments', 'storeAppOptions')(observer(ViewComments));
|
const _ViewComments = inject('storeComments', 'storeAppOptions')(observer(ViewComments));
|
||||||
|
|
||||||
|
|
||||||
const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment}) => {
|
const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const _t = t('Common.Collaboration', {returnObjects: true});
|
const _t = t('Common.Collaboration', {returnObjects: true});
|
||||||
|
@ -703,10 +757,6 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let arrayComments = []
|
|
||||||
comment.comment && comment.comment.replace(/((?:https?:\/\/|ftps?:\/\/|\bwww\.)(?:(?![.,?!;:()]*(?:\s|$))[^\s]){2,})|(\n+|(?:(?!(?:https?:\/\/|ftp:\/\/|\bwww\.)(?:(?![.,?!;:()]*(?:\s|$))[^\s]){2,}).)+)/gim,
|
|
||||||
(match, link, text) => {console.log(match); arrayComments.push(link ? <a onClick={() => window.open(link)} href={(link[0]==="w" ? "//" : "") + link} key={arrayComments.length}>{link}</a>
|
|
||||||
: text)})
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Toolbar position='bottom'>
|
<Toolbar position='bottom'>
|
||||||
|
@ -740,7 +790,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
||||||
</div>
|
</div>
|
||||||
<div slot='footer'>
|
<div slot='footer'>
|
||||||
{comment.quote && <div className='comment-quote'>{sliceQuote(comment.quote)}</div>}
|
{comment.quote && <div className='comment-quote'>{sliceQuote(comment.quote)}</div>}
|
||||||
<div className='comment-text'><pre>{arrayComments}</pre></div>
|
<div className='comment-text' dangerouslySetInnerHTML={{__html: pickLink(comment.comment)}}></div>
|
||||||
{comment.replies.length > 0 &&
|
{comment.replies.length > 0 &&
|
||||||
<ul className='reply-list'>
|
<ul className='reply-list'>
|
||||||
{comment.replies.map((reply, indexReply) => {
|
{comment.replies.map((reply, indexReply) => {
|
||||||
|
@ -770,7 +820,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div slot='footer'>
|
<div slot='footer'>
|
||||||
<div className='reply-text'><pre>{reply.reply}</pre></div>
|
<div className='reply-text' dangerouslySetInnerHTML={{__html: pickLink(reply.reply)}}></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue