Commit 19088daf authored by Liyuan Li's avatar Liyuan Li

vditor

parent e57cd2cf
...@@ -8676,17 +8676,17 @@ ...@@ -8676,17 +8676,17 @@
} }
}, },
"vcmt": { "vcmt": {
"version": "1.1.5", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/vcmt/-/vcmt-1.1.5.tgz", "resolved": "https://registry.npmjs.org/vcmt/-/vcmt-1.1.6.tgz",
"integrity": "sha512-1+lCCu7kd7QjFRvzXUJISnc6yD3kVNGn1T+l9hpzDJmGe/+z/K1dpbjR7LWhg3YlDC2YrJi7Aad7VXtzGbxg3Q==", "integrity": "sha512-gWD+HZDuFrx7YFVtBBAVqGGh68HrjrV/qQaUOiXfmR1yTO6yeoyQPoAm1vnS4ux8fDDXdu8++yIOFQG9DLAQYA==",
"requires": { "requires": {
"jquery": "^3.4.1" "jquery": "^3.4.1"
} }
}, },
"vditor": { "vditor": {
"version": "3.1.10", "version": "3.1.11",
"resolved": "https://registry.npmjs.org/vditor/-/vditor-3.1.10.tgz", "resolved": "https://registry.npmjs.org/vditor/-/vditor-3.1.11.tgz",
"integrity": "sha512-WKkowreJoBVE+8NV2h7ZYMVUfXyui8PpOBr9Eike/HSoRQLLkTkFV1LP4rC8JH4oH05eqXqRBhcgrzMMe9ZGaQ==", "integrity": "sha512-+RBgMhB+zJcOOVYbKrIRJIoHEw5FgPLYeDqyq3+KsTsyvXoDgi5os375a4+taqowBihYE/vNdAH1vpurWVaQHw==",
"requires": { "requires": {
"diff-match-patch": "^1.0.4" "diff-match-patch": "^1.0.4"
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
"jquery": "^3.4.1", "jquery": "^3.4.1",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"uvstat": "^1.0.7", "uvstat": "^1.0.7",
"vcmt": "^1.1.5", "vcmt": "^1.1.6",
"vditor": "^3.1.10" "vditor": "^3.1.11"
} }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.1.0, Apr 13, 2020 * @version 1.6.0.0, Apr 16, 2020
*/ */
admin.editors = {} admin.editors = {}
...@@ -114,9 +114,9 @@ $.extend(SoloEditor.prototype, { ...@@ -114,9 +114,9 @@ $.extend(SoloEditor.prototype, {
if ($(window).width() < 768) { if ($(window).width() < 768) {
options.toolbar = [ options.toolbar = [
'emoji', 'emoji',
'bold',
'link', 'link',
'list', 'upload',
'insert-after',
'edit-mode', 'edit-mode',
'preview', 'preview',
'fullscreen', 'fullscreen',
......
...@@ -301,7 +301,7 @@ window.Util = { ...@@ -301,7 +301,7 @@ window.Util = {
loadVditor: function (cb) { loadVditor: function (cb) {
$.ajax({ $.ajax({
method: 'GET', method: 'GET',
url: 'https://cdn.jsdelivr.net/npm/vditor@3.1.10/dist/index.min.js', url: 'https://cdn.jsdelivr.net/npm/vditor@3.1.11/dist/index.min.js',
dataType: 'script', dataType: 'script',
cache: true, cache: true,
success: () => { success: () => {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.7.0.0, Apr 12, 2020 * @version 2.8.0.0, Apr 16, 2020
*/ */
window.Page = function (tips) { window.Page = function (tips) {
this.currentCommentId = '' this.currentCommentId = ''
...@@ -151,6 +151,8 @@ $.extend(Page.prototype, { ...@@ -151,6 +151,8 @@ $.extend(Page.prototype, {
'code', 'code',
'inline-code', 'inline-code',
'table', 'table',
'insert-before',
'insert-after',
'|', '|',
'undo', 'undo',
'redo', 'redo',
...@@ -161,15 +163,16 @@ $.extend(Page.prototype, { ...@@ -161,15 +163,16 @@ $.extend(Page.prototype, {
'format', 'format',
'|', '|',
'fullscreen', 'fullscreen',
'devtools',
'info', 'info',
'help', 'help',
], resizeEnable = true ], resizeEnable = true
if ($(window).width() < 768) { if ($(window).width() < 768) {
toolbar = [ toolbar = [
'emoji', 'emoji',
'bold',
'link', 'link',
'list', 'upload',
'insert-after',
'edit-mode', 'edit-mode',
'preview', 'preview',
'fullscreen', 'fullscreen',
......
!function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=60)}({60:function(e,t){window.Page=function(e){this.currentCommentId="",this.tips=e},$.extend(Page.prototype,{vcomment:function(){var e=$("#vcomment");if(0!==e.length){var t=new Vcomment({id:"vcomment",postId:e.data("postid"),url:"https://hacpai.com",userName:e.data("name"),currentPage:1,vditor:{lineNumber:Label.showCodeBlockLn,hljsEnable:!Label.luteAvailable,hljsStyle:Label.hljsStyle},error:function(){e.remove(),$("#soloComments").show()}});t.render()}},share:function(){var e=$(".article__share");if(0!==e.length){var t=e.find(".item__qr"),o=e.data("url"),n=e.data("avatar"),r=encodeURIComponent(e.data("title")+" - "+e.data("blogtitle")),i=encodeURIComponent(o),l={};l.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+r+"&url="+i+"&pic="+n,l.weibo="http://v.t.sina.com.cn/share/share.php?title="+r+"&url="+i+"&pic="+n,l.qqz="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+i+"&sharesource=qzone&title="+r+"&pics="+n,l.twitter="https://twitter.com/intent/tweet?status="+r+" "+i,e.find("span").click((function(){var e=$(this).data("type");if(e){if("wechat"===e){if("undefined"==typeof QRious&&Util.addScript(Label.staticServePath+"/js/lib/qrious.min.js","qriousScript"),"none"===t.css("background-image")){var n=new QRious({padding:0,element:t[0],value:o,size:99});t.css("background-image","url(".concat(n.toDataURL("image/jpeg"),")"))}else t.slideToggle();return!1}window.open(l[e],"_blank","top=100,left=200,width=648,height=618")}}))}},load:function(){var e=this;$("#comment").click((function(){e.toggleEditor()})).attr("readonly","readonly"),$("#soloEditorCancel").click((function(){e.toggleEditor()})),$("#soloEditorAdd").click((function(){e.submitComment()})),e.vcomment()},toggleEditor:function(e,t){var o=$("#soloEditor");if(0!==o.length){if(!$("#soloEditorComment").hasClass("vditor")){var n=["emoji","headings","bold","italic","strike","link","|","list","ordered-list","check","outdent","indent","|","quote","line","code","inline-code","table","|","undo","redo","|","edit-mode","both","preview","format","|","fullscreen","info","help"],r=!0;$(window).width()<768&&(n=["emoji","bold","link","list","edit-mode","preview","fullscreen"],r=!1),window.vditor=new Vditor("soloEditorComment",{placeholder:this.tips.commentContentCannotEmptyLabel,height:180,tab:"\t",esc:function(){$("#soloEditorCancel").click()},ctrlEnter:function(){$("#soloEditorAdd").click()},preview:{delay:500,mode:"editor",url:Label.servePath+"/console/markdown/2html",hljs:{enable:!Label.luteAvailable,style:Label.hljsStyle},parse:function(e){"none"!==e.style.display&&Util.parseMarkdown()}},counter:{enable:!0,max:500},resize:{enable:r,position:"top"},lang:Label.langLabel,toolbar:n,after:function(){vditor.focus()}})}"-300px"===o.css("bottom")||e?($("#soloEditorError").text(""),$(window).width()<768?o.css({top:"0",bottom:"auto",opacity:1}):o.css({bottom:"0",top:"auto",opacity:1}),this.currentCommentId=e,$("#soloEditorReplyTarget").text(t?"@"+t:""),"undefined"!=typeof vditor&&vditor.vditor.wysiwyg&&vditor.focus()):o.css({bottom:"-300px",top:"auto",opacity:0})}else location.href=Label.servePath+"/start"},loadRandomArticles:function(e){var t=this.tips.randomArticles1Label;$.ajax({url:Label.servePath+"/articles/random",type:"POST",success:function(o,n){var r=o.randomArticles;if(r&&0!==r.length){for(var i="",l=0;l<r.length;l++){var a=r[l],s=a.articleTitle;i+="<li><a rel='nofollow' title='"+s+"' href='"+Label.servePath+a.articlePermalink+"'>"+s+"</a></li>"}var c=(e||"<h4>"+t+"</h4>")+"<ul>"+i+"</ul>";$("#randomArticles").append(c)}else $("#randomArticles").remove()}})},loadRelevantArticles:function(e,t){$.ajax({url:Label.servePath+"/article/id/"+e+"/relevant/articles",type:"GET",success:function(e,o){var n=e.relevantArticles;if(n&&0!==n.length){for(var r="",i=0;i<n.length;i++){var l=n[i],a=l.articleTitle;r+="<li><a rel='nofollow' title='"+a+"' href='"+Label.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var s=t+"<ul>"+r+"</ul>";$("#relevantArticles").append(s)}else $("#relevantArticles").remove()},error:function(){$("#relevantArticles").remove()}})},loadExternalRelevantArticles:function(e,t){var o=this.tips;try{$.ajax({url:"https://rhythm.b3log.org/get-articles-by-tags.do?tags="+e+"&blogHost="+o.blogHost+"&paginationPageSize="+o.externalRelevantArticlesDisplayCount,type:"GET",cache:!0,dataType:"jsonp",error:function(){$("#externalRelevantArticles").remove()},success:function(e,n){var r=e.articles;if(r&&0!==r.length){for(var i="",l=0;l<r.length;l++){var a=r[l],s=a.articleTitle;i+="<li><a rel='nofollow' title='"+s+"' target='_blank' href='"+a.articlePermalink+"'>"+s+"</a></li>"}var c=(t||"<h4>"+o.externalRelevantArticles1Label+"</h4>")+"<ul>"+i+"</ul>";$("#externalRelevantArticles").append(c)}else $("#externalRelevantArticles").remove()}})}catch(e){}},submitComment:function(){var e=this,t=this.tips;if(vditor.getValue().length>1&&vditor.getValue().length<500){$("#soloEditorAdd").attr("disabled","disabled");var o={oId:t.oId,commentContent:vditor.getValue()};this.currentCommentId&&(o.commentOriginalCommentId=this.currentCommentId),$.ajax({type:"POST",url:Label.servePath+"/article/comments",cache:!1,contentType:"application/json",data:JSON.stringify(o),success:function(t){$("#soloEditorAdd").removeAttr("disabled"),t.sc?(e.toggleEditor(),vditor.setValue(""),e.addCommentAjax(t.cmtTpl)):$("#soloEditorError").html(t.msg)}})}else $("#soloEditorError").text(e.tips.commentContentCannotEmptyLabel)},hideComment:function(e){$("#commentRef"+e).hide()},showComment:function(e,t,o,n){var r=parseInt($(e).position().top);if(n&&(r=parseInt($(e).parents(n).position().top)),$("#commentRef"+t).length>0)$("#commentRef"+t).show().css("top",r+o+"px");else{var i=$("#"+t).clone();i.addClass("comment-body-ref").attr("id","commentRef"+t),i.find("#replyForm").remove(),$("#comments").append(i),$("#commentRef"+t).css("top",r+o+"px")}},addCommentAjax:function(e){$("#comments").children().length>0?$($("#comments").children()[0]).before(e):$("#comments").html(e),Util.parseMarkdown(),window.location.hash="#comments"}})}}); !function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=60)}({60:function(e,t){window.Page=function(e){this.currentCommentId="",this.tips=e},$.extend(Page.prototype,{vcomment:function(){var e=$("#vcomment");if(0!==e.length){var t=new Vcomment({id:"vcomment",postId:e.data("postid"),url:"https://hacpai.com",userName:e.data("name"),currentPage:1,vditor:{lineNumber:Label.showCodeBlockLn,hljsEnable:!Label.luteAvailable,hljsStyle:Label.hljsStyle},error:function(){e.remove(),$("#soloComments").show()}});t.render()}},share:function(){var e=$(".article__share");if(0!==e.length){var t=e.find(".item__qr"),o=e.data("url"),n=e.data("avatar"),r=encodeURIComponent(e.data("title")+" - "+e.data("blogtitle")),i=encodeURIComponent(o),l={};l.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+r+"&url="+i+"&pic="+n,l.weibo="http://v.t.sina.com.cn/share/share.php?title="+r+"&url="+i+"&pic="+n,l.qqz="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+i+"&sharesource=qzone&title="+r+"&pics="+n,l.twitter="https://twitter.com/intent/tweet?status="+r+" "+i,e.find("span").click((function(){var e=$(this).data("type");if(e){if("wechat"===e){if("undefined"==typeof QRious&&Util.addScript(Label.staticServePath+"/js/lib/qrious.min.js","qriousScript"),"none"===t.css("background-image")){var n=new QRious({padding:0,element:t[0],value:o,size:99});t.css("background-image","url(".concat(n.toDataURL("image/jpeg"),")"))}else t.slideToggle();return!1}window.open(l[e],"_blank","top=100,left=200,width=648,height=618")}}))}},load:function(){var e=this;$("#comment").click((function(){e.toggleEditor()})).attr("readonly","readonly"),$("#soloEditorCancel").click((function(){e.toggleEditor()})),$("#soloEditorAdd").click((function(){e.submitComment()})),e.vcomment()},toggleEditor:function(e,t){var o=$("#soloEditor");if(0!==o.length){if(!$("#soloEditorComment").hasClass("vditor")){var n=["emoji","headings","bold","italic","strike","link","|","list","ordered-list","check","outdent","indent","|","quote","line","code","inline-code","table","insert-before","insert-after","|","undo","redo","|","edit-mode","both","preview","format","|","fullscreen","devtools","info","help"],r=!0;$(window).width()<768&&(n=["emoji","link","upload","insert-after","edit-mode","preview","fullscreen"],r=!1),window.vditor=new Vditor("soloEditorComment",{placeholder:this.tips.commentContentCannotEmptyLabel,height:180,tab:"\t",esc:function(){$("#soloEditorCancel").click()},ctrlEnter:function(){$("#soloEditorAdd").click()},preview:{delay:500,mode:"editor",url:Label.servePath+"/console/markdown/2html",hljs:{enable:!Label.luteAvailable,style:Label.hljsStyle},parse:function(e){"none"!==e.style.display&&Util.parseMarkdown()}},counter:{enable:!0,max:500},resize:{enable:r,position:"top"},lang:Label.langLabel,toolbar:n,after:function(){vditor.focus()}})}"-300px"===o.css("bottom")||e?($("#soloEditorError").text(""),$(window).width()<768?o.css({top:"0",bottom:"auto",opacity:1}):o.css({bottom:"0",top:"auto",opacity:1}),this.currentCommentId=e,$("#soloEditorReplyTarget").text(t?"@"+t:""),"undefined"!=typeof vditor&&vditor.vditor.wysiwyg&&vditor.focus()):o.css({bottom:"-300px",top:"auto",opacity:0})}else location.href=Label.servePath+"/start"},loadRandomArticles:function(e){var t=this.tips.randomArticles1Label;$.ajax({url:Label.servePath+"/articles/random",type:"POST",success:function(o,n){var r=o.randomArticles;if(r&&0!==r.length){for(var i="",l=0;l<r.length;l++){var a=r[l],s=a.articleTitle;i+="<li><a rel='nofollow' title='"+s+"' href='"+Label.servePath+a.articlePermalink+"'>"+s+"</a></li>"}var c=(e||"<h4>"+t+"</h4>")+"<ul>"+i+"</ul>";$("#randomArticles").append(c)}else $("#randomArticles").remove()}})},loadRelevantArticles:function(e,t){$.ajax({url:Label.servePath+"/article/id/"+e+"/relevant/articles",type:"GET",success:function(e,o){var n=e.relevantArticles;if(n&&0!==n.length){for(var r="",i=0;i<n.length;i++){var l=n[i],a=l.articleTitle;r+="<li><a rel='nofollow' title='"+a+"' href='"+Label.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var s=t+"<ul>"+r+"</ul>";$("#relevantArticles").append(s)}else $("#relevantArticles").remove()},error:function(){$("#relevantArticles").remove()}})},loadExternalRelevantArticles:function(e,t){var o=this.tips;try{$.ajax({url:"https://rhythm.b3log.org/get-articles-by-tags.do?tags="+e+"&blogHost="+o.blogHost+"&paginationPageSize="+o.externalRelevantArticlesDisplayCount,type:"GET",cache:!0,dataType:"jsonp",error:function(){$("#externalRelevantArticles").remove()},success:function(e,n){var r=e.articles;if(r&&0!==r.length){for(var i="",l=0;l<r.length;l++){var a=r[l],s=a.articleTitle;i+="<li><a rel='nofollow' title='"+s+"' target='_blank' href='"+a.articlePermalink+"'>"+s+"</a></li>"}var c=(t||"<h4>"+o.externalRelevantArticles1Label+"</h4>")+"<ul>"+i+"</ul>";$("#externalRelevantArticles").append(c)}else $("#externalRelevantArticles").remove()}})}catch(e){}},submitComment:function(){var e=this,t=this.tips;if(vditor.getValue().length>1&&vditor.getValue().length<500){$("#soloEditorAdd").attr("disabled","disabled");var o={oId:t.oId,commentContent:vditor.getValue()};this.currentCommentId&&(o.commentOriginalCommentId=this.currentCommentId),$.ajax({type:"POST",url:Label.servePath+"/article/comments",cache:!1,contentType:"application/json",data:JSON.stringify(o),success:function(t){$("#soloEditorAdd").removeAttr("disabled"),t.sc?(e.toggleEditor(),vditor.setValue(""),e.addCommentAjax(t.cmtTpl)):$("#soloEditorError").html(t.msg)}})}else $("#soloEditorError").text(e.tips.commentContentCannotEmptyLabel)},hideComment:function(e){$("#commentRef"+e).hide()},showComment:function(e,t,o,n){var r=parseInt($(e).position().top);if(n&&(r=parseInt($(e).parents(n).position().top)),$("#commentRef"+t).length>0)$("#commentRef"+t).show().css("top",r+o+"px");else{var i=$("#"+t).clone();i.addClass("comment-body-ref").attr("id","commentRef"+t),i.find("#replyForm").remove(),$("#comments").append(i),$("#commentRef"+t).css("top",r+o+"px")}},addCommentAjax:function(e){$("#comments").children().length>0?$($("#comments").children()[0]).before(e):$("#comments").html(e),Util.parseMarkdown(),window.location.hash="#comments"}})}});
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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