Commit 1f2844c0 authored by Van's avatar Van

vditor -> 0.4.0

parent 2598922f
......@@ -5343,9 +5343,9 @@
"dev": true
},
"vditor": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/vditor/-/vditor-0.3.0.tgz",
"integrity": "sha512-+sh+w1lsAh5UQ5/l0puuALO1MMpI+kgHCueKG6WQAh9sxmlJtxVAIiuQwS+Qb3+uGCbWKOIBI37+Z2Bc6fCVSA==",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/vditor/-/vditor-0.4.0.tgz",
"integrity": "sha512-BjyBy0Nq2HUZ5IReZrIvEp5Ggu8kKua3aqTUEb5m11NP+i/ERPjxGcszGPYA4GdpSMxJQbuy+d0IQUwdV5GzrQ==",
"requires": {
"turndown": "^5.0.3",
"turndown-plugin-gfm": "^1.0.2"
......
......@@ -36,6 +36,6 @@
"gulp-uglify": "^3.0.1"
},
"dependencies": {
"vditor": "^0.3.0"
"vditor": "^0.4.0"
}
}
......@@ -167,7 +167,7 @@
</div>
</div>
<script src="${staticServePath}/js/lib/compress/admin-lib.min.js"></script>
<script src="${staticServePath}/js/lib/vditor-0.3.0/index.min.js"></script>
<script src="${staticServePath}/js/lib/vditor-0.4.0/index.min.js"></script>
<script src="${staticServePath}/js/common${miniPostfix}.js"></script>
<#if "" == miniPostfix>
<script src="${staticServePath}/js/admin/admin.js"></script>
......
......@@ -105,7 +105,7 @@ $.extend(Page.prototype, {
if (typeof Vditor === 'undefined') {
$.ajax({
method: 'GET',
url: latkeConfig.staticServePath + '/js/lib/vditor-0.3.0/index.min.js',
url: latkeConfig.staticServePath + '/js/lib/vditor-0.4.0/index.min.js',
dataType: 'script',
cache: true,
async: false,
......
var Page=function(e){this.currentCommentId="",this.tips=e};$.extend(Page.prototype,{replaceCommentsEm:function(e){for(var t=$(e),o=0;o<t.length;o++){var i=t[o].innerHTML;t[o].innerHTML=Util.replaceEmString(i)}},parseLanguage:function(e){var t=!1;$(".content-reset pre").each(function(){t=!0}),t&&(document.createStyleSheet?document.createStyleSheet(latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/styles/"+(e&&e.theme||"github")+".css"):$("head").append($("<link rel='stylesheet' href='"+latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/styles/"+(e&&e.theme||"github")+".css'>")),Label.markedAvailable||$.ajax({url:latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/highlight.pack.js",dataType:"script",cache:!0,success:function(){hljs.initHighlighting.called=!1,hljs.initHighlighting()}}))},load:function(e){var t=this;t.parseLanguage(e),$("#comment").click(function(){t.toggleEditor()}).attr("readonly","readonly"),$("#soloEditorCancel").click(function(){t.toggleEditor()}),$("#soloEditorAdd").click(function(){t.submitComment()})},toggleEditor:function(e,t){var o=this;"undefined"==typeof Vditor&&$.ajax({method:"GET",url:latkeConfig.staticServePath+"/js/lib/vditor-0.3.0/index.min.js",dataType:"script",cache:!0,async:!1,success:function(){window.vditor=new Vditor("soloEditorComment",{placeholder:o.tips.commentContentCannotEmptyLabel,height:180,hint:{emojiPath:latkeConfig.staticServePath+"/js/lib/emojify.js-1.1.0/images/basic"},esc:function(){$("#soloEditorCancel").click()},ctrlEnter:function(){$("#soloEditorAdd").click()},preview:{delay:500,show:!1,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(e){"none"!==e.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},counter:500,resize:{enable:!0,position:"top",after:function(){$("body").css("padding-bottom",$("#soloEditor").outerHeight())}},lang:o.tips.langLabel,toolbar:["emoji","headings","bold","italic","strike","|","line","quote","|","list","ordered-list","check","|","code","inline-code","|","undo","redo","|","link","table","|","preview","fullscreen","info","help"],classes:{preview:"content__reset"}}),vditor.focus()}});var i=$("#soloEditor");0!==i.length?"0px"===$("body").css("padding-bottom")||e?($("#soloEditorError").text(""),i.css({bottom:"0",opacity:1}),$("body").css("padding-bottom","238px"),this.currentCommentId=e,$("#soloEditorReplyTarget").text(t?"@"+t:""),"undefined"!=typeof vditor&&vditor.focus()):(i.css({bottom:"-300px",opacity:0}),$("body").css("padding-bottom",0)):location.href=latkeConfig.servePath+"/start"},loadRandomArticles:function(s){var c=this.tips.randomArticles1Label;$.ajax({url:latkeConfig.servePath+"/articles/random",type:"POST",success:function(e,t){var o=e.randomArticles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' href='"+latkeConfig.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var r=(s||"<h4>"+c+"</h4>")+"<ul>"+i+"</ul>";$("#randomArticles").append(r)}else $("#randomArticles").remove()}})},loadRelevantArticles:function(e,s){$.ajax({url:latkeConfig.servePath+"/article/id/"+e+"/relevant/articles",type:"GET",success:function(e,t){var o=e.relevantArticles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' href='"+latkeConfig.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var r=s+"<ul>"+i+"</ul>";$("#relevantArticles").append(r)}else $("#relevantArticles").remove()},error:function(){$("#relevantArticles").remove()}})},loadExternalRelevantArticles:function(e,s){var c=this.tips;try{$.ajax({url:"https://rhythm.b3log.org/get-articles-by-tags.do?tags="+e+"&blogHost="+c.blogHost+"&paginationPageSize="+c.externalRelevantArticlesDisplayCount,type:"GET",cache:!0,dataType:"jsonp",error:function(){$("#externalRelevantArticles").remove()},success:function(e,t){var o=e.articles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' target='_blank' href='"+l.articlePermalink+"'>"+a+"</a></li>"}var r=(s||"<h4>"+c.externalRelevantArticles1Label+"</h4>")+"<ul>"+i+"</ul>";$("#externalRelevantArticles").append(r)}else $("#externalRelevantArticles").remove()}})}catch(e){}},submitComment:function(){var t=this,e=this.tips,o="article";if(void 0===e.externalRelevantArticlesDisplayCount&&(o="page"),1<vditor.getValue().length&&vditor.getValue().length<500){$("#soloEditorAdd").attr("disabled","disabled");var i={oId:e.oId,commentContent:vditor.getValue()};this.currentCommentId&&(i.commentOriginalCommentId=this.currentCommentId),$.ajax({type:"POST",url:latkeConfig.servePath+"/"+o+"/comments",cache:!1,contentType:"application/json",data:JSON.stringify(i),success:function(e){$("#soloEditorAdd").removeAttr("disabled"),e.sc?(t.toggleEditor(),vditor.setValue(""),t.addCommentAjax(Util.replaceEmString(e.cmtTpl))):$("#soloEditorError").html(e.msg)}})}else $("#soloEditorError").text(t.tips.commentContentCannotEmptyLabel)},addReplyForm:function(e,t){this.currentCommentId=e,this.toggleEditor(e,t)},hideComment:function(e){$("#commentRef"+e).hide()},showComment:function(e,t,o,i){var n=parseInt($(e).position().top);if(i&&(n=parseInt($(e).parents(i).position().top)),0<$("#commentRef"+t).length)$("#commentRef"+t).show().css("top",n+o+"px");else{var l=$("#"+t).clone();l.addClass("comment-body-ref").attr("id","commentRef"+t),l.find("#replyForm").remove(),$("#comments").append(l),$("#commentRef"+t).css("top",n+o+"px")}},addCommentAjax:function(e){0<$("#comments").children().length?$($("#comments").children()[0]).before(e):$("#comments").html(e),window.location.hash="#comments"}});
\ No newline at end of file
var Page=function(e){this.currentCommentId="",this.tips=e};$.extend(Page.prototype,{replaceCommentsEm:function(e){for(var t=$(e),o=0;o<t.length;o++){var i=t[o].innerHTML;t[o].innerHTML=Util.replaceEmString(i)}},parseLanguage:function(e){var t=!1;$(".content-reset pre").each(function(){t=!0}),t&&(document.createStyleSheet?document.createStyleSheet(latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/styles/"+(e&&e.theme||"github")+".css"):$("head").append($("<link rel='stylesheet' href='"+latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/styles/"+(e&&e.theme||"github")+".css'>")),Label.markedAvailable||$.ajax({url:latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/highlight.pack.js",dataType:"script",cache:!0,success:function(){hljs.initHighlighting.called=!1,hljs.initHighlighting()}}))},load:function(e){var t=this;t.parseLanguage(e),$("#comment").click(function(){t.toggleEditor()}).attr("readonly","readonly"),$("#soloEditorCancel").click(function(){t.toggleEditor()}),$("#soloEditorAdd").click(function(){t.submitComment()})},toggleEditor:function(e,t){var o=this;"undefined"==typeof Vditor&&$.ajax({method:"GET",url:latkeConfig.staticServePath+"/js/lib/vditor-0.4.0/index.min.js",dataType:"script",cache:!0,async:!1,success:function(){window.vditor=new Vditor("soloEditorComment",{placeholder:o.tips.commentContentCannotEmptyLabel,height:180,hint:{emojiPath:latkeConfig.staticServePath+"/js/lib/emojify.js-1.1.0/images/basic"},esc:function(){$("#soloEditorCancel").click()},ctrlEnter:function(){$("#soloEditorAdd").click()},preview:{delay:500,show:!1,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(e){"none"!==e.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},counter:500,resize:{enable:!0,position:"top",after:function(){$("body").css("padding-bottom",$("#soloEditor").outerHeight())}},lang:o.tips.langLabel,toolbar:["emoji","headings","bold","italic","strike","|","line","quote","|","list","ordered-list","check","|","code","inline-code","|","undo","redo","|","link","table","|","preview","fullscreen","info","help"],classes:{preview:"content__reset"}}),vditor.focus()}});var i=$("#soloEditor");0!==i.length?"0px"===$("body").css("padding-bottom")||e?($("#soloEditorError").text(""),i.css({bottom:"0",opacity:1}),$("body").css("padding-bottom","238px"),this.currentCommentId=e,$("#soloEditorReplyTarget").text(t?"@"+t:""),"undefined"!=typeof vditor&&vditor.focus()):(i.css({bottom:"-300px",opacity:0}),$("body").css("padding-bottom",0)):location.href=latkeConfig.servePath+"/start"},loadRandomArticles:function(s){var c=this.tips.randomArticles1Label;$.ajax({url:latkeConfig.servePath+"/articles/random",type:"POST",success:function(e,t){var o=e.randomArticles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' href='"+latkeConfig.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var r=(s||"<h4>"+c+"</h4>")+"<ul>"+i+"</ul>";$("#randomArticles").append(r)}else $("#randomArticles").remove()}})},loadRelevantArticles:function(e,s){$.ajax({url:latkeConfig.servePath+"/article/id/"+e+"/relevant/articles",type:"GET",success:function(e,t){var o=e.relevantArticles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' href='"+latkeConfig.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var r=s+"<ul>"+i+"</ul>";$("#relevantArticles").append(r)}else $("#relevantArticles").remove()},error:function(){$("#relevantArticles").remove()}})},loadExternalRelevantArticles:function(e,s){var c=this.tips;try{$.ajax({url:"https://rhythm.b3log.org/get-articles-by-tags.do?tags="+e+"&blogHost="+c.blogHost+"&paginationPageSize="+c.externalRelevantArticlesDisplayCount,type:"GET",cache:!0,dataType:"jsonp",error:function(){$("#externalRelevantArticles").remove()},success:function(e,t){var o=e.articles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' target='_blank' href='"+l.articlePermalink+"'>"+a+"</a></li>"}var r=(s||"<h4>"+c.externalRelevantArticles1Label+"</h4>")+"<ul>"+i+"</ul>";$("#externalRelevantArticles").append(r)}else $("#externalRelevantArticles").remove()}})}catch(e){}},submitComment:function(){var t=this,e=this.tips,o="article";if(void 0===e.externalRelevantArticlesDisplayCount&&(o="page"),1<vditor.getValue().length&&vditor.getValue().length<500){$("#soloEditorAdd").attr("disabled","disabled");var i={oId:e.oId,commentContent:vditor.getValue()};this.currentCommentId&&(i.commentOriginalCommentId=this.currentCommentId),$.ajax({type:"POST",url:latkeConfig.servePath+"/"+o+"/comments",cache:!1,contentType:"application/json",data:JSON.stringify(i),success:function(e){$("#soloEditorAdd").removeAttr("disabled"),e.sc?(t.toggleEditor(),vditor.setValue(""),t.addCommentAjax(Util.replaceEmString(e.cmtTpl))):$("#soloEditorError").html(e.msg)}})}else $("#soloEditorError").text(t.tips.commentContentCannotEmptyLabel)},addReplyForm:function(e,t){this.currentCommentId=e,this.toggleEditor(e,t)},hideComment:function(e){$("#commentRef"+e).hide()},showComment:function(e,t,o,i){var n=parseInt($(e).position().top);if(i&&(n=parseInt($(e).parents(i).position().top)),0<$("#commentRef"+t).length)$("#commentRef"+t).show().css("top",n+o+"px");else{var l=$("#"+t).clone();l.addClass("comment-body-ref").attr("id","commentRef"+t),l.find("#replyForm").remove(),$("#comments").append(l),$("#commentRef"+t).css("top",n+o+"px")}},addCommentAjax:function(e){0<$("#comments").children().length?$($("#comments").children()[0]).before(e):$("#comments").html(e),window.location.hash="#comments"}});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment