diff --git a/extensions/mentions/js/dist/forum.js b/extensions/mentions/js/dist/forum.js index 76cadc528..ef1ae2da7 100644 --- a/extensions/mentions/js/dist/forum.js +++ b/extensions/mentions/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=28)}([function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["components/CommentPost"]},function(t,e){t.exports=flarum.core.compat.app},function(t,e){t.exports=flarum.core.compat["utils/string"]},function(t,e){t.exports=flarum.core.compat["helpers/username"]},function(t,e){t.exports=flarum.core.compat["components/PostPreview"]},function(t,e){t.exports=flarum.core.compat["helpers/icon"]},function(t,e){t.exports=flarum.core.compat["components/EditPostComposer"]},function(t,e){t.exports=flarum.core.compat.Fragment},function(t,e){t.exports=flarum.core.compat["components/Notification"]},function(t,e){t.exports=flarum.core.compat["components/TextEditor"]},function(t,e){t.exports=flarum.core.compat["utils/extractText"]},function(t,e){t.exports=flarum.core.compat["components/NotificationGrid"]},function(t,e){t.exports=flarum.core.compat["components/LoadingIndicator"]},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat["models/Post"]},function(t,e){t.exports=flarum.core.compat["helpers/punctuateSeries"]},function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["utils/DiscussionControls"]},function(t,e,n){!function(){var e=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],n="undefined"!=typeof window,o=n&&null!=window.mozInnerScreenX;function r(t,r,i){if(!n)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var s=i&&i.debug||!1;if(s){var a=document.querySelector("#input-textarea-caret-position-mirror-div");a&&a.parentNode.removeChild(a)}var u=document.createElement("div");u.id="input-textarea-caret-position-mirror-div",document.body.appendChild(u);var c=u.style,p=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,f="INPUT"===t.nodeName;c.whiteSpace="pre-wrap",f||(c.wordWrap="break-word"),c.position="absolute",s||(c.visibility="hidden"),e.forEach((function(t){f&&"lineHeight"===t?c.lineHeight=p.height:c[t]=p[t]})),o?t.scrollHeight>parseInt(p.height)&&(c.overflowY="scroll"):c.overflow="hidden",u.textContent=t.value.substring(0,r),f&&(u.textContent=u.textContent.replace(/\s/g," "));var l=document.createElement("span");l.textContent=t.value.substring(r)||".",u.appendChild(l);var d={top:l.offsetTop+parseInt(p.borderTopWidth),left:l.offsetLeft+parseInt(p.borderLeftWidth),height:parseInt(p.lineHeight)};return s?l.style.backgroundColor="#aaa":document.body.removeChild(u),d}void 0!==t.exports?t.exports=r:n&&(window.getCaretCoordinates=r)}()},function(t,e){t.exports=flarum.core.compat["components/TextEditorButton"]},function(t,e){t.exports=flarum.core.compat["components/ReplyComposer"]},function(t,e){t.exports=flarum.core.compat["helpers/avatar"]},function(t,e){t.exports=flarum.core.compat["helpers/highlight"]},function(t,e){t.exports=flarum.core.compat["utils/KeyboardNavigatable"]},function(t,e){t.exports=flarum.core.compat["components/UserPage"]},function(t,e){t.exports=flarum.core.compat["components/LinkButton"]},function(t,e){t.exports=flarum.core.compat["components/PostsUserPage"]},function(t,e,n){"use strict";n.r(e),n.d(e,"filterUserMentions",(function(){return vt})),n.d(e,"filterPostMentions",(function(){return bt}));var o=n(0),r=n(2),i=n.n(r),s=n(12),a=n.n(s),u=n(3),c=n(1),p=n.n(c),f=n(5),l=n.n(f),d=n(13),h=n.n(d);var v=n(14),b=n.n(v),g=n(15),y=n.n(g),w=n(16),x=n.n(w),C=n(4),P=n.n(C),T=n(6),S=n.n(T);var _=n(17),j=n.n(_),M=n(18),B=n.n(M),O=n(7),k=n.n(O);function A(t,e,n){var o=t.user(),r="@"+(o?o.username():t.number())+"#"+t.id()+" ";e.fields.content()||(e.body.attrs.originalContent=r);var i=e.editor.getSelectionRange()[0],s=e.fields.content().slice(0,i),a=0==s.length?0:3-s.match(/(\n{0,2})$/)[0].length;e.editor.insertAtCursor(Array(a).join("\n")+(n?"> "+r+n.trim().replace(/\n/g,"\n> ")+"\n\n":r))}function H(t,e){app.composer.bodyMatches(k.a)&&app.composer.body.attrs.post.discussion()===t.discussion()?A(t,app.composer,e):B.a.replyAction.call(t.discussion()).then((function(n){return A(t,n,e)}))}function I(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var W=n(8),E=n.n(W),N=function(t){function e(e){var n;return(n=t.call(this)||this).post=e,n}I(e,t);var n=e.prototype;return n.view=function(){var t=this;return m("button",{class:"Button PostQuoteButton",onclick:function(){H(t.post,t.content)}},S()("fas fa-quote-left",{className:"Button-icon"}),app.translator.trans("flarum-mentions.forum.post.quote_button"))},n.show=function(t,e){var n=this.$().show(),o=n.offsetParent().offset();n.css("left",t-o.left).css("top",e-o.top),this.hideHandler=this.hide.bind(this),$(document).on("mouseup",this.hideHandler)},n.showStart=function(t,e){var n=this.$();this.show(t,$(window).scrollTop()+e-n.outerHeight()-5)},n.showEnd=function(t,e){var n=this.$();this.show(t-n.outerWidth(),$(window).scrollTop()+e+5)},n.hide=function(){this.$().hide(),$(document).off("mouseup",this.hideHandler)},e}(E.a);function D(){Object(o.extend)(p.a.prototype,"oncreate",(function(){var t=this.attrs.post;if(!(t.isHidden()||app.session.user&&!t.discussion().canReply())){var e=this.$(".Post-body"),n=$('
'),o=new N(t),r=function(t){setTimeout((function(){var r=function(t){var e=window.getSelection();if(e.rangeCount){var n=e.getRangeAt(0),o=n.commonAncestorContainer;if(t[0]===o||$.contains(t[0],o)){var r=$("
").append(n.cloneContents());return r.find("img.emoji").replaceWith((function(){return this.alt})),r.find("img").replaceWith((function(){return"![]("+this.src+")"})),r.find("a").replaceWith((function(){return"["+this.innerText+"]("+this.href+")"})),r.text()}}return""}(e);if(r){o.content=r,m.render(n[0],o.render());var i=window.getSelection().getRangeAt(0).getClientRects(),s=i[0];if(t.clientY=o.length&&(r=0),this.index=r;var i=o.removeClass("active").eq(r).addClass("active");if(e){var s,a=n.scrollTop(),u=n.offset().top,c=u+n.outerHeight(),p=i.offset().top,f=p+i.outerHeight();pc&&(s=a-c+f+parseInt(n.css("padding-bottom"),10)),void 0!==s&&n.stop(!0).animate({scrollTop:s},100)}}},e}(E.a);function ot(){Object(o.extend)(U.a.prototype,"oncreate",(function(){var t,e,n,o=$('
'),r=new nt,i=this.$("textarea").wrap('
'),s=[],a=Array.from(app.store.all("users")),c=new Set(a.map((function(t){return t.id()})));this.navigator=new Z.a,this.navigator.when((function(){return r.active})).onUp((function(){return r.navigate(-1)})).onDown((function(){return r.navigate(1)})).onSelect(r.complete.bind(r)).onCancel(r.hide.bind(r)).bindTo(i),i.after(o).on("click keyup input",(function(i){var p=this;if(-1===[9,13,27,40,38,37,39].indexOf(i.which)){var f=this.selectionStart;if(!(this.selectionEnd-f>0)){var l=this.value;t=0;for(var d=f-1;d>=f-30;d--){if("@"===l.substr(d,1)){t=d+1;break}}if(r.hide(),r.active=!1,t){e=l.substring(t,f).toLowerCase();var h=function(n,o,i,s){void 0===s&&(s="");var a=P()(n);return e&&(a.children=[Q()(a.text,e)],delete a.text),m("button",{className:"PostPreview "+s,onclick:function(){return function(e){app.composer.editor.replaceBeforeCursor(t-1,e+" "),r.hide()}(o)},onmouseenter:function(){r.setIndex($(this).parent().index())}},m("span",{className:"PostPreview-content"},G()(n),a," "," ",i))},v=function(t){return[t.username(),t.displayName()].some((function(t){return t.toLowerCase().substr(0,e.length)===e}))},b=function(){var n=[];if(e&&a.forEach((function(t){v(t)&&n.push(h(t,"@"+t.username(),"","MentionsDropdown-user"))})),app.composer.bodyMatches(Y.a)||app.composer.bodyMatches(k.a)){var i=app.composer.body.attrs,s=i.post,c=s&&s.discussion()||i.discussion;c&&c.posts().filter((function(t){return t&&"comment"===t.contentType()&&(!s||t.number()b.height()&&(y=f.top-p.scrollTop-d-15),g+l>b.width()&&(g=b.width()-l),r.show(g,y)}else r.active=!1,r.hide()};r.active=!0,b(),r.setIndex(0),r.$().scrollTop(0),clearTimeout(n),e.length>1&&(n=setTimeout((function(){var t=e.toLowerCase();-1===s.indexOf(t)&&(app.store.find("users",{filter:{q:e},page:{limit:5}}).then((function(t){t.forEach((function(t){c.has(t.id())||(c.add(t.id()),a.push(t))})),r.active&&b()})),s.push(t))}),250))}}}}))})),Object(o.extend)(U.a.prototype,"toolbarItems",(function(t){var e=this;t.add("mention",m(J.a,{onclick:function(){return e.props.composer.editor.insertAtCursor("@")},icon:"fas fa-at"},app.translator.trans("flarum-mentions.forum.composer.mention_tooltip")))}))}var rt=n(9),it=n.n(rt),st=function(t){function e(){return t.apply(this,arguments)||this}I(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-reply"},n.href=function(){var t=this.attrs.notification,e=t.subject(),n=t.content();return app.route.discussion(e.discussion(),n&&n.replyNumber)},n.content=function(){var t=this.attrs.notification.fromUser();return app.translator.transChoice("flarum-mentions.forum.notifications.post_mentioned_text",1,{user:t})},n.excerpt=function(){return Object(u.truncate)(this.attrs.notification.subject().contentPlain(),200)},e}(it.a),at=function(t){function e(){return t.apply(this,arguments)||this}I(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-at"},n.href=function(){var t=this.attrs.notification.subject();return app.route.discussion(t.discussion(),t.number())},n.content=function(){var t=this.attrs.notification.fromUser();return app.translator.trans("flarum-mentions.forum.notifications.user_mentioned_text",{user:t})},n.excerpt=function(){return Object(u.truncate)(this.attrs.notification.subject().contentPlain(),200)},e}(it.a),ut=n(25),ct=n.n(ut),pt=n(26),ft=n.n(pt),lt=n(27),dt=function(t){function e(){return t.apply(this,arguments)||this}return I(e,t),e.prototype.loadResults=function(t){return app.store.find("posts",{filter:{type:"comment",mentioned:this.user.id()},page:{offset:t,limit:this.loadLimit},sort:"-createdAt"})},e}(n.n(lt).a),mt=n(11),ht=n.n(mt);function vt(t){var e=app.store.getBy("users","username",t.getAttribute("username"));if(e)return t.setAttribute("id",e.id()),t.setAttribute("displayname",ht()(P()(e))),!0}function bt(t){var e=app.store.getById("posts",t.getAttribute("id"));if(e)return t.setAttribute("discussionid",e.discussion().id()),t.setAttribute("number",e.number()),t.setAttribute("displayname",ht()(P()(e.user()))),!0}i.a.initializers.add("flarum-mentions",(function(){!function(){function t(){var t=this.attrs.post.contentHtml();if(t!==this.oldPostContentHtml&&!this.isEditing()){this.oldPostContentHtml=t;var e=this.attrs.post,n=this.$();this.$().on("click",".UserMention, .PostMention",(function(t){m.route.set(this.getAttribute("href")),t.preventDefault()})),this.$(".PostMention").each((function(){var t,o=$(this),r=o.data("id"),i=$('