|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import ImageLayer from './ImageLayer'
|
|
|
|
|
import { isImageExtension } from 'educoder'
|
|
|
|
|
const $ = window.$;
|
|
|
|
|
export function ImageLayerOfCommentHOC(options = {}) {
|
|
|
|
|
return function wrap(WrappedComponent) {
|
|
|
|
@ -16,18 +17,29 @@ export function ImageLayerOfCommentHOC(options = {}) {
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
// commentsDelegateParent #game_left_contents #tab_con_4
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
$(".commentsDelegateParent")
|
|
|
|
|
.delegate(".J_Comment_Reply .comment_content img, .J_Comment_Reply .childrenCommentsView img","click", (event) => {
|
|
|
|
|
$(options.parentSelector || ".commentsDelegateParent")
|
|
|
|
|
.delegate(options.imgSelector || ".J_Comment_Reply .comment_content img, .J_Comment_Reply .childrenCommentsView img","click", (event) => {
|
|
|
|
|
|
|
|
|
|
const imageSrc = event.target.src
|
|
|
|
|
// 非回复里的头像图片; 非emoticons
|
|
|
|
|
if (imageSrc.indexOf('/images/avatars/User') === -1 &&
|
|
|
|
|
imageSrc.indexOf('kindeditor/plugins/emoticons') === -1 ) {
|
|
|
|
|
this.setState({
|
|
|
|
|
showImage: true,
|
|
|
|
|
imageSrc,
|
|
|
|
|
})
|
|
|
|
|
const imageSrc = event.target.src || event.target.getAttribute('src') || event.target.getAttribute('href')
|
|
|
|
|
// 判断imageSrc是否是图片
|
|
|
|
|
const fileName = event.target.innerHTML.trim()
|
|
|
|
|
if (isImageExtension(imageSrc.trim()) || isImageExtension(fileName)) {
|
|
|
|
|
// 非回复里的头像图片; 非emoticons
|
|
|
|
|
if (imageSrc.indexOf('/images/avatars/User') === -1 &&
|
|
|
|
|
imageSrc.indexOf('kindeditor/plugins/emoticons') === -1 ) {
|
|
|
|
|
this.setState({
|
|
|
|
|
showImage: true,
|
|
|
|
|
imageSrc,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
event.preventDefault && event.preventDefault()
|
|
|
|
|
event.originalEvent.preventDefault()
|
|
|
|
|
// event.originalEvent.stopPropagation()
|
|
|
|
|
// event.originalEvent.cancelBubble = true
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}, 3000)
|
|
|
|
|
|
|
|
|
|