remove kindeEditor

dev_aliyun2
harry 5 years ago
parent 6706cb5135
commit 54a44ebb61

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name=”Keywords” Content=”EduCoder,信息技术实践教学,精品课程网,慕课MOOC″>
@ -37,7 +38,7 @@
<link rel="stylesheet" type="text/css" href="%PUBLIC_URL%/css/css_min_all.css">
<link rel="stylesheet" type="text/css" href="%PUBLIC_URL%/css/iconfont.css">
<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/quill/1.3.7/quill.core.min.css">
</head>
@ -52,31 +53,6 @@
<!-- js css合并 文件优先级的问题 -->
<script type="text/javascript" src="%PUBLIC_URL%/js/js_min_all.js"></script>
<script type="text/javascript" src="%PUBLIC_URL%/js/flv.min.js"></script>
<!-- 在tpi js里加载这3个脚本 -->
<script>
(function () { // Scoping function to avoid globals
var href = location.href;
if (window.location.port === "3007") {
if (href.indexOf('/tasks/') != -1) {
document.write('<script type="text/javascript" src="https://newweb.educoder.net/assets/kindeditor/kindeditor.js"><\/script>');
document.write('<script type="text/javascript" src="/js/create_kindeditor.js"><\/script>');
document.write('<script type="text/javascript" src="https://newweb.educoder.net/javascripts/educoder/edu_application.js"><\/script>');
} else if (href.indexOf('/paths/') != -1) {
document.write('<script type="text/javascript" src="https://newweb.educoder.net/javascripts/educoder/edu_application.js"><\/script>');
}
} else {
if (href.indexOf('/tasks/') != -1) {
document.write('<script type="text/javascript" src="/assets/kindeditor/kindeditor.js"><\/script>');
document.write('<script type="text/javascript" src="%PUBLIC_URL%/js/create_kindeditor.js"><\/script>');
document.write('<script type="text/javascript" src="/javascripts/educoder/edu_application.js"><\/script>');
} else if (href.indexOf('/paths/') != -1) {
document.write('<script type="text/javascript" src="/javascripts/educoder/edu_application.js"><\/script>');
}
}
})();
</script>
<script type="text/javascript" src="https://cdn.bootcss.com/quill/1.3.7/quill.core.min.js"></script>
</body>

@ -109,16 +109,13 @@ class TPIContextProvider extends Component {
}
componentWillUnmount() {
this._updateCostTime();
this.costTimeInterval && window.clearInterval(this.costTimeInterval)
}
componentDidMount() {
window.$(window).unload( ()=>{
console.log(12321)
});
// TODO 登录状态的判断?
// request
// var shixunId = this.props.match.params.shixunId;
var stageId = this.props.match.params.stageId;
window.__fetchAllFlag = false;
@ -135,25 +132,8 @@ class TPIContextProvider extends Component {
})
}
}, 1000)
// 页面离开时存下用户的任务耗时
window.$(window).bind('beforeunload', function (e) {
console.log(111111)
this._updateCostTime();
})
// // 页面离开时存下用户的任务耗时
// window.$(window).unload( ()=>{
// this._updateCostTime();
// });
}
// force 评测通过后异步执行该方法强制同步costTime到服务端
_updateCostTime(async = false, force) {
const { game, loading } = this.state;

@ -2,34 +2,9 @@ import React, { Component } from 'react'
import { Tooltip } from 'antd'
import './Comment.css'
const $ = window.$
function pasteListener(event) {
if (event.clipboardData.types[0] === 'Files') {
event.preventDefault();
}
}
class CommentInput extends Component {
componentWillReceiveProps(newProps, newContext) {
// TODO 暂没有切实训的场景
if (newProps.challenge && newProps.challenge.shixun_id
&& (!this.props.challenge.shixun_id || newProps.challenge.shixun_id != this.props.challenge.shixun_id)) {
setTimeout(() => {
window.sd_create_editor_from_shixun_data(newProps.challenge.shixun_id, null, "100%", "Shixun");
if ($.browser.mozilla) {
setTimeout(() => {
const _body = $('.ke-edit-iframe')[0].contentWindow.document.body;
_body.removeEventListener('paste', pasteListener)
_body.addEventListener('paste', pasteListener)
}, 4200)
}
}, 100)
}
}
render() {
const { createNewComment, editedComment, commentOnChange, challenge, shixun, loading, praisePlus, gotNewReply, showNewReply } = this.props;
return (

@ -1,61 +0,0 @@
import React, { Component } from 'react';
const _origin = window.location.origin;
class CommentItemKEEditor extends Component {
componentDidUpdate(prevProps) {
const { item, currentReplyComment } = this.props;
if (prevProps.showReplyEditorFlag != this.props.showReplyEditorFlag &&
currentReplyComment && currentReplyComment.id == item.id) {
this.showOrHideEditor(currentReplyComment)
}
}
// 如果未初始化,会先初始化
showOrHideEditor = (comment) => {
const { user } = this.props;
console.log('initReply ', comment)
const $ = window.$;
var id = comment.id
var reply_message_el = `#reply_message_${id}`
var reply_iconup_el = `#reply_iconup_${id}`
if ($(reply_message_el).html() == "") {
$(".reply_to_message").html("");
$(reply_message_el).html(`<div className=\"orig_reply_box borderBottomNone reply_to_message\" id=\"reply_to_message_${id}\">\n <div class=\"homepagePostReplyPortrait mr15 imageFuzzy fl\" id=\"reply_image_${id}\"><a href=\"${user.user_url}\" target=\"_blank\" alt=\"用户头像\"><img alt=\"0?1442652658\" height=\"33\" src=\"${_origin}/images/${user.image_url}\" width=\"33\" /><\/a><\/div>\n <div class=\"orig_textarea fl\" style=\"margin-bottom: 0px\">\n <div nhname=\'new_message_${id}\'>\n <form accept-charset=\"UTF-8\" action=\"/discusses?challenge_id=118&amp;dis_id=61&amp;dis_type=Shixun\" data-remote=\"true\" id=\"new_comment_form\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"HJTbMpfI8LKUpwghfkvgB2SaMmcIVyVdAezyKmzJ7FU=\" /><\/div>\n <input type=\"hidden\" id=\"dis_reply_id\" name=\"reply_id\" value=\"${id}\">\n <div nhname=\'toolbar_container_${id}\'><\/div>\n <textarea placeholder=\"有问题或有建议,请直接给我留言吧!\" id=\"comment_news_${id}\" style=\"display: none\" nhname=\'new_message_textarea_${id}\' name=\"content\"><\/textarea>\n <a id=\"new_message_submit_btn_${id}\" href=\"javascript:void(0)\" onclick=\"this.style.display=\'none\'\" class=\"mt10 task-btn task-btn-orange fr\">发送<\/a>\n <div class=\"cl\"><\/div>\n <p nhname=\'contentmsg_${id}\'><\/p>\n<\/form> <\/div>\n <div class=\"cl\"><\/div>\n <\/div>\n <div class=\"cl\"><\/div>\n<\/div>\n`); //" ide语法识别
$(reply_iconup_el).show();
$(function () {
window.sd_create_editor_from_data(id, null, "100%", "Discuss");
});
} else {
if ($(reply_message_el).is(':visible')) {
$(reply_message_el).hide();
} else {
$(reply_message_el).show();
}
}
// 自动focus
setTimeout(() => {
var iframe = $(`#reply_to_message_${id}`).find('iframe')[0]
iframe && iframe.contentDocument.body.focus()
}, 200)
}
render() {
const { match, history, item, user } = this.props
if (!item) {
return <div></div>
}
return (
<div>
<div className="cl"></div>
<div id={`reply_message_${item.id}`} className="reply_to_message"></div>
</div>
);
}
}
export default (CommentItemKEEditor);

@ -2,7 +2,6 @@ import React, { Component } from 'react';
import { Tooltip, Modal } from 'antd'
import { getImageUrl } from 'educoder';
import CommentItemKEEditor from './CommentItemKEEditor';
import CommentItemMDEditor from './CommentItemMDEditor';
import './Comment.css'
@ -101,36 +100,11 @@ class Comments extends Component {
}
initReply(comment) {
this.props.initReply && this.props.initReply(comment)
// 如果配置的使用kindEditor
if (window.__useKindEditor === true) {
const { user } = this.props;
console.log('initReply ', comment)
const $ = window.$;
var id = comment.id
var reply_message_el = `#reply_message_${id}`
var reply_iconup_el = `#reply_iconup_${id}`
if ($(reply_message_el).html() == "") {
$(".reply_to_message").html("");
$(reply_message_el).html(`<div className=\"orig_reply_box borderBottomNone reply_to_message\" id=\"reply_to_message_${id}\">\n <div class=\"homepagePostReplyPortrait mr15 imageFuzzy fl\" id=\"reply_image_${id}\"><a href=\"${user.user_url}\" target=\"_blank\" alt=\"用户头像\"><img alt=\"0?1442652658\" height=\"33\" src=\"${_origin}/images/${user.image_url}\" width=\"33\" /><\/a><\/div>\n <div class=\"orig_textarea fl\" style=\"margin-bottom: 0px\">\n <div nhname=\'new_message_${id}\'>\n <form accept-charset=\"UTF-8\" action=\"/discusses?challenge_id=118&amp;dis_id=61&amp;dis_type=Shixun\" data-remote=\"true\" id=\"new_comment_form\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"HJTbMpfI8LKUpwghfkvgB2SaMmcIVyVdAezyKmzJ7FU=\" /><\/div>\n <input type=\"hidden\" id=\"dis_reply_id\" name=\"reply_id\" value=\"${id}\">\n <div nhname=\'toolbar_container_${id}\'><\/div>\n <textarea placeholder=\"有问题或有建议,请直接给我留言吧!\" id=\"comment_news_${id}\" style=\"display: none\" nhname=\'new_message_textarea_${id}\' name=\"content\"><\/textarea>\n <a id=\"new_message_submit_btn_${id}\" href=\"javascript:void(0)\" onclick=\"this.style.display=\'none\'\" class=\"mt10 task-btn task-btn-orange fr\">${this.props.buttonText || '发送'}<\/a>\n <div class=\"cl\"><\/div>\n <p nhname=\'contentmsg_${id}\'><\/p>\n<\/form> <\/div>\n <div class=\"cl\"><\/div>\n <\/div>\n <div class=\"cl\"><\/div>\n<\/div>\n`); //" ide语法识别
$(reply_iconup_el).show();
$(function () {
window.sd_create_editor_from_data(id, null, "100%", "Discuss");
});
this.setState({
currentReplyComment: comment,
showReplyEditorFlag: !this.state.showReplyEditorFlag
})
} else {
if ($(reply_message_el).is(':visible')) {
$(reply_message_el).hide();
} else {
$(reply_message_el).show();
}
}
} else { // MD
this.setState({
currentReplyComment: comment,
showReplyEditorFlag: !this.state.showReplyEditorFlag
})
}
}
renderChildenComments(comment) {
if (!comment.children || comment.children.length === 0) {
@ -353,21 +327,13 @@ class Comments extends Component {
</span>
</p>
{/* __useKindEditor暂时没用到了TODO 可以去掉 */}
{window.__useKindEditor ? <CommentItemKEEditor showReplyEditorFlag={showReplyEditorFlag}
<CommentItemMDEditor showReplyEditorFlag={showReplyEditorFlag}
currentReplyComment={currentReplyComment}
item={item}
user={user}
buttonText={this.props.buttonText}
>
</CommentItemKEEditor>
:
<CommentItemMDEditor showReplyEditorFlag={showReplyEditorFlag}
currentReplyComment={currentReplyComment}
item={item}
user={user}
buttonText={this.props.buttonText}
>
</CommentItemMDEditor>
}
</CommentItemMDEditor>
</div>
</div>

@ -492,11 +492,7 @@ class TopicDetail extends Component {
}
// --------------------------------------------------------------------------------------------帖子獎勵 END
showCommentInput = () => {
if (window.__useKindEditor === true) {
this.refs.editor.showEditor();
} else {
this.refs.editor.showEditor();
}
this.refs.editor.showEditor();
}
initReply = (parent) => {
if (!parent.isAllChildrenLoaded) {
@ -557,71 +553,71 @@ class TopicDetail extends Component {
width: 1072px;
}
`}</style>
<CBreadcrumb className={'independent'} items={[
{ to: current_user&&current_user.first_category_url, name: this.props.coursedata.name},
{ to: `/classrooms/${courseId}/boards/${boardId}`, name: memo.board_name },
{ name: '帖子详情'}
]}></CBreadcrumb>
<SendToCourseModal
ref="sendToCourseModal"
{...this.props}
moduleName="帖子"
seletedMessageIds={[messageId]}
></SendToCourseModal>
<div className="clearfix">
<div id="forum_list" className="forum_table mh650">
<div className="padding30 bor-bottom-greyE" style={{paddingBottom: '20px'}}>
<div className="font-16 cdefault clearfix pr pr35">
<span className="noteDetailTitle">{memo.subject}</span>
{ !!memo.sticky && <span className="btn-cir btn-cir-red ml10"
style={{position: 'relative', bottom: '4px'}}>置顶</span>}
{ !!memo.reward && <span className="color-orange font-14 ml15"
data-tip-down={`获得平台奖励金币:${memo.reward}`} >
<i className="iconfont icon-gift mr5"></i>{memo.reward}
</span> }
{/* || current_user.user_id === author_info.user_id */}
{ current_user && (isAdmin || isCurrentUserTheAuthor) &&
<div className="edu-position-hidebox" style={{position: 'absolute', right: '2px',top:'4px'}}>
<a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a>
<ul className="edu-position-hide undis">
{ ( isCurrentUserTheAuthor || isAdmin ) &&
<li><a
onClick={() => this.props.toEditPage( Object.assign({}, this.props.match.params, {'coursesId': this.state.memo.course_id}) ) }
>&nbsp;&nbsp;</a></li>}
{ isAdmin &&
( memo.sticky == true ?
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li>
:
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>&nbsp;&nbsp;</a></li> )
}
{ isAdmin &&
<li><a href="javascript:void(0);" onClick={() => this.refs.sendToCourseModal.setVisible(true)}>&nbsp;&nbsp;</a></li>
}
{ ( isCurrentUserTheAuthor || isAdmin ) && <li>
<a href="javascript:void(0)" onClick={() =>
window.delete_confirm_box_2_react(`onMemoDelete`, '您确定要删除吗?' , memo)}>
&nbsp;&nbsp;</a>
</li>
}
</ul>
</div>
}
</div>
<div className="df mt20">
<img src={setImagesUrl(`/images/${author && author.image_url}`)} className="radius mr10 mt2" width="40px" height="40px"/>
<div className="flex1">
<div className="color-grey-9 lineh-20">
<span class="color-grey-3 mr20 fl" style={{"fontWeight":"400"}}>{author && author.name}</span>
<span className="fl">{moment(memo.created_on).fromNow()} 发布</span>
</div>
<div className="color-grey-9 clearfix">
<span className="fl" style={{marginTop: '4px'}}>
{/* { current_user.admin && <Tooltip title={ "" }>
<CBreadcrumb className={'independent'} items={[
{ to: current_user && current_user.first_category_url, name: this.props.coursedata.name },
{ to: `/classrooms/${courseId}/boards/${boardId}`, name: memo.board_name },
{ name: '帖子详情' }
]}></CBreadcrumb>
<SendToCourseModal
ref="sendToCourseModal"
{...this.props}
moduleName="帖子"
seletedMessageIds={[messageId]}
></SendToCourseModal>
<div className="clearfix">
<div id="forum_list" className="forum_table mh650">
<div className="padding30 bor-bottom-greyE" style={{ paddingBottom: '20px' }}>
<div className="font-16 cdefault clearfix pr pr35">
<span className="noteDetailTitle">{memo.subject}</span>
{!!memo.sticky && <span className="btn-cir btn-cir-red ml10"
style={{ position: 'relative', bottom: '4px' }}>置顶</span>}
{!!memo.reward && <span className="color-orange font-14 ml15"
data-tip-down={`获得平台奖励金币:${memo.reward}`} >
<i className="iconfont icon-gift mr5"></i>{memo.reward}
</span>}
{/* || current_user.user_id === author_info.user_id */}
{current_user && (isAdmin || isCurrentUserTheAuthor) &&
<div className="edu-position-hidebox" style={{ position: 'absolute', right: '2px', top: '4px' }}>
<a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a>
<ul className="edu-position-hide undis">
{(isCurrentUserTheAuthor || isAdmin) &&
<li><a
onClick={() => this.props.toEditPage(Object.assign({}, this.props.match.params, { 'coursesId': this.state.memo.course_id }))}
>&nbsp;&nbsp;</a></li>}
{isAdmin &&
(memo.sticky == true ?
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li>
:
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>&nbsp;&nbsp;</a></li>)
}
{isAdmin &&
<li><a href="javascript:void(0);" onClick={() => this.refs.sendToCourseModal.setVisible(true)}>&nbsp;&nbsp;</a></li>
}
{(isCurrentUserTheAuthor || isAdmin) && <li>
<a href="javascript:void(0)" onClick={() =>
window.delete_confirm_box_2_react(`onMemoDelete`, '您确定要删除吗?', memo)}>
&nbsp;&nbsp;</a>
</li>
}
</ul>
</div>
}
</div>
<div className="df mt20">
<img src={setImagesUrl(`/images/${author && author.image_url}`)} className="radius mr10 mt2" width="40px" height="40px" />
<div className="flex1">
<div className="color-grey-9 lineh-20">
<span class="color-grey-3 mr20 fl" style={{ "fontWeight": "400" }}>{author && author.name}</span>
<span className="fl">{moment(memo.created_on).fromNow()} 发布</span>
</div>
<div className="color-grey-9 clearfix">
<span className="fl" style={{ marginTop: '4px' }}>
{/* { current_user.admin && <Tooltip title={ "" }>
<span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}>
<i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i>
</span>

@ -655,17 +655,10 @@ class MemoDetail extends Component {
}
// --------------------------------------------------------------------------------------------帖子獎勵 END
showCommentInput = () => {
if (window.__useKindEditor === true) {
this.refs.editor.showEditor();
} else {
this.refs.editor.showEditor();
}
this.refs.editor.showEditor();
}
render() {
const { match, history } = this.props
const { memo, recommend_shixun, current_user, author_info } = this.props;
const { memo, author_info } = this.props;
const { comments, hasMoreComments, goldRewardDialogOpen } = this.state;
document.title = memo && memo.subject != undefined ? memo && memo.subject : "交流问答";
if (!memo || this.state.memoLoading) {
@ -673,13 +666,7 @@ class MemoDetail extends Component {
}
// --------------------------------------------------------------------------------------------帖子獎勵 END
showCommentInput = () => {
if (window.__useKindEditor === true) {
this.refs.editor.showEditor();
} else {
this.refs.editor.showEditor();
}
this.refs.editor.showEditor();
}
(_current_user.user_url = `/users/${_current_user.login}`);
memo.isDetailPage = true;
@ -809,12 +796,7 @@ class MemoDetail extends Component {
</div>
}
</div>
{window.__useKindEditor === true ?
<MemoDetailKEEditor ref="editor" memo={memo} {...this.props}></MemoDetailKEEditor>
:
<MemoDetailMDEditor ref="editor" memo={memo} {...this.props}></MemoDetailMDEditor>
}
<MemoDetailMDEditor ref="editor" memo={memo} {...this.props}></MemoDetailMDEditor>
{/* onClick={ this.createNewComment } */}
<div className="padding40 bor-bottom-greyE memoReplies commentsDelegateParent"
style={{ display: (comments && !!comments.length) ? 'block' : 'none' }}>

Loading…
Cancel
Save