diff --git a/apps/common/mobile/lib/view/collaboration/Comments.jsx b/apps/common/mobile/lib/view/collaboration/Comments.jsx index 0311bf177..e4daa793e 100644 --- a/apps/common/mobile/lib/view/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/view/collaboration/Comments.jsx @@ -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: '' + subStr + ''}); + 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) && (offsetitem.start)); + }); + if (!elem) + arrayComment.push({start: offset, end: len+offset, str: '' + subStr + ''}); + 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) && (offsetitem.start)); + }); + if (!elem) + arrayComment.push({start: offset, end: len+offset, str: '' + subStr + ''}); + 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; i0) { + str_res += Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, message.length)); + } + + return str_res; +} + // View comments const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment}) => { const { t } = useTranslation(); @@ -615,7 +668,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
{comment.quote &&
{sliceQuote(comment.quote)}
} -
{comment.comment}
+
{comment.replies.length > 0 &&
    {comment.replies.map((reply, indexReply) => { @@ -645,7 +698,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes }
-
{reply.reply}
+
@@ -670,6 +723,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes const _ViewComments = inject('storeComments', 'storeAppOptions')(observer(ViewComments)); + const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment}) => { const { t } = useTranslation(); 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 ? window.open(link)} href={(link[0]==="w" ? "//" : "") + link} key={arrayComments.length}>{link} - : text)}) return ( @@ -740,7 +790,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
{comment.quote &&
{sliceQuote(comment.quote)}
} -
{arrayComments}
+
{comment.replies.length > 0 &&
    {comment.replies.map((reply, indexReply) => { @@ -770,7 +820,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC }
-
{reply.reply}
+